Intel ITANIUM ARCHITECTURE - SOFTWARE DEVELOPERS MANUAL VOLUME 1 REV 2.3 Manual page 1642

Hide thumbs Also See for ITANIUM ARCHITECTURE - SOFTWARE DEVELOPERS MANUAL VOLUME 1 REV 2.3:
Table of Contents

Advertisement

RET—Return from Procedure
Opcode
C3
CB
C2 iw
CA iw
Description
Transfers program control to a return address located on the top of 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 source operand specifies the number of stack bytes to be released after
the return address is popped; the default is none. This operand can be used to release
parameters from the stack that were passed to the called procedure and are no longer
needed.
The RET instruction can be used to execute three different types of returns:
• Near return – A return to a calling procedure within the current code segment (the
segment currently pointed to by the CS register), sometimes referred to as an
intrasegment return.
• Far return – A return to a calling procedure located in a different segment than the
current code segment, sometimes referred to as an intersegment return.
• Inter-privilege-level far return – A far return to a different privilege level than that
of the currently executing program or procedure.
The inter-privilege-level return type can only be executed in protected mode.
When executing a near return, the processor pops the return instruction pointer (offset)
from the top of the procedure stack into the EIP register and begins program execution
at the new instruction pointer. The CS register is unchanged.
When executing a far return, the processor pops the return instruction pointer from the
top of the procedure stack into the EIP register, then pops the segment selector from
the top of the stack into the CS register. The processor then begins program execution
in the new code segment at the new instruction pointer.
The mechanics of an inter-privilege-level far return are similar to an intersegment
return, except that the processor examines the privilege levels and access rights of the
code and stack segments being returned to determine if the control transfer is allowed
to be made. The DS, ES, FS, and GS segment registers are cleared by the RET
instruction during an inter-privilege-level return if they refer to segments that are not
allowed to be accessed at the new privilege level. Since a stack switch also occurs on an
inter-privilege level return, the ESP and SS registers are loaded from the stack.
4:340
Instruction
Description
RET
Near return to calling procedure
RET
Far return to calling procedure
RET imm16
Near return to calling procedure and pop imm16 bytes from
stack
RET imm16
Far return to calling procedure and pop imm16 bytes from stack
Volume 4: Base IA-32 Instruction Reference

Advertisement

Table of Contents
loading

This manual is also suitable for:

Itanium architecture 2.3

Table of Contents