; .TITLE LOG.MAC ;====================================================================== ; I.Calhaem & D.Woodward 13-Jul-80 ; ; A foreground job to intercept input from the Console and output it ; to a printer. When the foreground job is terminated (^F^C^C) the ; vectors are restored. ; Word wrap included. ; ; (3 character escape secquences are removed) ;====================================================================== .MCALL .SPND,.PRINT LP$CSR =176504 ; Printer status register ; PDT (177514) ; Serial printer (176504) ; ************************************* START: MOV R1,-(SP) ; save R1 on stack MOV @#60,JMPMON ; save console interrupt vector MOV @#62,JMPMON+2 ; save console interrupt status ; MOV PC,R1 ; move new interrupt vector to MOV #,WCK ; location 60 ADD R1,WCK MOV WCK,@#60 ; ADD #,WCK ; move psuedo console registers MOV @#54,R1 ; into monitor at offset #304 ADD #304,R1 MOV WCK,(R1)+ ADD #2,WCK MOV WCK,(R1) MOV (SP)+,R1 ; 1$: TST @#LP$CSR ; check if printer ready BPL 2$ ; branch if ready .PRINT #PRTMSG ; tell operator if not ; 2$: .PRINT #MSG1 ; output logging message .SPND CLNUP: MOV JMPMON,@#60 ; restore vector MOV JMPMON+2,@#62 ; and status MOV R1,-(SP) MOV @#54,R1 ADD #304,R1 MOV #177560,(R1)+ ; restore true console vector MOV #177562,(R1) ; and status MOV (SP)+,R1 .PRINT #MSG2 ; tell operator JMP CONT ; exit ; Interrupt Routine ; INT: MOV @#177560,STAT ; save console vector MOV @#177562,BUFF ; and status MOVB BUFF,CHAR ; and character BIC #177600,CHAR ; TST (PC)+ ; test if escape sequence ESC: .WORD 0 BEQ 1$ ; branch if not DEC ESC BR CONT ; 1$: CMPB #33,CHAR ; is it an escape character ? BNE 12$ ; branch if not MOV #2,ESC ; set counter BR CONT ; 12$: CMPB #40,CHAR ; is it a space ? BNE 2$ ; branch if not CMPB #15,CHCNT ; within 15 characters of full line ? BLO 2$ ; branch if not MOV #15,CHAR ; change to return character BR 5$ ; 2$: CMPB #6,CHAR ; is it a ^F BNE 3$ ; branch if not MOV #2,CTRLC ; set ^C counter BR 5$ ; output ^F ; 3$: CMPB #3,CHAR ; is it a ^C BNE 4$ ; branch if not TST CTRLC ; are we in ^F sequence ? BLE 4$ ; branch if not DEC CTRLC BEQ CLNUP ; received ^F^C^C so finish BR 5$ ; 4$: CLR CTRLC ; reset ^C counter CMPB #177,CHAR ; is it a `delete' BNE 5$ ; branch if not INC CHCNT ; adjust character count INC CHCNT ; adjust character count MOV #10,CHAR ; change it to a backspace 5$: TSTB @#LP$CSR ; is printer ready ? BPL 5$ ; no MOVB CHAR,@#LP$CSR+2 ; output character ; DEC CHCNT ; decrement character count BNE 11$ ; branch if not zero MOVB #15,CHAR ; output CR BR 5$ ; 11$: CMPB #15,CHAR ; was it a CR ? BNE 7$ ; no ; MOV #75.,CHCNT ; reset character count DEC LNCNT ; decrement line counter BEQ 10$ ; new page 6$: MOVB #12,CHAR ; output LF BR 5$ ; 7$: TST SPCNT ; finished skipping lines ? BEQ CONT ; yes DEC SPCNT ; no, so output another BR 6$ ; 10$: MOV #58.,LNCNT ; reset counter to 58. MOV #8.,SPCNT ; set counter to 8. BR 6$ CONT: JMP @JMPMON ; back to monitor RTT WCK: .WORD 0 STAT: .WORD 0 BUFF: .WORD 0 CHAR: .WORD 0 CTRLC: .WORD 0 LNCNT: .WORD 58. ; initial number of printed lines SPCNT: .WORD 0 CHCNT: .WORD 75. ; initial number of characters/line JMPMON: .WORD 0,0 .NLIST BEX MSG1: .ASCIZ / Logging input from screen to printer/ MSG2: .ASCIZ / Logging terminated - back to normal operation/ PRTMSG: .ASCIZ / WARNING - printer not ready/ .END START