.TITLE MISWRT - MISH Write Routines .IDENT /1.1/ .ENABL LC ;+ ; ; Free software BY ; Project Software & Development, Inc. ; ; This software is furnished for free and may be used and copied as ; desired. This software or any other copies thereof may be provided or ; otherwise made available to any other person. No title to and ; ownership of the software is hereby transferred or allowed. ; ; The information in this software is subject to change without notice ; and should not be construed as a commitment by PROJECT SOFTWARE ; AND DEVELOPMENT, INC. ; ; PROJECT SOFTWARE assumes no responsibility for the use or reliability ; of this software on any equipment whatsoever. ; ; Project Software & Development, Inc. ; 14 Story St. ; Cambridge, Ma. 02138 ; 617-661-1444 ; ; ; Title: MISWRT.MAC ; Author: Robin Miller ; Date: October 20, 1982 ; ; Description: ; ; This module contains the write routines for the MISH program. ; ; Modification History: ; ; May 10, 1984 by Robin Miller ; Display the output file name along with the totals. Only use the ; write-all function (IO.WAL) when displaying data in reverse video. ; ;- .ENABL AMA .NLIST BEX .MCALL PUT$, QIOW$S ; ASCII Messages: FILNAM: .ASCIZ "File: " TOTBLK: .ASCIZ ", total number of blocks = " TOTREC: .ASCIZ ", total number of records = " .EVEN .SBTTL DOPUT - DO A PUT TO THE OUTPUT FILE ;+ ; ; DOPUT - Write a record to the output file. ; ; Inputs: ; R1 = the buffer address. ; R2 = the buffer byte count. ; ; Outputs: ; Carry bit clear/set = success/failure. ; ; All registers are preserved. ; ;- DOPUT:: CALL $SAVAL ; Save all the registers. PUT$ #OUTFDB,R1,R2 ; Write the output record. BCC 10$ ; If CC, success. CALL FILERR ; Else, output the error message. 10$: RETURN .SBTTL WRTBLA - Write A Blank Record ;+ ; ; WRTBLA - Write a blank record. ; ; This routine simply writes a blank record to the output file. ; ; Inputs: ; None. ; ; Outputs: ; Carry bit clear/set = success/failure. ; ; All registers are preserved. ; ;- WRTBLA::JSR R2,$SAVVR ; Save R0 - R2. MOV #FMTBUF,R1 ; Output buffer address. CLR R2 ; Prepare to write a null record. CALL DOPUT ; And do it. RETURN .SBTTL WRTIN - Write The Input Buffer ;+ ; ; WRTIN - Write the input record to the output file. ; ; Inputs: ; R5 = the argument block address. ; ; Outputs: ; C bit clear/set = success/failure on PUT$. ; ; All registers are preserved. ; ;- WRTIN:: JSR R2,$SAVVR ; Save R0 - R2. MOV O.RADR(R5),R1 ; Address of the input record. MOV @O.RLEN(R5),R2 ; The input record byte count. CALL DOPUT ; Write it to the output buffer. RETURN .SBTTL WRTOUT - Write The Output Buffer ;+ ; ; WRTOUT - Write the current output buffer. ; ; Inputs: ; R1 = the address of the input buffer ; R5 = the argument block address. ; ; Outputs: ; C bit clear/set = success/failure on PUT$. ; ; All registers are preserved. ; ;- WRTOUT::JSR R2,$SAVVR ; Save R0 - R2. INC RECNUM ; Count the number of records. ; MOV #BUFADR,R1 ; Address of the output buffer. MOV @O.BLEN(R5),R2 ; Copy output buffer length for PUT$. CALL DOPUT ; Write it to the output buffer. 10$: RETURN .SBTTL WRTTOT - Write The Totals ;+ ; ; WRTTOT - Write the totals. ; ; Inputs: ; BLKNUM = the number of blocks. ; RECNUM = the number of records. ; ; Outputs: ; C bit clear/set = success/failure from write. ; ; All registers are preserved. ; ;- WRTTOT::JSR R2,$SAVVR ; Save R0 - R2. BIT #B.TOT,STATUS ; Should we output the totals ? BEQ 100$ ; If EQ, no. ; Format the output file name. MOV #FMTBUF,R0 ; The output buffer address. MOV #FILNAM,R1 ; Address of file name message. CALL MOVEC ; Copy it. MOV #OUTFIL,R1 ; Address of output file name. CALL MOVEC ; Copy it. ; Format the total number of blocks. MOV #TOTBLK,R1 ; Address of total blocks message. CALL MOVEC ; Copy it. MOV BLKNUM,R1 ; Copy the number of blocks. CALL CVTDEC ; Convert it to decimal ASCII. ; Format the total number of records. MOV #TOTREC,R1 ; Address of total records message. CALL MOVEC ; Copy it. MOV RECNUM,R1 ; Copy the number of records. CALL CVTDEC ; Convert it to decimal ASCII. ; Write the totals to the terminal. MOV #FMTBUF,R1 ; Address of the output buffer. MOV R0,R2 ; Copy the updated buffer address. SUB R1,R2 ; Calulate the byte count. MOV #TOFDB,R0 ; Address of terminal output FDB. CALL WRTFDB ; Write it to the termminal/file. 100$: RETURN .SBTTL WRTFDB - Write To The Terminal/File ;+ ; ; WRTFDB - Write to the terminal or a disk file. ; ; This routine is used to write a message to either the terminal or a disk ; file. If the LUN is assigned to a terminal, then a QIO write-all function ; is used to write the message (for analyze with reverse video). If the LUN ; is not assigned to a terminal, then a PUT$ is used to write the message. ; ; Inputs: ; R0 = the FDB address. ; R1 = address of the buffer to write. ; R2 = the buffer byte count. ; ; Outputs: ; All registers are preserved. ; ;- WRTFDB::JSR R2,$SAVVR ; Save R0 - R2. BITB #FD.TTY,F.RCTL(R0) ; Are we assigned to a terminal ? BEQ 10$ ; If EQ, no (must be a file). CMP R2,#80. ; Exceeding the terminal width ? BLT 10$ ; If LT, no (write via PUT$). ; Write the buffer to the terminal. MOV #IO.WLB,R0 ; Presume not analyzing data. BIT #B.REV,STATUS ; Display data in reverse video ? BEQ 5$ ; If EQ, no. MOV #IO.WAL,R0 ; Yes, disable terminal wraparound. 5$: QIOW$S R0,#TOLUN,#TOEFN,,#TIOSB,, CALL CHKERR ; Check/report any errors. BR 100$ ; And return ... ; Write the buffer to a disk file. 10$: PUT$ R0,R1,R2 ; Write to the disk file. BCC 100$ ; If CC, success. CALL FILERR ; Else, report the error. 100$: RETURN .SBTTL EIGHTY - Write eighty byte records ;+ ; ; EIGHTY - Write eighty byte records. ; ; This routine is used to write eighty byte output records. ; ; Inputs: ; R1 = address of the buffer to write. ; R5 = the argument block address. ; ; Outputs: ; All registers are preserved. ; ;- EIGHTY:: CALL $SAVAL ; Save all registers MOV @O.BLEN(R5),R2 ; Total length of output buffer 10$: MOV R2,R3 ; Save the remainder BEQ 30$ ; If EQ, nothing more to write SUB #BUFSIZ,R2 ; Write out eighty bytes at a time BLT 20$ ; If LT, Not eighty bytes in buffer MOV #BUFSIZ,@O.BLEN(R5) ; Else setup output buffer length CALL WRTOUT ; and write it ADD #BUFSIZ,R1 ; Point past bytes just written BR 10$ ; and do the rest 20$: MOV R3,@O.BLEN(R5) ; Remainder of the buffer to write CALL WRTOUT ; Go write it 30$: RETURN ; and return .END