I am working on a bootloader, and am doing the high level C part. I am making that will drop down to real mode. After debugging, I see that it jumps to a bogus memory location, and locks up the computer. It gets to 16 bit PMode fine, but when I far jump to real modeis when it occurs. Here is the code:
Code: Select all
pstack dd 0 ; PMode state variables
pmodeGdt:
dw 0
dd 0
; Writes a char to screen
global _IoWriteChar ; Used in C
_IoWriteChar:
pushad ; Push regs on stack
cli
mov dword [pstack], esp ; Save state
sgdt [pmodeGdt]
jmp 0x18:pmode16 ; Go to 16 bit pmode
bits 16
pmode16:
mov eax, cr0 ; get cr0
and al, 0xFE ; Turn off PE bit
mov cr0, eax ; Enter into real mode
jmp 0xA00:rmode - 0xA000
rmode:
cli
hlt