.title termio terminal handler ; DECUS C Calling Format ; ; jsr r5,csv$ ;save r2,r3, and r4 ; ;r5 is parameter base ; ;c$pmtr(r5) is first argument ; ;c$pmtr+2(r5) is second argument ; ;... ; ;return args in r0 ; ... ; user code ; ... ; ; jmp cret$ ;restore r2-r5 and return ; rts pc ;does the same (cret$ follows csv$) ; ; csv$ and cret$ need be used only if arguments are used ; .include "os.mac" .mcall .ttyin .ttinr .print .rctrlo ; oubufr has been replaced with a 'bottom of the stack' buffer ; which is probably good to 512 bytes. If the length becomes ; excessive then the stack will be overwritten and the program ; will crash. ; .print is used for output to override any ; job blocking that may occur under RT-11 ; The variable tt.prnt/kb.prnt can be used to ; enable/disable all printing through the TERMIO ; routines. This is used by the server programs ; to inhibit the output of status messages. JSW = 44 ;job status word TTSPC$ = 050100 ;single character activation ;enable lower case KBISIZ = 16. ;input buffer size (2^N) KBOSIZ = 128. ;output buffer size arg1 = 2 .sbttl keyboard initialization .psect c$code kb.init:: tt.init:: mov arg1(sp),brkchr ;save break character clr fndbrk ;clear flag clr inptri ;clear buffer clr inptro rts pc .psect c$data fndbrk::.word 0 ;foundbreak flag brkchr: .word 3 ;break character (default = ^C) .page .sbttl Keyboard Input / Output .psect c$code kb.inp:: tt.inp:: clr r0 ;null character cmp inptri,inptro ;any characters ? beq 1$ ;no - return null mov inptro,r1 ;pointer bisb inbufr(r1),r0 ;get character inc r1 ;update position bic #^c,r1 ;mod KBISIZ mov r1,inptro ;save new pointer 1$: rts pc ;r0 = character kb.out:: tt.out:: tst tt.prnt ;enabled ? beq 1$ ;no - skip mov #oubufr,r0 ;output character mov #100000,(r0) movb arg1(sp),(r0) .print 1$: rts pc kbprintf:: ttprintf:: tst tt.prnt ;enabled ? beq 2$ ;no - skip mov (sp)+,1$ ;save return mov #oubufr,-(sp) ;internal buffer jsr pc,sprintf ;use sprintf to evaluate string mov #oubufr,(sp) ;internal buffer jsr pc,tt.puts mov (pc)+,(sp) ;restore return 1$: .word 0 2$: rts pc ;finished kb.puts:: tt.puts:: tst tt.prnt ;enabled ? beq 2$ ;no - skip mov arg1(sp),r1 1$: tstb (r1)+ ;scan for end of string bne 1$ movb #200,-(r1) ;inhibits .print arg1(sp) ;output a string clrb (r1) ;terminate string 2$: rts pc kb.nline:: tt.nline:: tst tt.prnt ;enabled ? beq 1$ ;no - skip .print #2$ ;print 1$: rts pc 2$: .byte 0,0 .sbttl keyboard data buffer .psect c$data kb.prnt:: tt.prnt:: .word 1 ;tt/kb print enable flag .if eq 1 oubufr: .blkb 128. ;output buffer .iff oubufr = 500 ;output buffer .endc inbufr: .blkb KBISIZ ;input buffer inptri: .word 0 inptro: .word 0 .page .sbttl Asynchronous Terminal input .psect c$code keyinp: .if ne rt$sys ;rt-11 specific .ttinr ;a character ? bcs 4$ ;no - skip .endc cmpb r0,brkchr ;break character ? bne 1$ ;no - skip inc fndbrk ;yes - set flag br 3$ 1$: movb r0,-(sp) ;save character cmpb #15,r0 ;a ? bne 2$ ;no skip .ttyin ;dump following a 2$: mov inptri,r0 ;input pointer movb (sp)+,inbufr(r0) ;place character inc r0 ;next position bic #^c,r0 ;mod KBISIZ cmp r0,inptro ;buffer full ? beq 3$ ;yes - skip mov r0,inptri ;save pointer 3$: jsr pc,resume ;resume any suspension .if ne ts$sys ;tsx-plus specific incmpl: mov #inarg,r0 ;set up next interrupt emt 375 ;tt input completion request rts pc .endc .if ne rt$sys ;rt-11 specific mov #3.,mrktim ;recheck in .05 seconds 4$: cmp mrktim,#30. ;at .5 seconds ? bhis incmpl ;yes - hold it here dec mrkcnt ;update counter bgt incmpl mov #60.,mrkcnt ;reset counter inc mrktim ;lengthen recheck time ;.mrkt #mrkt,#1$,#keyinp,#2 incmpl: mov #mrkt,r0 ;.mrkt timed interrupt emt 375 rts pc .endc ; Initializer init: bis #TTSPC$,@#JSW ;set single character mode .rctrlo ;note change mov #scca,r0 ;inhibit ^C aborts emt 375 br incmpl .psect c$data .if ne ts$sys ;tsx-plus specific inarg: .byte 1,133 ;emt block .word keyinp ;entry point .endc .if ne rt$sys ;rt-11 specific mrkt: .byte 0,22 ;.mrkt .word 1$ ;time .word keyinp ;completion routine .word 2 ;id = 2 1$: .word 0 mrktim: .word 3. ;.05 second scan time mrkcnt: .word 60. ;counter .endc scca: .byte 0,35 ;.scca .word 1$ 1$: .word 0 ;^C status .page .sbttl Initializer and Finalizer Code ; The initializer calls init to ; initialize the terminal I/O handler. .psect $init .psect $init$ .word init ;initalizer routine .psect $init. ; The finalizer is not required .psect $finl .psect $finl$ .psect $finl. .end