.TITLE CARIAGE CONTROL INSERTION .IDENT /V1.01/ .NLIST TOC,SYM .ENABL LC ; Part of Sira Paper Tape Punch Despooler. ; ; COPYRIGHT(C) 1981,1982 Sira Institute Ltd., ; South Hill, Chislehurst, Kent, BR7 5EH, England. ; ; Author: C.J. Doran ; ; Assemble as: ; >MAC PPPCARIAG=PPPCARIAG ;+ ; Prefix and suffix text buffer with carriage-control bytes appropriate to ; the file format. ; On entry, %3-> start of buffer ; %4= no of bytes ; %2-> character after end of buffer ; Adjust these to describe the new buffer on exit. ;- ; MODIFICATIONS RECORD ; ==================== ; V1.01 13-Jul-82 CJD ; Don't append CR/LF if record ends in delete, as used by CORAL ; to mark long records. .PSECT CODE,I,RO CARIAG::BITB #FD.CR,FDB+F.RATT ; Append CR/LF? BEQ 10$ ; No, go try FORTRAN TST %4 ; Empty buffer? BEQ 5$ ; Yes, not the CORAL special case CMPB -1(%2),#377 ; No, is last char delete? BNE 5$ ; No, go add CR/LF CMPB -(%2),-(%4) ; Yes, skip the delete and dec counter BR 50$ ; Return with their modified values 5$: MOVB #CR,(%2)+ ; Yes, append CR MOVB #LF,(%2)+ ; LF CMPB (%4)+,(%4)+ ; Add 2 to count BR 50$ ; and exit 10$: BITB #FD.FTN,FDB+F.RATT ; FORTRAN carriage control? BEQ 50$ ; No, assume embedded -- do nothing TST %4 ; Yes, check for zero-length record, BNE 15$ ; produced by /. Branch if not CMPB (%2)+,(%4)+ ; Treat zero-length record BR 30$ ; as 1-space record 15$: CMPB @%3,#<' > ; Look for the usual control -- space BEQ 30$ ; to speed things up CMPB (%3)+,#'+ ; No, is control byte '+' = overprint? BEQ 39$ ; Yes, just append CR (at 39$) CMPB -(%3),#'$ ; '$' = prompting? BNE 20$ ; No, branch MOVB #LF,@%3 ; Yes, just start buffer with LF TSTB LINE1 ; But is this the first line? BEQ 50$ ; No, that's right CMPB -(%4),(%3)+ ; Yes, skip the LF, dec counter BR 40$ ; and exit 20$: CMPB @%3,#'1 ; '1' = form feed? BNE 25$ ; No, branch MOVB #FF,@%3 ; Yes, start with it INC %4 ; Note 1 more char BR 39$ ; Go append CR 25$: CMPB @%3,#'0 ; '0' = double-space? BNE 30$ ; No, default to single-space MOVB #LF,@%3 ; Yes, prefix buffer with LF MOVB #CR,-(%3) ; CR DEC %3 ; Space for first LF CMPB (%4)+,(%4)+ ; 2 more chars 30$: MOVB #LF,@%3 ; Default, single-space, start with LF INC %4 ; Add it to count TSTB LINE1 ; But is this the first line? BEQ 39$ ; No, that's right CMPB -(%4),(%3)+ ; Yes, skip the LF, and dec counter 39$: MOVB #CR,(%2)+ ; Terminate with CR 40$: CLRB LINE1 ; Not line 1 now 50$: RTS PC ; Done .END