
Instruction Set
4-202
RE T
Return from Procedure
RET
What It Does
Used at the end of a called procedure, RET restores the Instruction Pointer (IP) register
and the Code Segment (CS) register (if necessary) and releases any input parameters from
the stack before resuming the calling procedure.
S yntax
Desc ription
RET transfers control to a return address located on the stack. The address is usually
placed on the stack by a CALL instruction, and the return is made to the instruction that
follows the CALL instruction. The optional numeric parameter to the RET instruction gives
the number of stack bytes to be released after the return address is popped. These items
are typically used as input parameters to the called procedure. For the intrasegment (near)
return, the address on the stack is an offset, which is popped into the instruction pointer.
The CS register is unchanged.
For the intersegment (far) return, the address on the stack is a long pointer. The offset is
popped first, followed by the segment.
Form
Opcode
Description
Clocks
Am186 Am188
RET
C3
Return near to calling procedure
16
20
RET
CB
Return far to calling procedure
22
30
RET imm16
C2 iw
Return near; pop imm16 parameters
18
22
RET imm16
CA iw
Return far; pop imm16 parameters
25
33
If the calling procedure doesn’t use the stack to pass nput
parameters to this procedure, use this form. Also use this
form if the calling procedure uses the stack to pass input
parameters, and it requires this procedure to pass them
back as output parameters.
If the calling procedure uses the stack to pass input
parameters to this procedure, but it doesn’t need this
procedure to pass them back as output parameters,
use this form to return and pop the input parameters
from the stack.
RET
RET
components