I'm developing a bootloader to load my OS (I didn't use GRUB, because I wanted to learn assembler), and my code triple faults and resets QEMU. Here is the code in question:
Bootloader
[ org 0x7c00 ]
[ BITS 16 ]
jmp 0x0000:Start
%include 'PrintFunc.asm'
%include 'DiskOp.asm'
Start:
cli
xor ax, ax
mov ss, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov sp, 500h
mov bp, 1500h
cld
sti
mov ax, 0007h
int 10h
mov si, A1
call printStr
mov [BootDrive], dl
mov al, 2
call diskLoad
mov si, A2
call printStr
jmp Cont
A1: db 'Loading sectors...', 0xA, 0xD, 0
BootDrive: db 0x00
times 510-($-$$) db 0
dw 0xAA55
A2: db 'Loaded two more sectors.', 0xA, 0xD, 0xA, 0
A3: db 'Checking A20...', 0xA, 0xD, 0
A4: db 'Enabling A20...', 0xA, 0xD, 0
A5: db 'A20 Enabled.', 0xA, 0xD, 0xA, 0
A6: db 'Loaded GDT, preparing to jump into PM.', 0xA, 0xD, 0
A7: db 'Landed in 32bit Protected Mode.', 0xA, 0xD, 0xA, 0
A8: db 0xA, 'Current FlameLoader version: ', 0
Ver: db '0.1', 0xA, 0xD, 0
GDT:
.NULL:
dq 0
.CodeSeg:
dw 0FFFFh
dw 0
db 0
db 010011010b
db 011011111b
db 0
.DataSeg:
dw 0FFFFh
dw 0
db 0
db 010010010b
db 011011111b
db 0
.end:
.desc:
dw .end - GDT - 1
db GDT
%include 'A20Func.asm'
Cont:
mov si, A3
call printStr
call testA20
cmp ax, 1
je EA20
mov si, A4
call printStr
call enableA20
EA20: ; A20 Enabled
mov si, A5
call printStr
cli
lgdt [GDT.desc]
sti
mov si, A6
call printStr
cli
mov eax, cr0
or eax, 1
mov cr0, eax
jmp 0x8:Init32
[BITS 32]
Init32:
jmp $ ; Debug
mov ax, 0x10
mov ds, ax
mov ss, ax
mov es, ax
mov esp, 500h
jmp Start32
%include 'Print32.asm'
Start32:
mov esi, A7
call PrintStr32
jmp $ ; Actual program end
Based on BOCHS debugger and trying to stop the program at various points with jmp $, I have deduced that the problem lies with this line:
jmp 0x8:Init32
P.S. I didn't include the function files as I don't think they would be useful here.