Académique Documents
Professionnel Documents
Culture Documents
--------------------------------------------Since books on the Z80 are getting harder & harder to find,
hopefully the information here might be helpful to those
trying to understand assembly language specific to GameBoy.
If 'Flags affected' is not given for a command then none
are affected.
Commands
-------ADC A,n
ADD A,n
affected:
- Set if result is zero.
- Reset.
- Set if carry from bit 3.
- Set if carry from bit 7.
- Add n to A.
n = A,B,C,D,E,H,L,(HL),#
Flags
Z
N
H
C
ADD HL,n
affected:
- Set if result is zero.
- Reset.
- Set if carry from bit 3.
- Set if carry from bit 7.
- Add n to HL.
n = BC,DE,HL
Flags
Z
N
H
C
ADD SP,n
affected:
- Not affected.
- Reset.
- Set if carry from bit 11.
- Set if carry from bit 15.
- Add n to Stack Pointer (SP).
affected:
- Reset.
- Reset.
- Set or reset according to operation.
- Set or reset according to operation.
- Logically AND n with A, result in A.
n = A,B,C,D,E,H,L,(HL),#
Flags
Z
N
H
C
affected:
- Set if result is zero.
- Reset.
- Set.
- Reset.
BIT b,r
affected:
- Set if bit b of register r is 0.
- Reset.
- Set.
- Not affected.
CALL n
CALL cc,n
cc
cc
cc
cc
=
=
=
=
CCF
NZ,
Z,
NC,
C,
Call
Call
Call
Call
if
if
if
if
Z
Z
C
C
flag
flag
flag
flag
is
is
is
is
reset.
set.
reset.
set.
CP n
affected:
- Not affected.
- Reset.
- Reset.
- Complemented.
- Compare A with n.
affected:
- Set if result is zero. (Set if A = n.)
- Set.
- Set if no borrow from bit 4.
- Set for no borrow. (Set if A < n.)
CPL
DAA
affected:
- Not affected.
- Set.
- Set.
- Not affected.
- Decimal adjust register A.
affected:
- Set if register A is zero.
- Not affected.
- Reset.
- Set or reset according to operation.
- Decrement register n.
n = A,B,C,D,E,H,L,(HL)
Flags
Z
N
H
C
DEC nn
affected:
- Set if reselt is zero.
- Set.
- Set if no borrow from bit 4.
- Not affected.
- Decrement register nn.
nn = BC,DE,HL,SP
Flags affected:
None
DI
- Disable interrupts.
Flags affected:
None.
EI
- Enable interrupts.
This intruction enables interrupts but not immediately.
Interrupts are enabled after instruction after EI is
executed.
Flags affected:
None.
INC n
- Increment register n.
n = A,B,C,D,E,H,L,(HL)
Flags
Z
N
H
C
affected:
- Set if result is zero.
- Reset.
- Set if carry from bit 3.
- Not affected.
INC nn
JP n
- Jump to address n.
n = two byte immediate value. (LS byte first.)
JP cc,n
=
=
=
=
NZ,
Z,
NC,
C,
Jump
Jump
Jump
Jump
if
if
if
if
Z
Z
C
C
flag
flag
flag
flag
is
is
is
is
reset.
set.
reset.
set.
JP (HL)
JR n
JR cc,n
=
=
=
=
NZ,
Z,
NC,
C,
Jump
Jump
Jump
Jump
if
if
if
if
Z
Z
C
C
flag
flag
flag
flag
is
is
is
is
reset.
set.
reset.
set.
HALT
LD A,n
LD n,A
n = A,B,C,D,E,H,L,(BC),(DE),(HL),(nnnn)
LD A,(C)
LD A,(HL+)
- Same as LD A,(HLI).
LD A,(HL-)
- Same as LD A,(HLD).
LD A,(HLI)
LD A,(HLD)
LD (C),A
LD (HL+),A
- Same as LD (HLI),A.
LD (HL-),A
- Same as LD (HLD),A.
LD (HLI),A
LD (HLD),A
LD r1,r2
r1,r2 = A,B,C,D,E,H,L,(HL)
LD n,nn
LD HL,(SP+n)
LD SP,HL
LD (n),SP
- Same as LD A,(HLD).
LDD (HL),A
- Same as LD (HLD),A.
LDH (n),A
affected:
- Reset.
- Reset.
- Set or reset according to operation.
- Set or reset according to operation.
LDI A,(HL)
- Same as LD A,(HLI).
LDI (HL),A
- Same as LD (HLI),A.
NOP
- No operation.
OR n
POP nn
affected:
- Set if result is zero.
- Reset.
- Reset.
- Reset.
- Pop two bytes off stack into register pair nn.
Increment Stack Pointer (SP) twice.
nn = AF,BC,DE,HL
PUSH nn
RES b,r
None.
RET
RET cc
=
=
=
=
NZ,
Z,
NC,
C,
Return
Return
Return
Return
if
if
if
if
Z
Z
C
C
flag
flag
flag
flag
is
is
is
is
reset.
set.
reset.
set.
RETI
RL n
RLC n
affected:
- Set if result is zero.
- Reset.
- Reset.
- Contains old bit 7 data.
- Rotate n left. Old bit 7 to Carry flag.
n = A,B,C,D,E,H,L,(HL)
Flags
Z
N
H
C
RR n
affected:
- Set if result is zero.
- Reset.
- Reset.
- Contains old bit 7 data.
- Rotate n right through Carry flag.
n = A,B,C,D,E,H,L,(HL)
Flags
Z
N
H
C
RRC n
affected:
- Set if result is zero.
- Reset.
- Reset.
- Contains old bit 0 data.
- Rotate n right. Old bit 0 to Carry flag.
n = A,B,C,D,E,H,L,(HL)
Flags
Z
N
H
C
affected:
- Set if result is zero.
- Reset.
- Reset.
- Contains old bit 0 data.
RST n
SBC A,n
SCF
affected:
- Set if result is zero.
- Set.
- Set if no borrow from bit 4.
- Set if no borrow.
- Set Carry flag.
Flags
Z
N
H
C
SET b,r
affected:
- Not affected.
- Reset.
- Reset.
- Set.
- Set bit b in register r.
b = 0 - 7, r = A,B,C,D,E,H,L,(HL)
Flags affected:
None.
SLA n
SRA n
affected:
- Set if result is zero.
- Reset.
- Reset.
- Contains old bit 7 data.
- Shift n right into Carry. MSB doesn't change.
n = A,B,C,D,E,H,L,(HL)
Flags
Z
N
H
C
SRL n
affected:
- Set if result is zero.
- Reset.
- Reset.
- Contains old bit 0 data.
- Shift n right into Carry. MSB set to 0.
n = A,B,C,D,E,H,L,(HL)
Flags
Z
N
H
C
affected:
- Set if result is zero.
- Reset.
- Reset.
- Contains old bit 0 data.
STOP
- ???
SUB n
- Subtract n from A.
n = A,B,C,D,E,H,L,(HL),#
Flags
Z
N
H
C
SWAP n
affected:
- Set if result is zero.
- Set.
- Set if no borrow from bit 4.
- Set if no borrow.
- Swap upper & lower bits of n.
n = A,B,C,D,E,H,L,(HL)
Flags
Z
N
H
C
XOR n
affected:
- Set if result is zero.
- Reset.
- Reset.
- Reset.
- Logical exclusive OR n with
register A, result in A.
n = A,B,C,D,E,H,L,(HL),#
Flags
Z
N
H
C
affected:
- Set if result is zero.
- Reset.
- Reset.
- Reset.