.NLIST TOC,SYM .TITLE $PUTLN .SBTTL ULBLIB 009 - Put the next line .IDENT \V01.00\ .PSECT .LIBC. .ENABL LC,GBL ; 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. ;+ ; $PUTLN ; The Put Line routine places a line in the output file. If the last ; character on the line is not a vertical tab or form feed, a carriage ; return/line feed pair is appended to the line. ; ; R0 -> File Descriptor Block (FDB) ; F.NRBD(R0) = the size of the line ; F.NRBD+2(R0) = the start address of the line ; ; CALL $PUTLN ; ; Line is placed in output buffer. ;- .MCALL .WRITW VT = 13 FF = 14 CRLF: .BYTE 15,12 ; $PUTLN:: CALL $SAVAL MOV R0,R1 ;Copy -> FDB MOV F.IOBF(R1),R5 ;Get the start address of the buffer ADD F.BFSZ(R1),R5 ;Point to the end of it MOV F.NRBD+2(R1),R2 ;Get the address of the line MOV F.NRBD(R1),R3 ; and its length 1$: MOV F.BPTR(R1),R4 ;Get the buffer put pointer TST R3 ;What is the length? BEQ 5$ ;Branch if 0 length, it's a blank line 2$: CMP R4,R5 ;At the end? BLO 4$ ;Branch if room for more ADD #F.IO.,R0 ;Point to the I/O area block .WRITW ;Write a block BCC 3$ ;Branch if no error JMP $OERR ;Go handle error 3$: MOV F.IOWC(R1),R0 ;Get the word count BIC #377,R0 ;Need to get the number of blocks SWAB R0 ; (WC / 256.) ADD R0,F.IOBK(R1) ;Bump the block number for the next time MOV F.IOBF(R1),F.BPTR(R1) ;Reset the buffer pointer MOV R1,R0 ;Restore R0 BR 1$ ; 4$: MOVB (R2)+,(R4)+ ;Put a character in the buffer DEC R3 ;Down the count BNE 2$ ;Branch if more to come CMP #CRLF+2,R2 ;Are we putting the on the end? BEQ 6$ ;Branch if so, we're done CMPB #FF,-1(R4) ;Was the last character a form feed? BEQ 6$ ;Branch if so. CMPB #VT,-1(R4) ;How about a vertical tab? BEQ 6$ ;Branch if so. It's a line terminator 5$: MOV #CRLF,R2 ;Point to a MOV #2,R3 ;2 characters BR 2$ ;Go put them in the buffer 6$: MOV R4,F.BPTR(R1) ;Update the buffer pointer CLC ;Indicate success RETURN .END