LDIR

Operation

{(DE) <- (HL), DE <- DE+1, HL <- HL+1, BC <- BC-1} while (BC != 0)

Mnemonic

LDIR

Operands

None

b7b6b5b4b3b2b1b0
1 1 1 0 1 1 0 1$ED
1 0 1 1 0 0 0 0$B0

Description

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.

Condition Bits Affected

Sis not affected.
Zis not affected.
His reset.
P/Vis set if BC-1 != 0; otherwise, it is reset.
Nis reset.
Cis not affected.

Example

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:

HLcontains$1114
DEcontains$2225
BCcontains$0000
($1111)contains$88($2222)contains$88
($1112)contains$36($2223)contains$36
($1113)contains$A5($2224)contains$A5