Talk:Unreal mode
From Wikipedia, the free encyclopedia
Although not mentionned in the main article ATM, there was also the possibility of loading the descriptor part of the CPU segment registers by way of special so-called undocumented instructions on the 80286 - 386 and early 486, rather than switching to and fro between RM/PM. This opened the way to even more exotic "modes" than can be attained using the now standard technique. One very creative use of the capability is found in the 80286-specific code inside MS-DOS Himem.sys, allowing it not only to access the extended memory while staying in real mode all the time, using a REP MOVSW instreuction, but to do so with interrupts ALLOWED ! The trick is that not only are DS and ES pointing to extended memory, but also the CS selector is "desynchronised" so that an interrupt occurring in the middle of the move will return to some place different than the interrupted REP MOV itself, allowing the code to correct things, reload the "unreal" descriptors and resume the REP MOV where it left!!! Very ingenious, and I don't know the history of that piece of code but I doubt it originated inside of Microsoft in the 1st place. Rather from Intel ?
-- Ninho
[edit] Incorrectness of information here?
Either we don't have the same definition of "unreal mode" or something's wrong in the article...
From what I know it's perfectly possible to have INTs allowed.
For me the technique consists in altering only the LIMIT part of all DATA descriptors and setting them to 4G, then coming back in real mode (all this with INTs off). after setting PE=0 again and before allowing INTs, it's safe to reload all the segments touched with their previous values. The rules of real mode apply and and the BASE value gets REGISTER*16.
BUT the LIMIT value is not changed. THIS is the "bug" that allows it all.
So from this moment on it's just like normel real mode again. you can load and use 16bits segments addresses again and it works OK. So INTs that push/pop them work fine. Only thing is you can use a 32b offset with immediate or register, and it works.
See:
http://my.execpc.com/~geezer/osd/pmode/unreal.asm (google's second link, too bad wikipedia is the first)
In the code you see "pop es" and "pop ds" . This illustrates what I said.
So for me the 4th paragraph of the article is wrong.
Helloworld256 06:35, 15 January 2007 (UTC)
Just had a go at rewriting the opening paragraphs, did i screw up? This is my first major edit. Ripdog2121 18:49, 12 April 2007 (UTC)
The truth is, unreal mode might not work with interrupts enabled for the following reason. Unreal mode exploits the fact that x86 CPU caches the contents of the BASE and LIMIT inside hidden parts of the segment / selector registers. In protected mode, BASE can be any value from 0 to 4GB, but in real mode BASE is 16*(value of segment). This means, that any code which runs in real mode and modifies the segment registers (such as interrupts through push / pop) will flush the hidden part of the segment / selector registers and reload it to a valid real-mode value. This is the reason why the article states that unreal mode cannot be used with interrupts enabled. --193.226.6.226 21:11, 29 June 2007 (UTC)
- NOT true, unreal mode can be used with interrupts enabled. Reloading the segment registers in real mode only affects the base, and not the limit, part of the descriptor caches. To get back to true real mode, you have to go to protected mode, set the selectors to a descriptor containing a valid base and limit for real mode, and go back to real mode. Interrupts must be disabled when switching to and from protected mode, but once in unreal mode, there is no reason to leave them disabled. System86 (talk) 14:12, 30 January 2008 (UTC)
- System86: We agree. Thats what I said :D . Only the unregistered wikipedia user previous your post added incorrect info.Helloworld256 (talk) 20:13, 1 February 2008 (UTC)
[edit] Not really a bug
This article associates unreal mode with a x86 bug. Intel Programmers Reference clearly explains the hidden part of the segment / selector registers (i.e. the cache of the base and limit), how it gets loaded etc. A programmer should expect unreal mode if he is familiar with theses concepts.

