Intel architecture ia-32 Manuale Utente

Pagina di 636
15-18 Vol. 3A
8086 EMULATION
Interrupt and exception handlers can examine the VM flag on the stack to determine if the inter-
rupted procedure was running in virtual-8086 mode. If so, the interrupt or exception can be
handled in one of three ways:
The protected-mode interrupt or exception handler that was called can handle the interrupt
or exception.
The protected-mode interrupt or exception handler can call the virtual-8086 monitor to
handle the interrupt or exception.
The virtual-8086 monitor (if called) can in turn pass control back to the 8086 program’s
interrupt and exception handler.
If the interrupt or exception is handled with a protected-mode handler, the handler can return to
the interrupted program in virtual-8086 mode by executing an IRET instruction. This instruction
loads the EFLAGS and segment registers from the images saved in the privilege level 0 stack
(see Figure 15-4). A set VM flag in the EFLAGS image causes the processor to switch back to
virtual-8086 mode. The CPL at the time the IRET instruction is executed must be 0, otherwise
the processor does not change the state of the VM flag.
Figure 15-4.  Privilege Level 0 Stack After Interrupt or Exception in Virtual-8086 Mode
Unused
Old GS
Old ESP
With Error Code
ESP from
Old FS
Old DS
Old ES
Old SS
Old EFLAGS
Old CS
Old EIP
Error Code
New ESP
TSS
Unused
Old GS
Old ESP
Without Error Code
ESP from
Old FS
Old DS
Old ES
Old SS
Old EFLAGS
Old CS
Old EIP
New ESP
TSS