13.07.2015 Views

Volume 3: General-Purpose and System Instructions - Stanford ...

Volume 3: General-Purpose and System Instructions - Stanford ...

Volume 3: General-Purpose and System Instructions - Stanford ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

24594 Rev. 3.10 February 2005 AMD64 TechnologyCALL (Near)Near Procedure CallPushes the offset of the next instruction onto the stack <strong>and</strong> branches to the targetaddress, which contains the first instruction of the called procedure. The targetoper<strong>and</strong> can specify a register, a memory location, or a label. A procedure accessed bya near CALL is located in the same code segment as the CALL instruction.If the CALL target is specified by a register or memory location, then a 16-, 32-, or 64-bit rIP is read from the oper<strong>and</strong>, depending on the oper<strong>and</strong> size. A 16- or 32-bit rIP iszero-extended to 64 bits.If the CALL target is specified by a displacement, the signed displacement is added tothe rIP (of the following instruction), <strong>and</strong> the result is truncated to 16, 32, or 64 bits,depending on the oper<strong>and</strong> size. The signed displacement is 16 or 32 bits, depending onthe oper<strong>and</strong> size.In all cases, the rIP of the instruction after the CALL is pushed on the stack, <strong>and</strong> thesize of the stack push (16, 32, or 64 bits) depends on the oper<strong>and</strong> size of the CALLinstruction.For near calls in 64-bit mode, the oper<strong>and</strong> size defaults to 64 bits. The E8 opcoderesults in RIP = RIP + 32-bit signed displacement <strong>and</strong> the FF /2 opcode results inRIP = 64-bit offset from register or memory. No prefix is available to encode a 32-bitoper<strong>and</strong> size in 64-bit mode.At the end of the called procedure, RET is used to return control to the instructionfollowing the original CALL. When RET is executed, the rIP is popped off the stack,which returns control to the instruction after the CALL.See CALL (Far) for information on far calls—calls to procedures located outside of thecurrent code segment. For details about control-flow instructions, see “ControlTransfers” in <strong>Volume</strong> 1, <strong>and</strong> “Control-Transfer Privilege Checks” in <strong>Volume</strong> 2.Mnemonic Opcode DescriptionCALL rel16offCALL rel32offE8 iwE8 idNear call with the target specified by a 16-bit relativedisplacement.Near call with the target specified by a 32-bit relativedisplacement.CALL reg/mem16 FF /2 Near call with the target specified by reg/mem16.CALL (Near) 87

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!