failed to load file

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
McZ

failed to load file

Post by McZ »

I can't figure out what I'm doing wrong in my bootsector code, it failes to load the boot loader.. I'm trying to load it through the FAT12 filesystem but it failes to load it


source:
www.hig.se/~hco03phe/bootsctr.asm
Curufir

Re:failed to load file

Post by Curufir »

Your code to calculate the size of the root dir is wrong.

The calculation is:

Root_Dir_Size = ( (BPB_DirEntries * 32) / 512) rounded up

You're currently using:

Root_Dir_Size = ( ( (BPB_DirEntries * 32) + 512 - 1) / 512)

This is horribly wrong.

So use something like:

Code: Select all

MOV DX, [BPB_DirEntries]
AND DX, 0xF
JZ .1
ADD DX, 0x10
.1
SHR DX, 0x4
That error pretty much screws anything else you're trying to do.
bakery2k

Re:failed to load file

Post by bakery2k »

Curufir wrote: The calculation is:

Root_Dir_Size = ( (BPB_DirEntries * 32) / 512) rounded up

You're currently using:

Root_Dir_Size = ( ( (BPB_DirEntries * 32) + 512 - 1) / 512)

This is horribly wrong.
Err...No. His calculation will produce the same result as yours.
Curufir

Re:failed to load file

Post by Curufir »

Yeah you're correct of course (Basic algebra coming back to haunt me :)).

Hell, it'd be boring to be right all the time.

Waiter! More coffee.
Curufir

Re:failed to load file

Post by Curufir »

In penance I took another look.

This is one of the more amusing bugs I've seen.

Code: Select all

   div word[BPB_SectorsPerTrack]   ; divide AX with SectorsPerTrack (LBA / SPT)    inc dl                          ; increase the remainder of the division
There's no line break before the 'inc dl' instruction.

This means NASM interprets it as part of the comment and it's never assembled.

Which means all the LBAtoCHS conversions are wrong.

Nasty.
McZ

Re:failed to load file

Post by McZ »

Curufir wrote: In penance I took another look.

This is one of the more amusing bugs I've seen.

Code: Select all

   div word[BPB_SectorsPerTrack]   ; divide AX with SectorsPerTrack (LBA / SPT)    inc dl                          ; increase the remainder of the division
There's no line break before the 'inc dl' instruction.

This means NASM interprets it as part of the comment and it's never assembled.

Which means all the LBAtoCHS conversions are wrong.

Nasty.

oh.. I can't remember there is missing a linebreak but I have to make sure as soon as I get home :)

but lets say there is a line break there is there anything else that can be wrong then?
McZ

Re:failed to load file

Post by McZ »

so I have been trying to fix the problem with my file loader... but so far no success... altough I have found out that it looks like it doesn't load anything from disk, I used my bPrintHex16 function to print out the stuff in the FAT_BUFF and it writes only 0000 for each value.. wich wont be correct becouse I have one file that is 1kb in size, then it would be fitted into 2 sectors, but how come the 1 entry I should get in the FAT_BUFF is empty or 0000 ? shouldn't it be some other value?
Post Reply