Boot Sector won't load Kernel
Posted: Sat Aug 05, 2006 8:19 pm
Hey first time posting here, friend refered me.
My situation is this: I have a boot sector, it seems to have loaded anouther simple asm bin file perfectly, but now that I introduced my kernel to the boot sector it doesn't seem to work.
Here is my boot sector code:
My kernel loading code is this:
It loads main wich is defined in my C++ code and that prints some text alerting me it loaded and ran. I as well tried anouther kernel that I know works in the same way but also nothing. It just prints loading, returns twice like it should but than sits there until I manualy restart it.
Any help is welcome, and thanks in advance!
My situation is this: I have a boot sector, it seems to have loaded anouther simple asm bin file perfectly, but now that I introduced my kernel to the boot sector it doesn't seem to work.
Here is my boot sector code:
Code: Select all
[ORG 0x7C00]
[BITS 16]
jmp start
start:
mov si,Print_loading ;Prints "Loading" to the screen
call printstring ;And returns twice
reset_drive:
mov ah, 0 ;RESET-command
int 13h ;Call interrupt 13h
or ah, ah ;Check for error code
jnz reset_drive ;Try again if ah != 0
mov ax,0x08 ;Location to load code
mov es,ax
mov bx,0x7E00
mov ah,02h ;When ah=02h, int13 reads a disk sector
mov al,8 ;Al is how many sectors to read
mov ch,0 ;The track to read from
mov cl,2 ;Sector Id
mov dh,0 ;Head
mov dl,0 ;Drive (0 is floppy)
int 13h
or ah, ah ;Check for error code
jnz reset_drive ;Try again if ah != 0
mov ax,0x08 ;Not sure about this code
mov ds,ax ;Doesn't seem to make a difference
jmp 0x08:0x7E00
printstring: ;Print string routine.
mov ah,0eh ;Mov ah into 0, so int 10 prints
stringloop: ;The following code loads each seperate charcter so it can be printed
lodsb
cmp al,00 ;If al =0, then the string has all been loaded
je endstring
int 10h ;When int 10 is called, and ah=0eh, it prints
jmp stringloop
endstring:
ret
Print_loading db 13,10,'Loading',13,10,13,10,0
Code: Select all
[BITS 32] ;protected mode
[global start]
[extern _main] ;this is in our C++ code
start:
call _main ;call int main(void) from our C++ code
cli ;interrupts could disturb the halt
hlt ;halt the CPU
Any help is welcome, and thanks in advance!