Page 1 of 1

Switching to Virtual 8086 Mode

Posted: Sun Apr 27, 2014 2:45 pm
by inixsoftware
So far I have been displaying text using the default VGA text-mode. How would I switch to Virtual 8086 mode so I can make the video change and return back to Protected mode?

Re: Switching to Virtual 8086 Mode

Posted: Sun Apr 27, 2014 2:49 pm
by Combuster
If you haven't read the processor manual, now would be a good time to do that.

Re: Switching to Virtual 8086 Mode

Posted: Sun Apr 27, 2014 3:49 pm
by alexfru
We just had a related thread. I gave a link to example code there.

Re: Switching to Virtual 8086 Mode

Posted: Mon Apr 28, 2014 2:47 am
by Bender
Has been discussed n number of times (where n > 50). Also, virtual 8086 isn't supported in Long Mode, and I doubt if Intel bothers to improve it. V8086 is used mainly for running 16-bit programs, It is preferable to use an existing 80(3)86 emulator. It's easier than using v86 as emulators don't require user mode and can run in any sort of environment. Just re quoting myself:
If you ever wish to support x64 (or get bored with v86) just grab a copy of Real-Mode Emulator or x86emu, for mode-switching I just wrote a simple program that captures arguments and switches to relevant video mode and is linked against Real Mode Emulator. Whenever I want to switch I just execute that program with arguments. IIRC both RME and x86emu don't require any sort of library unless you wan't to debug in which both will require a fairly standard printf.

Re: Switching to Virtual 8086 Mode

Posted: Mon Apr 28, 2014 10:59 am
by PearOs
Bender wrote:Has been discussed n number of times (where n > 50). Also, virtual 8086 isn't supported in Long Mode, and I doubt if Intel bothers to improve it. V8086 is used mainly for running 16-bit programs, It is preferable to use an existing 80(3)86 emulator. It's easier than using v86 as emulators don't require user mode and can run in any sort of environment. Just re quoting myself:
If you ever wish to support x64 (or get bored with v86) just grab a copy of Real-Mode Emulator or x86emu, for mode-switching I just wrote a simple program that captures arguments and switches to relevant video mode and is linked against Real Mode Emulator. Whenever I want to switch I just execute that program with arguments. IIRC both RME and x86emu don't require any sort of library unless you wan't to debug in which both will require a fairly standard printf.
Well in this situation, he could in "theory" do what a lot of people suggest, which is fairly reasonable. Just while your in 32bit protected mode, set the highest video mode you want, since you probably won't ever change it anyways. I mean I don't, and even if you did.. Just program your Os to reboot and then set the new mode on next boot. Just an idea, although emulating can work. I wouldn't write your own emulator though, I attempted it, learned a lot but it was a very complex process and in the end I decided to just use V8086.

Good luck!

- Matt