Page 1 of 1

Error with LBA to CHS conversion

Posted: Sun Dec 09, 2007 11:03 pm
by Andyhhp
Im sorry to moan but I hope you dont mind having errors pointed out :oops:

in the OS series, in, and in the comments in the downloadable source code, the following is written about converting an LBA address to a CHS one:

absolute sector = (logical sector / sectors per track) + 1
absolute head = (logical sector / sectors per track) MOD number of heads
absolute track = logical sector / (sectors per track * number of heads)

after spending 2 weeks trying to find out why my bootloader wasn't working, I found that the formula for Absolute Sector should be
absolute sector = (logical sector MOD sectors per track) + 1

The actual source code itself in the download is correct but the comment is the same as above.

The reason I got so stuck on this is because, rightly or wrongly, I dont copy source code - I try to write it myself so I fully understand what is going on (I still have much to learn about assembly).

Anyway, I hope you dont mind a constructive criticism.


Posted: Tue Dec 11, 2007 3:34 pm
by Mike

The comments from the source code were copied directly from the tutorial when it was originally written. So, while the code was correct, the comment contained the same formula noted from the tutorials.

Thanks for letting us know about the error :) We are going to fix that in the next series upgrade (Which will include [so far] two new tutorials.)

Thanks again! :D

Posted: Wed Dec 12, 2007 11:00 pm
by Andyhhp
Having read both of the new tutorials, ive noticed that the same error occurs when you are rewriting the FAT12 driver for the second stage. I assume this is for the same reason :wink: