Basic bootloader problem
Posted: Sun Feb 01, 2015 3:16 pm
Hey guys. So I've been trying to write a small-ish bootloader which can load a kernel. But I cannot seem to do that... INT 13h gives me no errors (at least I think so - carry flag is 0), but nothing happens when i try to run that kernel code. I am not sure if it is my code's problem or floppy disk having a wrong format. Here is my assembly code (fasm):
I've put some code after label kernel so it'd get loaded into the floppy file (it works). I create the floppy file using:
Any ideas?
Code: Select all
mov ax, 7c0h
mov ds, ax
mov ah, 02h ; read sector(s) into the memory
mov al, 01h ; number of sectors to read
mov ch, 00h ; cylinder (track) number
mov cl, 01h ; sector number (1 is the first one)
mov dh, 00h ; head number
mov dl, 00h ; floppy disk
mov bx, kernel
int 13h
jc error
jmp kernel
jmp error ; No idea how may this ever run
error:
mov si, error_msg
.next:
lodsb
cmp al, 00h
je .f_end
mov ah, 0Eh
mov bh, 00h
mov bl, 0fh
int 10h
jmp .next
.f_end:
jmp $
error_msg db 'Error!', 00h
nulls: times 510-($-$$) db 00h
boot_signature dw 0xAA55 ; Boot sector signature
kernel:
mov ah, 0Eh
mov al, 35h
int 10h
mov ah, 00h
int 16h
Code: Select all
fasm boot.asm boot.bin
dd if=/dev/zero bs=1474560 count=1 of=boot.flp
dd status=noxfer conv=notrunc if=boot.bin of=boot.flp