	.ident /20APR1/
; 20-APR-81 15:52:22
.iif ndf $temp$ $temp$=0
$top$=.
$auto$=$temp$
.enabl lc
; Mp version as of: 28-jan-81
	.title  jplget
        con.0==0
        con.a==1
        con.b==2
        con.c==3
        con.d==4
        con.e==5
        con.f==6
        con.g==7
        con.h==10
        con.i==11
        con.j==12
        con.k==13
        con.l==14
        con.m==15
        con.n==16
        con.o==17
        con.p==20
        con.q==21
        con.r==22
        con.s==23
        con.t==24
        con.u==25
        con.v==26
        con.w==27
        con.x==30
        con.y==31
        con.z==32
        esc==33
        tab==9.
        space==40
        rub==177
        nl==12
        lf==12
        uparo==136
        bs==10
        cr==15
        con.qq==37
        .mcall qiow$,dir$,qiow$s
read:   qiow$   io.rtt!tf.tmo,5,5,,qios,,<qioin,84.,180.,tbl>
tbl:    .word 1+2+4+10+20+40+100+000+400+0000+2000+4000+10000+20000+40000+100000
        .word 1+2+4+10+20+40+100+200+400+1000+2000+4000+100000
        .word 0,0,0,0
        .word 0,100000,0,0              ;rubout
        .word 0,0,0,0,0,0
ios:    .word        0,0
qios:
ok:     .byte        0         ;1 = ok
term:   .byte        0         ;terminator character
len:    .word        0         ;length of input
qioin:  .blkb        84.
inp:    .word
linf:   .asciz    <lf>                  ;
rb:     .asciz    <bs><space><bs>       ;rub out stuff
clear:  .asciz    <cr><esc>'K'          ;clear line on control u
clear1: .asciz    <uparo>'u'<cr><lf>    ;this if a slow terminal
        .even
s=10.
speed=12.
prm=14.
line::
	jsr r0,$$csav
	add #$auto$,sp
	$auto.=$auto$
	$auto$=$temp$
	mov s(r5),inp
	clrb @inp
	JSR PC,outprompt
jpl1=.
	dir$ #read
	CMPB ok,#2
	BNE jpl3
	jmp timout
jpl3=.			; 
jpl5=.
	JSR PC,apinput
jpl6=.
	CMPB term,#rub
	BNE jpl8
	cmp inp,s(r5)
	BLOS jpl10
	dec inp
	mov #rb,r0
	JSR PC,outstr
jpl10=.			; 
jpl12=.
	clrb @inp
	JMP jpl7         ;break
jpl8=.
	CMPB term,#con.r
	BNE jpl13
	JSR PC,outprompt
	mov s(r5),r0
	JSR PC,outstr
	JMP jpl7         ;break
jpl13=.
	CMPB term,#con.u
	BNE jpl15
	mov s(r5),inp
	clrb @inp
	cmp speed(r5),#300.
	BLE jpl17
	mov #clear,r0
	JMP jpl20
jpl17=.			; 
	mov #clear1,r0
jpl20=.			; 
jpl19=.
	JSR PC,outstr
	mov prm(r5),r0
	JSR PC,outstr
	JMP jpl7         ;break
jpl15=.
	CMPB term,#con.o
	BNE jpl21
	JMP jpl7         ;break
jpl21=.
	movb term,r0
	bic #177400,r0
	jmp $$cret
jpl7=.
jpl23=.
	JMP jpl1		;Repeat loop
jpl2=.
timout:
	mov #-1,r0
	jmp $$cret
apinput:
	mov #qioin,r3
	mov #1,r2
jpl24=.
	cmp r2,len
	BLE jpl26
	JMP  jpl25
jpl26=.
	movb (r3)+,@inp
	clr -(sp)
	mov s(r5),(sp)
	ADD #79.,(sp)
	cmp inp,(sp)+
	BHIS jpl27
	inc inp
jpl27=.			; 
jpl29=.
	clrb @inp
	INC r2
	JMP jpl24		;back to top
jpl25=.
	rts pc
outprompt:                              ;output the prompt
	mov #linf,r0
	JSR PC,outstr
	mov prm(r5),r0
	JSR PC,outstr
	rts pc
outstr::                                ;output a string
	mov r0,-(SP)
	mov r1,-(SP)
	mov r0,r1
10$:
	tstb (r0)+
	bne 10$
	sub r1,r0
	dec r0
        qiow$s #io.wvb,#5,#5,,#ios,,<r1,r0,#0>
	mov (SP)+,r1
	mov (SP)+,r0
	rts pc
$temp$=-4.
.END 
