ld

Load

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

SZHP/VNC ––––––
  • Changes no flag

The rows that do otherwise show their own flags.

Forms

  • The contents of r' are loaded into r.

  • Loads nn into r.

  • The contents of (HL) are loaded into r.

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

  • The contents of r are loaded into (HL).

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

  • ld , 2 bytes · 10 cycles

    Loads nn into (HL).

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

  • ld a, (bc) 1 byte · 7 cycles

    Loads the value pointed to by BC into A.

  • ld a, (de) 1 byte · 7 cycles

    Loads the value pointed to by DE into A.

  • ld a, () 3 bytes · 13 cycles

    Loads the value pointed to by nnnn into A.

  • ld (bc), a 1 byte · 7 cycles

    Stores A into the memory location pointed to by BC.

  • ld (de), a 1 byte · 7 cycles

    Stores A into the memory location pointed to by DE.

  • ld (), a 3 bytes · 13 cycles

    Stores A into the memory location pointed to by nnnn.

  • ld a, i 2 bytes · 9 cycles S●Z●H0P/V●N0

    Stores the value of register I into A.

  • ld a, r 2 bytes · 9 cycles S●Z●H0P/V●N0

    Stores the value of register R into A.

  • ld i, a 2 bytes · 9 cycles

    Stores the value of A into register I.

  • ld r, a 2 bytes · 9 cycles

    Stores the value of A into register R.

  • Loads nnnn into rr.

  • Loads nnnn into register IX.

  • ld hl, () 3 bytes · 16 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 bytes · 16 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 byte · 6 cycles

    Loads the value of HL into SP.

  • Loads the value of IX into SP.

Pseudo-instructions

Other spellings the assembler accepts; each form shows the instruction it becomes.

  • The contents of rr' are loaded into rr.

  • The contents of (HL) are loaded into BC.

  • The contents of rr are loaded into (HL).

Undocumented 4 rows

Left out of Zilog's manual, but the Z80 runs them, and so does this emulator.

  • Loads nn into ixh/l.

  • The contents of ixh/l are loaded into r.

  • The contents of r are loaded into ixh/l.

  • The contents of ixh/l' are loaded into ixh/l.

Operands

r
An 8-bit register: a, b, c, d, e, h or l. The placeholder r stands for an 8-bit register. In ld a, r and ld r, a, the literal r names 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