Page 1 of 1

confusion in converting LBA to CHS

Posted: Tue May 11, 2010 8:04 am
by brainbarshan
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.

Re: confusion in converting LBA to CHS

Posted: Tue May 11, 2010 5:01 pm
by Andyhhp
You are correct. The calculation should use modulus.

~Andrew