up:
Chapter 15 -- Virtual 8086 Mode
prev: 15.3 Entering and Leaving V86 Mode
next: 15.5 Virtual I/O
15.4 Additional Sensitive Instructions
When the 80386 is executing in V86 mode, the instructions
PUSHF,
POPF,
INT n, and
IRET are sensitive to IOPL. The instructions
IN,
INS,
OUT, and
OUTS,
which are ordinarily sensitive in protected mode, are not sensitive
in V86 mode. Following is a complete list of instructions that are sensitive
in V86 mode:
- CLI -- Clear Interrupt-Enable Flag
- STI -- Set Interrupt-Enable Flag
- LOCK -- Assert Bus-Lock Signal
- PUSHF -- Push Flags
- POPF -- Pop Flags
- INT n -- Software Interrupt
- RET -- Interrupt Return
CPL is always three in V86 mode; therefore, if IOPL < 3, these instructions
will trigger a general-protection exceptions. These instructions are made
sensitive so that their functions can be simulated by the V86 monitor.
15.4.1 Emulating 8086 Operating System Calls
INT n
is sensitive so that the V86 monitor can intercept calls to the
8086 OS. Many 8086 operating systems are called by pushing parameters onto
the stack, then executing an
INT n instruction. If IOPL < 3,
INT n
instructions will be intercepted by the V86 monitor. The V86 monitor can
then emulate the function of the 8086 operating system or reflect the
interrupt back to the 8086 operating system in V86 mode.
15.4.2 Virtualizing the Interrupt-Enable Flag
When the processor is executing 8086 code in a V86 task, the instructions
PUSHF,
POPF, and
IRET are sensitive to IOPL so that the V86 monitor can
control changes to the interrupt-enable flag (IF). Other instructions that
affect IF
(STI and
CLI) are IOPL sensitive both in 8086 code and in
80386/80386 code.
Many 8086 programs that were designed to execute on single-task systems set
and clear IF to control interrupts. However, when these same programs are
executed in a multitasking environment, such control of IF can be
disruptive. If IOPL is less than three, all instructions that change or
interrogate IF will trap to the V86 monitor. The V86 monitor can then
control IF in a manner that both suits the needs of the larger environment
and is transparent to the 8086 program.
up:
Chapter 15 -- Virtual 8086 Mode
prev: 15.3 Entering and Leaving V86 Mode
next: 15.5 Virtual I/O