Unreal Mode: Difference between revisions
Jump to navigation
Jump to search
[unchecked revision] | [unchecked revision] |
Content deleted Content added
No edit summary |
|||
Line 1: | Line 1: | ||
'''Unreal mode''' |
'''Unreal mode''' consists of breaking the 64KiB limit of real mode segments (while retaining 16-bit instructions and the <tt>segment * 16 + offset</tt> addressing mode) by tweaking the [[Descriptor Cache|descriptor caches]]. |
||
==Usage== |
==Usage== |
||
Unreal mode is recommended in the two following cases |
Unreal mode is usually recommended in the two following cases: |
||
* you're trying to extend a legacy 16- |
* you're trying to extend a legacy 16-bit DOS program so that it can deal with larger data and neither [[Virtual 8086 Mode]], nor xms are suitable for your needs. |
||
* you're trying to load something that will run in 32 |
* you're trying to load something that will run in 32-bit mode which is larger than 640K (therefore you cannot load it in conventional memory) and you don't want to bother writing a protected mode disk driver yet, but you also want to avoid switching between real and protected mode to copy chunks from the conventional memory buffer into extended memory. |
||
You still will not have full access to all physical RAM if you do not |
You still will not have full access to all physical RAM if you do not have the [[A20 Line]] enabled; all the "odd" 1 MiB blocks will be unavailable. |
||
==Implementation== |
==Implementation== |
||
To do this, you need to set the descriptor cache's limits for your segment register(s) to any value higher than 64KiB (usually a full 4GiB (<tt>0xffffffff</tt>)). |
|||
The reason for doing this is to enable 32-bit offsets in real mode. However, you won't be able to go past 1 meg quite yet. |
|||
In protected mode, |
In protected mode, bits 3-15 in the segment registers represent an index into [[GDT|the global descriptor table]]. That's why in the following code 0x08 = 1000b gets you entry #1 (entry #0 is ALWAYS a null descriptor). |
||
When |
When (in protected mode) a segment register is loaded with a "selector", a "segment descriptor cache register" is filled with the descriptor's values, including the size (or limit). After the switch back to real mode, these values are not modified, regardless of what value is in the 16-bit segment register. So the 64KiB limit is no longer valid and 32-bit offsets can be used in Real Mode to actually access areas above 64KiB (<tt>segment * 16 + 32-bit offset</tt>). |
||
===Big Unreal Mode=== |
===Big Unreal Mode=== |
||
This won't touch CS. <br /> |
|||
Therefore IP is unaffected by all this, |
Therefore IP is unaffected by all this, and the code itself is still limited to 64KiB. |
||
<source lang="asm"> |
<source lang="asm"> |
||
Line 73: | Line 73: | ||
===Huge Unreal Mode=== |
===Huge Unreal Mode=== |
||
Huge Unreal Mode enables code over |
Huge Unreal Mode enables code over 64KiB. However, it is more difficult to implement as real mode interrupts do not automatically save the high 16 bits of EIP. Initialization is simple though, you just load a code segment with a 4GiB limit: |
||
<source lang="asm"> |
<source lang="asm"> |
||
Line 114: | Line 114: | ||
</source> |
</source> |
||
WARNING: this may not work on some emulators or some hardware |
WARNING: this may not work on some emulators or some hardware. |
||
==Compiler Support== |
==Compiler Support== |