In your dump, ESP isn't 0x1000. Set the stack like this:
Code: Select all
[BITS 16]
;; Real mode
mov ax, 0xC00
mov ss, ax
mov esp, 0x1000
Check your stack address so it doesn't overwrite anything. Also, set your PM stack to a BSS buffer in your kernel, like:
Code: Select all
[BITS 32]
;; PM init code
mov esp, StackTop
call _main
...
[SECTION .bss]
resb 1024 ;; 1024 bytes of PM stack
StackTop:
How are you loading your kernel? Are you using GRUB or your own bootloader? If you are using your own bootloader, is your kernel loaded correctly (fully loaded, no bad sectors, etc)?
Is the GDT being set correctly? Make sure your gdt_set_gate function is correct (and if you are using C structs for the GDT entries, make sure they aren't aligned by the compiler)
Are you still moving the IVT to 0x4000? If some other code is overwriting the IVT, fix that code, but don't move the IVT.
Is your other code changing the hardware config (like PIC config), modifying BIOS structures (like the IVT) or affecting this code in any way? If that is true, we can't help you.
Place infinite loops along your code (jmp $). Use the Bochs debugger and the magic breakpoint (xchg bx, bx).
Check that register values are correct in each infinite loop/breakpoint. If you are using the debugger, step through the code, printing registers as you advance.
And don't give up: debugging is fun. There's nothing like the feeling of accomplishment when you finally correct a nasty bug in the code