Bootloader doesn't load kernel

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Joe
Posts: 3
Joined: Tue May 26, 2009 9:44 am

Bootloader doesn't load kernel

Post 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
User avatar
mathematician
Member
Member
Posts: 437
Joined: Fri Dec 15, 2006 5:26 pm
Location: Church Stretton Uk

Re: Bootloader doesn't load kernel

Post by mathematician »

It might be because you are not specifying a page number in bh for the int 10h call. (Usually bh=0.)
The continuous image of a connected set is connected.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Bootloader doesn't load kernel

Post by Combuster »

You're not doing error checking on int13. Real floppy drives are notorious for the problems you get with them.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
xDDunce
Member
Member
Posts: 173
Joined: Tue Aug 12, 2008 4:04 pm
Contact:

Re: Bootloader doesn't load kernel

Post 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.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Bootloader doesn't load kernel

Post 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.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
Joe
Posts: 3
Joined: Tue May 26, 2009 9:44 am

Re: Bootloader doesn't load kernel

Post 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
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Bootloader doesn't load kernel

Post 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.
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
Post Reply