Download Print this page

ZiLOG Z80 Handbook page 149

Hide thumbs Also See for Z80:

Advertisement

NEXT LDI TRANSFER BYTE
INC HL POINT TO NEXT BYTE
INC HL
INC HL
JP PE,NEXT GO IF NOT DONE
DONE
SOURCE
TABLE
DESTINATION
TABLE
SRTAB
+1
+2
+3
+4
BYTE 1
BYTE 2
BYTE 64
DSTTB
+252
+253
+254
+255
+63
Fig. 10 -4. Moving noncontiguous data with LDI.
There are several subtleties in the above code. The expression
100H/4 will work in many assemblers and enables an assembly-time
calculation of the number of bytes. After the LDI has transferred
the Ith byte, the HL register points to I + 1. The three increments
bump the HL to point to I + 4.
If no processing is to take place between the transfer of individ-
ual bytes, then the LDIR may be used. The LDIR is set up in exactly
the same manner as the LDI. If N bytes are to be transferred, how-
ever, the LDIR will execute N times. For each transfer, the LDIR
takes 5.25 microseconds (the LDI takes 4.0 microseconds) except
for the last transfer (BC = 0) in which the LDIR takes 4.0 micro-
seconds.
LD HL,STRTS SOURCE START
LD DE,STRTD DEST START
LD BC,64 # OF BYTES
LDIR TRANSFER 64 BYTES IN
DONE ABOUT 335 MICROSEC.
In the LDI and LDIR instructions, data is transferred in forward
order, that is, it is transferred starting from low memory and ascend-
ing to high memory. The only difference between the LDI and
1
+2
+3
158

Advertisement

loading
Need help?

Need help?

Do you have a question about the Z80 and is the answer not in the manual?