ld

Load

Copies a value between registers, memory and immediate data, 8 or 16 bits at a time.

SZHP/VNC ––––––
  • Most forms leave every flag unchanged

Forms that affect the flags differently are shown in their row.

Forms

  • Loads r' into r.

  • Loads nn into r.

  • Loads (HL) into r.

  • Loads the value pointed to by IX plus dd into r.

  • Stores r into (HL).

  • Stores r into the memory location pointed to by IX plus dd.

  • ld , 2 bytes10 cycles

    Stores nn into (HL).

  • Stores nn into the memory location pointed to by IX plus dd.

  • ld a, (bc) 1 byte7 cycles

    Loads the value pointed to by BC into A.

  • ld a, (de) 1 byte7 cycles

    Loads the value pointed to by DE into A.

  • ld a, () 3 bytes13 cycles

    Loads the value pointed to by nnnn into A.

  • ld (bc), a 1 byte7 cycles

    Stores A into the memory location pointed to by BC.

  • ld (de), a 1 byte7 cycles

    Stores A into the memory location pointed to by DE.

  • ld (), a 3 bytes13 cycles

    Stores A into the memory location pointed to by nnnn.

  • ld a, i 2 bytes9 cycles S●Z●H0P/V●N0

    Loads the interrupt vector register I into A. The parity/overflow flag receives the interrupt flip-flop IFF2, which tells whether maskable interrupts are enabled.

  • ld a, r 2 bytes9 cycles S●Z●H0P/V●N0

    Loads the memory refresh register R into A. The parity/overflow flag receives the interrupt flip-flop IFF2, which tells whether maskable interrupts are enabled.

  • ld i, a 2 bytes9 cycles

    Loads A into the interrupt vector register I.

  • ld r, a 2 bytes9 cycles

    Loads A into the memory refresh register R.

  • Loads nnnn into rr.

  • Loads nnnn into IX.

  • ld hl, () 3 bytes16 cycles

    Loads the value pointed to by nnnn into HL.

  • Loads the value pointed to by nnnn into rr.

  • Loads the value pointed to by nnnn into IX.

  • ld (), hl 3 bytes16 cycles

    Stores HL into the memory location pointed to by nnnn.

  • Stores rr into the memory location pointed to by nnnn.

  • Stores IX into the memory location pointed to by nnnn.

  • ld sp, hl 1 byte6 cycles

    Loads HL into SP.

  • Loads IX into SP.

Pseudo-instructions

The assembler also accepts these forms, which are other ways to write Z80 instructions. Open a row to see what each form becomes.

  • Loads rr' into rr.

  • Loads the value pointed to by HL into BC.

  • Stores rr into the memory location pointed to by HL.

Undocumented 4 rows

Zilog’s manual does not list these forms, but the Z80 runs them.

  • Loads nn into ixh/l.

  • Loads ixh/l into r.

  • Loads r into ixh/l.

  • Loads ixh/l' into ixh/l.

Operands

r
An 8-bit register: a, b, c, d, e, h or l. The rows ld a, r and ld r, a are different: there r is the name of the refresh register.
r'
An 8-bit register: a, b, c, d, e, h or l. It may be the same register as r.
nn
An 8-bit immediate value, 0 to 255 or -128 to 127, written as a number, character constant or symbol. More
(hl)
The byte in memory at the address stored in hl. More
(ix+dd)
The byte in memory at ix + dd, where dd is a signed displacement from -128 to 127, for example (ix+5) or (ix-3). (iy+dd) works the same way. More
nnnn
A 16-bit value or address, 0 to 65535, written as a number or label. (nnnn) accesses memory at that address. More
rr
A register pair: bc, de, hl or sp.
ix
The ix index register. You can also use iy, with the same instruction size and timing. More
rr'
A register pair: bc, de or hl. It may be the same pair as rr.
ixh/l
The high or low byte of ix: ixh or ixl. For iy, use iyh or iyl. More
ixh/l'
Choose ixh or ixl again; the same half may be used twice. If the other operand uses iyh or iyl, choose from iyh or iyl here too.
        .org 0x8000
        ld bc, 0x9000
        halt