home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.update.uu.se
/
ftp.update.uu.se.2014.03.zip
/
ftp.update.uu.se
/
pub
/
rainbow
/
msdos
/
latrobe
/
b
/
biodif.arc
/
HDISKDRV.DIF
< prev
next >
Wrap
Text File
|
1987-06-20
|
24KB
|
950 lines
----------HDISKDRV.OLD
; HREAD -- Read sector(s)
; HWRITE -- Write sector(s)
; HWRITEV -- Write sectos(s) with verify
; HFORMAT -- Format track(s)
; HINIT -- Init hard disk drive
; HMCHK -- Media check
; HVDISK -- Verify disk
; INTHDL -- Hard disk interrupt handler
;
----------HDISKDRV.ASM
; HREAD -- Read sector(s)
; HWRITE -- Write sector(s)
; HWRITEV -- Write sectos(s) with verify
; HREAD_PHYS -- Read physical sector(s) ;RGT
; HWRITE_PHYS -- Write physical sector(s) ;RGT
; HWRITEV_PHYS -- Write physical sectos(s) with verify;RGT
; HFORMAT -- Format track(s)
; HINIT -- Init hard disk drive
; HMCHK -- Media check
; HVDISK -- Verify disk
; INTHDL -- Hard disk interrupt handler
;
-----------------------------------------------
----------HDISKDRV.OLD
; RETRY -- Error recovery after a read
; HOMET -- Restore head
; MOVEMX -- Move head to maximum track
; MOVEH -- Move head
; LDTSKF -- Load hard disk task file
; OUTCMD -- Output command and wait for cmd completion
; ADVTNS -- Advance to next logical sector (OS dependent)
; ADVTNT -- Advance to next logical track
; DELAY -- Delay for 0.5 milliseconds
;
----------HDISKDRV.ASM
; HREAD_ONE_SECTOR -- Read one physical sector;RGT
; HWRITE_ONE_SECTOR -- Write one physical sector;RGT
; RETRY -- Error recovery after a read
; HOMET -- Restore head
; MOVEMX -- Move head to maximum track
; MOVEH -- Move head
; LDTSKF -- Load hard disk task file
; OUTCMD -- Output cmd and wait for completion
; ADVTNT -- Advance to next logical track
; DELAY -- Delay for 0.5 milliseconds
;
-----------------------------------------------
----------HDISKDRV.OLD
;
----------HDISKDRV.ASM
; RGT 8 Feb 1987 Added routines to call cache control.
;
-----------------------------------------------
----------HDISKDRV.OLD
PUBLIC HFORMAT ;Format track(s)
----------HDISKDRV.ASM
PUBLIC HREAD_PHYS ;Read physical sector(s) ;RGT
PUBLIC HWRITE_PHYS ;Write physical sector(s) ;RGT
PUBLIC HWRITEV_PHYS ;Write physical sector(s) with verify;RGT
PUBLIC HFORMAT ;Format track(s)
-----------------------------------------------
----------HDISKDRV.OLD
;
----------HDISKDRV.ASM
EXTRN TEMP_TRK:WORD, TEMP_SEC:BYTE ;RGT
EXTRN GETFTN:NEAR ;RGT
; ;RGT
; Define the entry points for the disk cache routines ;RGT
; ;RGT
EXTRN READ_BLOCK_FROM_CACHE:NEAR ;Routine to read cache ;RGT
EXTRN WRITE_BLOCK_TO_CACHE:NEAR ;Routine to write cache ;RGT
EXTRN INVALIDATE_DISK_CACHE:NEAR ;Routine to invalidate ;RGT
;specific disk in cache ;RGT
EXTRN INVALIDATE_HARD_DISK_CACHE:NEAR ;Routine to invalidate ;RGT
;hard disk in cache ;RGT
;
-----------------------------------------------
----------HDISKDRV.OLD
; Reg BH -- Surface/drive number
----------HDISKDRV.ASM
; Reg AL -- Unit code ;RGT
; Reg CX -- Sector count
; Reg DX -- Logical sector number ;RGT
; Reg ES:DI -- Buffer start address
;
; Exit Parameters:
;
; Z-flag is clear if error (return Zero for no error)
; Reg AX -- Error status
; Reg AL = 0 -- no error
; = 1 -- error
; = 3 -- Drive defective
; = 5 -- Disk defective
; = 0DH -- Write verify error
; = 0FH -- Soft error
; Reg AH Bit 0 -- DAM not found
; Bit 1 -- Track 0 error
; Bit 2 -- Aborted command
; Bit 4 -- ID not found
; Bit 6 -- CRC error in data field
; Bit 7 -- Bad block detect
; (RETNS) -- Number of sectors performed the retry
;
; Registers Changed: All
;
;--
;
HREAD:
CLD ;Set forward flag
MOV BYTE PTR RETNS,0 ;No sector did retry yet
MOV BX,AX ;Move disk code to reg BX
;
; Read sector(s) loop
;
HREAD5:
; ;RGT
; First, try to read the block from the disk cache ;RGT
; ;RGT
CALL READ_BLOCK_FROM_CACHE ;Read block from disk cache ;RGT
JNC HREAD_NEXT ;If found in cache, do not read ;RGT
; ;RGT
; Disk block not in cache -- read the block from the disk ;RGT
; ;RGT
PUSH BX ;Save logical code of disk ;RGT
PUSH DX ;Save logical sector of disk ;RGT
PUSH DI ;Save address of buffer ;RGT
CALL SETPAR ;Set up the disk parameters ;RGT
CALL HREAD_ONE_SECTOR ;Read in the hard disk sector ;RGT
POP SI ;Restor adr of buffer in reg SI ;RGT
POP DX ;Restore logical sector of disk ;RGT
POP BX ;Restore logical code of disk ;RGT
JNZ HREAD2 ;If error, just return ;RGT
; ;RGT
; Disk block has been read -- now write it to the disk cache ;RGT
; ;RGT
XCHG SI,DI ;Store new buffer address ;RGT
;and get old one ;RGT
MOV AX,BX ;Move logical disk code to AX ;RGT
CALL WRITE_BLOCK_TO_CACHE ;Write block to disk cache ;RGT
XCHG SI,DI ;Restore new buffer address ;RGT
;
; Done with this read -- read next sector
;
HREAD_NEXT:
INC DX ;Inc to next logical sector ;RGT
LOOP HREAD5 ;Loop for multi-sector read
;
; Read completed -- clear error and return
;
XOR AX,AX ;Assume no error
TEST BYTE PTR RETNS,0FFH ;Retry before?
JZ HREAD2 ;If not, then just exit
MOV AL,SERR ;Otherwise, set soft error
;
; Done with the read -- turn the LED off on the disk drive
;
HREAD2:
JMP LED_OFF ;Deselect device and return
;
;++ ;RGT
; ;RGT
; Function: HREAD_PHYS ;RGT
;
; Abstract:
;
; Read physical sector or sectors from the hard disk. ;RGT
;
; Entry Parameters:
;
; Reg BH -- Surface/drive number
-----------------------------------------------
----------HDISKDRV.OLD
; Z-flag is set if error
; Reg AX -- Error status
----------HDISKDRV.ASM
; Z-flag is clear if error (Zero indicates no error)
; Reg AX -- Error status
-----------------------------------------------
----------HDISKDRV.OLD
HREAD:
CLD ;Set forward flag
----------HDISKDRV.ASM
HREAD_PHYS: ;RGT
CLD ;Set forward flag
-----------------------------------------------
----------HDISKDRV.OLD
HREAD5:
CALL LDTSKF ;Load task file for winchester
JNZ HREAD2 ;Error if past limit
MOV AL,RDREAD+ATRETRY ;Load read command
----------HDISKDRV.ASM
HREAD_PHYS5: ;RGT
CALL HREAD_ONE_SECTOR ;Read in the hard disk sector ;RGT
JNZ HREAD_PHYS2 ;If error, just return ;RGT
;
; Done with this read -- read next sector
;
CALL ADVTNS ;Advance to next sector
LOOP HREAD_PHYS5 ;Loop for multi-sector read
;
; Read completed -- clear error and return
;
XOR AX,AX ;Assume no error
TEST BYTE PTR RETNS,0FFH ;Retry before?
JZ HREAD_PHYS2 ;If not, then just exit
MOV AL,SERR ;Otherwise, set soft error
;
; Done with the read -- turn the LED off on the disk drive
;
HREAD_PHYS2:
JMP LED_OFF ;Deselect device
;
;++
;
; Function: HREAD_ONE_SECTOR ;RGT
;
; Abstract:
;
; Read in one physical sector from the hard disk.
;
; Entry Parameters:
;
; Reg BH -- Surface/drive number
; Bits 0-3 - surface number
; Bits 4-7 - drive number
; Reg BL -- Sector number
; Reg CX -- Sector count
; Reg DX -- Cylinder number
; Reg ES:DI -- Buffer start address
;
; Exit Parameters:
;
; Z-flag is clear if error (Zero indicates no error)
; Reg AX -- Error status
; Reg AL = 0 -- no error
; = 1 -- error
; = 3 -- Drive defective
; = 5 -- Disk defective
; = 0DH -- Write verify error
; = 0FH -- Soft error
; Reg AH Bit 0 -- DAM not found
; Bit 1 -- Track 0 error
; Bit 2 -- Aborted command
; Bit 4 -- ID not found
; Bit 6 -- CRC error in data field
; Bit 7 -- Bad block detect
; (RETNS) -- Number of sectors performed the retry
;
; Registers Changed: All
;
;--
;
HREAD_ONE_SECTOR: ;RGT
CALL LDTSKF ;Load task file for winchester
JNZ HREAD_ONE_SECT_RET ;Error if past limit ;RGT
MOV AL,RDREAD+ATRETRY ;Load read command
-----------------------------------------------
----------HDISKDRV.OLD
HREAD10:
OR AL,AL ;Check for error
JZ HREAD3 ;Skip if no error
;
----------HDISKDRV.ASM
HREAD_ONE_SECT10: ;RGT
OR AL,AL ;Check for error
JZ HREAD_ONE_SECT3 ;Skip if no error ;RGT
;
-----------------------------------------------
----------HDISKDRV.OLD
JNZ HREAD2 ;If so, then abort command
;
----------HDISKDRV.ASM
JNZ HREAD_ONE_SECT_RET ;If so, then abort command ;RGT
;
-----------------------------------------------
----------HDISKDRV.OLD
HREAD3:
PUSH DX ;Save cylinder number
----------HDISKDRV.ASM
HREAD_ONE_SECT3: ;RGT
PUSH DX ;Save cylinder number
-----------------------------------------------
----------HDISKDRV.OLD
HREAD1:
IN AL,DX ;Get data byte
----------HDISKDRV.ASM
HREAD_ONE_SECT1: ;RGT
IN AL,DX ;Get data byte
-----------------------------------------------
----------HDISKDRV.OLD
LOOP HREAD1 ;Loop for all words in buffer
;
----------HDISKDRV.ASM
LOOP HREAD_ONE_SECT1 ;Loop for all words in buffer ;RGT
;
-----------------------------------------------
----------HDISKDRV.OLD
; Done with this read -- read next sector
;
CALL ADVTNS ;Advance to next sector
LOOP HREAD5 ;Loop for multi-sector read
;
; Read completed -- clear error and return
;
XOR AX,AX ;Assume no error
TEST BYTE PTR RETNS,0FFH ;Retry before?
JZ HREAD2 ;If not, then just exit
MOV AL,SERR ;Otherwise, set soft error
;
; Done with the read -- turn the LED off on the disk drive
;
HREAD2:
JMP LED_OFF ;Deselect device
RET ;Return (Do not know why this is here)
----------HDISKDRV.ASM
; Clear reg AX to indicate success
;
XOR AX,AX ;Clear reg AX for no error
;
; Done with this read -- return to caller ;RGT
;
HREAD_ONE_SECT_RET: ;RGT
RET ;And return to caller ;RGT
;
-----------------------------------------------
----------HDISKDRV.OLD
; Reg BH -- Surface/drive number
----------HDISKDRV.ASM
; Reg AL -- Unit code ;RGT
; Reg CX -- Sector count
; Reg DX -- Logical sector number ;RGT
; Reg ES:DI -- Buffer start address
;
; Exit Parameters:
;
; Z-flag is clear if error (Zero indicates no error)
; Reg AX -- Error status
; Reg AL = 0 -- no error
; = 1 -- error
; = 3 -- Drive defective
; = 5 -- Disk defective
; = 0DH -- Write verify error
; = 0FH -- Soft error
; Reg AH Bit 0 -- DAM not found
; Bit 1 -- Track 0 error
; Bit 2 -- Aborted command
; Bit 4 -- ID not found
; Bit 6 -- CRC error in data field
; Bit 7 -- Bad block detect
;
; Registers Changed: All
;
;--
;
HWRITEV:
MOV BYTE PTR WRTWVF,1 ;Set write with verify flag
JMP SHORT HWRITE1 ;And perform write
HWRITE:
MOV BYTE PTR WRTWVF,0 ;Clear write with verify flag
HWRITE1:
CLD ;Set forward flag
MOV SI,DI ;Set SI to buffer address
MOV BX,AX ;Move disk code to reg BX
;
; Write sector loop
;
HWRITE5:
MOV AX,BX ;Move logical disk code to AX ;RGT
CALL WRITE_BLOCK_TO_CACHE ;Write block to disk cache ;RGT
PUSH BX ;Save logical code of disk ;RGT
PUSH DX ;Save logical sector of disk ;RGT
PUSH SI ;Save buffer address ;RGT
CALL SETPAR ;Set up the disk parameters ;RGT
POP SI ;Restore buffer address ;RGT
CALL HWRITE_ONE_SECTOR ;Write sector to disk ;RGT
POP DX ;Restore logical sector of disk ;RGT
POP BX ;Restore logical code of disk ;RGT
JNZ HWRITE2 ;If error, just return ;RGT
;
; Write complete -- advance to next sector
;
INC DX ;Inc to next logical sector ;RGT
LOOP HWRITE5 ;And perform multi-sector write
;
; Done with write -- clear error status
;
XOR AX,AX ;Clear error status
;
; Done with the write -- turn the LED off on the disk drive
;
HWRITE2:
JMP LED_OFF ;Deselect device
;
;++
;
; Function: HWRITE_PHYS and HWRITEV_PHYS ;RGT
;
; Abstract:
;
; Write physical hard disk sector with and without verify ;RGT
;
; Entry Parameters:
;
; Reg BH -- Surface/drive number
-----------------------------------------------
----------HDISKDRV.OLD
; Z-flag is set if error
; Reg AX -- Error status
----------HDISKDRV.ASM
; Z-flag is clear if error (Zero indicates no error)
; Reg AX -- Error status
-----------------------------------------------
----------HDISKDRV.OLD
HWRITEV:
MOV BYTE PTR WRTWVF,1 ;Set write with verify flag
JMP SHORT HWRITE1 ;And perform write
HWRITE:
MOV BYTE PTR WRTWVF,0 ;Clear write with verify flag
HWRITE1:
CLD ;Set forward flag
MOV SI,DI ;Set SI to buffer address
;
----------HDISKDRV.ASM
HWRITEV_PHYS: ;RGT
MOV BYTE PTR WRTWVF,1 ;Set write with verify flag
JMP SHORT HWRITE_PHYS1 ;And perform write ;RGT
HWRITE_PHYS: ;RGT
MOV BYTE PTR WRTWVF,0 ;Clear write with verify flag
HWRITE_PHYS1: ;RGT
CLD ;Set forward flag
MOV SI,DI ;Set SI to buffer address
CALL HWRITE_ONE_SECTOR ;Write sector to disk ;RGT
JNZ HWRITE_PHYS2 ;If error, just return ;RGT
;
-----------------------------------------------
----------HDISKDRV.OLD
HWRITE5:
MOV DI,SI ;Set DI to buffer address
CALL LDTSKF ;Load task file
JNZ HWRITE2 ;Error if past limit
MOV AL,RDWRITE+ATRETRY ;Load the write command
----------HDISKDRV.ASM
HWRITE_PHYS5: ;RGT
MOV DI,SI ;Set DI to buffer address
;
; Write complete -- advance to next sector
;
CALL ADVTNS ;Advance to next sector
LOOP HWRITE_PHYS5 ;And perform multi-sector write
;
; Done with write -- clear error status
;
XOR AX,AX ;Clear error status
;
; Done with the write -- turn the LED off on the disk drive
;
HWRITE_PHYS2:
JMP LED_OFF ;Deselect device
;
;++ ;RGT
;
; Function: HWRITE_ONE_SECTOR ;RGT
;
; Abstract:
;
; Write one hard disk sector with and without verify ;RGT
;
; Entry Parameters:
;
; Reg BH -- Surface/drive number
; Bits 0-3 - surface number
; Bits 4-7 - drive number
; Reg BL -- Sector number
; Reg CX -- Sector count
; Reg DX -- Cylinder number
; Reg ES:SI -- Buffer start address
;
; Exit Parameters:
;
; Z-flag is clear if error (Zero indicates no error)
; Reg AX -- Error status
; Reg AL = 0 -- no error
; = 1 -- error
; = 3 -- Drive defective
; = 5 -- Disk defective
; = 0DH -- Write verify error
; = 0FH -- Soft error
; Reg AH Bit 0 -- DAM not found
; Bit 1 -- Track 0 error
; Bit 2 -- Aborted command
; Bit 4 -- ID not found
; Bit 6 -- CRC error in data field
; Bit 7 -- Bad block detect
;
; Registers Changed: All
;
;--
;
HWRITE_ONE_SECTOR: ;RGT
CALL LDTSKF ;Load task file
JNZ HWRITE_ONE_SECT_RET ;Error if past limit ;RGT
MOV AL,RDWRITE+ATRETRY ;Load the write command
-----------------------------------------------
----------HDISKDRV.OLD
JNZ HWRITE2 ;If so, abort
;
----------HDISKDRV.ASM
JNZ HWRITE_ONE_SECT_RET ;If so, abort ;RGT
;
-----------------------------------------------
----------HDISKDRV.OLD
HWRITE21:
LODSW ;Get word of data from buffer
----------HDISKDRV.ASM
HWRITE_ONE_SECT21: ;RGT
LODSW ;Get word of data from buffer
-----------------------------------------------
----------HDISKDRV.OLD
LOOP HWRITE21 ;Loop for all bytes of sector
;
----------HDISKDRV.ASM
LOOP HWRITE_ONE_SECT21 ;Loop for all bytes of sector
;
-----------------------------------------------
----------HDISKDRV.OLD
JNZ HWRITE2 ;If error, then abort
;
----------HDISKDRV.ASM
JNZ HWRITE_ONE_SECT_RET ;If error, then abort
;
-----------------------------------------------
----------HDISKDRV.OLD
JZ HWRITE11 ;If none, then advance to next sector
;
----------HDISKDRV.ASM
JZ HWRITE_ONE_SECT11 ;If none, then advance to next sector
;
-----------------------------------------------
----------HDISKDRV.OLD
JNZ HWRITE2 ;If error, then abort
PUSH CX ;Save sector count
MOV CX,SECSIZE ;Get sector size
HWRITE15:
IN AL,DATA ;Read byte from disk
SCASB ;Compare to original data
JNZ HWRITE16 ;If not equal, then exit with error
LOOP HWRITE15 ;Otherwise, continue for all bytes
;
----------HDISKDRV.ASM
JNZ HWRITE_ONE_SECT_RET ;If error, then abort
PUSH CX ;Save sector count
MOV CX,SECSIZE ;Get sector size
HWRITE_ONE_SECT15: ;RGT
IN AL,DATA ;Read byte from disk
SCASB ;Compare to original data
JNZ HWRITE_ONE_SECT16 ;If not equal, then exit with error;RGT
LOOP HWRITE_ONE_SECT15 ;Otherwise, continue for all bytes;RGT
;
-----------------------------------------------
----------HDISKDRV.OLD
HWRITE16:
POP CX ;Restore sector count
----------HDISKDRV.ASM
HWRITE_ONE_SECT16: ;RGT
POP CX ;Restore sector count
-----------------------------------------------
----------HDISKDRV.OLD
; Write complete -- advance to next sector
;
HWRITE11:
CALL ADVTNS ;Advance to next sector
LOOP HWRITE5 ;And perform multi-sector write
;
; Done with write -- clear error status
;
XOR AX,AX ;Clear error status
;
; Done with the write -- turn the LED off on the disk drive
;
HWRITE2:
; CALL LED_OFF ;Deselect device
; RET ;Return to caller
----------HDISKDRV.ASM
; Write complete -- return to caller ;RGT
;
HWRITE_ONE_SECT11: ;RGT
XOR AX,AX ;Clear error status
HWRITE_ONE_SECT_RET:
RET ;Return to caller
-----------------------------------------------
----------HDISKDRV.OLD
; Registers Changed: All
;
----------HDISKDRV.ASM
; Registers Changed: AX
;
-----------------------------------------------
----------HDISKDRV.OLD
;++
;
; Function: ADVTNS
;
; Abstract:
;
; Advance to next logical sector on disk.
;
; NOTE:
;
; 1) This routine is operating system dependent
;
; 2) (XLT_F) must be set before entering this routine.
; This flag will fix the logical/not logical and
; physical/not physical problem.
; Actually, only routines HREAD, HWRITE, and HWRITEV
; call this routine.
;
; Entry Parameters:
;
; Reg BH -- Surface/drive number
; Bits 0-3 - surface number
; Bits 4-7 - drive number
; Reg BL -- Sector number
; Reg DX -- Cylinder number
; RDXLT -- Address of sector translation table
; (XLT_F) -- Translation flag (0 if no translation
; should be done)
;
; Exit Parameters:
;
; None
;
; Registers Changed: AX
;
;
;--
;
ADVTNS:
TEST BYTE PTR XLT_F,0FFH ;Check if using translation table
JNZ ADVTNS3 ;If so, then translate
INC BL ;Otherwise, just set to next sector no.
CMP BL,SECPTRK ;See if past end of track
JLE ADVT1 ;If not, then just return
MOV BL,1 ;Otherwise, reset sector number to first
JMP SHORT ADVTNT ;And update surface/cylinder number
;
; Sectors are being translated -- translate them
;
ADVTNS3:
PUSH CX ;Save registers used
PUSH DI
PUSH ES
;
; Set reg ES to this code segment
;
PUSH CS ;Set ES to CS
POP ES
;
; Get address of translation table
;
MOV DI,OFFSET RDXLT ;Get address of translation table
MOV CX,SECPTRK ;Set count to no. of sectors per track
MOV AL,BL ;Get sector number
REPNZ SCASB ;Search for sector in table
MOV BL,BYTE PTR [DI] ;Get next sector number
POP ES ;Restore registers saved
POP DI
JCXZ ADVT2 ;If not in table, set to first
POP CX ;Restore register CX
RET ;And return to caller
;
; Sector was not in translation table -- set to first sector number
;
ADVT2:
POP CX ;Restore reg CX
MOV BL,RDXLT ;Set to first sector
; JMP ADVTNT ;Advance to next track
----------HDISKDRV.ASM
;
-----------------------------------------------
----------HDISKDRV.OLD
; Function: ADVTNT
----------HDISKDRV.ASM
; Function: ADVTNS
;
; Abstract:
;
; Advance to next logical sector on disk.
;
; NOTE:
;
; 1) This routine is operating system dependent
;
; 2) (XLT_F) must be set before entering this routine.
; This flag will fix the logical/not logical and
; physical/not physical problem.
; Actually, only routines HREAD, HWRITE, and HWRITEV
; call this routine.
;
; Entry Parameters:
;
; Reg BH -- Surface/drive number
; Bits 0-3 - surface number
; Bits 4-7 - drive number
; Reg BL -- Sector number
; Reg DX -- Cylinder number
; RDXLT -- Address of sector translation table
; (XLT_F) -- Translation flag (0 if no translation
; should be done)
;
; Exit Parameters:
;
; None
;
; Registers Changed: AX
;
;
;--
;
ADVTNS:
TEST BYTE PTR XLT_F,0FFH ;Check if using translation table
JNZ ADVTNS3 ;If so, then translate
INC BL ;Otherwise, just set to next sector no.
CMP BL,SECPTRK ;See if past end of track
JLE ADVT1 ;If not, then just return
MOV BL,1 ;Otherwise, reset sector number to first
JMP SHORT ADVTNT ;And update surface/cylinder number
;
; Sectors are being translated -- translate them
;
ADVTNS3:
PUSH CX ;Save registers used
PUSH DI
PUSH ES
;
; Set reg ES to this code segment
;
PUSH CS ;Set ES to CS
POP ES
;
; Get address of translation table
;
MOV DI,OFFSET RDXLT ;Get address of translation table
MOV CX,SECPTRK ;Set count to no. of sectors per track
MOV AL,BL ;Get sector number
REPNZ SCASB ;Search for sector in table
MOV BL,BYTE PTR [DI] ;Get next sector number
POP ES ;Restore registers saved
POP DI
JCXZ ADVT2 ;If not in table, set to first
POP CX ;Restore register CX
RET ;And return to caller
;
; Sector was not in translation table -- set to first sector number
;
ADVT2:
POP CX ;Restore reg CX
MOV BL,RDXLT ;Set to first sector
; JMP ADVTNT ;Advance to next track
;++
;
; Function: ADVTNT
-----------------------------------------------
----------HDISKDRV.OLD
; Function: CLTPN
----------HDISKDRV.ASM
; Function: SETPAR
;
; Abstract:
;
; Set up disk interface parameters.
;
; Entry Parameters:
;
; Reg AL -- Unit code
; Reg DX -- Logical sector number
;
; Exit Parameters:
;
; Reg BL -- Sector number
; Reg BH -- Surface number
; Reg DX -- Cylinder number
; (XLT_F) -- Logical/Physical flag
;
; Registers Changed: All, except reg DI
;
;
;--
;
SETPAR:
MOV BYTE PTR XLT_F,1 ;Assume using translation table
MOV SI,DX ;Save logical sector number
CALL GETFTN ;Get partition first track
MOV AX,SI ;Get logical sector number
AND SI,0FH ;Form logical sector number
MOV BL,BYTE PTR RDXLT[SI] ;Get sector from translation table
SHR AX,1 ;Shift to track offset
SHR AX,1
SHR AX,1
SHR AX,1
CMP AX,2 ;Check if tracks 0 or 1
JGE SETPAR1 ;If so, use translation table
MOV BX,SI ;Otherwise, do not skew first 2 tracks
INC BL ;Sector number is based at 1
MOV BYTE PTR XLT_F,0 ;Do not use translation table
SETPAR1:
ADD DX,AX ;Add partition offset
MOV TEMP_TRK,DX ;Save track no. in case of error
MOV TEMP_SEC,BL ;Save sector no. in case of error
; ;RGT
; Fall through to CLTPN to convert to physical ;RGT
; ;RGT
; JMP CLTPN ;Convert logical track no. to
;physical surface/cylinder number
;
;++
;
; Function: CLTPN
-----------------------------------------------
----------HDISKDRV.OLD
PUSH BX ;Save register used
MOV AX,DX ;Get cylinder number in DX:AX
MUL WORD PTR NUMSURF ;Divide by number of surfaces
XOR DX,DX ;Clear upper word
MOV DL,BH ;Get surface number
ADD DX,AX ;Add in logical track number
POP BX ;Restore register used
RET ;Return to caller
----------HDISKDRV.ASM
MOV AX,DX ;Get cylinder number in reg AX
MUL WORD PTR NUMSURF ;Multiply by number of surfaces
XOR DX,DX ;Clear upper byte
MOV DL,BH ;Get surface number
ADD DX,AX ;Add in logical track number
RET ;Return to caller
-----------------------------------------------