Jump Instructions - Nintendo GAME BOY Programming Manual

Hide thumbs Also See for GAME BOY:
Table of Contents

Advertisement

Game Boy Programming Manual

2.7 Jump Instructions

JP
Loads the operand nn to the program counter (PC).
nn specifies the address of the subsequently executed instruction.
The lower-order byte is placed in byte 2 of the object code and the higher-order byte is placed in byte 3.
Example: JP 8000h ; Jump to 8000h.
JP
cc,
Loads operand nn in the PC if condition cc and the flag status match.
The subsequent instruction starts at address nn.
If condition cc and the flag status do not match, the contents of the PC are incremented, and the
instruction following the current JP instruction is executed.
The relation between conditions and cc codes are as follows.
Cc
00
01
10
11
Example: When Z = 1 and C = 0,
JP NZ, 8000h ;
JP
Z, 8000h ;
JP
C, 8000h ;
JP NC, 8000h ;
PC ← nn
nn
If cc true, PC ← nn
nn
Flag
Condition
NZ
Z = 0
Z
Z = 1
NC
CY = 0
C
CY = 1
Moves to next instruction after 3 cycles.
Jumps to address 8000h.
Moves to next instruction after 3 cycles.
Jumps to address 8000h.
CY
H
N
--
--
--
L - ADRS
H - ADRS
CY
H
N
--
--
--
*Cycle no. is 3 when
116
Z
CYCL
7 6
5 4 3
--
4
11
000
Z
CYCL
7 6
5 4 3
--
4/3
11
Occ
L - ADRS
H - ADRS
cc
2 1 0
011
n
n
2 1 0
010
n
n
does not match

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents