User Guide

General-Purpose Programming 79
24592—Rev. 3.15—November 2009 AMD64 Technology
3.7.5 Procedure Calls
The CALL instruction transfers control unconditionally to a new address, but unlike jump instructions,
it saves a return pointer (CS:rIP) on the stack. The called procedure can use the RET instruction to pop
the return pointers to the calling procedure from the stack and continue execution with the instruction
following the CALL.
There are four types of CALL:
Near Call—When the target address is within the current code segment.
Far Call—When the target address is outside the current code segment.
Interprivilege-Level Far Call—A far call that changes privilege level.
Task Switch—A call to a target address in another task.
Near Call. When a near CALL is executed, only the calling procedure’s rIP (the return offset) is
pushed onto the stack. After the rIP is pushed, control is transferred to the new rIP value specified by
Table 3-8. Instructions that Implicitly Reference RSP in 64-Bit Mode
Mnemonic
Opcode
(hex)
Description
Operand Size (bits)
Default
Possible
Overrides
1
CALL E8, FF /2 Call Procedure Near
64 16
ENTER C8 Create Procedure Stack Frame
LEAVE C9 Delete Procedure Stack Frame
POP reg/mem 8F /0 Pop Stack (register or memory)
POP reg 58 to 5F Pop Stack (register)
POP FS 0F A1 Pop Stack into FS Segment Register
POP GS 0F A9 Pop Stack into GS Segment Register
POPF
POPFQ
9D Pop to EFLAGS Word or Quadword
PUSH imm32 68 Push onto Stack (sign-extended doubleword)
PUSH imm8 6A Push onto Stack (sign-extended byte)
PUSH reg/mem FF /6 Push onto Stack (register or memory)
PUSH reg 50–57 Push onto Stack (register)
PUSH FS 0F A0 Push FS Segment Register onto Stack
PUSH GS 0F A8 Push GS Segment Register onto Stack
PUSHF
PUSHFQ
9C Push rFLAGS Word or Quadword onto Stack
RET C2, C3 Return From Call (near)
Note:
1. There is no 32-bit operand-size override prefix in 64-bit mode.