Vol. 3 17-9
8086 EMULATION
17.2.1 Enabling Virtual-8086 Mode
The processor runs in virtual-8086 mode when the VM (virtual machine) flag in the
EFLAGS register is set. This flag can only be set when the processor switches to a
new protected-mode task or resumes virtual-8086 mode via an IRET instruction.
System software cannot change the state of the VM flag directly in the EFLAGS
register (for example, by using the POPFD instruction). Instead it changes the flag in
the image of the EFLAGS register stored in the TSS or on the stack following a call to
an interrupt- or exception-handler procedure. For example, software sets the VM flag
in the EFLAGS image in the TSS when first creating a virtual-8086 task.
The processor tests the VM flag under three general conditions:
• When loading segment registers, to determine whether to use 8086-style
address translation.
• When decoding instructions, to determine which instructions are not supported in
virtual-8086 mode and which instructions are sensitive to IOPL.
• When checking privileged instructions, on page accesses, or when performing
other permission checks. (Virtual-8086 mode always executes at CPL 3.)
17.2.2 Structure of a Virtual-8086 Task
A virtual-8086-mode task consists of the following items:
• A 32-bit TSS for the task.
• The 8086 program.
• A virtual-8086 monitor.
• 8086 operating-system services.
The TSS of the new task must be a 32-bit TSS, not a 16-bit TSS, because the 16-bit
TSS does not load the most-significant word of the EFLAGS register, which contains
the VM flag. All TSS’s, stacks, data, and code used to handle exceptions when in
virtual-8086 mode must also be 32-bit segments.
19-31 (Intel reserved. Do not use.) Reserved Reserved Reserved
32-
255
User Defined Interrupts Yes Yes Yes
NOTE:
* In the real-address mode, vector 13 is the segment overrun exception. In protected and vir-
tual-8086 modes, this exception covers all general-protection error conditions, including traps
to the virtual-8086 monitor from virtual-8086 mode.
Table 17-1. Real-Address Mode Exceptions and Interrupts (Contd.)
Vector
No.
Description Real-Address
Mode
Virtual-8086
Mode
Intel 8086
Processor