Operands: n an 8-bit number, nn a 16-bit number, d a displacement. An opcode marked with * is undocumented
(details). Each instruction is listed once under its mnemonic.
Main page, $00–$3F
| x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x | nop | ld bc,nn | ld (bc),a | inc bc | inc b | dec b | ld b,n | rlca | ex af,af' | add hl,bc | ld a,(bc) | dec bc | inc c | dec c | ld c,n | rrca |
| 1x | djnz d | ld de,nn | ld (de),a | inc de | inc d | dec d | ld d,n | rla | jr d | add hl,de | ld a,(de) | dec de | inc e | dec e | ld e,n | rra |
| 2x | jr nz,d | ld hl,nn | ld (nn),hl | inc hl | inc h | dec h | ld h,n | daa | jr z,d | add hl,hl | ld hl,(nn) | dec hl | inc l | dec l | ld l,n | cpl |
| 3x | jr nc,d | ld sp,nn | ld (nn),a | inc sp | inc (hl) | dec (hl) | ld (hl),n | scf | jr c,d | add hl,sp | ld a,(nn) | dec sp | inc a | dec a | ld a,n | ccf |
Main page, $40–$7F: LD r,r'
Opcode $40 + 8·dst + src is LD dst,src with both numbered in the order B C D E H L (HL) A (0 to 7). The one that would be
LD (HL),(HL), $76, is HALT. Opcodes 40, 49, 52 and 5B (LD B,B and so on) do nothing; on the eZ80 they are suffixes.
Main page, $80–$BF: arithmetic
Opcode $80 + 8·op + src, where op is 0 ADD A,, 1 ADC A,, 2 SUB, 3 SBC A,, 4 AND, 5 XOR,
6 OR, 7 CP, and src is numbered B C D E H L (HL) A.
Main page, $C0–$FF
| x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Cx | ret nz | pop bc | jp nz,nn | jp nn | call nz,nn | push bc | add a,n | rst $00 | ret z | ret | jp z,nn | CB | call z,nn | call nn | adc a,n | rst $08 |
| Dx | ret nc | pop de | jp nc,nn | out (n),a | call nc,nn | push de | sub n | rst $10 | ret c | exx | jp c,nn | in a,(n) | call c,nn | DD | sbc a,n | rst $18 |
| Ex | ret po | pop hl | jp po,nn | ex (sp),hl | call po,nn | push hl | and n | rst $20 | ret pe | jp (hl) | jp pe,nn | ex de,hl | call pe,nn | ED | xor n | rst $28 |
| Fx | ret p | pop af | jp p,nn | di | call p,nn | push af | or n | rst $30 | ret m | ld sp,hl | jp m,nn | ei | call m,nn | FD | cp n | rst $38 |
CB page
Opcode CB xx. The bits split as x (bits 7–6), y (5–3), z (2–0); z is the register in the order B C D E H L (HL) A.
| Opcodes | Instruction |
|---|---|
00–3F | By y: RLC RRC RL RR SLA SRA SLL* SRL, on register z |
40–7F | BIT y,r |
80–BF | RES y,r |
C0–FF | SET y,r |
ED page
| x0 | x1 | x2 | x3 | x4 | x5 | x6 | x7 | x8 | x9 | xA | xB | xC | xD | xE | xF | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 4x | in b,(c) | out (c),b | sbc hl,bc | ld (nn),bc | neg | retn | im 0 | ld i,a | in c,(c) | out (c),c | adc hl,bc | ld bc,(nn) | neg* | reti | im 0* | ld r,a |
| 5x | in d,(c) | out (c),d | sbc hl,de | ld (nn),de | neg* | retn* | im 1 | ld a,i | in e,(c) | out (c),e | adc hl,de | ld de,(nn) | neg* | retn* | im 2 | ld a,r |
| 6x | in h,(c) | out (c),h | sbc hl,hl | ld (nn),hl* | neg* | retn* | im 0* | rrd | in l,(c) | out (c),l | adc hl,hl | ld hl,(nn)* | neg* | retn* | im 0* | rld |
| 7x | in f,(c)* | out (c),0* | sbc hl,sp | ld (nn),sp | neg* | retn* | im 1* | nop* | in a,(c) | out (c),a | adc hl,sp | ld sp,(nn) | neg* | retn* | im 2* | nop* |
| Ax | ldi | cpi | ini | outi | nop* | ldd | cpd | ind | outd | nop* | ||||||
| Bx | ldir | cpir | inir | otir | nop* | lddr | cpdr | indr | otdr | nop* | ||||||
Every other ED opcode (00–3F, 80–9F, A4–A7, AC–AF, B4–B7, BC–FF) is a two-byte NOP*.
DD and FD pages
Take the main page, replace HL by IX (DD) or IY (FD), and (HL) by (IX+d) or (IY+d) with the displacement after the opcode. The opcodes that change:
| Opcodes | Instruction |
|---|---|
09 19 29 39 | ADD IX,BC / DE / IX / SP |
21 22 2A 23 2B | LD IX,nn, LD (nn),IX, LD IX,(nn), INC IX, DEC IX |
34 35 36 | INC (IX+d), DEC (IX+d), LD (IX+d),n |
46 4E 56 5E 66 6E 7E | LD r,(IX+d) (r = B C D E H L A) |
70–75, 77 | LD (IX+d),r |
86 8E 96 9E A6 AE B6 BE | ADD A,(IX+d), ADC, SUB, SBC, AND, XOR, OR, CP |
E1 E3 E5 E9 F9 | POP IX, EX (SP),IX, PUSH IX, JP (IX), LD SP,IX |
CB | DD CB d op: the CB page on (IX+d); see DDCB |
24 25 26 2C 2D 2E, 44 45 4C 4D 54 55 5C 5D, 60–65, 67–6D, 6F, 7C 7D, 84 85 8C 8D 94 95 9C 9D A4 A5 AC AD B4 B5 BC BD | * The IXH and IXL forms of the H and L opcodes. |
| every other | * The prefix is ignored: a one-byte instruction of 4 T-states, then the opcode as on the main page. After DD or FD the opcodes ED, DD and FD are likewise not changed. |
Sources
- Z80 CPU User Manual (UM0080) – Zilog
- The Undocumented Z80 Documented – Sean Young
The maps above were compared opcode by opcode with the decoder (11,964 comparisons).
Not described
Nothing of the Z80’s opcode space is left out. The eZ80 and SM83 maps are on their own pages.