Hello! I'm learning OS development and I'm stuck on a bootloader problem.
My issue:
The bootloader loads correctly. BIOS interrupt int 0x13 works and loads the kernel from disk. The A20 line is enabled through int 0x15 without problems. After that I load the GDT through lgdt and enable Protected Mode with mov cr0, eax and or eax, 1.
Then I do a FAR JMP to jmp 0x08:0x1000 where the kernel should be.
But here's what happens: the kernel code doesn't execute at all. In BOCHS I see "Booting from Hard Disk..." but nothing happens after that. In QEMU I also see "Booting from Hard Disk..." and then the system just stops.
I've tried different ways of writing the GDT, different jump methods, both BOCHS and QEMU emulators give the same result.
Here is my bootloader and kernel code. The file sizes are correct: boot.bin is 512 bytes, kernel.bin is 25600 bytes, disk.img is 102400 bytes.
I create the disk with dd commands and everything looks correct, but the kernel just doesn't work.
Please help! What am I doing wrong? i sended the file .asm with my code but, if you lazy code is here
org 0x7C00
xor ax, ax
mov es, ax
mov ds, ax
mov ss, ax
mov sp, 0x7C00
mov ah, 0x02
mov al, 50
mov ch, 0
mov cl, 2
mov dh, 0
mov dl, 0x80
mov bx, 0x1000
int 0x13
a20:
mov ax, 0x2401
int 0x15
gdt:
dq 0x0000000000000000
dq 0x00cf9a000000ffff
dq 0x00cf92000000ffff
gdt_descriptor:
dw $ - gdt - 1
dd gdt
cli
lgdt [gdt_descriptor]
mov eax, cr0
or eax, 1
mov cr0, eax
jmp 0x08:0x1000
times 510-($-$$) db 0
dw 0xAA55
x86 Bootloader not jumping to kernel
-
Octocontrabass
- Member

- Posts: 6250
- Joined: Mon Mar 25, 2013 7:01 pm
Re: x86 Bootloader not jumping to kernel
After the INT 0x15 call returns, which instruction will the CPU execute next?
Re: x86 Bootloader not jumping to kernel
After INT 0x15 returns, the next instruction is the GDT definition in memory, which is followed by the GDT descriptor that calculates the size of the GDT using ($ - gdt - 1). Then lgdt is called to load the GDT
into the register.
into the register.
Re: x86 Bootloader not jumping to kernel
When int 15h occurs, it will start executing the GDT data. You don't want that. That's invalid code and is making the CPU crash. What you could do is move the data to the bottom of the file, or just jump over it