home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Software Du Jour
/
SoftwareDuJour.iso
/
BUSINESS
/
DBASE
/
DBAPG.ARC
/
DOS-COPY.A86
< prev
next >
Wrap
Text File
|
1984-06-26
|
2KB
|
94 lines
; Subroutine.: DOS-COPY.A86
; Author.....: Kelly Mc Tiernan
; Date.......: 12/12/83
; Notice.....: Copyright 1983, All Rights Reserved.
; Notes......: MS-DOS 2.0X COPY function.
;
;
ORG DE00H ; 56832 DECIMAL=TOP OF DBASE
;
START: PUSH AX ; SAVE MACHINE STATE.
PUSH BX ; PROBLEMS WILL ARISE IF
PUSH CX ; THESE ARE NOT SAVED.
PUSH DX
PUSHF ; SAVE FLAGS
MOV [SAVSTK],SP ; SAVE STACK POINTER
;
MOV AH,3CH ; CREATE DESTINATION FILE
MOV DX,[DEST] ; ASCIIZ (zero-terminated)
; PATHNAME
MOV CX,0020H ; FILE ATTRIBUTE
INT 21H ; DOS FUNCTION CALL
JC ERROR ; ERROR HANDLING ROUTINE
MOV [SAVHNDLE],AX ; SAVE NEW FILE HANDLE
;
MOV AH,3DH ; OPEN FILE (SOURCE FILE)
MOV AL,00 ; READ ONLY
MOV DX,SRCE ; ASCIIZ PATHNAME
INT 21H ; FUNCTION CALL
JC ERROR
MOV BX,AX ; GET NEW HANDLE WHERE WE CAN
; USE IT
;
RDWRTE: MOV CX,0010H ; BYTES TO R/W (BUFFER)
MOV AH,3FH ; READ SOURCE FILE
INT 21H ; READ IT
JC ERROR ; CARRY=FILE ERROR, ALL TREATED
; THE SAME WAY
OR AX,AX ; CHECK FOR ZERO=EOF
JZ DONE ; IF SO GO CLOSE FILES
MOV CX,0010H ; BYTES TO WRITE ( =READ )
; THIS IS A 16-BYTE BUFFER.
; IT CAN BE INCREASED TO ?KELLY?
;
MOV AH,40H ; WRITE FUNCTION
MOV DX,SRCE ; OLD ASCIIZ SOURCE PATH=BUFFER
XCHG [SAVHNDLE],BX ; GET DESTINATION FILE HANDLE
INT 21H ; WRITE TO FILE
JC ERROR
;
XCHG [SAVHNDLE],BX ; GET BACK SOURCE HANDLE
JMP RDWRTE ; DO NEXT READ/WRITE
;
DONE: MOV AH,3EH ; CLOSE FILES
INT 21H ; FIRST FILE
JC ERROR
;
XCHG [SAVHNDLE],BX ; NEXT FILE HANDLE
MOV AH,3EH
INT 21H
JC ERROR
;
MOV SP,[SAVSTK] ; RESTORE MACHINE STATE
POPF ; RESTORE FLAGS
POP DX
POP CX
POP BX
POP AX
RET ; RETURN TO DBASE
;
ERROR: MOV AH,3EH ; FIRST TRY TO CLOSE FILES
INT 21H
XCHG [SAVHNDLE],BX
MOV AH,3EH
INT 21H
;
MOV SP,[SAVSTK] ; RESTORE MACHINE STATE
POPF ; RESTORE FLAGS
POP DX
POP CX
POP BX
POP AX
;
INC BX ; POINT TO FIRST CHAR. OF "ERROR"
MOV BYTE PTR[BX],'E'; 'E' IS ERROR CODE TO DBASE PRG.
DEC BX ; RESTORE POINTER
RET ; RETURN TO DBASE
;
SAVSTK RS 02
SAVHNDLE RS 01
SRCE RS 64 ; SOURCE FILE POKED FROM DBASE
DEST RS 64 ; DESTINATION FILE POKED
; ; FROM DBASE
END.