# `ldir`

[Z80 Documentation](https://asm-editor.specy.app/documentation/z80.md) › [Instructions](https://asm-editor.specy.app/documentation/z80/instruction.md)

Web page: https://asm-editor.specy.app/documentation/z80/instruction/ldir

**Load, increment and repeat**

Category: Block and string

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

2 bytes · 21/16 cycles · 21 cycles each time it repeats, 16 the last time

Used in: [The Z80 instruction set](https://asm-editor.specy.app/learn/courses/z80/introduction/the-z80-instruction-set.md) (Z80 assembly)

## Flags

| Flag | Effect |
| --- | --- |
| S | not changed |
| Z | not changed |
| H | always 0 |
| P/V | always 0 |
| N | always 0 |
| C | 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 increments HL and DE and decrements BC. Repeats this operation until BC is zero. Interrupts can trigger while this instruction is processing.

## Example

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