Page 1 of 1

Bootloader doesn't load kernel

Posted: Wed May 27, 2009 12:11 pm
by Joe
hi,

I've written a simple bootloader using emu8086:

Code: Select all

#make_boot#
org 7c00h	

mov al, 'a'
mov ah, 0eh
int 10h

mov ah, 0x02h    
mov al, 0x01h    
mov ch, 0x00h    
mov cl, 0x02h    
mov dh, 0x00h    
mov dl, 0x00h    
mov bx, 0x2000h  
mov es, bx      
mov bx, 0x0000h 

int 0x13h          

mov ax, 0x2000h 
mov ds, ax     

jmp 0x2000:0x00
The above code executes the code below, which I am currently using as a placeholder for the actual kernel.

Code: Select all

mov al, 'a'
mov ah, 0eh
int 10h

mov al, 'b'
mov ah, 0eh
int 10h

mov al, 'c'
mov ah, 0eh
int 10h
It works fine with the emulator using the virtual floppy drive but when I write them to a floppy it prints the 'a' but it doesn't execute the kernel.

If anyone can answer it would be greatly appreciated.

Other information:
-The bootloader is written to sector 1
-The kernel is written to sector 2

Re: Bootloader doesn't load kernel

Posted: Wed May 27, 2009 2:46 pm
by mathematician
It might be because you are not specifying a page number in bh for the int 10h call. (Usually bh=0.)

Re: Bootloader doesn't load kernel

Posted: Wed May 27, 2009 3:00 pm
by Combuster
You're not doing error checking on int13. Real floppy drives are notorious for the problems you get with them.

Re: Bootloader doesn't load kernel

Posted: Wed May 27, 2009 3:49 pm
by xDDunce
also, you may want to reset the floppy controller (int 13h/ah=00h).

it just makes sure the drive is ready. consider using it before any floppy access.

Re: Bootloader doesn't load kernel

Posted: Wed May 27, 2009 5:31 pm
by Troy Martin
Reset the drive and attempt to load the kernel at least thrice before giving up, as most floppy drives take time to spin up.
mathematician wrote:It might be because you are not specifying a page number in bh for the int 10h call. (Usually bh=0.)
Theoretically any other page would probably just put the text on a different "layer." But as BX should be kept as 0 after the int 13h call, it should print to the zeroth page.

Re: Bootloader doesn't load kernel

Posted: Thu May 28, 2009 12:32 am
by Joe
Thanks everyone it works fine now :D

I used xDDunce's suggestion to reset the floppy controller and made a few changes and it worked fine! Here it is:

Code: Select all

org 7c00h

mov al, 'a'
mov ah, 0eh
int 10h

mov ah, 00h
mov dl, 0
int 0x13h

mov ah, 0x02h    
mov al, 0x01h    
mov ch, 0x00h    
mov cl, 0x02h    
mov dh, 0x00h    
mov dl, 0x00h    
mov bx, 0800h  
mov es, bx      
mov bx, 0x0000h 

int 0x13h   
   
mov ax, 0800h 
mov ds, ax     

jmp 0800h:0000

Code: Select all

#make_bin#

#load_segment=0800#
#load_offset=0000#

org 0000h

mov al, 'a'
mov ah, 0eh
int 10h
	
mov al, 'b'
mov ah, 0eh
int 10h	
	
mov al, 'c'
mov ah, 0eh
int 10h

jmp $
Thank you everyone for your help :D

Re: Bootloader doesn't load kernel

Posted: Thu May 28, 2009 8:43 am
by Troy Martin
I'd suggest not using emu8086 and use a real assembler like NASM and an emulator like bochs. emu8086 is terribly slow and only executes 8086 instructions, nothing higher.