home *** CD-ROM | disk | FTP | other *** search
- DOSSEG
- .MODEL medium
-
- PUBLIC _SecRed
-
- ;========================================================
- ; Read diskette sectors. The usage is:
- ;
- ; push <drive> ;drive number
- ; push <head> ;head (side) number
- ; push <track> ;track number
- ; push <sector> ;sectors number
- ; push <count> ;number of sectors to write
- ; push <segment> ;segment of buffer
- ; push <offset> ;offset of buffer
- ; call _SecRed ;write
- ;
- ; The values are not checked. AX = 0 if no errors,
- ; otherwise the disk status is returned in AL and
- ; AH = 0.
- ;
- ; The stack is cleared on exit and all registers are
- ; preserved except AX.
-
- SecRedStk STRUC
- registers dw 7 DUP (?)
- retaddr dw 2 DUP (?)
- buf_off dw ?
- buf_seg dw ?
- count dw ?
- sector dw ?
- track dw ?
- head dw ?
- drive dw ?
- SecRedStk ENDS
-
- ASSUME ds:NOTHING, es:NOTHING, ss:NOTHING
-
- .CODE
-
- _SecRed PROC
- push bx
- push cx
- push dx
- push di
- push si
- push bp
- push es
- mov bp, sp
-
- ;--- read the sectors
-
- mov al, byte ptr [bp].count ;sector count
- mov ch, byte ptr [bp].track ;track number
- mov cl, byte ptr [bp].sector ;sector number
- mov dh, byte ptr [bp].head ;head number
- mov dl, byte ptr [bp].drive ;drive number
- mov bx, [bp].buf_off ;buffer offset
- mov es, [bp].buf_seg ;buffer segment
-
- push es
- mov ah, 2 ;read function
- int 13h ;execute
- pop es
- jnc Scrd1
-
- ;--- error, reset disk and try again
-
- push es
- mov ah, 0 ;reset function
- int 13h ;execute
- pop es
-
- push es
- mov ah, 2 ;read function
- int 13h ;execute
- pop es
- jnc Scrd1 ;jump if okay
-
- ;--- error reading sectors
-
- mov al, ah
- sub ah, ah
- jmp Scrd2
-
- ;--- sector is read
-
- Scrd1: sub ax, ax
-
- Scrd2: pop es
- pop bp
- pop si
- pop di
- pop dx
- pop cx
- pop bx
- ret 14
- _SecRed ENDP
-
- END
-