ld
Load
Copies a value between registers, memory and immediate data, 8 or 16 bits at a time.
- Getting started with the Z80Z80 assembly
- Registers, pairs and the shadow setZ80 assembly
- The 64 KB address spaceZ80 assembly
- org, db, dw and dsZ80 assembly
- Bytes and 16-bit pairsZ80 assembly
- The Z80 instruction setZ80 assembly
- Addressing on the Z80Z80 assembly
- The F registerZ80 assembly
- Memory regions and executable filesZ80 assembly
- jp, jr and the conditionsZ80 assembly
- Most forms leave every flag unchanged
Forms that affect the flags differently are shown in their row.
Forms
-
Loads
r'intor. -
Loads
nnintor. -
Loads (HL) into
r. -
Loads the value pointed to by IX plus
ddintor. -
Stores
rinto (HL). -
Stores
rinto the memory location pointed to by IX plusdd. ld ,2 bytes10 cyclesStores
nninto (HL).-
Stores
nninto the memory location pointed to by IX plusdd. ld a, (bc)1 byte7 cyclesLoads the value pointed to by BC into A.
ld a, (de)1 byte7 cyclesLoads the value pointed to by DE into A.
ld a, ()3 bytes13 cyclesLoads the value pointed to by
nnnninto A.ld (bc), a1 byte7 cyclesStores A into the memory location pointed to by BC.
ld (de), a1 byte7 cyclesStores A into the memory location pointed to by DE.
ld (), a3 bytes13 cyclesStores A into the memory location pointed to by
nnnn.ld a, i2 bytes9 cycles S●Z●H0P/V●N0Loads 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, r2 bytes9 cycles S●Z●H0P/V●N0Loads 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, a2 bytes9 cyclesLoads A into the interrupt vector register I.
ld r, a2 bytes9 cyclesLoads A into the memory refresh register R.
-
Loads
nnnnintorr. -
Loads
nnnninto IX. ld hl, ()3 bytes16 cyclesLoads the value pointed to by
nnnninto HL.-
Loads the value pointed to by
nnnnintorr. -
Loads the value pointed to by
nnnninto IX. ld (), hl3 bytes16 cyclesStores HL into the memory location pointed to by
nnnn.-
Stores
rrinto the memory location pointed to bynnnn. -
Stores IX into the memory location pointed to by
nnnn. ld sp, hl1 byte6 cyclesLoads 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'intorr. -
Loads the value pointed to by HL into BC.
-
Stores
rrinto the memory location pointed to by HL.
Undocumented 4 rows
Zilog’s manual does not list these forms, but the Z80 runs them.
-
Loads
nnintoixh/l. -
Loads
ixh/lintor. -
Loads
rintoixh/l. -
Loads
ixh/l'intoixh/l.
Operands
r- An 8-bit register:
a,b,c,d,e,horl. The rowsld a, randld r, aare different: thereris the name of the refresh register. r'- An 8-bit register:
a,b,c,d,e,horl. It may be the same register asr. nn- An 8-bit immediate value,
0to255or-128to127, 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, whereddis a signed displacement from-128to127, for example(ix+5)or(ix-3).(iy+dd)works the same way. More nnnn- A 16-bit value or address,
0to65535, written as a number or label.(nnnn)accesses memory at that address. More rr- A register pair:
bc,de,hlorsp. ix- The
ixindex register. You can also useiy, with the same instruction size and timing. More rr'- A register pair:
bc,deorhl. It may be the same pair asrr. ixh/l- The high or low byte of
ix:ixhorixl. Foriy, useiyhoriyl. More ixh/l'- Choose
ixhorixlagain; the same half may be used twice. If the other operand usesiyhoriyl, choose fromiyhoriylhere too.
.org 0x8000
ld bc, 0x9000
halt