You are on page 1of 2

1.

Instruction OR 80H SUB C IN A,(20H) DEC (HL) write the name(s) of machine cycles in the instruction in the correct order 1- opcode fetch 2- memory read 1- opcode fetch 2- memory read 2- memory read 2- memory read 3- memory read 3- I/O read 3- memory write
Address Contents of memory Follow the operations in the program, compute the final result below and find the status of the flags

LD (2050H),A 1- opcode fetch 1- opcode fetch 1- opcode fetch

4- memory write

2. (13 points)

Translate the Z80 Assembly language program given below into machine code using your instruction list. Find the addresses and contents (machine code instructions) of program memory by ORG 0200H filling the table given on the LD A,(NUM1) LD B,A right. Later examine the LD A,(NUM2) program and determine the SUB B status of the S,Z,C,P/V flags HALT (give reasons) when the NUM1 DB 4FH program stops.
NUM2 DB 8FH

0200 0201 0202 0203 0204 0205 0206 0207 0208 0209 020A

3A 09 05 47 3A 0A 05 90 76 4F 8F

Before SUB B instruction: A 8FH B 4FH After SUB B instruction: 10001111 01001111 --------------01000000 ; A 40H
Flag State of the flag Reason

S Z C P/V

0 0 0 1

MSB of result Nonzero result No carry out of MSB 0XOR1=1 (overflow for signed)

3. a.

b.
The locations 0030H, 0031H, and 0032H should have the instruction JP 22F0H to transfer the program to the service routine at 22F0H.

c.

we can use the same circuit in (a) for mode 2, but inputs of the buffer must be set up to an even byte, say F8H.

4.

Write a Z-80 Assembly language main program that sums only absolute values of even numbers (all 8-bit) in the memory locations from F000H to F063H. In your program, make a call to the subroutine that finds the absolute value of a number. You must also write this subroutine. Odd numbers will not be summed. The computed sum is an 16-bit number and use register pair HL to hold it. Your main program must have a single loop.

subroutine: ABS BIT 7, A JR Z, EXIT NEG EXIT RET Main program: LD IX, FC00H ; set address pointer LD HL, 0 ; reset sum LD D,0 ; LD B, 64H ; loop counter is set to length of block LOOP LD A, (IX) ; get next data ; BIT 0,A ; is it even? ( Z=? 1 ) JR NZ, ODDN ; if not even jump CALL ABS ; it is even so call ABS LD E,A ADD HL,DE ; sum absolute value ODDN INC IX ; IX points to the next data DJNZ LOOP ; loop till end of block HALT

5.
A15 A14 A13 A12 A11 A10 A9 A8 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 1 0 1 0 1 A7 A6 A5 A4 0 0 0 0 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 A3 A2 A1 A0 11 0 0 0 0 0000H-07FFH EPROM1 (2 = 2 KByte) 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1000H-1FFFH RAM (2 = 4 KByte) F000H-F7FFH EPROM2 (211= 2 KByte)
12

1 1 1 1 1 1 1 1 Decoder inputs

You might also like