Conventions in instruction source:
D = Destination register (8 bit) S = Source register (8 bit)
RP = Register pair (16 bit)
# = 8 or 16 bit immediate operand a = 16 bit Memory address
p = 8 bit port address ccc = Conditional
Conventions in instruction encoding: db = Data byte (8 bit)
lb = Low byte of 16 bit value hb = High byte of 16 bit value pa = Port address (8 bit)
Dest and Source reg fields: 111=A (Accumulator) 000=B
001=C
010=D
011=E
100=H
101=L
110=M (Memory reference through address in H:L)
Register pair 'RP' fields:
00=BC (B:C as 16 bit register) 01=DE (D:E as 16 bit register) 10=HL (H:L as 16 bit register)
11=SP (Stack pointer, refers to PSW (FLAGS:A) for PUSH/POP)
Condition code 'CCC' fields: (FLAGS: S Z x A x P x C) 000=NZ (Zero flag not set)
001=Z (Zero flag set) 010=NC (Carry flag not set) 011=C (Carry flag set)
100=PO (Parity flag not set - ODD) 101=PE (Parity flag set - EVEN) 110=P (Sign flag not set - POSITIVE) 111=M (Sign flag set - MINUS)
Inst |
Encoding |
Flags |
Description |
|||||
ACI |
# |
11001110 |
db |
ZSCPA |
Add |
immediate to A with carry* |
||
ADC |
S |
10001SSS |
|
ZSCPA |
Add |
register to A with carry |
||
ADD |
S |
10000SSS |
|
ZSPCA |
Add |
register to A |
||
ADI |
# |
11000110 |
db |
ZSCPA |
Add |
immediate to A |
||
ANA |
S |
10100SSS |
|
ZSCPA |
AND |
register with A |
||
ANI |
# |
11100110 |
db |
ZSPCA |
AND |
immediate with A |
||
CALL |
|
a |
11001101 |
lb |
hb |
- |
Unconditional subroutine call |
|
Cccc |
|
a |
11CCC100 |
lb |
hb |
- |
Conditional subroutine call |
|
CMA |
|
|
00101111 |
|
|
- |
Complement A |
|
CMC |
|
|
00111111 |
|
|
C |
Complement Carry flag |
|
CMP |
S |
|
10111SSS |
|
|
ZSPCA |
Compare register with A |
|
CPI |
# |
|
11111110 |
|
|
ZSPCA |
Compare immediate with A |
|
DAA |
|
|
00100111 |
|
|
ZSPCA |
Decimal Adjust accumulator |
|
DAD |
R |
P |
00RP1001 |
|
|
C |
Add register pair to HL (16 bit add)* |
|
DCR |
D |
|
00DDD101 |
|
|
ZSPA |
Decrement register* |
|
DCX |
R |
P |
00RP1011 |
|
|
- |
Decrement register pair |
|
DI |
|
|
11110011 |
|
|
- |
Disable interrupts |
|
EI |
|
|
11111011 |
|
|
- |
Enable interrupts |
|
HLT |
|
|
01110110 |
|
|
- |
Halt processor |
|
IN p |
|
|
11011011 |
pa |
|
- |
Read input port into A |
|
INR |
D |
|
00DDD100 |
|
|
ZSPA |
Increment register |
|
INX Jccc |
R |
P a |
00RP0011 11CCC010 |
lb |
hb |
- - |
Increment register pair Conditional jump* |
|
JMP |
a |
|
11000011 |
lb |
hb |
- |
Unconditional jump* |
|
LDA |
a |
|
00111010 |
lb |
hb |
- |
Load A from memory |
|
LDAX |
|
RP |
00RP1010 |
*1 |
|
- |
Load indirect through BC or DE |
|
LHLD |
|
a |
00101010 |
lb |
hb |
- |
Load H:L from memory* |
|
LXI |
R |
P,# |
00RP0001 |
lb |
hb |
- |
Load register pair immediate* |
|
MOV |
D |
,S |
01DDDSSS |
|
|
- |
Move register to register* |
|
MVI |
D |
,# |
00DDD110 |
db |
|
- |
Move immediate to register* |
|
NOP |
|
|
00000000 |
|
|
- |
No operation |
|
ORA |
S |
|
10110SSS |
|
|
ZSPCA |
OR register with A |
|
ORI |
# |
|
11110110 |
|
|
ZSPCA |
OR immediate with A |
|
OUT |
p |
|
11010011 |
pa |
|
- |
Write A to output port |
|
PCHL |
|
|
11101001 |
|
|
- |
Jump to address in H:L |
|
POP |
R |
P |
11RP0001 |
*2 |
|
*2 |
Pop register pair from the stack |
|
PUSH |
|
RP |
11RP0101 |
*2 |
|
- |
Push register pair on the stack |
|
RAL |
|
|
00010111 |
|
|
C |
Rotate A left through carry* |
|
RAR |
|
|
00011111 |
|
|
C |
Rotate A right through carry |
|
Rccc |
|
|
11CCC000 |
|
|
- |
Conditional return from subroutine |
|
RET |
|
|
11001001 |
|
|
- |
Unconditional return from subroutine |
|
RLC |
|
|
00000111 |
|
|
C |
Rotate A left |
|
RRC |
|
|
00001111 |
|
|
C |
Rotate A right |
|
RST |
n |
|
11NNN111 |
|
|
- |
Restart (Call n*8) |
|
SBB |
S |
|
10011SSS |
|
|
ZSCPA |
Subtract register from A with borrow |
|
SBI |
# |
|
11011110 |
db |
|
ZSCPA |
Subtract immediate from A with borrow |
|
SHLD |
|
a |
00100010 |
lb |
hb |
- |
Store H:L to memory* |
|
SPHL |
|
|
11111001 |
|
|
- |
Set SP to content of H:L |
|
STA |
a |
|
00110010 |
lb |
hb |
- |
Store A to memory |
|
STAX |
|
RP |
00RP0010 |
*1 |
|
- |
Store indirect through BC or DE |
|
STC |
|
|
00110111 |
|
|
C |
Set Carry flag |
|
SUB |
S |
|
10010SSS |
|
|
ZSCPA |
Subtract register from A |
|
SUI |
# |
|
11010110 |
db |
|
ZSCPA |
Subtract immediate from A |
|
XCHG |
|
|
11101011 |
|
|
- |
Exchange DE and HL content |
|
XRA |
S |
|
10101SSS |
|
|
ZSPCA |
Exclusive OR register with A |
|
XRI |
# |
|
11101110 |
db |
|
ZSPCA |
Exclusive OR immediate with A |
|
XTHL |
|
|
11100011 |
|
|
- |
Swap H:L with top word on stack |
*1 = Only RP=00(BC) and 01(DE) are allowed for LDAX/STAX
*2 = RP=11 refers to PSW for PUSH/POP (cannot push/pop SP).
When PSW is POP'd, ALL flags are affected.
Encoding |
|
|
Inst |
|
|
Flags |
Description |
|
00000000 |
|
|
NOP |
|
|
- |
No operation |
|
00000111 |
|
|
RLC |
|
|
C |
Rotate A left |
|
00001111 |
|
|
RRC |
|
|
C |
Rotate A right |
|
00010111 |
|
|
RAL |
|
|
C |
Rotate A left through carry* |
|
00011111 |
|
|
RAR |
|
|
C |
Rotate A right through carry |
|
00100010 |
lb |
hb |
SHLD |
|
a |
- |
Store H:L to memory* |
|
00100111 |
|
|
DAA |
|
|
ZSPCA |
Decimal Adjust accumulator |
|
00101010 |
lb |
hb |
LHLD |
|
a |
- |
Load H:L from memory* |
|
00101111 |
|
|
CMA |
|
|
- |
Complement A |
|
00110010 |
lb |
hb |
STA |
a |
- |
Store A to memory |
||
00110111 |
|
|
STC |
|
C |
Set Carry flag |
||
00111010 |
lb |
hb |
LDA |
a |
- |
Load A from memory |
||
00111111 |
|
|
CMC |
|
C |
Complement Carry flag |
||
00DDD100 |
|
|
INR |
D |
ZSPA |
Increment register |
||
00DDD101 |
|
|
DCR |
D |
ZSPA |
Decrement register* |
||
00DDD110 |
db |
|
MVI |
D,# |
- |
Move immediate to register* |
||
00RP0001 |
lb |
hb |
LXI |
RP,# |
- |
Load register pair immediate* |
||
00RP0010 |
*1 |
|
STAX RP |
- Store indirect through BC or DE |
||||
00RP0011 |
|
|
INX RP |
- Increment register pair |
||||
00RP1001 |
|
|
DAD RP |
C Add register pair to HL (16 bit add)* |
||||
00RP1010 |
*1 |
|
LDAX RP |
- Load indirect through BC or DE |
||||
00RP1011 |
|
|
DCX RP |
- Decrement register pair |
||||
01110110 |
|
|
HLT |
- Halt processor |
||||
01DDDSSS |
|
|
MOV D,S |
- Move register to register* |
||||
10000SSS |
|
|
ADD S |
ZSPCA Add register to A |
||||
10001SSS |
|
|
ADC S |
ZSCPA Add register to A with carry |
||||
10010SSS |
|
|
SUB S |
ZSCPA Subtract register from A |
||||
10011SSS |
|
|
SBB S |
ZSCPA Subtract register from A with borrow |
||||
10100SSS |
|
|
ANA S |
ZSCPA AND register with A |
||||
10101SSS |
|
|
XRA S |
ZSPCA Exclusive OR register with A |
||||
10110SSS |
|
|
ORA S |
ZSPCA OR register with A |
||||
10111SSS |
|
|
CMP S |
ZSPCA Compare register with A |
||||
11000011 |
lb |
hb |
JMP a |
- Unconditional jump* |
||||
11000110 |
db |
|
ADI # |
ZSCPA Add immediate to A |
||||
11001001 |
|
|
RET |
- Unconditional return from subroutine |
||||
11001101 |
lb |
hb |
CALL a |
- Unconditional subroutine call |
||||
11001110 |
db |
|
ACI |
# |
|
ZSCPA |
Add immediate to A with carry* |
|
11010011 |
pa |
OUT |
p |
- |
Write A to output port |
|
||
11010110 |
db |
SUI |
# |
ZSCPA |
Subtract immediate from |
A |
||
11011011 |
pa |
IN p |
|
- |
Read input port into A |
|
||
11011110 |
db |
SBI |
# |
ZSCPA |
Subtract immediate from |
A with borrow |
||
11100011 XTHL - Swap H:L with top word on stack |
||||||||
11100110 |
db |
ANI |
# |
ZSPCA |
AND immediate with |
A |
||
11101001 |
|
PCHL |
|
- |
Jump to address in |
H:L |
||
11101011 |
|
XCHG |
|
- |
Exchange DE and HL |
content |
||
11101110 |
db |
|
XRI |
# |
|
ZSPCA Exclusive OR immediate with A |
||
11110011 |
|
|
DI |
|
|
- Disable interrupts |
||
11110110 |
|
|
ORI |
# |
|
ZSPCA OR immediate with A |
||
11111001 |
|
|
SPHL |
|
|
- Set SP to content of H:L |
||
11111011 |
|
|
EI |
|
|
- Enable interrupts |
||
11111110 |
|
|
CPI |
# |
|
ZSPCA Compare immediate with A |
||
11CCC000 |
|
|
Rccc |
|
|
- Conditional return from subroutine |
||
11CCC010 |
lb |
hb |
Jccc |
|
a |
- Conditional jump* |
||
11CCC100 |
lb |
hb |
Cccc |
|
a |
- Conditional subroutine call |
||
11NNN111 |
|
|
RST |
n |
|
- Restart (Call n*8) |
||
11RP0001 |
*2 |
|
POP |
R |
P |
*2 Pop register pair from the stack |
||
11RP0101 *2 PUSH RP - Push register pair on the stack |
*1 = Only RP=00(BC) and 01(DE) are allowed for LDAX/STAX
*2 = RP=11 refers to PSW for PUSH/POP (cannot push/pop SP).
When PSW is POP'd, ALL flags are affected.