Loading file from disk
Posted: Thu May 19, 2005 7:02 am
Hi im currently writing a boot loader for my OS, it loads that fine and loads the second program off the disk which takes care of everything else (loading the kernel at the moment) the problem is that I cant seem to get it to load my kernel of the disk it finds the file ok but after that it doesn?t work it just seems to get into an endless loop, well here is the code that im using to load the kernel.
Code: Select all
LoadKernelSector:
mov si, Dot
call PrintMsg
pop bx ; Restore write address
push ax ; Preserve sectore number
add ax, 001Fh ; Add data cluster offset
mov cx, 0001h ; Load 1 sector
call LoadSectors
pop ax ; Restore sector number
push bx ; Preserve write address
mov bx, ax ; Copy sector number
shr bx, 0001h ; Divide by 2
add bx, ax ; Add orginal sector number
add bx, 0200h ; Add offset to FAT
mov bx, WORD [bx] ; Load next sector number
test ax, 0001h ; Get lostest byte of sector number
jnz ODD ; If present the number is odd
and bx, 0FFFh ; if even take low 12 bytes
jmp Done
ODD:
shr bx, 0004h ; If odd take high 12 bytes
Done:
mov ax, bx ; Move sector number back into ax
cmp ax, 0FF0h ; Check for EOF
jb LoadKernelSector ;load next sector
mov si, KernelDone
call PrintMsg