Home arrow Forums
OSDEV Forums  


spider
User

Fresh Osdever
Posts: 2
graphgraph
Karma: 0  
loading file from disk - 2005/05/20 06:25 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.

<div class='indent'>

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
</div>
  | | The administrator has disabled public write access.
OSDEV
Community
Advertisement
   
DRF
User

Platinum Osdever
Posts: 123
graphgraph
Karma: 1  
Re: loading file from disk - 2005/05/20 18:21 I'm in a bit of a rush at the moment and your code not being to clearly commented in places could take a while to figure out. (I'm sure it makes sense to you).

It does look however like some of your figures are assumed rather than calculated. Could you say which print messages appear on the screen and it might be an idea to add to print a dot or hash to represent each cluster loaded to see if it gets stuck in a loop where you think it does. (basiclly fill the code with tonnes of messages). Remember to save all the register values on the stack before printing a message of course!

I've got an example of my Fat12 code here: http://www.dftech.cwc.net/osdev/docs.html if you want to compare it with yours and see how someone else has gone about implementing FAT12.

Daniel
  | | The administrator has disabled public write access.

A WebArticles site. Sponsored by Evoleto. Motorola V525 / Business Directory / Delaware Incorporation / Home Made Bazaar