1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML 2.0//EN">
4 <TITLE>80386 Programmer's Reference Manual -- Opcode JMP
</TITLE>
7 <B>up:
</B> <A HREF=
"c17.htm">
8 Chapter
17 --
80386 Instruction Set
</A><BR>
9 <B>prev:
</B><A HREF=
"Jcc.htm"> Jcc Jump if Condition is Met
</A><BR>
10 <B>next:
</B><A HREF=
"LAHF.htm"> LAHF Load Flags into AH Register
</A>
18 Opcode Instruction Clocks Description
20 EB cb JMP rel8
7+m Jump short
21 E9 cw JMP rel16
7+m Jump near, displacement relative
23 FF /
4 JMP r/m16
7+m/
10+m Jump near indirect
24 EA cd JMP ptr16:
16 12+m,pm=
27+m Jump intersegment,
4-byte
26 EA cd JMP ptr16:
16 pm=
45+m Jump to call gate, same
28 EA cd JMP ptr16:
16 ts Jump via task state segment
29 EA cd JMP ptr16:
16 ts Jump via task gate
30 FF /
5 JMP m16:
16 43+m,pm=
31+m Jump r/m16:
16 indirect and
32 FF /
5 JMP m16:
16 pm=
49+m Jump to call gate, same
34 FF /
5 JMP m16:
16 5 + ts Jump via task state segment
35 FF /
5 JMP m16:
16 5 + ts Jump via task gate
36 E9 cd JMP rel32
7+m Jump near, displacement relative
38 FF /
4 JMP r/m32
7+m,
10+m Jump near, indirect
39 EA cp JMP ptr16:
32 12+m,pm=
27+m Jump intersegment,
6-byte
41 EA cp JMP ptr16:
32 pm=
45+m Jump to call gate, same
43 EA cp JMP ptr16:
32 ts Jump via task state segment
44 EA cp JMP ptr16:
32 ts Jump via task gate
45 FF /
5 JMP m16:
32 43+m,pm=
31+m Jump intersegment, address at
47 FF /
5 JMP m16:
32 pm=
49+m Jump to call gate, same
49 FF /
5 JMP m16:
32 5 + ts Jump via task state segment
50 FF /
5 JMP m16:
32 5 + ts Jump via task gate
55 Values of ts are given by the following table:
60 386 TSS
386 TASK
286 TSS
63 Old Task Via Task Gate?
67 TSS VM=
0 303 312 220 229 276 285
70 TSS
301 310 218 227 274 283
78 IF instruction = relative JMP
79 (* i.e. operand is rel8, rel16, or rel32 *)
81 EIP := EIP + rel8/
16/
32;
83 THEN EIP := EIP AND
0000FFFFH;
86 IF instruction = near indirect JMP
87 (* i.e. operand is r/m16 or r/m32 *)
91 EIP := [r/m16] AND
0000FFFFH;
92 ELSE (* OperandSize =
32 *)
97 IF (PE =
0 OR (PE =
1 AND VM =
1)) (* real mode or V86 mode *)
98 AND instruction = far JMP
99 (* i.e., operand type is m16:
16, m16:
32, ptr16:
16, ptr16:
32 *)
100 THEN GOTO REAL-OR-V86-MODE;
101 IF operand type = m16:
16 or m16:
32
106 EIP := EIP AND
0000FFFFH; (* clear upper
16 bits *)
107 ELSE (* OperandSize =
32 *)
111 IF operand type = ptr16:
16 or ptr16:
32
116 EIP := EIP AND
0000FFFFH; (* clear upper
16 bits *)
117 ELSE (* OperandSize =
32 *)
123 IF (PE =
1 AND VM =
0) (* Protected mode, not V86 mode *)
124 AND instruction = far JMP
126 IF operand type = m16:
16 or m16:
32
128 check access of EA dword;
129 #GP(
0) or #SS(
0) IF limit violation;
131 Destination selector is not null ELSE #GP(
0)
132 Destination selector index is within its descriptor table limits ELSE
134 Depending on AR byte of destination descriptor:
135 GOTO CONFORMING-CODE-SEGMENT;
136 GOTO NONCONFORMING-CODE-SEGMENT;
139 GOTO TASK-STATE-SEGMENT;
140 ELSE #GP(selector); (* illegal AR byte in descriptor *)
143 CONFORMING-CODE-SEGMENT:
144 Descriptor DPL must be <= CPL ELSE #GP(selector);
145 Segment must be present ELSE #NP(selector);
146 Instruction pointer must be within code-segment limit ELSE #GP(
0);
148 THEN Load CS:EIP from destination pointer;
149 ELSE Load CS:IP from destination pointer;
151 Load CS register with new segment descriptor;
153 NONCONFORMING-CODE-SEGMENT:
154 RPL of destination selector must be <= CPL ELSE #GP(selector);
155 Descriptor DPL must be = CPL ELSE #GP(selector);
156 Segment must be present ELSE # NP(selector);
157 Instruction pointer must be within code-segment limit ELSE #GP(
0);
159 THEN Load CS:EIP from destination pointer;
160 ELSE Load CS:IP from destination pointer;
162 Load CS register with new segment descriptor;
163 Set RPL field of CS register to CPL;
166 Descriptor DPL must be
>= CPL ELSE #GP(gate selector);
167 Descriptor DPL must be
>= gate selector RPL ELSE #GP(gate selector);
168 Gate must be present ELSE #NP(gate selector);
169 Examine selector to code segment given in call gate descriptor:
170 Selector must not be null ELSE #GP(
0);
171 Selector must be within its descriptor table limits ELSE
173 Descriptor AR byte must indicate code segment
174 ELSE #GP(CS selector);
176 THEN code-segment descriptor, DPL must = CPL
177 ELSE #GP(CS selector);
180 THEN code-segment descriptor DPL must be <= CPL;
181 ELSE #GP(CS selector);
182 Code segment must be present ELSE #NP(CS selector);
183 Instruction pointer must be within code-segment limit ELSE #GP(
0);
185 THEN Load CS:EIP from call gate;
186 ELSE Load CS:IP from call gate;
188 Load CS register with new code-segment descriptor;
192 Gate descriptor DPL must be
>= CPL ELSE #GP(gate selector);
193 Gate descriptor DPL must be
>= gate selector RPL ELSE #GP(gate
195 Task Gate must be present ELSE #NP(gate selector);
196 Examine selector to TSS, given in Task Gate descriptor:
197 Must specify global in the local/global bit ELSE #GP(TSS selector);
198 Index must be within GDT limits ELSE #GP(TSS selector);
199 Descriptor AR byte must specify available TSS (bottom bits
00001);
200 ELSE #GP(TSS selector);
201 Task State Segment must be present ELSE #NP(TSS selector);
202 SWITCH-TASKS (without nesting) to TSS;
203 Instruction pointer must be within code-segment limit ELSE #GP(
0);
206 TSS DPL must be
>= CPL ELSE #GP(TSS selector);
207 TSS DPL must be
>= TSS selector RPL ELSE #GP(TSS selector);
208 Descriptor AR byte must specify available TSS (bottom bits
00001)
209 ELSE #GP(TSS selector);
210 Task State Segment must be present ELSE #NP(TSS selector);
211 SWITCH-TASKS (without nesting) to TSS;
212 Instruction pointer must be within code-segment limit ELSE #GP(
0);
217 The JMP instruction transfers control to a different point in the
218 instruction stream without recording return information.
220 The action of the various forms of the instruction are shown below.
222 Jumps with destinations of type r/m16, r/m32, rel16, and rel32 are near
223 jumps and do not involve changing the segment register value.
225 The JMP rel16 and JMP rel32 forms of the instruction add an offset to
226 the address of the instruction following the JMP to determine the
227 destination. The rel16 form is used when the instruction's operand-size
228 attribute is
16 bits (segment size attribute
16 only); rel32 is used when
229 the operand-size attribute is
32 bits (segment size attribute
32 only). The
230 result is stored in the
32-bit EIP register. With rel16, the upper
16 bits
231 of EIP are cleared, which results in an offset whose value does not exceed
234 JMP r/m16 and JMP r/m32 specifies a register or memory location from which
235 the absolute offset from the procedure is fetched. The offset fetched from
236 r/m is
32 bits for an operand-size attribute of
32 bits (r/m32), or
16 bits
237 for an operand-size attribute of
16 bits (r/m16).
239 The JMP ptr16:
16 and ptr16:
32 forms of the instruction use a four-byte
240 or six-byte operand as a long pointer to the destination. The JMP
241 and forms fetch the long pointer from the memory location
242 specified (indirection). In Real Address Mode or Virtual
8086 Mode,
243 the long pointer provides
16 bits for the CS register and
16 or
32 bits
244 for the EIP register (depending on the operand-size attribute). In
245 Protected Mode, both long pointer forms consult the Access Rights (AR)
246 byte in the descriptor indexed by the selector part of the long pointer.
248 Depending on the value of the AR byte, the jump will perform one of
249 the following types of control transfers:
251 <LI> A jump to a code segment at the same privilege level
255 For more information on protected mode control transfers, refer to
256 <A HREF=
"c06.htm">Chapter
6</A> and
<A HREF=
"c07.htm">Chapter
7</A>.
258 <H2>Flags Affected
</H2>
260 All if a task switch takes place; none if no task switch occurs
262 <H2>Protected Mode Exceptions
</H2>
264 Far jumps: #GP, #NP, #SS, and #TS, as indicated in the list above.
266 Near direct jumps: #GP(
0) if procedure location is beyond the code
269 Near indirect jumps: #GP(
0) for an illegal memory operand effective
270 address in the CS, DS, ES, FS, or GS segments: #SS(
0) for an illegal
271 address in the SS segment; #GP if the indirect offset obtained is beyond
272 the code segment limits; #PF(fault-code) for a page fault.
274 <H2>Real Address Mode Exceptions
</H2>
276 Interrupt
13 if any part of the operand would be outside of the effective
277 address space from
0 to
0FFFFH
279 <H2>Virtual
8086 Mode Exceptions
</H2>
281 Same exceptions as under Real Address Mode; #PF(fault-code) for a
288 <B>up:
</B> <A HREF=
"c17.htm">
289 Chapter
17 --
80386 Instruction Set
</A><BR>
290 <B>prev:
</B><A HREF=
"Jcc.htm"> Jcc Jump if Condition is Met
</A><BR>
291 <B>next:
</B><A HREF=
"LAHF.htm"> LAHF Load Flags into AH Register
</A>