move far jump setup in EnterUnrealMode to right after we save CS

This commit is contained in:
2024-10-11 21:51:07 -04:00
parent 59678149e0
commit 60aaf5cdd9

View File

@@ -285,12 +285,14 @@ EnterUnrealMode:
push ss
push cs ; save real mode code selector
lgdt [unreal_gdt_info]
pop ax ; save cs to ax to setup far jump
mov word [ds:__UNREAL_SEGMENT], ax
mov eax, cr0 ; switch to pmode
lgdt [unreal_gdt_info]
mov eax, cr0
or al,1 ; set pmode bit
mov cr0, eax
jmp $+2
mov cr0, eax ; switch to pmode
jmp $+2 ; clear instruction cache
;jmp far 0x0008:EnterUnrealMode.load_cs
db 0xEA ; jmp far imm16:imm16
@@ -303,14 +305,12 @@ EnterUnrealMode:
mov ss, bx
mov es, bx
mov fs, bx
mov gs, bx ; other data/stack to desc. 2
mov gs, bx ; other data/stack to index 2 (off 0x10)
and al,0xFE ; back to realmode
mov cr0, eax ; by toggling bit again
jmp $+2
and al,0xFE ; toggle bit 1 of cr0
mov cr0, eax ; back to realmode
jmp $+2 ; clear instruction cache again
pop ax ; save cs to ax to setup far jump
mov word [ds:__UNREAL_SEGMENT], ax
;jmp far 0x0008:EnterUnrealMode.unload_cs
db 0xEA ; jmp far imm16:imm16
dw EnterUnrealMode.unload_cs ; error_far_ptr