I recently started in os programming and I've written a bootloader with nasm that calls a kernel... when I emulate it , the bootloader works perfectly but the kernel doesn't load , my code :
bootloader.asm
%define os 0x1000
%define drive 0x80
%define os_sect 3
%define ftable 0x2000
%define ftabsect 2
[BITS 16]
[org 0x7c00]
start:
;boot message
mov si, bootMsg
call printstring
;waitin for user press key
mov ah, 0
int 16h
;load sector os
mov ax, os
mov es, ax
mov cl, os_sect
mov al, 2
call sectorloader
jmp 0x1000:0
;print character function
printchar:
mov ah, 0x0E
mov bh, 0x00
mov bl, 0x03
int 0x10
ret
;print string function ~ using printchar function
printstring:
nextchar:
mov al, [si]
inc si
or al, al
jz exit
call printchar
jmp nextchar
exit:
ret
sectorloader:
mov bx, 0
mov dl, drive
mov dh, 0
mov ch, 0
mov ah, 2
int 0x13
jc loaderror
ret
loaderror:
mov si,loadsectorError
call printstring
mov ah,0
int 16h
int 19h
;data
bootMsg db 'Booting [OK]',10,13,'Press any key !',10,13,10,13,0
loadsectorError db 'Error while loading sector[!]',10,13,0
TIMES 510 - ($-$$) db 0
DW 0xAA55
kernel.asm
[bits 16]
[org 0]
mov al, 65
mov ah, 0x0E
mov bh, 0x00
mov bl, 0x03
int 0x10
I build the programs like so :
nasm -f bin -o try.bin bootloader.asm -p kernel.bin
And I emulated it like so : qemu-system-i386 try.bin
So if someone can help me ... thanks