Block movement without overlap in Z-80



In this section, we will see how we can use the Zilog Z-80 Microprocessor to move a block of data to another location. There is one assumption, there is sufficient distance between source and destination. So blocks are non-overlapping. Basically the block movement is not exact moving, it is copying the data to other locations.

The number of items in the block is given at location 5000H, and the block is located at position 5050H.

So before movement, the items in the memory is looking like this.

Address Value
5000H 04H

.
.
.
5050H 89H
5051H 7AH
5052H 2FH
5053H 56H

.
.
.

Now, we are writing a program at location 8000H to move the block contents to other locations.

Program

Address Hex Codes Labels Mnemonics Comments
8000 21 00 50
LD HL, 5000H Load the HL pair with 5000H
8003 DD 21 50 50
LD IX, 5050H Set the index register with 5050H
8007 DD 7E 00 LOOP LD A, (IX+00H) Load Acc with IX + 00H
800A DD 77 20
LD (IX+20H), A Load content of Acc at IX + 20H
800D DD 23
INC IX Increase the Index Register
800F 35
DEC (HL) Decrease the content of memory location, pointed with HL pair
8010 C2 07 80
JP NZ, LOOP Jump to Loop, when Zero flag is off
8013 76
HALT Stop the program

Output

Address Value
5000H 04H

.
.
.
5050H 89H
5051H 7AH
5052H 2FH
5053H 56H

.
.
.
5070H 89H
5071H 7AH
5072H 2FH
5073H 56H

.
.
.
Updated on: 2020-06-26T13:17:38+05:30

189 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements