RET—Return from Procedure (Continued)
FI;
IF return code segment selector is null THEN GP(0); FI;
IF return code segment selector addrsses descriptor beyond diescriptor table limit
THEN GP(selector; FI;
Obtain descriptor to which return code segment selector points from descriptor table
IF return code segment descriptor is not a code segment THEN #GP(selector); FI;
if return code segment selector RPL < CPL THEN #GP(selector); FI;
IF return code segment descriptor is condorming
AND return code segment DPL > return code segment selector RPL
IF return code segment descriptor is not present THEN #NP(selector); FI:
IF return code segment selector RPL > CPL
THEN GOTO RETURN-OUTER-PRIVILEGE-LEVEL;
ELSE GOTO RETURN-TO-SAME-PRIVILEGE-LEVEL
FI;
END;FI;
RETURN-SAME-PRIVILEGE-LEVEL:
IF the return instruction pointer is not within ther return code segment limit
THEN #GP(0);
FI;
IF OperandSize=32
THEN
ELSE (* OperandSize=16 *)
FI;
IF Itanium System Environment AND PSR.tb THEN IA_32_Exception(Debug);
RETURN-OUTER-PRIVILEGE-LEVEL:
IF top (16 + SRC) bytes of stack are not within stack limits (OperandSize=32)
OR top (8 + SRC) bytes of stack are not within stack limits (OperandSize=16)
FI;
Read return segment selector;
IF stack segment selector is null THEN #GP(0); FI;
IF return stack segment selector index is not within its descriptor table limits
Read segment descriptor pointed to by return segment selector;
IF stack segment selector RPL RPL of the return code segment selector
OR stack segment is not a writable data segment
OR stack segment descriptor DPL RPL of the return code segment selector
4:342
IF second doubleword on stack is not within stack limits THEN #SS(0); FI;
ELSE (* OperandSize = 16 *)
IF second word on stack is not within stack limits THEN #SS(0); FI;
THEN #GP(selector); FI;
EIP Pop();
CS Pop(); (* 32-bit pop, high-order 16-bits discarded *)
ESP ESP + SRC;
EIP Pop();
EIP EIP AND 0000FFFFH;
CS Pop(); (* 16-bit pop *)
ESP ESP + SRC;
THEN #SS(0); FI;
THEN #GP(selector); FI;
THEN #GP(selector); FI;
Volume 4: Base IA-32 Instruction Reference