Volume 3: General-Purpose and System Instructions - Stanford ...
Volume 3: General-Purpose and System Instructions - Stanford ... Volume 3: General-Purpose and System Instructions - Stanford ...
AMD64 Technology 24594 Rev. 3.10 February 2005Mnemonic Opcode DescriptionCALL reg/mem32 FF /2Near call with the target specified by reg/mem32. (There is noprefix for encoding this in 64-bit mode.)CALL reg/mem64 FF /2 Near call with the target specified by reg/mem64.For details about control-flow instructions, see “Control Transfers” in Volume 1, and“Control-Transfer Privilege Checks” in Volume 2.Related InstructionsCALL(Far), RET(Near), RET(Far)rFLAGS AffectedNone.ExceptionsException RealVirtual8086 Protected Cause of ExceptionStack, #SS X X X A memory address exceeded the stack segment limit or was noncanonical.General protection,#GPXXXA memory address exceeded a data segment limit or was non-canonical.XXXThe target offset exceeded the code segment limit or was non-canonical.Alignment Check,#ACXA null data segment was used to reference memory.X X An unaligned memory reference was performed while alignmentchecking was enabled.Page Fault, #PF X X A page fault resulted from the execution of the instruction.88 CALL (Near)
24594 Rev. 3.10 February 2005 AMD64 TechnologyCALL (Far)Far Procedure CallPushes procedure linking information onto the stack and branches to the targetaddress, which contains the first instruction of the called procedure. The operandspecifies a target selector and offset.The instruction can specify the target directly, by including the far pointer in theCALL (Far) opcode itself, or indirectly, by referencing a far pointer in memory. In 64-bit mode, only indirect far calls are allowed, executing a direct far call (opcode 9A)generates an undefined opcode exception.The target selector used by the instruction can be a code selector in all modes.Additionally, the target selector can reference a call gate in protected mode, or a taskgate or TSS selector in legacy protected mode.• Target is a code selector—The CS:rIP of the next instruction is pushed to the stack,using operand-size stack pushes. Then code is executed from the target CS:rIP. Inthis case, the target offset can only be a 16- or 32-bit value, depending on operandsize,and is zero-extended to 64 bits. No CPL change is allowed.• Target is a call gate—The call gate specifies the actual target code segment and offset.Call gates allow calls to the same or more privileged code. If the target segmentis at the same CPL as the current code segment, the CS:rIP of the nextinstruction is pushed to the stack.If the CALL (Far) changes privilege level, then a stack-switch occurs, using aninner-level stack pointer from the TSS. The CS:rIP of the next instruction ispushed to the new stack. If the mode is legacy mode and the param-count field inthe call gate is non-zero, then up to 31 operands are copied from the caller's stackto the new stack. Finally, the caller's SS:rSP is pushed to the new stack.When calling through a call gate, the stack pushes are 16-, 32-, or 64-bits, dependingon the size of the call gate. The size of the target rIP is also 16, 32, or 64 bits,depending on the size of the call gate. If the target rIP is less than 64 bits, it iszero-extended to 64 bits. Long mode only allows 64-bit call gates that must point to64-bit code segments.• Target is a task gate or a TSS—If the mode is legacy protected mode, then a taskswitch occurs. See “Hardware Task-Management in Legacy Mode” in volume 2 fordetails about task switches. Hardware task switches are not supported in longmode.See CALL (Near) for information on near calls—calls to procedures located inside thecurrent code segment. For details about control-flow instructions, see “ControlTransfers” in Volume 1, and “Control-Transfer Privilege Checks” in Volume 2.CALL (Far) 89
- Page 68 and 69: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 70 and 71: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 72 and 73: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 74 and 75: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 76 and 77: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 78 and 79: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 80 and 81: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 82 and 83: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 84 and 85: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 86 and 87: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 88 and 89: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 90 and 91: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 92 and 93: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 94 and 95: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 96 and 97: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 98 and 99: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 100 and 101: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 102 and 103: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 104 and 105: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 106 and 107: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 108 and 109: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 110 and 111: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 112 and 113: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 114 and 115: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 116 and 117: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 120 and 121: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 122 and 123: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 124 and 125: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 126 and 127: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 128 and 129: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 130 and 131: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 132 and 133: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 134 and 135: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 136 and 137: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 138 and 139: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 140 and 141: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 142 and 143: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 144 and 145: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 146 and 147: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 148 and 149: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 150 and 151: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 152 and 153: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 154 and 155: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 156 and 157: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 158 and 159: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 160 and 161: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 162 and 163: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 164 and 165: AMD64 Technology 24594 Rev. 3.10 Fe
- Page 166 and 167: AMD64 Technology 24594 Rev. 3.10 Fe
AMD64 Technology 24594 Rev. 3.10 February 2005Mnemonic Opcode DescriptionCALL reg/mem32 FF /2Near call with the target specified by reg/mem32. (There is noprefix for encoding this in 64-bit mode.)CALL reg/mem64 FF /2 Near call with the target specified by reg/mem64.For details about control-flow instructions, see “Control Transfers” in <strong>Volume</strong> 1, <strong>and</strong>“Control-Transfer Privilege Checks” in <strong>Volume</strong> 2.Related <strong>Instructions</strong>CALL(Far), RET(Near), RET(Far)rFLAGS AffectedNone.ExceptionsException RealVirtual8086 Protected Cause of ExceptionStack, #SS X X X A memory address exceeded the stack segment limit or was noncanonical.<strong>General</strong> protection,#GPXXXA memory address exceeded a data segment limit or was non-canonical.XXXThe target offset exceeded the code segment limit or was non-canonical.Alignment Check,#ACXA null data segment was used to reference memory.X X An unaligned memory reference was performed while alignmentchecking was enabled.Page Fault, #PF X X A page fault resulted from the execution of the instruction.88 CALL (Near)