Error with LBA to CHS conversion

Feedback? Questions? Comments? All discussions on the articles and tutorials hosted or developed by us go in here.

Moderator:Moderators

Post Reply
Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:
Error with LBA to CHS conversion

Post by Andyhhp » Sun Dec 09, 2007 11:03 pm

Im sorry to moan but I hope you dont mind having errors pointed out :oops:

in the OS series, in http://www.brokenthorn.com/Resources/OSDev6.html, 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.

Andrew

User avatar
Mike
Site Admin
Posts:465
Joined:Sat Oct 20, 2007 7:58 pm
Contact:

Post by Mike » Tue Dec 11, 2007 3:34 pm

Hey,

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
Lead Programmer for BrokenThorn Entertainment, Co.
Website: http://www.brokenthorn.com
Email: webmaster@brokenthorn.com

Andyhhp
Moderator
Posts:387
Joined:Tue Oct 23, 2007 10:05 am
Location:127.0.0.1
Contact:

Post by Andyhhp » Wed Dec 12, 2007 11:00 pm

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:

Post Reply