My Questions About Tutorial 6
Posted: Sat Aug 06, 2011 8:15 pm
Hello I'm Jackson and I have a few questions about tut 6.
First is, Convert CHS to LBA.
the formula is:
LBA = (cluster - 2) * sectors per cluster
ClusterLBA:
sub ax, 0x0002 ;ax = cluster.
xor cx, cx ;clear cx
mov cl, BYTE [bpbSectorsPerCluster] ;cl = the current byte of sectors per cluster
mul cx ;Why multiply cl by cx. Why not moveSectors Per Cluster into the cx and then multiply cx by ax?
add ax, WORD [datasector] ;Add ax to the datasector variable
ret ;return
My next question is about Convert LBA to CHS
The formula is:
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)
LBACHS:
xor dx, dx ;clear dx which I'm guessing is thelogical sector
div WORD [bpbSectorsPerTrack] ; divide dx by sectors per track
inc dl ;Why increase dl instead of dx
mov BYTE [absoluteSector], dl ;absolute sector variable = dl
xor dx, dx ;clear
div WORD [bpbHeadsPerCylinder] ;Why divide by number of heads instead of sectors per track and then divide by number of heads and take the remainder(MOD)?
mov BYTE [absoluteHead], dl ;absolute head variable = dl
mov BYTE [absoluteTrack], al ;Why al?
ret ;ret
Thank you.
First is, Convert CHS to LBA.
the formula is:
LBA = (cluster - 2) * sectors per cluster
ClusterLBA:
sub ax, 0x0002 ;ax = cluster.
xor cx, cx ;clear cx
mov cl, BYTE [bpbSectorsPerCluster] ;cl = the current byte of sectors per cluster
mul cx ;Why multiply cl by cx. Why not moveSectors Per Cluster into the cx and then multiply cx by ax?
add ax, WORD [datasector] ;Add ax to the datasector variable
ret ;return
My next question is about Convert LBA to CHS
The formula is:
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)
LBACHS:
xor dx, dx ;clear dx which I'm guessing is thelogical sector
div WORD [bpbSectorsPerTrack] ; divide dx by sectors per track
inc dl ;Why increase dl instead of dx
mov BYTE [absoluteSector], dl ;absolute sector variable = dl
xor dx, dx ;clear
div WORD [bpbHeadsPerCylinder] ;Why divide by number of heads instead of sectors per track and then divide by number of heads and take the remainder(MOD)?
mov BYTE [absoluteHead], dl ;absolute head variable = dl
mov BYTE [absoluteTrack], al ;Why al?
ret ;ret
Thank you.