Intel 80286, 80287 manual Conditional Transfer Instructions

Models: 80287 80286

1 515
Download 515 pages 45.04 Kb
Page 75
Image 75

BASIC INSTRUCTION SET

Examples:

CALL NEAR_NEWCODE

,CALL SI CALL PTR.x

CALL CASE_TABLE [BP] CALL FAR-NEWCODE_FOO CALL NEWCODE

CALL CALLGATE_FOO CALL CASE_TABLE [BX]

See the previous treatment of JMP for a discussion of the operations of these instructions.

3.6.1.3 RETURN AND RETURN FROM INTERRUPT INSTRUCTION

RET (Return From Procedure) terminates the execution of a procedure and transfers control through a back·link on the stack to the program that originally invoked the procedure.

An intrasegment RET restores the value of IP that was saved on the stack by the previous intrasegment CALL instruction. An intersegment RET restores the values of both CS and IP which were saved on the stack by the previous intersegment CALL instruction.

RET instructions may optionally specify a constant to the stack pointer. This constant specifies the new top of stack to effectively remove any arguments that the calling program pushed on the stack before the execution of the CALL instruction.

Example: RET. If the previous CALL instruction did not transfer control to a new code segment, RET restores the value of IP pushed by the CALL instruction. If the previous CALL instruction transferred control to a new segment, RET restores the values of both IP and CS which were pushed on the stack by the CALL instruction.

Example: RET n. This form of the RET instruction performs identically to the above example except that it adds n (which must be an even value) to the value of SP to eliminate n bytes of parameter information previously pushed by the calling program.

IRET (Return From Interrupt or Nested Task) returns control to an interrupted routine or, optionally, reverses the action of a CALL or INT instruction that caused a task switch. See Chapter 8 for further information on task switching.

Example: IRET. Returns from an interrupt with or without a task switch based on the value of the NT bit.

3.6.2 Conditional Transfer Instructions

The conditional transfer instructions are jumps that mayor may not transfer control, depending on the state of the CPU flags when the instruction executes. Instruction encoding is most efficient when the target for the conditional jumps is in the current code segment and within -128 to +127 bytes of the first byte of the next instruction. Alternatively, the opposite sense of the conditional jump can skip around an unconditional jump to the destination.

3-19

Page 75
Image 75
Intel 80286, 80287 manual Conditional Transfer Instructions