Z80 and R800 Assembly/Machine Language Op-code Tables
Written by "Cyberknight" Masao Kawata.
E-Mail: cyberknight@catsrule.garfield.com
Home Page : http://welcome.to/unicorndreams
Revised: 1999-May-24 Monday.
Notes:
Z80/R800 Instruction Table:
Instructions sorted by Z80 mnemonics (compact) | ||||||||
Z80 Assembly Mnemonics (meaning) | R800 Assembly Mnemonics (meaning) | Operation, Description and Remarks | Flags | Op-codes | B | Z | R | |
Binary | Hex. | |||||||
SZ.HP.NC |
76543210 |
|||||||
adc a,(hl) (ADd with Carry) | addc .a,[.hl] (ADD with Carry) |
.a << .a + [.hl] + C | **?*o?0* |
10001110 | 8E | 1 | 7 | 2 |
adc a,(ii+d) | addc .a,[ii+d] | .a << .a + [ii + d] + C | **?*o?0* |
ii | ii 8E d |
3 | 19 | 5 |
adc a,n | addc .a,n | .a << .a + n + C | **?*o?0* |
11001110 | CE n |
2 | 7 | 2 |
adc a,r | addc .a,r | .a << .a + r + C | **?*o?0* |
10001 r | 1 | 4 | 1 | |
addc .a,p | .a << .a + p + C | **?*o?0* |
11011101 | DD |
2 | 2 | ||
addc .a,q | .a << .a + q + C | **?*o?0* |
11111101 | FD |
2 | 2 | ||
adc hl,ss | addc .hl,ss | .hl << .hl + ss + C | **?*o?0* |
11101101 | ED | 2 | 15 | 2 |
add a,(hl) (ADD) | add .a,[.hl] (ADD) |
.a << .a + [.hl] | **?*o?0* |
10000110 | 86 | 1 | 7 | 2 |
add a,(ii+d) | add .a,[ii+d] | .a << .a + [ii + d] | **?*o?0* |
ii | ii 86 d |
3 | 19 | 5 |
add a,n | add .a,n | .a << .a + n | **?*o?0* |
11000110 | C6 n |
2 | 7 | 2 |
add a,r | add .a,r | .a << .a + r | **?*o?0* |
10000 r | 1 | 4 | 1 | |
add .a,p | .a << .a + p | **?*o?0* |
11011101 | DD | 2 | 2 | ||
add .a,q | .a << .a + q | **?*o?0* |
11111101 | FD | 2 | 2 | ||
add hl,ss | add .hl,ss | .hl << .hl + ss | **?*o?0* |
00ss1001 | 1 | 11 | 1 | |
add ii,pp | add ii,pp | ii << ii + pp | **?*o?0* |
ii | ii | 2 | 15 | 2 |
and (hl) (AND) | and .a,[.hl] (AND) |
.a << .a & [.hl] | **?1p?00 |
10100110 | A6 | 1 | 7 | 2 |
and (ii+d) | and .a,[ii+d] | .a << .a & [ii + d] | **?1p?00 |
ii | ii A6 d |
3 | 19 | 5 |
and n | and .a,n | .a << .a & n | **?1p?00 |
11100110 | E6 n |
2 | 7 | 2 |
and r | and .a,r | .a << .a & r | **?1p?00 |
10100 r | 1 | 4 | 1 | |
and .a,p | .a << .a & p | **?1p?00 |
11011101 | DD | 2 | 2 | ||
and .a,q | .a << .a & q | **?1p?00 |
11111101 | FD | 2 | 2 | ||
bit b,(hl) (test BIT) | bit b,[.hl] (test BIT) |
Z << ¬ [.hl]{b} | ?*?1??0. |
11001011 | CB | 2 | 12 | 3 |
bit b,(ii+d) | bit b,[ii+d] | Z << ¬ [ii + d]{b} | ?*?1??0. |
ii | ii CB d |
4 | 20 | 5 |
bit b,r | bit b,r | Z << ¬ r{b} | ?*?1??0. |
11001011 | CB | 2 | 8 | 2 |
call nn (CALL) | call nn (CALL) |
[.sp - 2] << .pcl [.sp - 1] << .pch .sp << .sp - 2 .pc << nn | ........ |
11001101 | CD nnl nnh |
3 | 17 | 5 |
call c,nn (CALL if Carry) | call c,nn (CALL if Carry) |
if C = 1
[.sp - 1] << .pch .sp << .sp - 2 .pc << nn
| ........ |
11011100 | DC nnl nnh |
3 | 17 10 * | 5 3 * |
call m,nn (CALL if Minus) | call m,nn (CALL if Minus) |
if S = 1
[.sp - 1] << .pch .sp << .sp - 2 .pc << nn
| ........ |
11111100 | FC nnl nnh |
3 | 17 10 * | 5 3 * |
call nc,nn (CALL if Not Carry) | call nc,nn (CALL if Not Carry) |
if C = 0
[.sp - 1] << .pch .sp << .sp - 2 .pc << nn
| ........ |
11010100 | D4 nnl nnh |
3 | 17 10 * | 5 3 * |
call nz,nn (CALL if Not Zero) | call nz,nn (CALL if Not Zero) |
if Z = 0
[.sp - 1] << .pch .sp << .sp - 2 .pc << nn
| ........ |
11000100 | C4 nnl nnh |
3 | 17 10 * | 5 3 * |
call p,nn (CALL if Plus) | call p,nn (CALL if Plus) |
if S = 0
[.sp - 1] << .pch .sp << .sp - 2 .pc << nn
| ........ |
11110100 | F4 nnl nnh |
3 | 17 10 * | 5 3 * |
call pe,nn (CALL if Parity is Even) | call pe,nn (CALL if Parity is Even) |
if P = 1
[.sp - 1] << .pch .sp << .sp - 2 .pc << nn
| ........ |
11101100 | EC nnl nnh |
3 | 17 10 * | 5 3 * |
call po,nn (CALL if Parity is Odd) | call po,nn (CALL if Parity is Odd) |
if P = 0
[.sp - 1] << .pch .sp << .sp - 2 .pc << nn
| ........ |
11100100 | E4 nnl nnh |
3 | 17 10 * | 5 3 * |
call z,nn (CALL if Zero) | call z,nn (CALL if Zero) |
if Z = 1
[.sp - 1] << .pch .sp << .sp - 2 .pc << nn
| ........ |
11001100 | CC nnl nnh |
3 | 17 10 * | 5 3 * |
ccf (Complement Carry Flag) | notc (NOT Carry) |
C << ¬ C | ..??.?0* |
00111111 | 3F | 1 | 4 | 1 |
cp (hl) (ComPare) | cmp .a,[.hl] (CoMPare) |
.a - [.hl] | **?*o?1* |
10111110 | BE | 1 | 7 | 2 |
cp (ii+d) | cmp .a,[ii+d] | .a - [ii + d] | **?*o?1* |
ii | ii BE d |
3 | 19 | 5 |
cp n | cmp .a,n | .a - n | **?*o?1* |
11111110 | FE n |
2 | 7 | 2 |
cp r | cmp .a,r | .a - r | **?*o?1* |
10111 r | 1 | 4 | 1 | |
cmp .a,p | .a - p | **?*o?1* |
11011101 | DD | 2 | 2 | ||
cmp .a,q | .a - q | **?*o?1* |
11111101 | FD | 2 | 2 | ||
cpd (ComPare and Decrement) | cmp .a,[.hl--] | .a - [.hl] .hl << .hl - 1 .bc << .bc - 1 | *%?*$?*. |
11101101 | ED A9 |
2 | 16 | 4 |
cpdr (ComPare, Decrement and Repeat) | cmpm .a,[.hl--] (CoMPare Multiple) |
repeat
.hl << .hl - 1 .bc << .bc - 1
.a = [.hl] |
*%?*$?*. |
11101101 | ED B9 |
2 | 21 16 * | 4 4 * |
cpi (ComPare and Increment) | cmp .a,[.hl++] | .a - [.hl] .hl << .hl + 1 .bc << .bc - 1 | *%?*$?*. |
11101101 | ED A1 |
2 | 16 | 4 |
cpir (ComPare, Increment and Repeat) | cmpm .a,[.hl++] | repeat
.hl << .hl + 1 .bc << .bc - 1
.a = [.hl] |
*%?*$?*. |
11101101 | ED B1 |
2 | 21 16 * | 4 4 * |
cpl (ComPLement accumulator) | not .a (NOT) |
.a << ¬ .a | ..?1.?1. |
00101111 | 2F | 1 | 4 | 1 |
daa (Decimal Adjust Accumulator) | adj .a (ADJust) |
adjust to decimal | **?*p?.* |
00100111 | 27 | 1 | 4 | 1 |
dec (hl) (DECrement) | dec [.hl] (DECrement) |
[.hl] << [.hl] - 1 | **?*o?0. |
00110101 | 35 | 1 | 11 | 4 |
dec (ii+d) | dec [ii+d] | [ii + d] << [ii + d] - 1 | **?*o?0. |
ii | ii 35 d |
3 | 23 | 7 |
dec r | dec r | r << r - 1 | **?*o?0. |
00 r 101 | 1 | 4 | 1 | |
dec p | p << p - 1 | **?*o?0. |
11011101 | DD | 2 | 2 | ||
dec q | q << q - 1 | **?*o?0. |
11111101 | FD | 2 | 2 | ||
dec ss | dec ss | ss << ss - 1 | ........ |
00ss1011 | 1 | 6 | 1 | |
dec ii | dec ii | ii << ii - 1 | ........ |
ii | ii 2B |
2 | 10 | 2 |
di (Disable Interruption) | di (Disable Interruption) |
IFF << 0 | ........ |
11110011 | F3 | 1 | 4 | 2 |
djnz d (Decrement and Jump if Not Zero) | dbnz d (Decrement and Branch if Not Zero) |
.b << .b - 1 if .b not zero
| ........ |
00010000 | 10 d |
2 | 13 8 | 2 2 |
ei (Enable Interruption) | ei (Enable Interruption) |
IFF << 1 | ........ |
11111011 | FB | 1 | 4 | 1 |
ex (sp),hl (EXchange) | xch [.sp],.hl (eXCHange) |
.l <=> [.sp] .h <=> [.sp + 1] | ........ |
11100011 | E3 | 1 | 19 | 5 |
ex (sp),ii | xch [.sp],ii | iil <=> [.sp] iih <=> [.sp + 1] | ........ |
ii | ii E3 |
2 | 23 | 6 |
ex af,af' | xch .af,.af' | .af <=> .af' | ........ |
00001000 | 08 | 1 | 4 | 1 |
ex de,hl | xch .de,.hl | .de <=> .hl | ........ |
11101011 | EB | 1 | 4 | 1 |
exx (EXchange with auXiliar) | xchx (eXCHange with auXiliar) |
.bc <=> .bc' .de <=> .de' .hl <=> .hl' | ........ |
11011001 | D9 | 1 | 4 | 1 |
halt (HALT) | halt (HALT) |
halt processor | ........ |
01110110 | 76 | 1 | 4 | 2 |
im 0 (Interruption Mode 0) | im 0 (Interruption Mode 0) |
set interruption mode 0 | ........ |
11101101 | ED 46 |
2 | 8 | 3 |
im 1 (Interruption Mode 1) | im 1 (Interruption Mode 1) |
set interruption mode 1 | ........ |
11101101 | ED 56 |
2 | 8 | 3 |
im 2 (Interruption Mode 2) | im 2 (Interruption Mode 2) |
set interruption mode 2 | ........ |
11101101 | ED 5E |
2 | 8 | 3 |
in a,(n) (INput) | in .a,[n] (INput) |
.a << [n] | ........ |
11011011 | DB n |
2 | 11 | 3 |
in r,(c) | in r,[.c] | r << [.c] | **?0p?0. |
11101101 | ED | 2 | 12 | 3 |
*1 | in .f,[.c] | [.c] * note 1: this instruction has no mnemonic for Z80, so its op-code must be directly defined when necessary (in pseudo-code: db 0edh,070h) * note 2: the R800 mnemonic implies, but doesn't mean, that the datum is stored in .f; the mnemonic only indicates the instruction affects .f | **?0p?0. |
11101101 | ED 70 |
2 | 12 | 3 |
inc (hl) (INCrement) | inc [.hl] (INCrement) |
[.hl] << [.hl] + 1 | **?*o?0. |
00110100 | 34 | 1 | 11 | 4 |
inc (ii+d) | inc [ii+d] | [ii + d] << [ii + d] + 1 | **?*o?0. |
ii | ii 34 d |
3 | 23 | 7 |
inc r | inc r | r << r + 1 | **?*o?0. |
00 r 100 | 1 | 4 | 1 | |
inc p | p << p + 1 | **?*o?0. |
11011101 | DD | 2 | 2 | ||
inc q | q << q + 1 | **?*o?0. |
11111101 | FD | 2 | 2 | ||
inc ss | inc ss | ss << ss + 1 | ........ |
00ss0011 | 1 | 6 | 1 | |
inc ii | inc ii | ii << ii + 1 | ........ |
ii | ii 23 |
2 | 10 | 2 |
ind (INput and Decrement) | in [.hl--],[.c] (INput) |
[.hl] << [.c] .b << .b - 1 .hl << .hl - 1 | ?!????1. |
11101101 | ED AA |
2 | 16 | 4 |
indr (INput, Decrement and Repeat) | inm [.hl--],[.c] (INput Multiple) |
repeat
.b << .b - 1 .hl << .hl - 1
| ?1????1. |
11101101 | ED BA |
2 | 21 16 * | 4 3 * |
ini (INput and Increment) | in [.hl++],[.c] (INput) |
[.hl] << [.c] .b << .b - 1 .hl << .hl + 1 | ?!????1. |
11101101 | ED A2 |
2 | 16 | 4 |
inir (INput, Increment and Repeat) | inm [.hl++],[.c] | repeat
.b << .b - 1 .hl << .hl + 1
| ?1????1. |
11101101 | ED B2 |
2 | 21 16 * | 4 3 * |
jp (hl) (JumP) | br [.hl] (BRanch) |
.pc << [.hl] | ........ |
11101001 | E9 | 1 | 4 | 1 |
jp (ii) | br [ii] | .pc << [ii] | ........ |
ii | ii E9 |
2 | 8 | 2 |
jp nn | br nn | .pc << nn | ........ |
11000011 | C3 nnl nnh |
3 | 10 | 3 |
jp c,nn (JumP if Carry) | bc nn (Branch if Carry) |
if C = 1
| ........ |
11011010 | DA nnl nnh |
3 | 10 | 3 |
jp m,nn (JumP if Minus) | bm nn (Branch if Minus) |
if S = 1
| ........ |
11111010 | FA nnl nnh |
3 | 10 | 3 |
jp nc,nn (JumP if Not Carry) | bnc nn (Branch if Not Carry) |
if C = 0
| ........ |
11010010 | D2 nnl nnh |
3 | 10 | 3 |
jp nz,nn (JumP if Not Zero) | bnz nn (Branch if Not Zero) |
if Z = 0
| ........ |
11000010 | C2 nnl nnh |
3 | 10 | 3 |
jp p,nn (JumP if Plus) | bp nn (Branch if Plus) |
if S = 0
| ........ |
11110010 | F2 nnl nnh |
3 | 10 | 3 |
jp pe,nn (JumP if Parity is Even) | bpe nn (Branch if Parity is Even) |
if P = 1
| ........ |
11101010 | EA nnl nnh |
3 | 10 | 3 |
jp po,nn (JumP if Parity is Odd) | bpo nn (Branch if Parity is Odd) |
if P = 0
| ........ |
11100010 | E2 nnl nnh |
3 | 10 | 3 |
jp z,nn (JumP if Zero) | bz nn (Branch if Zero) |
if Z = 1
| ........ |
11001010 | CA nnl nnh |
3 | 10 | 3 |
jr d (Jump Relative) | short br d (SHORT BRanch) |
.pc << .pc + d | ........ |
00011000 | 18 d |
2 | 12 | 3 |
jr c,d (Jump Relative if Carry) | short bc d (SHORT Branch if Carry) |
if C = 1
| ........ |
00111000 | 38 d |
2 | 12 7 * | 3 2 * |
jr nc,d (Jump Relative if Not Carry) | short bnc d (SHORT Branch if Not Carry) |
if C = 0
| ........ |
00110000 | 30 d |
2 | 12 7 * | 3 2 * |
jr nz,d (Jump Relative if Not Zero) | short bnz d (SHORT Branch if Not Zero) |
if Z = 0
| ........ |
00100000 | 20 d |
2 | 12 7 * | 3 2 * |
jr z,d (Jump Relative if Zero) | short bz d (SHORT Branch if Zero) |
if Z = 1
| ........ |
00101000 | 28 d |
2 | 12 7 * | 3 2 * |
ld (nn),a (LoaD) | ld [nn],.a (LoaD) |
[nn] << .a | ........ |
00110010 | 32 nnl nnh |
3 | 13 | 4 |
ld (nn),ss | ld [nn],ss | [nn + 1] << ssh [nn] << ssl | ........ |
11101101 | ED nnl nnh |
4 | 20 | 6 |
ld (nn),hl | ld [nn],.hl | [nn + 1] << .h [nn] << .l | ........ |
00100010 | 22 nnl nnh |
3 | 16 | 5 |
ld (nn),ii | ld [nn],ii | [nn + 1] << iih [nn] << iil | ........ |
ii | ii 22 nnl nnh |
4 | 20 | 6 |
ld (bc),a | ld [.bc],.a | [.bc] << .a | ........ |
00000010 | 02 | 1 | 7 | 2 |
ld (de),a | ld [.de],.a | [.de] << .a | ........ |
00010010 | 12 | 1 | 7 | 2 |
ld (hl),n | ld [.hl],n | [.hl] << n | ........ |
00110110 | 36 n |
2 | 10 | 3 |
ld (hl),r | ld [.hl],r | [.hl] << r | ........ |
01110 r | 1 | 7 | 2 | |
ld (ii+d),n | ld [ii+d],n | [ii + d] << n | ........ |
ii | ii 36 d n |
4 | 19 | 5 |
ld (ii+d),r | ld [ii+d],r | [ii + d] << r | ........ |
ii | ii d |
3 | 19 | 5 |
ld a,(nn) | ld .a,[nn] | .a << [nn] | ........ |
00111010 | 3A nnl nnh |
3 | 13 | 4 |
ld a,(bc) | ld .a,[.bc] | .a << [.bc] | ........ |
00001010 | 0A | 1 | 7 | 2 |
ld a,(de) | ld .a,[.de] | .a << [.de] | ........ |
00011010 | 1A | 1 | 7 | 2 |
ld a,i | ld .a,.i | .a << .i | **?0I?0* |
11101101 | ED 57 |
2 | 9 | 2 |
ld a,r | ld .a,.r | .a << .r | **?0I?0* |
11101101 | ED 5F |
2 | 9 | 2 |
ld r,(hl) | ld r,[.hl] | r << [.hl] | ........ |
01 r 110 | 1 | 7 | 2 | |
ld r,(ii+d) | ld r,[ii+d] | r << [ii + d] | ........ |
ii | ii d |
3 | 19 | 5 |
ld r,n | ld r,n | r << n | ........ |
00 r 110 | n |
2 | 7 | 2 |
ld u,n | u << n | ........ |
11011101 | DD n |
3 | 3 | ||
ld v,n | v << n | ........ |
11111101 | FD n |
3 | 3 | ||
ld i,a | ld .i,.a | .i << .a | ........ |
11101101 | ED 47 |
2 | 9 | 2 |
ld r1,r2 | ld r1,r2 | r1 << r2 | ........ |
01 r1 r2 | 1 | 4 | 1 | |
ld u1,u2 | u1 << u2 | ........ |
11011101 | DD | 2 | 2 | ||
ld v1,v2 | v1 << v2 | ........ |
11111101 | FD | 2 | 2 | ||
ld ss,(nn) | ld ss,[nn] | ssh << [nn + 1] ssl << [nn] | ........ |
11101101 | ED nnl nnh |
4 | 20 | 6 |
ld ss,nn | ld ss,nn | ss << nn | ........ |
00ss0001 | nnl nnh |
3 | 10 | 3 |
ld hl,(nn) | ld .hl,[nn] | .h << [nn + 1] .l << [nn] | ........ |
00101010 | 2A nnl nnh |
3 | 16 | 5 |
ld ii,(nn) | ld ii,[nn] | iih << [nn + 1] iil << [nn] | ........ |
ii | ii 2A nnl nnh |
4 | 20 | 6 |
ld ii,nn | ld ii,nn | ii << nn | ........ |
ii | ii 21 nnl nnh |
4 | 14 | 4 |
ld r,a | ld .r,.a | .r << .a | ........ |
11101101 | ED 4F |
2 | 9 | 2 |
ld sp,hl | ld .sp,.hl | .sp << .hl | ........ |
11111001 | F9 | 1 | 6 | 1 |
ld sp,ii | ld .sp,ii | .sp << ii | ........ |
ii | ii F9 |
2 | 10 | 2 |
ldd (LoaD and Decrement) | move [.hl--],[.de--] (MOVE) |
[.de] << [.hl] .de << .de - 1 .hl << .hl - 1 .bc << .bc - 1 | ..?0$?0. |
11101101 | ED A8 |
2 | 16 | 4 |
lddr (LoaD, Decrement and Repeat) | movem [.hl--],[.de--] (MOVE Multiple) |