Block Copy // LDIR (LoaD and Increment Repeated)


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. For BC ≠ 0:


The HL register pair contains 11111h, the DE register pair contains 2222h, the BC register pair contains 0003h, and memory locations contain the following data. (1111h) contains 88h (2222h) contains 66h (1112h) contains 36h (2223h) contains 59h (1113h) contains A5h (2224h) contains C5h Upon the execution of an LDIR instruction, the contents of register pairs and memory locations now contain: HL contains 1114h DE contains 2225h BC contains 0000h (1111h) contains 88h (2222h) contains 88h (1112h) contains 36h (2223h) contains 36h (1113h) contains A5h (2224h) contains A5h