I recently picked up my mini OS project again to give kernel another go. Right now, I have a bootloader on the first sector and my assembly kernel on the second. I'm getting pretty sick of making the whole thing in assembly (Although I have a semi-working console) and wanted to move to C as I'm fairly well versed in it. The bootloader works fine and loads the kernel bin at the 0x1000 and then jumps to it. When I tried to replicate it using C, I ended up consulting tutorials (I was confused on the connection of assembly and C) but even through all the tutorials I came across, I never ended up with a working kernel bin file. I finally suspected it was an issue with the memory address and the way the I was instructing ld to set it up due to the way the kernel was not loading and QEMU was just sitting saying "Booting from floppy...". In addition, ld was the one common item that all of the c examples I looked at shared. To test this, I compiled my working kernel using
Code: Select all
nasm -f aout kernel.asm -o kernel.o
Code: Select all
ld -Ttest 0x1000 -o kernel.bin kernal.o
Code: Select all
ld -Ttest 0x1000-e start -o kernel.bin kernal.o
What I've tried:
http://www.osdever.net/tutorials/view/mixing-assembly-c (Although I recall someone calling this the "tutorial from hell")
http://www.osdever.net/tutorials/view/w ... e-c-kernel
http://wiki.osdev.org/C%2B%2B_Bare_Bones
The working bootloader:
Code: Select all
bits 16
org 0x7c00:boot
boot:
call load_kernal_sector
jmp 0x1000
load_kernal_sector:
xor ah, ah
int 0x13
mov ax, ds
mov es, ax
mov bx, 0x4000
mov dl, 0
mov dh, 0
mov al, 1
mov ch, 0
mov cl, 2
mov ah, 0x2
int 0x13
ret
times 510-($-$$) db 0
dw 0xAA55
Thanks for any help,
Paul