.TITLE PUTSTR .IDENT /V3.01/ .NLIST TOC,SYM .ENABL LC ;+ ; Sira Ltd., South Hill, Chislehurst, Kent, BR7 5EH, England ; ; Author: C J Doran, Date 26-Jan-83 ; ; Output a string from FORTRAN using direct call to FCS routine .PUTSQ . ; Reduces the time and code overhead of doing FORTRAN formatted I/O just ; to output a series of bytes. ; ; SUBROUTINE PUTSTR(LUN,STRING,CCHAR{,ERR}) ; ; LUN is unit number of channel to which output must be sent. ; STRING is an ASCIZ string to be output, in any of the usual forms -- ; Hollerith or quoted literal, or BYTE array ending in 0. ; CCHAR is a carriage control character with normal FORTRAN significance, ; used only if the file has FORTRAN carriage control, when it is ; prefixed to STRING before output. If CCHAR is 0, the control ; character is assumed to be in the first byte of STRING. ; ERR If given, is a BYTE variable returned as:- ; 0 If no errors occur, ; -1 If end-of-file is reached, ; -2 If any other hardware error is detected. ; -3 If the length of STRING exceeds RECORDSIZE. ; ; This subroutine is compatible with that in the RT-11 Syslib library. ; Note that ERR is optional, as in RT-11 V2, but seems to be mandatory in V3. ; ; Assemble as: ; >MAC PUTSTR=PUTSTR ;- D.RSIZ=10. ; Max record size D.FDB=12. ; Start of FCS FDB in LUB ; Enable the next two lines for F4P ;FL.FMP=1000 ; Formatted records ;FL.WRT=600 ; Write with implied OPEN ; Use the next two for F77 FL.FMP=200 ; Formatted records FL.WRT=140 ; Write with implied OPEN .PSECT $CODE1,I,RW,LCL,CON PUTSTR::MOV #FL.WRT!FL.FMP,%1 ; Formatted write with default OPEN JSR PC,$PGINI ; Perform common initialisation CLR -(SP) ; Set success flag MOV D.RSIZ-D.FDB(%0),%4 ; Get max no of bytes in record MOV F.NRBD+2(%0),%1 ; Address start of O/P buffer MOVB @(%5)+,@%1 ; Get prefix CCHAR BEQ 10$ ; Branch if there isn't one BITB #FD.FTN,F.RATT(%0) ; FORTRAN carriage-control? BEQ 10$ ; No, ignore CCHAR INC %1 ; Char present & reqd. Advance pointer 10$: TSTB @%2 ; End of STRING? BEQ 20$ ; Yes, done MOVB (%2)+,(%1)+ ; Yes, copy next byte to output SOB %4,10$ ; and repeat unless buffer full MOV #-3,@SP ; Full, set return flag=-3 20$: SUB F.NRBD+2(%0),%1 ; Compute length MOV %1,F.NRBD(%0) ; to complete FDB JSR PC,.PUTSQ ; Output record BCC 30$ ; Exit if write OK TRAP 128.+38. ; Record WRITE error ; Return error code -1 if e-o-f, -2 if anything else. MOV #-1,@SP ; Assume e-o-f CMPB F.ERR(%0),#IE.EOF ; End-of-file? BEQ 30$ ; Yes, return -1 DEC @SP ; No, return -2 30$: JMP $PGXIT ; Exit via common routine .END