Intel 64 and IA-32 Architectures Software Developers Manual Volume 2B, Instruction Set Reference, N-Z

Vol. 2B 4-257
INSTRUCTION SET REFERENCE, N-Z
FI;
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)
THEN #SS(0); 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
THEN #GP(selector); FI;
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
THEN #GP(selector); FI;
IF stack segment not present
THEN #SS(StackSegmentSelector); FI;
IF the return instruction pointer is not within the return code segment limit
THEN #GP(0); FI;
CPL ReturnCodeSegmentSelector(RPL);
IF OperandSize
= 32
THEN
EIP Pop();
CS Pop(); (* 32-bit pop, high-order 16 bits discarded; segment descriptor
information also loaded *)
CS(RPL) CPL;
ESP ESP + SRC; (* Release parameters from called procedure’s stack *)
tempESP Pop();
tempSS Pop(); (* 32-bit pop, high-order 16 bits discarded; segment
descriptor information also loaded *)
ESP tempESP;
SS tempSS;
ELSE (* OperandSize
= 16 *)
EIP Pop();
EIP EIP AND 0000FFFFH;
CS Pop(); (* 16-bit pop; segment descriptor information also loaded *)
CS(RPL) CPL;
ESP ESP + SRC; (* Release parameters from called procedure’s stack *)
tempESP Pop();
tempSS Pop(); (* 16-bit pop; segment descriptor information also loaded *)
ESP tempESP;
SS tempSS;