home *** CD-ROM | disk | FTP | other *** search
- DOSSEG
- .MODEL medium
-
- PUBLIC _SecWrt
-
- ;========================================================
- ; Write diskette sectors. The usage is:
- ;
- ; push <drive> ;drive number
- ; push <head> ;head (side) number
- ; push <track> ;track number
- ; push <sector> ;sector number
- ; push <count> ;number of sectors to write
- ; push <segment> ;segment of buffer
- ; push <offset> ;offset of buffer
- ; call _SecWrt ;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.
-
- SecWrtStk 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 ?
- SecWrtStk ENDS
-
- ASSUME ds:NOTHING, es:NOTHING, ss:NOTHING
-
- .CODE
-
- _SecWrt PROC
- push bx
- push cx
- push dx
- push di
- push si
- push bp
- push es
- mov bp, sp
-
- ;--- write 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, 3 ;write function
- int 13h ;execute
- pop es
- jnc Scwr1
-
- ;--- error, reset disk and try again
-
- push es
- mov ah, 0 ;reset function
- int 13h ;execute
- pop es
-
- push es
- mov ah, 4 ;write function
- int 13h ;execute
- pop es
- jnc Scwr1 ;jump if okay
-
- ;--- error writing sectors
-
- mov al, ah
- sub ah, ah
- jmp Scwr2
-
- ;--- sector is written
-
- Scwr1: sub ax, ax
-
- Scwr2: pop es
- pop bp
- pop si
- pop di
- pop dx
- pop cx
- pop bx
- ret 14
- _SecWrt ENDP
-
- END
-