/"readline" is general subroutine to read user input at terminal
/inputs:
/	r0 pts to place reading is to be done
/outputs:
/	no.chars = number of chars read including last <nl>
/	lastchar = address of last char before last <nl>
readline:
	mov	r0,-(sp)		/save regs
	mov	r1,-(sp)
	mov	r2,-(sp)
	cmp	r0,$bline		/check pointer range to ensure
	bhis	1f			/its being in line buffer
0:
	jsr	r5,ioerror
	<50>				/BAD LINE POINTER
1:
	cmp	r0,$eline
	bhi	0b
	mov	r0,r1			/r1=current byte cursor
	mov	r0,r2			/r2=cursor to beginning of
					/current physical line
0:
	mov	r1,1f
	clr	r0			/file='terminal'
	sys	read; 1:..; 1		/read 1 char
	tst	r0			/EOF?
	bne	1f
	sys	exit			/quit if yes
1:
	cmpb	(r1),$'\n
	bne	3f
	cmpb	-1(r1),$'^		/physical line to be deleted?
	bne	2f
	mov	r2,r1			/erase to beginning of physical
	br	0b			/line
2:
	cmpb	-1(r1),$'+		/continuation?
	bne	4f
	movb	$'\n,-1(r1)		/overwrite "+" with "\n"
	mov	r1,r2			/r2 points to beginning of next
	br	0b			/line
3:
	inc	r1
	cmp	r1,$eline		/end line buffer?
	blos	0b			/branch if not
	jsr	r5,mesg
	<3LINE TOO LONG. >
	<BEGINNING LOST.4\n\0>
	.even
	mov	4(sp),r1		/start reading again
	mov	r1,r2
	br	0b
4:
	mov	r1,no.chars		/numb chars read includes last
	sub	4(sp),no.chars		/last <nl>
	inc	no.chars
	mov	r1,lastchar		/lastchar=addr of last <nl> char
	mov	(sp)+,r2		/restore regs
	mov	(sp)+,r3
	tst	(sp)+			/pop r0 saved off stack
	rts	r5			/return
no.chars:
	.=.+2
lastchar:
	.=.+2
