
<
2
.75
7UGT U/CPWCN
=L/2*
#FFTGUU5RCEG
7/<:
RET
Return
Instruction Format:
RET
Operation:
PC
←
@SP
SP
←
SP + 2
This instruction is used to return from a procedure entered by a CALL instruction. The contents of the location
addressed by the stack pointer (SP) are popped into the Program Control. The next statement executed is the
one addressed by the new contents of the PC. The stack pointer is also incremented by 2.
Flags:
When the instruction is executed, the flags are set as follows:
NOTE:
Each
PUSH
instruction executed within the subroutine should be countered with a
POP
instruction
in order to guarantee the
SP
is at the correct location when the
RET
instruction is executed.
Otherwise the wrong address is loaded into the PC and the program does not operate as desired.
Example:
SP
contains
200H
. Memory location
200H
contains
18H
. Location
201H
contains
B5H
. The
following statement leaves the value
202H
in the
SP
, and the PC contains
18B5H
, the address of the next
instruction to be executed.
RET
Op Code: AF
C:
The value set by the preceding instruction.
Z:
The value set by the preceding instruction.
S:
The value set by the preceding instruction.
V:
The value set by the preceding instruction.
D:
The value set by the preceding instruction.
H:
The value set by the preceding instruction.
OPC
OPC (Hex)
AF