Unreal Mode: Difference between revisions

Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content deleted Content added
No edit summary
fix bug: far JMP is required to enter/exit protected mode
Line 25: Line 25:
; partcopy boot.bin 0 200 -f0
; partcopy boot.bin 0 200 -f0


[ORG 0x7c00] ; add to offsets
ORG 0x7c00 ; add to offsets


start:
start: xor ax, ax ; make it zero
xor ax, ax ; make it zero
mov ds, ax ; DS=0
mov ds, ax ; DS=0
mov ss, ax ; stack starts at seg 0
mov ss, ax ; stack starts at seg 0
Line 41: Line 42:
or al,1 ; set pmode bit
or al,1 ; set pmode bit
mov cr0, eax
mov cr0, eax
jmp 0x8:pmode


pmode:
jmp $+2 ; tell 386/486 to not crash
mov bx, 0x10 ; select descriptor 2

mov bx, 0x08 ; select descriptor 1
mov ds, bx ; 10h = 10000b
mov ds, bx ; 8h = 1000b


and al,0xFE ; back to realmode
and al,0xFE ; back to realmode
mov cr0, eax ; by toggling bit again
mov cr0, eax ; by toggling bit again
jmp 0x0:unreal


unreal:
pop ds ; get back old segment
pop ds ; get back old segment
sti
sti
Line 63: Line 66:
dd gdt ;start of table
dd gdt ;start of table


gdt dd 0,0 ; entry 0 is always unused
gdt: dd 0,0 ; entry 0 is always unused
flatdesc db 0xff, 0xff, 0, 0, 0, 10010010b, 11001111b, 0
codedesc: db 0xff, 0xff, 0, 0, 0, 10011010b, 00000000b, 0
flatdesc: db 0xff, 0xff, 0, 0, 0, 10010010b, 11001111b, 0
gdt_end:
gdt_end:


Line 70: Line 74:
dw 0xAA55 ; Required by some BIOSes
dw 0xAA55 ; Required by some BIOSes
</source>
</source>
* At least on the 486SL the jmp $+2 instruction is needed after toggling the PM bit off, not just on. - BASICFreak


===Huge Unreal Mode===
===Huge Unreal Mode===
Line 81: Line 84:
; partcopy boot.bin 0 200 -f0
; partcopy boot.bin 0 200 -f0


[ORG 0x7c00] ; add to offsets
ORG 0x7c00 ; add to offsets


start: xor ax, ax ; make it zero
start: xor ax, ax ; make it zero