What is wrong
Posted: Wed Mar 09, 2005 9:34 pm
the following code is ment to convert LBA to CHS. it is works in dos and windows(protected mode) but does not work in Real Mode
Any help will be good. thankyou
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