home *** CD-ROM | disk | FTP | other *** search
- ;Translates logical sector number in DX:AX to
- ;BIOSsec, HeadNum and CylNum
- ;---------------------------------------------
- DOS2BIOSsec PROC USES ax bx dx
- ;DX:AX contains LogSec, which we'll need later
- push dx
- push ax
- ;
- ;Get BIOSsec:
- ;Sector = 1 + LogSector MOD SectorsPerTrack
- ;--------------------------------------------
- mov bl,SecsPerTrac
- xor bh,bh ;zero extend SecsPerTrac
- div bx ;LogSec \ SecsPerTrac
- mov BIOSsec,dl ;Remainder in DX. We need only low
- ;byte because SecsPerTrac < 256.
- inc BIOSsec ;Add 1
- ;
- ;Get HeadNum
- ;Head = (LogSector \ SectorsPerTrack) MOD NumHeads
- ;-------------------------------------------------
- ;AX now contains (LogSec \ SecsPerTrac) from previous div
- mov bl,NumHeads ;Divide by NumHeads
- div bl ;Returns remainder in AH
- mov HeadNum,ah
- ;
- ;Get Cylinder
- ;Cylinder = LogSector \ (SectorsPerTrack * NumHeads)
- ;---------------------------------------------------
- ;Multiply SecsPerTrac * NumHeads
- mov al,SecsPerTrac ;BL already contains NumHeads
- mul bl ;Returns (SecsPerTrac*NumHeads) in AX
- mov bx,ax ;Save it in BX
- ;Restore LogSec to DX:AX
- pop ax
- pop dx
- ;Divide LogSec by (SecsPerTrac*NumHeads)
- div bx ;Returns quotient in AX
- mov CylNum,ax
- ret
- DOS2BIOSsec ENDP
- ;
- ReadSector PROC NEAR
- mov ah,02h ;BIOS Read Sector function
- mov al,1 ;Read one sector
- mov cx,CylNum
- xchg ch,cl ;Put low byte of CylNum in ch
- shl cl,6 ;Move bits 0 & 1 to bits 6 & 7
- add cl,BIOSsec ;(BIOSsec will not be more than 6 bits)
- mov dh,HeadNum
- mov dl,drive
- cmp dl,2 ;Is it a hard drive?
- jb ReadSector1
- add dl,7Eh ;80h=C:, 81h=D:, etc.
- ReadSector1:
- lea bx,text ;ES:BX points to text buffer
- int 13h ;BIOS Direct Disk Services
- jc goDOS
- ret
- ReadSector ENDP
- ;
-