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
failed to load file
Re:failed to load file
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:
That error pretty much screws anything else you're trying to do.
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
Re:failed to load file
Err...No. His calculation will produce the same result as yours.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.
Re:failed to load file
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.
Hell, it'd be boring to be right all the time.
Waiter! More coffee.
Re:failed to load file
In penance I took another look.
This is one of the more amusing bugs I've seen.
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.
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
This means NASM interprets it as part of the comment and it's never assembled.
Which means all the LBAtoCHS conversions are wrong.
Nasty.
Re:failed to load file
oh.. I can't remember there is missing a linebreak but I have to make sure as soon as I get homeCurufir wrote: In penance I took another look.
This is one of the more amusing bugs I've seen.
There's no line break before the 'inc dl' instruction.Code: Select all
div word[BPB_SectorsPerTrack] ; divide AX with SectorsPerTrack (LBA / SPT) inc dl ; increase the remainder of the division
This means NASM interprets it as part of the comment and it's never assembled.
Which means all the LBAtoCHS conversions are wrong.
Nasty.
but lets say there is a line break there is there anything else that can be wrong then?
Re:failed to load file
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?