Unreal Mode: Difference between revisions

[unchecked revision][unchecked revision]
Content deleted Content added
mNo edit summary
Added information on huge unreal mode
Line 15:
When this register given a "selector", a "segment descriptor cache register" is filled with the descriptor 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 64k limit is no longer valid and 32-bit offsets can be used with the real-mode addressing rules (i.e. shift segment 4 bits, then add offset).
 
===Big Unreal Mode===
Finally, note that IP is unaffected by all this, so the code itself is still limited to 64k.
These will not have affected CS. <br />
Finally, note thatTherefore IP is unaffected by all this, so the code itself is still limited to 64k.
 
<source lang="asm">
Line 67 ⟶ 69:
db 0xAA
</source>
 
===Huge Unreal Mode===
Huge Unreal Mode enables code over 64K. 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 32 bit code segment:
 
<source lang="asm">
; Assembly example
 
; nasmw boot.asm -o boot.bin
; partcopy boot.bin 0 200 -f0
 
[ORG 0x7c00] ; add to offsets
 
start: xor ax, ax ; make it zero
 
... ; As before
 
mov cr0, eax
jmp 0x8:pmode
pmode:
mov bx, 0x10 ; select descriptor 2, instead of 1
mov ds, bx ; 10h = 10000b
 
and al,0xFE ; back to realmode
mov cr0, eax ; by toggling bit again
jmp 0x0:huge_unreal
huge_unreal:
 
... ;As before
 
gdtinfo:
dw gdt_end - gdt - 1 ;last byte in table
dd gdt ;start of table
 
gdt dd 0,0 ; entry 0 is always unused
gdt_end:
flatcode db 0xff, 0xff, 0, 0, 0, 10011010b, 10001111b, 0
flatdata db 0xff, 0xff, 0, 0, 0, 10010010b, 11001111b, 0
 
times 510-($-$$) db 0 ; fill sector w/ 0's
db 0x55 ; req'd by some BIOSes
db 0xAA
</source>
 
WARNING: this may not work on some emulators or some hardware. This is because of direct 32bit PMODE -> (Un)real mode.
 
[[Category:X86 CPU]]