ldir

Load, increment and repeat

Copies BC bytes from (HL) to (DE), incrementing both, until BC is zero.

2 bytes · 21/16 cycles21 cycles for a pass that repeats, 16 for the last

Used in
SZHP/VNC ––000–
  • 0 always 0
  • – not changed

Forms

  • ldir

    Transfers a byte of data from the memory location pointed to by HL to the memory location pointed to by DE. Then HL and DE are incremented and BC is decremented. If BC is not zero, this operation is repeated. Interrupts can trigger while this instruction is processing.

        .org 0x8000
        ld hl, source
        ld de, 0x9000
        ld bc, 4
        ldir
        halt
source: .byte 1, 2, 3, 4