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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

24594 Rev. 3.10 February 2005 AMD64 TechnologyRET (Far)Far Return from Called ProcedureReturns from a procedure previously entered by a CALL Far instruction. This form ofthe RET instruction returns to a calling procedure in a different segment than thecurrent code segment. It can return to the same CPL or to a less privileged CPL.RET Far pops a target CS <strong>and</strong> rIP from the stack. If the new code segment is lessprivileged than the current code segment, the stack pointer is incremented by thenumber of bytes indicated by the immediate oper<strong>and</strong>, if present; then a new SS <strong>and</strong>rSP are also popped from the stack.The final value of rSP is incremented by the number of bytes indicated by theimmediate oper<strong>and</strong>, if present. This action skips over the parameters (previouslypassed to the subroutine) that are no longer needed.All stack pops are determined by the oper<strong>and</strong> size. If necessary, the target rIP is zeroextendedto 64 bits before assuming program control.If the CPL changes, the data segment selectors are set to NULL for any of the datasegments (DS, ES, FS, GS) not accessible at the new CPL.See RET (Near) for information on near returns—returns to procedures located insidethe 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 DescriptionRETF CB Far return to the calling procedure.RETF imm16CA iwFar return to the calling procedure, then pop of the specifiednumber of bytes from the stack.Action// Far returns (RETF)// See “Pseudocode Definitions” on page 49.RETF_START:IF (REAL_MODE)RETF_REAL_OR_VIRTUALELSIF (PROTECTED_MODE)RETF_PROTECTEDELSE // (VIRTUAL_MODE)RETF_REAL_OR_VIRTUALRET (Far) 247

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

Saved successfully!

Ooh no, something went wrong!