BASIC INSTRUCTION SET

3.6.1 Unconditional Transfer Instructions

JMP, CALL, RET, INT and IRET instructions transfer control from one code segment location to another. These locations can be within the same code segment or in different code segments.

3.6.1.1 JUMP INSTRUCTION

JMP (Jump) unconditionally transfers control to the target location. JMP is a one-way transfer of execution; it does not save a return address on the stack.

The JMP instruction always performs the same basic function of transferring control from the current location to a new location. Its implementation varies depending on the following factors:

Is the address specified directly within the instruction or indirectly through a register or memory?

Is the target location inside or outside the current code segment selected in CS?

A direct JMP instruction includes the destination address as part of the instruction. An indirect JMP instruction obtains the destination address indirectly through a register or a pointer variable.

Control transfers through a gate or to a task state segment are available only in Protected Mode opera- tion of the 80286. The formats of the instructions that transfer control through a call gate, a task gate, or to a task state segment are the same. The label included in the instruction selects one of these three paths to a new code segment.

Direct JMP within the current code segment. A direct JMP that transfers control to a target location within the current code segment uses a relative displacement value contained in the instruction. This can be either a 16-bit value or an 8-bit value sign extended to 16 bits. The processor forms an effective address by adding this relative displacement to the address contained in IP. IP refers to the next instruction when the additions are performed.

Example: JMP NEAlLNEWCODE. Transfers control to the target location labeled NEAlL NEWCODE, which is within the code segment currently selected in CS.

Indirect JMP within the current code segment. Indirect JMP instructions that transfer control to a location within the current code segment specify an absolute address in one of several ways. First, the program can JMP to a location specified by a 16-bit register (any of AX, DX, CX, BX, BP, SI, or DI). The processor moves this 16-bit value into IP and resumes execution.

Example: JMP SI. Transfers control to the target address formed by adding the 16-bit value contained in SI to the base address contained in CS.

The processor can also obtain the destination address within a current segment from a memory word operand specified in the instruction.

Example: JMP PTlLX. Transfers control to the target address formed by adding the l6-bit value contained in the memory word labeled PTR X to the base address contained in CS.

A register can modify the address of the memory word pointer to select a destination address.

Example: JMP CASE_TABLE [BX]. CASE_TABLE is the first word in an array of word pointers. The value of BX determines which pointer the program selects from the array. The JMP instruction then transfers control to the location specified by the selected pointer.

3-17

Page 73
Image 73
Intel 80286, 80287 manual Unconditional Transfer Instructions