.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 ; ; csv$ and cret$ need be used only if r2-r5 need to be ; saved or you wish to use the r5 stack frame ; .mcall .ttyin .ttyout .print .mcall .rsum .rctrlo JSW = 44 ;job status word TTSPC$ = 10000 ;single character activation arg1 = 2 .sbttl keyboard initialization .psect c$code kb.init:: tt.init:: mov arg1(sp),brkchr ;save break character clr fndbrk ;clear flag bis #TTSPC$,@#JSW ;set single character mode .rctrlo ;note change mov #scca,r0 ;inhibit ^C aborts emt 375 clr inptri ;clear buffer clr inptro jsr pc,incmpl rts pc .psect c$data fndbrk::.word 0 ;foundbreak flag brkchr: .word 0 ;break character scca: .byte 0,35 ;.scca .word 1$ 1$: .word 0 ;^C status .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 #-100,r1 ;mod 64. mov r1,inptro ;save new pointer 1$: rts pc ;r0 = character kb.out:: tt.out:: .ttyout arg1(sp) ;output character rts pc kbprintf:: ttprintf:: 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 rts pc ;finished kb.puts:: tt.puts:: 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 rts pc kb.nline:: tt.nline:: .print #1$ ;print rts pc 1$: .byte 0,0 .sbttl keyboard data buffer .psect c$data oubufr: .blkb 128. ;output buffer inbufr: .blkb 64. ;input buffer inptri: .word 0 inptro: .word 0 .page .sbttl Asynchronous Terminal input .psect c$code keyinp: 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 #-100,r0 ;mod 64. cmp r0,inptro ;buffer full ? beq 3$ ;yes - skip mov r0,inptri ;save pointer 3$: tst re.spnd bgt incmpl .rsum ;resume any suspension inc re.spnd incmpl: mov #inarg,r0 ;set up next interrupt emt 375 ;tt input completion request rts pc .psect c$data inarg: .byte 1,133 ;emt block .word keyinp ;entry point .end