Nintendo GAME BOY Programming Manual page 119

Hide thumbs Also See for GAME BOY:
Table of Contents

Advertisement

RET
Pops from the memory stack the PC value pushed when the subroutine was called, returning control to
the source program.
In this case, the contents of the address specified by the SP are loaded in the lower-order byte of the PC,
and the content of the SP is incremented by 1. The contents of the address specified by the new SP
value are then loaded in the higher-order byte of the PC, and the SP is again incremented by 1. (The
value of SP is 2 larger than before instruction execution.)
The next instruction is fetched from the address specified by the content of PC.
Examples:
Address
8000H
8003H
9000H
RETI
Used when an interrupt-service routine finishes.
The execution of this return is as follows.
The address for the return from the interrupt is loaded in program counter PC.
The master interrupt enable flag is returned to its pre-interrupt status.
Examples:
0040h
8000H
8001H
← (SP)
PC
L
← (SP + 1)
PC
H
SP ← SP + 2
CALL 9000H
RET
; Returns to address 0x8003
← (SP)
PC
L
← (SP + 1)
PC
H
SP ← SP + 2
RETI
; Pops the stack and returns to address 8001h.
INC L
:An external interrupt occurs here.
CY
H
N
--
--
--
CY
H
N
--
--
--
119
Chapter 4: CPU Instruction Set
Z
CYCL
7 6
5 4 3
--
4
11
001
Z
CYCL
7 6
5 4 3
--
4
11
011
2 1 0
001
2 1 0
001

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents