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

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

scs.stanford.edu
from scs.stanford.edu More from this publisher
13.07.2015 Views

AMD64 Technology 24594 Rev. 3.10 February 2005ExceptionRealVirtual8086 Protected Cause of ExceptionPage fault, #PF X X A page fault resulted from the execution of the instruction.Alignment check, #AC X X An unaligned memory reference was performed while alignmentchecking was enabled.244 RCR

24594 Rev. 3.10 February 2005 AMD64 TechnologyRET (Near)Near Return from Called ProcedureReturns from a procedure previously entered by a CALL near instruction. This form ofthe RET instruction returns to a calling procedure within the current code segment.This instruction pops the rIP from the stack, with the size of the pop determined bythe operand size. The new rIP is then zero-extended to 64 bits. The RET instructioncan accept an immediate value operand that it adds to the rSP after it pops the targetrIP. This action skips over any parameters previously passed back to the subroutinethat are no longer needed.In 64-bit mode, the operand size defaults to 64 bits (eight bytes) without the need for aREX prefix. No prefix is available to encode a 32-bit operand size in 64-bit mode.See RET (Far) for information on far returns—returns to procedures located outsideof the current code segment. For details about control-flow instructions, see “ControlTransfers” in Volume 1, and “Control-Transfer Privilege Checks” in Volume 2.Mnemonic Opcode DescriptionRET C3 Near return to the calling procedure.RET imm16Related InstructionsC2 iwNear return to the calling procedure then pop of the specifiednumber of bytes from the stack.CALL (Near), CALL (Far), RET (Far)rFLAGS AffectedNoneExceptionsException RealVirtual8086 Protected Cause of ExceptionStack, #SS X X X A memory address exceeded the stack segment limit or was noncanonical.General protection,#GPX X X The target offset exceeded the code segment limit or was non-canonical.RET (Near) 245

24594 Rev. 3.10 February 2005 AMD64 TechnologyRET (Near)Near Return from Called ProcedureReturns from a procedure previously entered by a CALL near instruction. This form ofthe RET instruction returns to a calling procedure within the current code segment.This instruction pops the rIP from the stack, with the size of the pop determined bythe oper<strong>and</strong> size. The new rIP is then zero-extended to 64 bits. The RET instructioncan accept an immediate value oper<strong>and</strong> that it adds to the rSP after it pops the targetrIP. This action skips over any parameters previously passed back to the subroutinethat are no longer needed.In 64-bit mode, the oper<strong>and</strong> size defaults to 64 bits (eight bytes) without the need for aREX prefix. No prefix is available to encode a 32-bit oper<strong>and</strong> size in 64-bit mode.See RET (Far) for information on far returns—returns to procedures located outsideof the current 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 DescriptionRET C3 Near return to the calling procedure.RET imm16Related <strong>Instructions</strong>C2 iwNear return to the calling procedure then pop of the specifiednumber of bytes from the stack.CALL (Near), CALL (Far), RET (Far)rFLAGS AffectedNoneExceptionsException RealVirtual8086 Protected Cause of ExceptionStack, #SS X X X A memory address exceeded the stack segment limit or was noncanonical.<strong>General</strong> protection,#GPX X X The target offset exceeded the code segment limit or was non-canonical.RET (Near) 245

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

Saved successfully!

Ooh no, something went wrong!