Switching to Virtual 8086 Mode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
inixsoftware
Member
Member
Posts: 32
Joined: Fri Jan 31, 2014 8:21 am

Switching to Virtual 8086 Mode

Post 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?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Switching to Virtual 8086 Mode

Post by Combuster »

If you haven't read the processor manual, now would be a good time to do that.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
alexfru
Member
Member
Posts: 1112
Joined: Tue Mar 04, 2014 5:27 am

Re: Switching to Virtual 8086 Mode

Post by alexfru »

We just had a related thread. I gave a link to example code there.
User avatar
Bender
Member
Member
Posts: 449
Joined: Wed Aug 21, 2013 3:53 am
Libera.chat IRC: bender|
Location: Asia, Singapore

Re: Switching to Virtual 8086 Mode

Post 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.
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
PearOs
Member
Member
Posts: 194
Joined: Mon Apr 08, 2013 3:03 pm
Location: Usually at my keyboard!

Re: Switching to Virtual 8086 Mode

Post 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
Post Reply