User Guide

80 General-Purpose Programming
AMD64 Technology 24592—Rev. 3.15—November 2009
the CALL instruction. Parameters can be pushed onto the stack by the calling procedure prior to
executing the CALL instruction. Figure 3-10 shows the stack pointer before (old rSP value) and after
(new rSP value) the CALL. The stack segment (SS) is not changed.
Figure 3-10. Procedure Stack, Near Call
Far Call, Same Privilege. A far CALL changes the code segment, so the full return pointer (CS:rIP)
is pushed onto the stack. After the return pointer is pushed, control is transferred to the new CS:rIP
value specified by the CALL instruction. Parameters can be pushed onto the stack by the calling
procedure prior to executing the CALL instruction. Figure 3-11 shows the stack pointer before (old
rSP value) and after (new rSP value) the CALL. The stack segment (SS) is not changed.
Figure 3-11. Procedure Stack, Far Call to Same Privilege
Far Call, Greater Privilege. A far CALL to a more-privileged procedure performs a stack switch
prior to transferring control to the called procedure. Switching stacks isolates the more-privileged
procedure’s stack from the less-privileged procedure’s stack, and it provides a mechanism for saving
the return pointer back to the procedure that initiated the call.
Calls to more-privileged software can only take place through a system descriptor called a call-gate
descriptor. Call-gate descriptors are created and m aintained by system software. In 64-bit mode, only
indirect far calls (those whose target memory address is in a register or other memory location) are
513-175.eps
Procedure
Stack
New rSPReturn rIP
Old rSP
Parameters
. . .
513-176.eps
Procedure
Stack
Return CS
Old rSP
New rSP
Parameters
Return rIP
. . .