.TITLE TIO Terminal input/output processes .NLIST BEX .ENABL LC ; ; Pdp11/dcn - terminal input/output processes ; ; In image mode bytes are copied to and from the device uninterpreted and ; unmodified. Two ascii modes are povided: dte, which emulates a terminal ; for a remote processor, and dce, which emulates a processor for a remote ; terminal. ; ; Option bits: ; dtebit 0: dce mode, 1: dte mode ; imgbit 0: ascii mode, 1: image mode ; bzybit 0: device available, 1: device in use ; ; External symbols ; .GLOBL $OFSET ;process pointer table ; ; Entry symbols ; .GLOBL IORINI ;input process initialization .GLOBL IOXINI ;output process initialization ; ; System definitions ; .ASECT .MCALL .COM,.CHR,.PSA,.TTD,.PAT ;definitions .MCALL .GETDA,.PUTDA,.INIT ;supervisor calls .COM ;define common data .CHR ;define ascii character codes .PSA ;define process storage areas .TTD ;define terminal storage areas .PAGE ; ; Process-state procedure ; Dsects: r3 = par, r5 = psa ; .PSECT $SUPI,RO,I ; ; Input process (ttr) ; IORINI: BIC #BZYBIT,PAROPT(R3) ;safety first CLR PARAUX(R3) MOVB #DLE,PARXSC(R3) ;initialize escape code EMT INIT ;initialize driver CLR R2 MOV R5,R4 ADD #TTRMSG+2,R4 1$: EMT SIO ;get next byte JSR PC,INPEDT BR 1$ ; ; Subroutine to process input byte ; R0 = byte ; ; In image mode the 8-bit byte is copied uninterpreted and unmodified. In ; ascii mode the driver is assumed to have stripped the parity bit. ; In dte mode the byte is discarded unless the device is in use (bzybit ; set in the options word). ; ; In dce mode a is inserted following a . In addition, an escape code ; (normally defaulted to ) causes the low-order two bits of the following ; byte to select channels 0-3 as defined by the command-language interpreter. ; INPEDT: BIT #DTEBIT,PAROPT(R3) ;is this dte BEQ 1$ ;branch if no BIT #BZYBIT,PAROPT(R3) ;yes. is device enabled BPL 2$ ;branch if no 1$: BIT #IMGBIT+DTEBIT,PAROPT(R3) ;is this image or dte BNE 3$ ;branch if yes BIT #ESCBIT,PARAUX(R3) ;no. is this escape sequence BEQ 4$ ;branch if no BIC #ESCBIT,PARAUX(R3) ;yes. end sequence CMPB R0,PARXSC(R3) ;is byte escape BEQ 5$ ;branch if yes CMPB R0,#'0 ;no. is it in range BLO 2$ ;branch if no CMPB R0,#'4 BHIS 2$ ;branch if no MOVB R0,PAROUT(R3) ;yes. save select char 2$: RTS PC ; 3$: MOVB R0,(R4)+ ;save byte BR 6$ ; 4$: CMPB R0,PARXSC(R3) ;is byte escape BNE 5$ ;branch if no BIS #ESCBIT,PARAUX(R3) ;yes. flag for following byte RTS PC ; 5$: MOVB R0,(R4)+ ;save byte CMPB R0,#CR ;is byte BNE 6$ ;branch if no MOVB #LF,(R4)+ ;yes. insert INC R2 6$: INC R2 ;tally count SWAB R0 ;is there more to come BEQ 7$ ;branch if no CMP R2,#SD.END-2-1 ;yes. is nibble full BLO 8$ ;branch if no 7$: MOV R5,R4 ;yes. complete header ADD #TTRMSG,R4 MOVB PAROUT(R3),R1 BIC #^C3,R1 ASH #3,R1 ADD R3,R1 MOVB PARLDN+2(R1),R1 BIC #^C377,R1 ADD #$OFSET,R1 ADD @R1,R1 MOVB PARPID(R1),SD.DST(R4) ASH #2,R2 BIS #STRCTL,R2 MOVB R2,SD.CTL(R4) .PUTDA R4 ;send to client process .GETDA R4 ;wait for reply CLR R2 TST (R4)+ 8$: RTS PC .PAGE ; ; Output process (ttx) ; IOXINI: EMT INIT ;initialize 1$: MOV R5,R2 ;wait for parameter message ADD #TTXMSG,R2 .GETDA R2 MOVB SD.CTL(R2),R4 ;extract count ASH #-2,R4 BEQ 1$ ;branch if runt MOVB #STRCTL,SD.CTL(R2) ;send reply .PUTDA R2 ADD #SD.CHN,R2 3$: MOVB (R2)+,R0 ;send bytes to device JSR PC,OUTEDT SOB R4,3$ BR 1$ ; ; Subroutine to process output byte ; R0 = byte ; ; In image mode the byte is copied uninterpreted and unmodified. In dte mode ; a immediately following a is discarded. In ascii mode the sender ; is presumed to have stripped the parity bit. ; ; In dce mode the byte is interpreted as follows: ; bs decrement column counter ; ht fill to the next tab stop (fixed at every eight columns) ; lf advance line counter by one ; ff reset line counter ; cr reset column counter ; Codes 000-037 and 177 (other than the above) do not affect column or line ; counters. Codes 040-176 advance column counter by one. If right margin is ; exceeded a sequence is inserted preceeding the byte. If bottom ; margin is exceeded a is inserted following the byte. ; OUTEDT: BIT #IMGBIT,PAROPT(R3) ;is this image mode BNE 2$ ;branch if yes BIT #DTEBIT,PAROPT(R3) ;no. is this dte BEQ OUTDCE ;branch if no BIT #STFBIT,PARAUX(R3) ;yes. was previous byte BEQ 1$ ;branch if no BIC #STFBIT,PARAUX(R3) ;yes. is byte CMPB R0,#LF BEQ 3$ ;yes. drop in bit bucket 1$: CMPB R0,#CR ;is byte BNE 2$ ;branch if no BIS #STFBIT,PARAUX(R3) ;yes. mark for destuff 2$: EMT SIO 3$: RTS PC ; OUTDCE: CMPB R0,#FF ;dce. is byte BEQ 1$ ;branch if yes CMPB R0,#LF ;no. is byte BNE 2$ ;branch if no EMT SIO ;yes. output INCB TTXLIN(R5) ;increment line counter TSTB PARPAG(R3) ;is bottom margin exceded BEQ 9$ ;branch if no CMPB TTXLIN(R5),PARPAG(R3) BLO 9$ ;branch if no MOVB #FF,R0 ;yes. output 1$: CLRB TTXLIN(R5) ;reset line counter BR 6$ ; 2$: CMPB R0,#CR ;is byte BEQ 3$ ;branch if yes CMPB R0,#BS ;no. is byte BNE 4$ ;branch if no DECB TTXCOL(R5) ;yes. back up pointer BPL 6$ 3$: CLRB TTXCOL(R5) ;reset column counter BR 6$ ; 4$: CMPB R0,#HT ;is byte BNE 6$ ;branch if no 5$: MOVB #<' >,R0 ;yes. fill to next tab stop JSR PC,OUTEDT BITB #7,TTXCOL(R5) BNE 5$ RTS PC ; 6$: CMPB R0,#040 ;is byte printing BLO 7$ ;branch if no CMPB R0,#177 BHIS 7$ ;branch if no INCB TTXCOL(R5) ;yes. bump column counter 7$: TSTB PARMAR(R3) ;is right margin exceeded BEQ 8$ ;branch if no CMPB TTXCOL(R5),PARMAR(R3) BLO 8$ ;branch if no MOV R0,-(SP) ;yes. output MOVB #CR,R0 JSR PC,OUTEDT MOVB #LF,R0 JSR PC,OUTEDT MOV (SP)+,R0 8$: EMT SIO ;output bute 9$: RTS PC ; .END