User Guide
General-Purpose Programming 83
24592—Rev. 3.15—November 2009 AMD64 Technology
Figure 3-14. Procedure Stack, Far Return from Same Privilege
Far Return, Less Privilege. Privilege-changing far RETs can only return to less-privileged code
segments, otherwise a general-protection exception occurs. The full return pointer is popped off the
stack and into the CS and rIP registers, and execution begins from the newly-loaded segment and
offset. A far RET that changes privilege levels also switches stacks. The return procedure’s stack
pointer is popped off the stack and into the SS and rSP registers. If an immediate operand is included
with the RET instruction, the newly-loaded stack pointer is adjusted by the number of bytes indicated.
Figure 3-15 shows the stack pointer before (old SS:rSP value) and after (new SS:rSP value) the RET.
“Segmented Virtual Memory” in Volume 2 provides additional information on privilege-changing
RETs.
Figure 3-15. Procedure Stack, Far Return from Less Privilege
513-179.eps
Procedure
Stack
Return CS
New rSP
Old rSP
Parameters
Return rIP
. . .
513-180.eps
Return
Procedure
Stack
New SS:rSP
Parameters
. . .
Old
Procedure
Stack
Old SS:rSP
Parameters
Return CS
Return rIP
. . .
Return SS
Return rSP