{(DE) <- (HL), DE <- DE+1, HL <- HL+1, BC <- BC-1} while (BC != 0)
LDIR
None
b7 | b6 | b5 | b4 | b3 | b2 | b1 | b0 | |
---|---|---|---|---|---|---|---|---|
1 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | $ED |
1 | 0 | 1 | 1 | 0 | 0 | 0 | 0 | $B0 |
This 2-byte instruction transfers a byte of data from the memory location addressed by the contents of the HL register pair to the memory location addressed by the DE register pair. Both these register pairs are incremented and the Byte Counter (BC) Register pair is decremented. If decrementing allows the BC to go to 0, the instruction is terminated. If BC is not 0, the program counter is decremented by two and the instruction is repeated. Interrupts are recognized and two refresh cycles are executed after each data transfer. When the BC is set to 0 prior to instruction execution, the instruction loops through 64 KB.
S | is not affected. |
Z | is not affected. |
H | is reset. |
P/V | is set if BC-1 != 0; otherwise, it is reset. |
N | is reset. |
C | is not affected. |
The HL register pair contains $1111, the DE register pair contains $2222, the BC register pair contains $0003, and memory locations contain the following data.
($1111) | contains | $88 | ($2222) | contains | $66 |
($1112) | contains | $36 | ($2223) | contains | $59 |
($1113) | contains | $A5 | ($2224) | contains | $C5 |
Upon the execution of
LDIR
the contents of register pairs and memory locations now contain:
HL | contains | $1114 | |||
DE | contains | $2225 | |||
BC | contains | $0000 | |||
($1111) | contains | $88 | ($2222) | contains | $88 |
($1112) | contains | $36 | ($2223) | contains | $36 |
($1113) | contains | $A5 | ($2224) | contains | $A5 |