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.

AddressValue
5000H04H

.
.
.
5050H89H
5051H7AH
5052H2FH
5053H56H

.
.
.

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

Program

AddressHex CodesLabelsMnemonicsComments
800021 00 50
LD HL, 5000HLoad the HL pair with 5000H
8003DD 21 50 50
LD IX, 5050HSet the index register with 5050H
8007DD 7E 00LOOPLD A, (IX+00H)Load Acc with IX + 00H
800ADD 77 20
LD (IX+20H), ALoad content of Acc at IX + 20H
800DDD 23
INC IXIncrease the Index Register
800F35
DEC (HL)Decrease the content of memory location, pointed with HL pair
8010C2 07 80
JP NZ, LOOPJump to Loop, when Zero flag is off
801376
HALTStop the program

Output

AddressValue
5000H04H

.
.
.
5050H89H
5051H7AH
5052H2FH
5053H56H

.
.
.
5070H89H
5071H7AH
5072H2FH
5073H56H

.
.
.

Updated on: 26-Jun-2020

89 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements