confusion in converting LBA to CHS

If you are new to OS Development, plan on spending some time here first before going into the other forums.

Moderator:Moderators

Post Reply
brainbarshan
Posts:9
Joined:Fri Feb 19, 2010 12:58 pm
confusion in converting LBA to CHS

Post by brainbarshan » Tue May 11, 2010 8:04 am

I am reading the tutorial 6 bootloader 4 chapter
As written here :

absolute sector = (logical sector / sectors per track) + 1

and the code written after this:
xor dx, dx ; prepare dx:ax for operation
div WORD [bpbSectorsPerTrack] ; divide by sectors per track
inc dl ; add 1 (obsolute sector formula)
mov BYTE [absoluteSector], dl
But in 16 bit division , where AX stores the quotient and DX stores the remainder. Hence a remainder is being stored in dl and that is next stored in the variable absoluteSector.

Then the formula for calculating sector should have been :
absolute sector = (logical sector MOD sectors per track) + 1

correct me if I am wrong.

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

Re: confusion in converting LBA to CHS

Post by Andyhhp » Tue May 11, 2010 5:01 pm

You are correct. The calculation should use modulus.

~Andrew
Image

Post Reply