Code: Select all
;+-------------------------------------------------+
;| LBAtoCHS - convert the LBA (Local block |
;| address) number into |
;| CHS (Cylinder head sector) |
;| |
;| Input |
;| dh = Sectors per track |
;| dl = number of heads |
;| ax = LBA number |
;| Output |
;| CH = Cylinder number |
;| CL = Sector Number |
;| DH = Head Number |
;| |
;+-------------------------------------------------+
LBAtoCHS:
div dh ; al = int(LBA / SectorsPerTrk)
; ah = LBA mod SectorsPerTrk;
mov cl,ah ; cl = LBA mod SectorsPerTrk;
inc cl ; cl = (LBA mod SectorsPerTrk)+1;
xor ah,ah ; clear remainder
div dl ; al = int(LBA / SectorsPerTrk / NumHeads)
;ah = int((LBA / SectorsPerTrk) mod NumHeads)
mov ch,al
mov dh,ah
ret