PROCEDURE ,010000 ;+ ; Copyright (c) 1976 ; Digital Equipment Corporation, Maynard, Mass. ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the inclu- ; sion 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 DEC. ; ; The information in this software is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation. ; ; DEC assumes no responsibility for the use or reliability of its ; software on equipment which is not supplied by DEC. ; ; Abstract: This module contains the FCS I/O routines ; for Runoff. ; ; Written: 1-Jun-72, -0.0.0-, L. Wade ; ; Modified: 10-Jan-80, -1.0.0-, Henry R. Tumblin ; Made Duke supported version ; ; Verified: 10-Jan-80, -1.0.0-, Henry R. Tumblin ; Modified: 25-October-80, -1.0.1-, Jon Berntsen ; Modified: 18-March-81, -1.0.2-, M.T.E. Woodbury ;- .SBTTL MCALLS AND RUNOFF DEFINITIONS .MCALL GET$,GET$S,PUT$S,CALLR,DIR$ ;+ ; RUNOFF global definitions ;- .GLOBL CR ; carriage return .GLOBL ENDFIL ; endfile processing .GLOBL EOF ; end of file character .GLOBL HFIN ; Input buffer descriptor .GLOBL HFOUT ; Output file buffer descriptor .GLOBL HGHCHP ; high limit of /ch:l:h .GLOBL HGHPAG ; high limit of /pa:l:h .GLOBL LF ; line feed .GLOBL LOWCHP ; low limit of /ch:l:h .GLOBL LOWPAG ; low limit of /pa:l:h .GLOBL LSTBLK ; output fdb address .GLOBL PAGENO ; current page number .GLOBL RUNOFF ; restart point after error .GLOBL S1 ; current pointer to string to output .GLOBL TTLDMY ; source input fdb .GLOBL $QIO ; Q-I/O DPB for terminal I/O ;+ ; globals defined in this module ;- .GLOBL CRLF ; output a cr/lf to listing file .GLOBL FIN ; read record from input file .GLOBL FMSG ; output asciz string to listing file .GLOBL FOUT ; insert character into listing ; file output buffer. .GLOBL OUTPUT ; output contents of line buffer to ; listing file. .GLOBL $OUT ; output string to TI0: .SBTTL FILE INPUT/OUTPUT ROUTINES CODE RNFIO ; declare p-sect ;+ ; file input/output routines ;- FMSGL: INC S1 ; bump up pointer to next char. FMSG:: MOVB @S1,R1 ; move character -> r1 to be output BNE 10$ ; eq- then end of string, return to caller RETURN ; ... 10$: CALL FOUT ; output character BR FMSGL ; loop ; crlf -- output cr/lf combination to output file CRLF:: TSTB $SWPFL ; swap files ? BEQ 10$ ; EQ - no JMP TCRLF ; Else do it to the TOC file 10$: MOV #CR,R1 ; Get carriage return CALL FOUT ; Output it to the file MOV #LF,R1 ; Get line feed CALL FOUT ; Output it RETURN ; Return to caller ; fout -- output character to output file FOUT:: TSTB $SWPFL ; Swap files ? BEQ 5$ ; EQ - no JMP TFOUT ; Else do it to the TOC file 5$: MOVB R1,@HFOUT+BF.PTR ; store character in buffer INC HFOUT+BF.PTR ; increment buffer pointer INC HFOUT+BF.LEN ; Bump up length of string CMP HFOUT+BF.PTR,HFOUT+BF.END ; At end of buffer ? BLO 10$ ; EQ - Yes, go output line CALL OUTPUT ; Output the line 10$: RETURN ; .sbttl FIN -- INPUT CHARACTER FROM INPUT FILE FIN:: TST HFIN+BF.LEN ; anything in buffer? BGT 40$ ; IF GT YES BITB #FIN.CR,FINFLG ; Has the been done yet ? BNE 2$ ; NE - then check BISB #FIN.CR,FINFLG ; Show that we've done MOV #CR,R1 ; Else insert BR 50$ ; And return 2$: BITB #FIN.LF,FINFLG ; Has the been done yet ? BNE 5$ ; NE - then read from file BISB #FIN.LF,FINFLG ; Show that we've done MOV #LF,R1 ; Else insert BR 50$ ; And return 5$: MOV #HFIN,R4 ; Get pointer to buffer header MOV BF.END(R4),R1 ; Get end SUB BF.ADR(R4),R1 ; Calculate length MOV BF.ADR(R4),BF.PTR(R4) ; Reset pointer CLR BF.LEN(R4) ; Reset length BICB #FIN.CR!FIN.LF,FINFLG ; Clear flags GET$ #TTLDMY,BF.ADR(R4),R1 ; Read a record BCC 20$ ; br if i/o ok CMPEQB #IE.EOF,F.ERR(R0),10$ ; not end of file? MOV R0,-(SP) ; point to fdb DIAG INPERR,FCS ; output diagnostic message CALLR RUNOFF ; restart 10$: CALL NXTFIL ; try to open the next file if possible. BCC 5$ ; success, try to read a record. MOV #EOF,R1 ; Set EOF byte BR 50$ ; And go do clean up 20$: .IF DF D$$BUG CALL IDSPLY ; display the input line .ENDC ; D$$BUG MOV #SELECT,R1 ; Get address of select string ;1.0.2 23$: TSTB (R1) ; Anything left in select string? ;1.0.2 BEQ 26$ ; No, process the line ;1.0.2 TST F.NRBD(R0) ; Anything left in buffer? ;1.0.2 BEQ 5$ ; No, get another line ;1.0.2 CMPB (R1)+,@F.NRBD+2(R0); Select string match? ;1.0.2 BNE 5$ ; No, ignore this line ;1.0.2 INC F.NRBD+2(R0) ; Advance to next character in line ;1.0.2 DEC F.NRBD(R0) ; ;1.0.2 BR 23$ ; Continue select match ;1.0.2 26$: TST F.NRBD(R0) ; Anything there ? BNE 30$ ; NE - then not a null line MOV #40,R1 ; Insert a blank CLR HFIN+BF.LEN ; Reset length BR 50$ ; And go do clean up 30$: MOV F.NRBD(R0),BF.LEN(R4) ; Set length CMP F.NRBD+2(R0),BF.ADR(R4) ; Are the buffers the same ? BEQ 40$ ; EQ - then don't update pointers MOV F.NRBD+2(R0),BF.PTR(R4) ; Set pointer to record 40$: MOVB @HFIN+BF.PTR,R1 ; get next character from input record INC HFIN+BF.PTR ; point to next character DEC HFIN+BF.LEN ; one less from total BIC #^C<177>,R1 ; clear excess bits BEQ FIN ; if eq null CMPEQ R1,#177,FIN ; rubout? 50$: RETURN ; .SBTTL OUTPUT THE CURRENT LINE BUFFER ; this routine outputs the current contents of the line buffer OUTPUT: TSTB $SWPFL ; Have files been swapped ? BEQ 5$ ; EQ - no JMP TOTPUT ; Else go do it to the TOC file 5$: TST HFOUT+BF.LEN ; Anything in buffer ? BEQ 10$ ; if eq empty buffer ; check chapter range TSTB LSTSPC ; Listing file exist? BEQ 10$ ; 0 if not. ; CLR R0 ; clear for byte move ; MOVB CHPTN,R0 ; get chapter number ; CMP R0,LOWCHP ; only print in selected ; BLO 10$ ; chapter range ; CMP R0,HGHCHP ; ... ; BHI 30$ ; quit if out of range ; check page range ; MOV PAGENO,R0 ; Put in page number ; TSTEQ $NUMLW,6$ ; Test number page lower ; INC R0 ; Number page lower so increment PAGENO ;6$: CMP R0,LOWPAG ; only print in the selected page ; BLO 10$ ; range ; CMP R0,HGHPAG ; ; BHI 30$ ; quit if beyond range MOV PAGENO,R0 ; put in page number TSTEQ $NUMLW,3$ ; test number page lower INC R0 ; Number page lower so increment PAGENO ; print only selected page and chapter range 3$: CMPB CHPTN,LOWCHP ; check for low chapter number BLO 10$ BEQ 6$ BR 4$ 6$: CMP R0,LOWPAG ; only print selected page range BLO 10$ 4$: CMPB CHPTN,HGHCHP ; quit if beyond range BHI 30$ BEQ 1$ BR 7$ 1$: CMP R0,HGHPAG ; quit if beyond page range BHI 30$ 7$: PUT$S #LSTBLK,HFOUT+BF.ADR,HFOUT+BF.LEN ; output line BCC 10$ ; if cs error MOV R0,-(SP) ; point to fdb DIAG OUTERR,FCS ; indicate error CALLR RUNOFF ; and leave 10$: MOV HFOUT+BF.ADR,HFOUT+BF.PTR ; Reset pointers CLR HFOUT+BF.LEN ; Reset length 20$: RETURN ; return to caller 30$: TSTEQ HGHPAG,7$ ; If here before, print last line. CLR HGHPAG ; Indicate last line pending. CALLR ENDFIL ; otherwise initiate termination .sbttl $OUT -- Output string to TI: $OUT: MOV 4(SP),$QIO+Q.IOPL+2 ; Set length BEQ 10$ ; EQ - then skip I/O MOV 2(SP),$QIO+Q.IOPL ; Set buffer pointer MOV 6(SP),$QIO+Q.IOPL+4 ; Set carriage control DIR$ #$QIO ; Perform Q-I/O 10$: MOV (SP),6(SP) ; Clear stack ADD #6,SP ; ... RETURN ; Return to caller .SBTTL Table of contents routines ; ; table of contents routines ; TCRLF:: MOV #CR,R1 ; Get carriage return CALL TFOUT ; Output to TOC file MOV #LF,R1 ; Get line feed CALL TFOUT ; Output to TOC file RETURN ; Return to caller TFOUT:: MOVB R1,@THFOUT+BF.PTR ; store character in buffer INC THFOUT+BF.PTR ; increment buffer pointer INC THFOUT+BF.LEN ; Bump up length CMP THFOUT+BF.PTR,THFOUT+BF.END ; any more room in buffer? BEQ TOTPUT ; if eq no RETURN ; ; ; TOTPUT:: TST THFOUT+BF.LEN ; Anything in buffer BEQ TOUT3 ; if eq empty buffer TSTB TOCSPC ; should we output? BEQ TOUT3 ; no PUT$S #TOCBLK,THFOUT+BF.ADR,THFOUT+BF.LEN ; output line BCC TOUT3 ; CC - then no error MOV R0,-(SP) ; point to fdb DIAG OUTERR,FCS ; indicate error CALLR RUNOFF ; and leave TOUT3: MOV THFOUT+BF.ADR,THFOUT+BF.PTR ; Reset pointers CLR THFOUT+BF.LEN ; Reset length RETURN .END