nexos wrote:
Hello,
I am working on a bootloader, and am doing the high level C part.
Not entirely sure what you mean by that. Are you writing your bootloader in high level C you mean?
nexos wrote:
I am making that will drop down to real mode. After debugging, I see that it jumps to a bogus memory location
This is most likely because you haven't set up the segment registers properly. Using "jmp A00:x" would need ORG 0 in your code. Oh, and you MUST restore IDT to IVT before you cloud use BIOS interrupts.
This is a working example (fasm syntax sorry), I keep CS to zero and I don't touch IDT in protmode, so it's still pointing to IVT:
Code:
prot_realmodefunc:
cli
;get return address
pop ebp
;save stack pointer
mov dword [hw_stack], esp
jmp CODE_BOOT:.back ;load 16 bit mode segment into cs
USE16
.back: mov eax, CR0
and al, 0FEh ;switching back to real mode
mov CR0, eax
xor ax, ax
mov ds, ax ;load registers 2nd turn
mov es, ax
mov ss, ax
jmp 0:.back2
.back2: mov sp, word [hw_stack]
sti
jmp bp
Cheers,
bzt