Zilog Z80 Instruction Set: Difference between revisions
Appearance
m →Single-byte Instructions: removed collapsible style from table. |
→Single-byte Instructions: added more instructions. |
||
| Line 38: | Line 38: | ||
|(IY+d) | |(IY+d) | ||
| align="left" |Identifies the contents of the memory location, whose address is specified by the contents of the '''IY''' Index Register plus the signed displacement '''d'''. | | align="left" |Identifies the contents of the memory location, whose address is specified by the contents of the '''IY''' Index Register plus the signed displacement '''d'''. | ||
|} | |||
{| class="wikitable mw-collapsible" style="text-align:center" | |||
|+8-bit Register Values | |||
!Registers | |||
!Value | |||
|- | |||
|B | |||
|000 | |||
|- | |||
|C | |||
|001 | |||
|- | |||
|D | |||
|010 | |||
|- | |||
|E/''(IX+d)<sup>†</sup>'' | |||
|011 | |||
|- | |||
|H | |||
|100 | |||
|- | |||
|L | |||
|101 | |||
|- | |||
|''(HL)<sup>*</sup>'' | |||
|110 | |||
|- | |||
|A/''(IY+d)<sup>‡</sup>'' | |||
|111 | |||
|- | |||
|colspan="2" align="left"| ''<sup>*</sup> indicates when mnemonic is '''m''''' | |||
''<sup>†</sup> indicates when mnemonic is '''m''' and prefix is '''''DD'''''<br /><sup>‡</sup> indicates when mnemonic is '''m''' and prefix is '''''FD''' | |||
|} | |||
{| class="wikitable mw-collapsible" style="text-align:center" | |||
|+16-bit Register Values | |||
!Registers | |||
!Value | |||
|- | |||
|BC | |||
|00 | |||
|- | |||
|DE | |||
|01 | |||
|- | |||
|HL/''IX<sup>†</sup>/IY<sup>‡</sup>'' | |||
|10 | |||
|- | |||
|SP | |||
|11 | |||
|- | |||
| colspan="2" |''<sup>†</sup> indicates when mnemonic is '''m''' and prefix is '''''DD'''''<br /><sup>‡</sup> indicates when mnemonic is '''m''' and prefix is '''''FD''' | |||
|} | |} | ||
| Line 111: | Line 164: | ||
|— | |— | ||
|— | |— | ||
| align="left" |EX AF, | | align="left" |EX AF,AF’ | ||
| align="left" |AF ↔ | | align="left" |AF ↔ AF’ | ||
|- | |- | ||
|0 | |0 | ||
| Line 278: | Line 331: | ||
| align="left" |CPL | | align="left" |CPL | ||
| align="left" |A ← ¬A | | align="left" |A ← ¬A | ||
|- | |||
|0 | |||
|0 | |||
|1 | |||
|1 | |||
|0 | |||
|0 | |||
|1 | |||
|0 | |||
|n-lo | |||
|n-hi | |||
| align="left" |LD (nn), A | |||
| align="left" |(nn) ← A | |||
|- | |||
|0 | |||
|0 | |||
|1 | |||
|1 | |||
|0 | |||
|1 | |||
|1 | |||
|1 | |||
|— | |||
|— | |||
| align="left" |SCF | |||
| align="left" |Cy ← 1 | |||
|- | |||
|0 | |||
|0 | |||
|1 | |||
|1 | |||
|1 | |||
|0 | |||
|1 | |||
|0 | |||
|n-lo | |||
|n-hi | |||
| align="left" |LD A, (nn) | |||
| align="left" |A ← (nn) | |||
|- | |||
|0 | |||
|0 | |||
|1 | |||
|1 | |||
|1 | |||
|1 | |||
|1 | |||
|1 | |||
|— | |||
|— | |||
| align="left" |CCF | |||
| align="left" |Cy ← ¬Cy | |||
|- | |||
|0 | |||
|1 | |||
| colspan="3" |r<sup>1</sup> | |||
| colspan="3" |r<sup>2</sup> | |||
|— | |||
|— | |||
| align="left" |LD r<sup>1</sup>, r<sup>2</sup> | |||
| align="left" |r<sup>1</sup> ← r<sup>2</sup> | |||
|- | |||
|0 | |||
|1 | |||
|1 | |||
|1 | |||
|0 | |||
|1 | |||
|1 | |||
|0 | |||
|— | |||
|— | |||
| align="left" |HALT | |||
| align="left" |Halt CPU | |||
|- | |||
|1 | |||
|0 | |||
|0 | |||
|0 | |||
|0 | |||
| colspan="3" |r | |||
|— | |||
|— | |||
| align="left" |ADD, r | |||
| align="left" |ADD A ← r | |||
|- | |||
|1 | |||
|0 | |||
|0 | |||
|0 | |||
|1 | |||
| colspan="3" |r | |||
|— | |||
|— | |||
| align="left" |ADC, r | |||
| align="left" |ADC A ← r | |||
|- | |||
|1 | |||
|0 | |||
|0 | |||
|1 | |||
|0 | |||
| colspan="3" |r | |||
|— | |||
|— | |||
| align="left" |SUB, r | |||
| align="left" |SUB A ← r | |||
|- | |||
|1 | |||
|0 | |||
|0 | |||
|1 | |||
|1 | |||
| colspan="3" |r | |||
|— | |||
|— | |||
| align="left" |SBC, r | |||
| align="left" |SBC A ← r | |||
|- | |||
|1 | |||
|0 | |||
|1 | |||
|0 | |||
|0 | |||
| colspan="3" |r | |||
|— | |||
|— | |||
| align="left" |AND, r | |||
| align="left" |AND A ← r | |||
|- | |||
|1 | |||
|0 | |||
|1 | |||
|0 | |||
|1 | |||
| colspan="3" |r | |||
|— | |||
|— | |||
| align="left" |XOR, r | |||
| align="left" |XOR A ← r | |||
|- | |||
|1 | |||
|0 | |||
|1 | |||
|1 | |||
|0 | |||
| colspan="3" |r | |||
|— | |||
|— | |||
| align="left" |OR, r | |||
| align="left" |OR A ← r | |||
|- | |||
|1 | |||
|0 | |||
|1 | |||
|1 | |||
|1 | |||
| colspan="3" |r | |||
|— | |||
|— | |||
| align="left" |CP, r | |||
| align="left" |CP A ← r | |||
|- | |||
|1 | |||
|1 | |||
| colspan="3" |cc | |||
|0 | |||
|0 | |||
|0 | |||
|— | |||
|— | |||
| align="left" |RET cc | |||
| align="left" |If cc true, PC ← (SP), SP ← SP + 2 | |||
|- | |||
|1 | |||
|1 | |||
| colspan="2" |rr | |||
|0 | |||
|0 | |||
|0 | |||
|1 | |||
|— | |||
|— | |||
| align="left" |POP rr | |||
| align="left" |rr ← (SP), SP ← SP + 2 | |||
|- | |||
|1 | |||
|1 | |||
| colspan="3" |cc | |||
|0 | |||
|1 | |||
|0 | |||
|n-lo | |||
|n-hi | |||
| align="left" |JP cc, nn | |||
| align="left" |If cc true, PC ← nn | |||
|- | |||
|1 | |||
|1 | |||
|0 | |||
|0 | |||
|0 | |||
|0 | |||
|1 | |||
|1 | |||
|n-lo | |||
|n-hi | |||
| align="left" |JP nn | |||
| align="left" |PC ← nn | |||
|- | |||
|1 | |||
|1 | |||
| colspan="3" |cc | |||
|1 | |||
|0 | |||
|0 | |||
|n-lo | |||
|n-hi | |||
| align="left" |CALL cc, nn | |||
| align="left" |If cc true, SP ← SP - 2, (SP) ← PC, PC ← nn | |||
|- | |||
|1 | |||
|1 | |||
|rr | |||
| | |||
|0 | |||
|1 | |||
|0 | |||
|1 | |||
|— | |||
|— | |||
| align="left" |PUSH rr | |||
| align="left" |SP ← SP - 2, (SP) ← rr | |||
|- | |- | ||
|} | |} | ||
Revision as of 13:01, 2 June 2026
Instructions by Opcode
| Mnemonic | Description |
|---|---|
| b | Identifies a one-bit expression in the range (0 to 7). The most-significant bit to the left is bit 7 and the least-significant bit to the right is bit 0. |
| cc | Identifies the status of the Flag Register as any of (NZ, Z, NC, C, PO, PE, P, or M) for the conditional jumps, calls, and return instructions. |
| d | Identifies a one-byte signed integer expression in the range ( -128 to +127). |
| e | Identifies a one-byte signed integer expression in the range (-126 to +129) for relative jump offset from current location. |
| m | Identifies any one of r, (HL), (IX+d) or (IY+d). |
| n | Identifies a one-byte unsigned integer expression in the range (0 to 255). |
| nn | Identifies a two-byte unsigned integer expression in the range (0 to 65535). |
| pp | Identifies any one of the 16-bit registers BC, DE, IX, SP. |
| Identifies any one of the 16-bit registers BC, DE, HL, AF. | |
| r | Identifies any one of the 8-bit registers A, B, C, D, E, H, L. |
| rr | Identifies any one of the 16-bit registers BC, DE, IY, SP. |
| ss | Identifies any one of the 16-bit registers BC, DE, HL, SP. |
| (HL) | Identifies the contents of the memory location, whose address is specified by the contents of the register pair HL. |
| (IX+d) | Identifies the contents of the memory location, whose address is specified by the contents of the IX Index Register plus the signed displacement d. |
| (IY+d) | Identifies the contents of the memory location, whose address is specified by the contents of the IY Index Register plus the signed displacement d. |
| Registers | Value |
|---|---|
| B | 000 |
| C | 001 |
| D | 010 |
| E/(IX+d)† | 011 |
| H | 100 |
| L | 101 |
| (HL)* | 110 |
| A/(IY+d)‡ | 111 |
| * indicates when mnemonic is m
† indicates when mnemonic is m and prefix is DD | |
| Registers | Value |
|---|---|
| BC | 00 |
| DE | 01 |
| HL/IX†/IY‡ | 10 |
| SP | 11 |
| † indicates when mnemonic is m and prefix is DD ‡ indicates when mnemonic is m and prefix is FD | |
Single-byte Instructions
| Opcode | Operands | Mnemonic | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | b2 | b3 | ||
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | — | — | NOP | No operation |
| 0 | 0 | rr | 0 | 0 | 0 | 1 | n-lo | n-hi | LD rr, nn | rr ← nn | |
| 0 | 0 | rr | 0 | 0 | 1 | 0 | — | — | LD (rr), A | rr ← A | |
| 0 | 0 | ss | 0 | 0 | 1 | 1 | — | — | INC ss | ss ← ss + 1 | |
| 0 | 0 | r | 1 | 0 | 0 | — | — | INC r | r ← r + 1 | ||
| 0 | 0 | r | 1 | 0 | 1 | — | — | DEC r | r ← r - 1 | ||
| 0 | 0 | r | 1 | 1 | 0 | n | — | LD r, n | r ← n | ||
| 0 | 0 | 0 | 0 | 0 | 1 | 1 | 1 | — | — | RLCA | A1-7 ← A0-6; A0 ← Cy ← A7 |
| 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | — | — | EX AF,AF’ | AF ↔ AF’ |
| 0 | 0 | rr | 1 | 0 | 0 | 1 | — | — | ADD HL, rr | HL ← HL + rr | |
| 0 | 0 | rr | 1 | 0 | 1 | 0 | — | — | LD A, (rr) | A ← (rr) [BC or DE only] | |
| 0 | 0 | rr | 1 | 0 | 1 | 1 | — | — | DEC rr | rr ← rr - 1 | |
| 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | — | — | RRCA | A0-6 ← A1-7; A7 ← Cy ← A0 |
| 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | d | — | DJNZ d | B = B - 1; if B ≠ 0 then PC ← PC + d |
| 0 | 0 | 0 | 1 | 0 | 1 | 1 | 1 | — | — | RLA | A1-7 ← A0-6; Cy ← A7; A0 ← Cy |
| 0 | 0 | 0 | 1 | 1 | 0 | 0 | 0 | d | — | JR d | PC ← PC + d |
| 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | — | — | RRA | A0-6 ← A1-7; Cy ← A0; A7 ← Cy |
| 0 | 0 | 1 | cc | 0 | 0 | 0 | d | — | JR cc, d | If cc0-1 true, PC ← PC + d (Only 2 bits of cc used: NZ, Z, NC, C) | |
| 0 | 0 | 1 | 0 | 0 | 0 | 1 | 0 | n-lo | n-hi | LD (nn), HL | (nn) ← HL |
| 0 | 0 | 1 | 0 | 0 | 1 | 1 | 1 | — | — | DAA | @ |
| 0 | 0 | 1 | 0 | 1 | 0 | 1 | 0 | n-lo | n-hi | LD HL, (nn) | HL ← (nn) |
| 0 | 0 | 1 | 0 | 1 | 1 | 1 | 1 | — | — | CPL | A ← ¬A |
| 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 | n-lo | n-hi | LD (nn), A | (nn) ← A |
| 0 | 0 | 1 | 1 | 0 | 1 | 1 | 1 | — | — | SCF | Cy ← 1 |
| 0 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | n-lo | n-hi | LD A, (nn) | A ← (nn) |
| 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | — | — | CCF | Cy ← ¬Cy |
| 0 | 1 | r1 | r2 | — | — | LD r1, r2 | r1 ← r2 | ||||
| 0 | 1 | 1 | 1 | 0 | 1 | 1 | 0 | — | — | HALT | Halt CPU |
| 1 | 0 | 0 | 0 | 0 | r | — | — | ADD, r | ADD A ← r | ||
| 1 | 0 | 0 | 0 | 1 | r | — | — | ADC, r | ADC A ← r | ||
| 1 | 0 | 0 | 1 | 0 | r | — | — | SUB, r | SUB A ← r | ||
| 1 | 0 | 0 | 1 | 1 | r | — | — | SBC, r | SBC A ← r | ||
| 1 | 0 | 1 | 0 | 0 | r | — | — | AND, r | AND A ← r | ||
| 1 | 0 | 1 | 0 | 1 | r | — | — | XOR, r | XOR A ← r | ||
| 1 | 0 | 1 | 1 | 0 | r | — | — | OR, r | OR A ← r | ||
| 1 | 0 | 1 | 1 | 1 | r | — | — | CP, r | CP A ← r | ||
| 1 | 1 | cc | 0 | 0 | 0 | — | — | RET cc | If cc true, PC ← (SP), SP ← SP + 2 | ||
| 1 | 1 | rr | 0 | 0 | 0 | 1 | — | — | POP rr | rr ← (SP), SP ← SP + 2 | |
| 1 | 1 | cc | 0 | 1 | 0 | n-lo | n-hi | JP cc, nn | If cc true, PC ← nn | ||
| 1 | 1 | 0 | 0 | 0 | 0 | 1 | 1 | n-lo | n-hi | JP nn | PC ← nn |
| 1 | 1 | cc | 1 | 0 | 0 | n-lo | n-hi | CALL cc, nn | If cc true, SP ← SP - 2, (SP) ← PC, PC ← nn | ||
| 1 | 1 | rr | 0 | 1 | 0 | 1 | — | — | PUSH rr | SP ← SP - 2, (SP) ← rr | |
Instructions by Group
8-bit Load Group
16-bit Load Group
Exchange, Block Transfer, Search Group
General Purpose Arithmetic and CPU Control Group
NOP
Operation
—
Op Code
NOP
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 00 |
Operands
None.
Description
The CPU performs no operation during the machine cycle.
| M-Cyles | T-States | 4 MHz E.T. |
|---|---|---|
| 1 | 4 | 1.0 |
Condition Bits Affected
None.