OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Jan 18, 2018 7:08 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: Help - Virtual 8086 mode
PostPosted: Tue Nov 21, 2017 8:24 pm 
Offline

Joined: Thu May 25, 2017 10:41 pm
Posts: 14
I have quite a few questions about Virtual 8086 mode;
I'm trying to enter it so I can enter a graphics mode.
But I don't think I'm understanding it right!
so I came up with a few questions:

- Why must we use IRET to set VM? Also how does IRET set the VM flag?
- What does the TSS have to do with virtual 8086 mode?
- How do you leave virtual 8086 mode? Can you just "unset" the VM flag?


Top
 Profile  
 
 Post subject: Re: Help - Virtual 8086 mode
PostPosted: Tue Nov 21, 2017 10:08 pm 
Offline
Member
Member

Joined: Sat Nov 21, 2009 5:11 pm
Posts: 653
The reason is simple. Imagine if it were possible to enter Virtual 8086 mode by executing a POPFD instruction. Then there would be all sorts of problems, due to the old values stored in the segment registers not being appropriate for Virtual 8086 mode. Therefore, POPFD does not update the VM flag, and IRET must be used. IRET sets the VM flag based on bit 17 of the popped EFLAGS value. Note that when entering or leaving Virtual 8086 mode, the interrupt stack frame contains four additional DWORDs, with the values for the DS, ES, FS and GS registers in Virtual 8086 mode, respectively.

In Virtual 8086 mode, the TSS can contain an interrupt redirection bitmap if VME is enabled in CR4. This lets you specify whether a particular software interrupt number should cause a GPF exception or be handled using the IVT, as in real-address mode. Also, like always when running at CPL=3, the TSS contains the values of SS and ESP to load when transitioning to a higher privilege level due to an exception, as well as the I/O permission bitmap.

You leave Virtual 8086 mode by triggering an exception, for example with an INT instruction or an undefined opcode. For the same reason as above, you can't unset the VM flag using POPFD.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group