3-335
INSTRUCTION SET REFERENCE
JMPJump (Continued)
When executing a far jump through a call gate, the segment selector specified by the target
operand identifies the call gate. (The offset part of the target operand is ignored.) The processor
then jumps to the code segment specified in the call gate descriptor and begins executing the
instruction at the offset specified in the call gate. No stack switch occurs. Here again, the target
operand can specify the far address of the call gate either directly with a pointer (ptr16:16 or
ptr16:32) or indirectly with a memory location (m16:16 or m16:32).
Executing a task switch with the JMP instruction, is somewhat similar to executing a jump
through a call gate. Here the target operand specifies the segment selector of the task gate for
the task being switched to (and the offset part of the target operand is ignored). The task gate in
turn points to the TSS for the task, which contains the segment selectors for the tasks code and
stack segments. The TSS also contains the EIP value for the next instruction that was to be
executed before the task was suspended. This instruction pointer value is loaded into EIP
register so that the task begins executing again at this next instruction.
The JMP instruction can also specify the segment selector of the TSS directly, which eliminates
the indirection of the task gate. Refer to Chapter 6, Task Management, of the Intel Architecture
Software Developers Manual, Volume 3, for detailed information on the mechanics of a task
switch.
Note that when you execute at task switch with a JMP instruction, the nested task flag (NT) is
not set in the EFLAGS register and the new TSSs previous task link field is not loaded with the
old tasks TSS selector. A return to the previous task can thus not be carried out by executing
the IRET instruction. Switching tasks with the JMP instruction differs in this regard from the
CALL instruction which does set the NT flag and save the previous task link information,
allowing a return to the calling task with an IRET instruction.