.MCALL .MODULE .MODULE BUPSRM,VERSION=06,IDENT=NO ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. .SBTTL BUPSRM - Disk-to-disk Copy loop ; 05-Jan-88 RHH V5.5 work ; Macro References .MCALL .READW, .WRITE, .WAIT, .PRINT .PSECT IMADAT,D ; Local Data AVABLK: .BLKW 1 ; Count of of blocks left to be written BUFTMP: .WORD 0 ; Holds buffer address between READ and WRITE BUFNUM: .BYTE 0 ; Current buffer indicator .EVEN .SBTTL COPY - Streaming copy ;++ ; [GLOBAL] ROUTINE: COPY ; ; FUNCTION: ; Copy a input device/file to output device. Use double-buffering. ; ; RETURNS: ; RETCOD = 0: Copying finished (for 1 output volume) ; 1: Hardware error on write ; 2: Backup all done ;-- .PSECT IMACOP,I .ENABL LSB COPY:: JSR R5,$SAVR1 ; Save registers CLR RETCOD ; Initialize return code to normal, MOV BLKCOP,AVABLK ; output device size CLRB BUFNUM ; start with 1st buffer ; Start reading... 10$: MOV AVABLK,R3 ; Get number of blocks left to copy BEQ 60$ ; no more? CMP R3,BUFBLK ; Blocks_to_copy count = BLOS 20$ ; MAX (buffer size, MOV BUFBLK,R3 ; blocks left) 20$: SWAB R3 ; Convert block count to WORD count. MOV BUFADD,R1 ; 1st buffer address TSTB BUFNUM ; is it the ODD time through? BEQ 30$ ; Branch if not. ADD BUFBYT,R1 ; Use 2nd buffer 30$: MOV R1,BUFTMP ; Save its address ; Read blocks from input. ; R1 = buffer address, MOV INBLK,R2 ; R2 = starting block number CALL GINBLK ; R3 = word count ; Update block information. 40$: MOV R3,R2 ; Save the word count for .WRITE SWAB R3 ; Convert word count to block count. ADD R3,INBLK ; Bump logical input block number, SUB R3,AVABLK ; "blocks left" count. ; Write it to the backup device. CALL WAITOU ; Wait for previous to complete, .WRITE #EMTARE,OUTCHA,BUFTMP,R2,OUTBLK ; write the stuff... BCC 50$ MOV #1,RETCOD ; Write stopped: hard output error BR 70$ ; Account for write. 50$: ADD R3,OUTBLK ; Update output block number COMB BUFNUM ; Indicate buffer switch, TST AVABLK ; More to go? BNE 10$ ; Branch up if so. ; No more blocks to transfer. Get ready to return. 60$: CMP INBLK,FILSIZ ; No. If input device BNE 70$ ; is empty MOV #2,RETCOD ; then, set return code = BUP done. ; Finished, for one reason or another. Time to return to caller. 70$: ; fall through ; Wait for output to finish. Look for errors. WAITOU: .WAIT OUTCHA ; Wait for previous writes to finish BCC 80$ .ERR #ERRARE,#WR2,LEVEL=ERROR,RETURN=YES,FILE=#OUTFIL 80$: RETURN .DSABL LSB .END