972
edits
[unchecked revision] | [unchecked revision] |
m (Improved grammar and spelling.) |
m (Bot: Replace deprecated source tag with syntaxhighlight) |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 3:
==Entering V86==
The CPU is executing in virtual 86 mode when the VM bit (bit 17) is set in the ''EFLAGS'' register. If you want to enter virtual 86 mode you must set this bit to 1.
A way of modifying the
A task gate can also be used to enter V86. This allows setting the segment registers. It is probably not necessary to do it this way unless the OS is using hardware multitasking.
[[File:Fig15-3.gif]]
==V86 Problem==
Line 32 ⟶ 20:
EFLAGS.VM is NEVER pushed onto the stack if the V86 task uses PUSHFD. You should check if CR0.PE=1 and then assume it's V86 if that bit is set.
<syntaxhighlight lang="asm">
detect_v86:
smsw ax
and eax,1 ;CR0.PE bit
ret
</syntaxhighlight>
VM mode detection is mainly useful when writing DOS extenders or other programs that could be started either in plain real mode or in virtual mode from a protected mode system. An 'ordinary' bootloader shouldn't worry about this since the BIOS will not set up VM86 to read the bootsector ;)
|