Intel 80287, 80286 manual RET -Return from Procedure

Models: 80287 80286

1 515
Download 515 pages 45.04 Kb
Page 304
Image 304

THE 80286 INSTRUCTION SET

RET -Return from Procedure

Opcode

Instruction

Clocks·

Description

CB

 

RET

 

15,pm=25

Return to far caller, same privilege

CB

 

RET

 

55

Return, lesser privilege, switch stacks

C3

 

RET

 

11

Return to near caller, same privilege

CA

dw

RET

dw

15,pm=25

RET (far), same privilege, pop dw bytes

CA

dw

RET

dw

55

RET (far), lesser privilege, pop dw bytes

C2

dw

RET

dw

11

RET (near), same privilege, pop dw bytes

 

 

 

 

 

pushed before Call

• Add 1 clock for each byte in the next instruction executed.

FLAGS MODIFIED

None

FLAGS UNDEFINED

None

OPERATION

RET transfers control to a return address located on the stack. The address is usually placed on the stack by a CALL instruction; in that case, the return is made to the instruction that follows the CALL.

There is an optional numeric parameter to RET. It gives the number of stack bytes to be released after the return address is popped. These bytes are typically used as input parameters to the procedure called.

For the intra-segment return, the address on the stack is a 2-byte quantity popped into IP. The CS register is unchanged.

For the inter-segment return, the address on the stack is a 4-byte-long pointer. The offset is popped first, followed by the selector. In real address mode, CS and IP are directly loaded.

In protected mode, an inter-segment return causes the processor to consult the descriptor addressed by the return selector. The AR byte of the descriptor must indicate a code segment of equal or less privi- lege (of greater or equal numeric value) than the current privilege level. Returns to a lesser privilege level cause the stack to be reloaded from the value saved beyond the parameter block.

The DS u;;.d ES Geg:ne~t registers !!!'!yb~ 8f:'tto 7.~rn hy the inter-segment RET instruction. If these registers refer to segments which cannot be used by the new privilege level, they are set to zero to prevent unauthorized access.

The following list of checks and actions describes the protected-mode inter-segment return in detail.

Inter-segment RET:

Second word on stack must be within stack limits else #SS(O)

Return selector RPL must be 2:: CPL else #GP (return selector)

If return selector RPL = CPL then

B-94

Page 304
Image 304
Intel 80287, 80286 manual RET -Return from Procedure