.TITLE CRUCC .IDENT /X01.00/ ; ; Author: Gilbert J. DeLeeuw ; Date: May 3, 1984 ; Name: Compress and Restore Utility - Carriage Control Conversions ; Function: Subroutine to determine which conversion routine is ; required for carriage control ; ; Algorithm: Test racc bytes in input and output FDB's to determine ; conversion required. ; ; Parameter conventions: ; ; R0 contains the FDB address of the output file ; R1 contains the FDB address of the input file ; R2 returns the address of required conversion routine ; ; Macros .MCALL FHDOF$,PUT$ ; ; Define offsets FHDOF$ ; ; Entry point - Set up routine CRUCC:: ; 10$: BITB #FD.CR,F.RATT(R1) ;Is input FD.CR BEQ 20$ ;No ; ; Input is FD.CR 12$: BITB #FD.CR,F.RATT(R0) ;Is output FD.CR BEQ 14$ ;No MOV #CCCCC,R2 ;Address of conversion routine RTS PC ; 14$: BITB #FD.FTN,F.RATT(R0) ;Is output FD.FTN BEQ 16$ ;No MOV #CCCCF,R2 ;Address of conversion routine RTS PC ; 16$: MOV #CCCCN,R2 ;Address of conversion routine RTS PC ; 20$: BITB #FD.FTN,F.RATT(R1) ;Is input FD.FTN BEQ 32$ ;No ; ; Input is FD.CR 22$: BITB #FD.CR,F.RATT(R0) ;Is output FD.CR BEQ 24$ ;No MOV #CCCFC,R2 ;Address of conversion routine RTS PC ; 24$: BITB #FD.FTN,F.RATT(R0) ;Is output FD.FTN BEQ 26$ ;No MOV #CCCFF,R2 ;Address of conversion routine RTS PC ; 26$: MOV #CCCFN,R2 ;Address of conversion routine RTS PC ; ; Input is NONE 32$: BITB #FD.CR,F.RATT(R0) ;Is output FD.CR BEQ 34$ ;No MOV #CCCNC,R2 ;Address of conversion routine RTS PC ; 34$: BITB #FD.FTN,F.RATT(R0) ;Is output FD.FTN BEQ 36$ ;No MOV #CCCNF,R2 ;Address of conversion routine RTS PC ; 36$: MOV #CCCNN,R2 ;Address of conversion routine RTS PC .PAGE .SBTTL CCCXX - Carriage Control Conversion Routines ; ; Parameter conventions ; ; R0 - Contains address of output FDB ; R2 - Contains length of current record ; R3 - Contains address of current record ; ; Note that the current record must have at least 1 free byte ; before, and 1 free byte following for inserting and appending ; carriage control characters. ; ; Definitions ; LF=12 FF=14 CR=15 ; ; CCCCC - Convert from FD.CR to FD.CR ; CCCCC:: RTS PC ;No conversion required ; ; CCCCF - Convert from FD.CR to FD.FTN ; CCCCF:: TST R2 ;Test length BLE 99$ ;No conversion possible ; 10$: CMPB #FF,(R3) ;Form Feed? BNE 20$ ;No MOVB #'1,(R3) ;Convert to '1' BR 99$ ;Return to caller ; 20$: MOVB #' ,-(R3) ;Insert space at beginning of record INC R2 ;Increment record size 99$: RTS PC ;Return to caller ; ; CCCCN - Convert from FD.CR to NONE ; CCCCN:: MOV R3,R5 ;Copy address ADD R2,R5 ;Point to end of buffer MOVB #CR,(R5) ;Append CR at end of record INC R2 ;Include CR in buffer count ; MOVB #LF,-(R3) ;Insert LF at beginning of record INC R2 ;Include LF in record size 99$: RTS PC ;Return to caller ; ; CCCFC - Convert from FD.FTN to FD.CR ; CCCFC:: TST R2 ;Null record? BLE 99$ ;No conversion necessary ; 10$: CMPB #'1,(R3) ;Form Feed request? BNE 20$ ;No MOVB #FF,(R3) ;Replace with form feed BR 99$ ;Return to caller ; 20$: MOVB (R3)+,R5 ;Get cc byte and remove from rec DEC R2 ;Subtract cc from rec size CMPB #' ,R5 ;Was cc a space BEQ 99$ ;Yes, so we are done ; 30$: CMPB #'0,R5 ;Double space request? BNE 40$ ;No PUT$ ,R3,#0 ;Write null record BR 99$ ;Return to caller ; 40$: CMPB #'$,R5 ;Trailing CR suppressed? BEQ 50$ ;Yes CMPB #'+,R5 ;Leading LF suppressed? BEQ 50$ ;Yes TSTB R5 ;Both suppressed? BNE 99$ ;No 50$: SEC ;Indicate error ; 99$: RTS PC ;Return to caller ; ; CCCFF - Convert from FD.FTN to FD.FTN ; CCCFF:: RTS PC ;No conversion required ; ; CCCFN - Convert from FD.FTN to NONE ; CCCFN:: TST R2 ;Null record? BLE 70$ ;Yes ; 10$: MOVB (R3),R5 ;Copy cc byte BEQ 99$ ;No carriage control ; 20$: CMPB #'+,R5 ;LF Suppression? BNE 30$ ;Yes INC R3 ;Remove carriage control byte DEC R2 ;Remove from buffer count BR 50$ ; 30$: CMPB #'1,R5 ;Form Feed request? BNE 40$ ;No MOVB #FF,(R3) ;Insert Form Feed BR 50$ ; ; 40$: MOVB #LF,(R3) ;Replace cc with Line Feed ; 50$: CMPB #'$,R5 ;Trailing CR suppressed? BEQ 99$ ;Then done ; 60$: CMPB #'0,R5 ;Double space request? BNE 80$ ;No ; 70$: MOVB #LF,-(R3) ;Insert LF INC R2 ;Include in record count ; 80$: MOV R3,R5 ;Copy address ADD R2,R5 ;Point to end of buffer MOVB #CR,(R5) ;Append CR at end of record INC R2 ;Include CR in buffer count ; 99$: RTS PC ;Done ; ; CCCNC - Convert from NONE to FD.CR ; CCCNC:: TST R2 ;Null record? BLE 50$ ;Yes - then error ; 10$: MOV R3,R5 ;Copy pointer ADD R2,R5 ;Point to end of buffer CMPB #CR,-(R5) ;CR at end of record? BNE 20$ ;No DEC R2 ;Subtract from record size ; 20$: CMPB #LF,(R3) ;LF at beginning of record? BNE 40$ ;No INC R3 ;Remove LF DEC R2 ;Subtract from record size ; 30$: CMPB #LF,(R3) ;LF at beginnig of record? BNE 99$ ;Done PUT$ ,R3,#0 ;Write null record INC R3 ;Remove LF from record DEC R2 ;Subtract from record size BR 30$ ;Search for more ; 40$: CMPB #FF,(R3) ;Form feed? BEQ 99$ ;Yes ; 50$: SEC ;Indicate Error 99$: RTS PC ;Return to caller ; ; CCCNF - Convert from NONE to FD.FTN ; CCCNF:: TST R2 ;Null record? BLE 60$ ;Yes - then error ; 10$: MOV R3,R5 ;Copy pointer ADD R2,R5 ;Point to end of buffer CMPB #CR,-(R5) ;CR at end of record? BNE 20$ ;No DEC R2 ;Subtract from record size ; 20$: CMPB #LF,(R3)+ ;LF at beginning of record? BNE 50$ ;No MOV #' ,R5 ;Carriage control character CMPB #LF,(R3)+ ;Another LF? BNE 40$ ;No MOV #'0,R5 ;Carriage control character DEC R2 ;Subtract from record size ; 30$: CMPB #LF,(R3)+ ;LF at benginnig of record? BNE 40$ ;Done PUT$ ,R3,#0 ;Write null record DEC R2 ;Subtract from record size BR 30$ ;Search for more ; 40$: DEC R3 ;Move back to beginning of record MOVB R5,-(R3) ;Insert carriage control BR 99$ ;Done ; 50$: CMPB #FF,-(R3) ;Form feed? BEQ 99$ ;Yes ; 60$: SEC ;Indicate Error 99$: RTS PC ;Return to caller ; ; CCCNN ; CCCNN:: RTS PC ;No conversion necessary .END