x86 Assembly Language Reference Manual

Return from Procedure (ret)

ret
ret		imm16
Operation

return to caller

Description

The ret instruction transfers control to the return address located on the stack. This address is usually placed on the stack by a call instruction. Issue the ret instruction within the called procedure to resume execution flow at the instruction following the call.

The optional numeric (16- or 32-bit) parameter to ret specifies the number of stack bytes or words to be released after the return address is popped from the stack. Typically, these bytes or words are used as input parameters to the called procedure.

For an intersegment (near) return, the address on the stack is a segment offset that is popped onto the instruction pointer. The CS register remains unchanged.

Example

Transfer control to the return address located on the stack.

ret

Transfer control to the return address located on the stack. Release the next 16-bytes of parameters.

ret $-32767