background image

20-6 Vol. 3B

8086 EMULATION

As in real-address mode, any new or legacy program that has been assembled and/or compiled to run on an Intel 
8086 processor will run in a virtual-8086-mode task. And several 8086 programs can be run as virtual-8086-mode 
tasks concurrently with normal protected-mode tasks, using the processor’s multitasking facilities.

20.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.

Table 20-1.  Real-Address Mode Exceptions and Interrupts

Vector 

No.

Description

Real-Address Mode

Virtual-8086 Mode

Intel 8086 Processor

 0

Divide Error (#DE)

Yes

Yes

Yes

 1

Debug Exception (#DB)

Yes

Yes

No

 2

NMI Interrupt

Yes

Yes

Yes

 3

Breakpoint (#BP)

Yes

Yes

Yes

 4

Overflow (#OF)

Yes

Yes

Yes

 5

BOUND Range Exceeded (#BR)

Yes

Yes

Reserved

 6

Invalid Opcode (#UD)

Yes

Yes

Reserved

 7

Device Not Available (#NM)

Yes

Yes

Reserved

 8

Double Fault (#DF)

Yes

Yes

Reserved

 9

(Intel reserved. Do not use.)

Reserved

Reserved

Reserved

10

Invalid TSS (#TS)

Reserved

Yes

Reserved

11

Segment Not Present (#NP)

Reserved

Yes

Reserved

12

Stack Fault (#SS)

Yes

Yes

Reserved

13

General Protection (#GP)*

Yes

Yes

Reserved

14

Page Fault (#PF)

Reserved

Yes

Reserved

15

(Intel reserved. Do not use.)

Reserved

Reserved

Reserved

16

Floating-Point Error (#MF)

Yes

Yes

Reserved

17

Alignment Check (#AC)

Reserved

Yes

Reserved

18

Machine Check (#MC)

Yes

Yes

Reserved

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 virtual-8086 modes, this exception cov-

ers all general-protection error conditions, including traps to the virtual-8086 monitor from virtual-8086 mode.