AMD amd64 architecture User Manual

Page of 336
General-Purpose Programming
81
24592—Rev. 3.15—November 2009
AMD64 Technology
supported. Absolute far calls (those that reference the base of the code segment) are not supported in
64-bit mode.
When a call to a more-privileged procedure occurs, the processor locates the new procedure’s stack
pointer from its task-state segment (TSS). The old stack pointer (SS:rSP) is pushed onto the new stack,
and (in legacy mode only) any parameters specified by the count field in the call-gate descriptor are
copied from the old stack to the new stack (long mode does not support this automatic parameter
copying). The return pointer (CS:rIP) is then pushed, and control is transferred to the new procedure.
Figure 3-12 shows an example of a stack switch resulting from a call to a more-privileged procedure.
“Segmented Virtual Memory” in Volume 2 provides additional information on privilege-changing
CALLs.
Figure 3-12.
Procedure Stack, Far Call to Greater Privilege
Task Switch.
In legacy mode, when a call to a new task occurs, the processor suspends the currently-
executing task and stores the processor-state information at the point of suspension in the current task’s
task-state segment (TSS). The new task’s state information is loaded from its TSS, and the processor
resumes execution within the new task.
In long mode, hardware task switching is disabled. Task switching is fully described in “SegmentedVirtual Memory” in Volume 2.
3.7.6 Returning from Procedures
The RET instruction reverses the effect of a CALL instruction. The return address is popped off the
procedure stack, transferring control unconditionally back to the calling procedure at the instruction
following the CALL. A return that changes privilege levels also switches stacks.
513-177.eps
Old
Procedure
Stack
Old SS:rSP
Parameters
. . .
Called
Procedure
Stack
New SS:rSP
Parameters *
* Parameters are copied only in 
Legacy Mode, not in Long Mode.
Return CS
Return rIP
. . .
Return SS
Return rSP