.MCALL .MODULE .MODULE OPENA,VERSION=03,COMMENT= ; 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. .ENABL GBL,LC .SBTTL Macro definitions ;+ ;External macro library calls. ;- .MCALL FDBDF$, FERDF$, DEFIN$ FDBDF$ ;Define FDB offsets FERDF$ ;Define file error codes DEFIN$ ;Definitions for IND files .PSECT $OPENA .SBTTL $OPENA - Open file for append ;+ ;$OPENA ;This routine opens a file to append data to. If the specified file exists, ;the contents of the file is copied block by block from the secondary file ;to the primary file and the FDB is updated to reflect the current file ;position. If the file to append does not exist, a file is created and data ;is then stored in that file. ; ;Input: R1 -> Address of primary FDB ; R2 -> Address of four word RAD50 file specification ; R3 -> Address of secondary FDB (TSTFDB) ; ;Output: R1 -> Address of primary FDB ; R2 -> Address of four word RAD50 file specification ; R3 -> Address of secondary FDB (TSTFDB) ; C-bit set if error otherwise the it is cleared upon exit ;- .ENABL LSB $OPENA::CALL $SAVAL ;Save all registers MOV R3,R0 ;Save address of secondary FDB MOV R1,-(SP) ;Save primary FDB address on stack MOV $OOWNR,R1 ;Write the current block to file BEQ 5$ ;No owner as of yet CALL $WRLST ;Have a owner, preserve buff contents BCS 40$ ;Branch if error occured 5$: MOV @SP,R1 ;Claim the output buffer for use MOV R1,$OOWNR ; ... CALL $OPENW ;Open the primary file for write BCS 40$ ;Branch if error MOV R0,R1 ;Point to area for secondary FDB CALL $OPENR ; ... BCC 6$ ;Branch if no error CLR $OOWNR ;Note that the buffer is not owned BR 40$ ;and branch out with error set 6$: CLR R3 ;Initialize block number MOV F$BLKM(R0),R2 ;Get the current file size DEC R2 ;Decreament block count (N-1) 10$: MOV #$OUPBF,R4 ;Set up address of output buffer MOV #$OUPND-$OUPBF,R5 ; and length of buffer CALL $RDBLK ;Read a block from the secondary file BCS 40$ ;Branch if error CMP R2,R3 ;Just read the last block into buffer? BEQ 15$ ;Branch if yes MOV @SP,R1 ;Write the block to the primary file CALL $WRBLK ;No, read it into file & get next blk BCS 40$ ;Branch if error MOV R0,R1 ;Point back to secondary file INC R3 ;Increment block number BR 10$ ;Go get the next block 15$: CALL C$LOSE ;Close the secondary file BCS 40$ ;Branch if error MOV (SP)+,R1 ;Restore primary FDB address MOV #$OUPND,R5 ;Point to end of buffer MOV R4,R2 ;Point to start of buffer 25$: MOVB (R2)+,@R4 ;Suppress nulls in buffer BEQ 30$ ;Null encountered. Don't update R4 INC R4 ;Update actual text pointer 30$: CMP R2,R5 ;End of buffer? BLO 25$ ;No 35$: MOV R4,F$BUFP(R1) ;Save buffer pointer in FDB TST (PC)+ ;Make sure C-bit clear for success ;+ ;The following instructions are executed if the C-bit is set in any routines ;called by this routine. The stack must first be cleaned up, the C-bit is ;reset, then we return to the caller. ;- 40$: COM (SP)+ ;Make sure C-bit is set for error RETURN .DSABL LSB .END