	.ident /20APR1/
; 20-APR-81 15:51:22
        maxline=78.
	input=0
term=input
        input=input+2
string=input
   input=input+<82.>
.iif ndf $temp$ $temp$=0
$top$=.
$auto$=$temp$
.enabl lc
; Mp version as of: 28-jan-81
	.title  editm
delim:  .asciz '_'
prm:    .asciz    <15>'?'
prm2:   .asciz    <15><12>'ed:'
crlf:   .asciz    <15><12>
        .even
	$auto$=$auto$-<2>
supp=	$auto$
lh=10.
cur=12.
s=14.
editm::
	jsr r0,$$csav
	add #$auto$,sp
	$auto.=$auto$
	$auto$=$temp$
        t=r2
        typ=r4
	clr supp(r5)
edi1=.
	tst supp(r5)
	BNE edi3
	mov #prm2,r0
	JSR PC,outstr
	mov cur(r5),r0
	ADD #string,r0
	JSR PC,outstr
edi3=.			; 
edi5=.
	clr supp(r5)
	mov #prm,-(SP)
	mov speed,-(SP)
	mov s(r5),-(SP)
      jsr pc,line
	add #006,sp
	mov r0,t
	mov t,-(SP)
      jsr pc,ctype
  tst (sp)+
	mov r0,typ
	clr -(sp)
	mov s(r5),-(SP)
      jsr pc,strlen
  tst (sp)+
	mov r0,(sp)
	cmp (sp)+,#0
	BNE edi6
	BR edi9
edi6:	JMP edi10
edi9:
edi11=.
	cmp typ,#control
	BNE edi13
	clr -(sp)
	mov cur(r5),r1
	mov term(r1),r0
	mov r0,(sp)
	cmp (sp)+,t
	BEQ edi15
	mov cur(r5),-2.(r5)
	ADD #string,-2.(r5)
	mov -2.(r5),-(SP)
	mov t,-(SP)
	mov lh(r5),-(SP)
      jsr pc,stuff
	add #006,sp
edi15=.			; 
edi17=.
	JMP edi12         ;break
edi13=.
	cmp typ,#cr
	BNE edi18
	mov #1,r0
	jmp $$cret
edi18=.
	cmp typ,#esc
	BNE edi20
	clr r0
	jmp $$cret
edi20=.
	cmp typ,#con.z
	BNE edi22
	mov cur(r5),r1
	add #string,r1
	mov r1,r0
	mov r1,-(sp)
	clr -(sp)
	clr (sp)
	mov (sp)+,@(sp)+
	clr r0
	jmp $$cret
edi12=.
edi22=.
	JMP edi24
edi10=.			; 
edi25=.
	cmp typ,#control
	BNE edi27
	JSR PC,ccont
	JMP edi26         ;break
edi27=.
	cmp typ,#cr
	BNE edi29
       BR edi30
edi29=.
	cmp typ,#esc
	BNE edi31
edi30=.
	mov cur(r5),-(SP)
	mov cur(r5),-(SP)
	mov s(r5),-(SP)
      jsr pc,change
	add #006,sp
	JMP edi26         ;break
edi31=.
	JSR PC,creturn
	BR edi35
edi34=.
	.ASCIZ _I can't do that_
	.EVEN
edi35=.
	mov r0,-(sp)
	mov r1,-(sp)
	mov #edi34,-(SP)
	mov #$buf$,-(SP)
      jsr pc,sprint
  cmp (sp)+,(sp)+
	mov #$buf$,-(sp)
	jsr pc,$type$
	mov (sp)+,r1
	mov (sp)+,r0
edi26=.
edi33=.
edi24=.			; 
edi8=.
	JMP edi1		;Repeat loop
edi2=.
ccont:
	JSR PC,creturn
edi36=.
	mov t,-(SP)
	mov lh(r5),-(SP)
      jsr pc,find
  cmp (sp)+,(sp)+
	mov r0,r3
	cmp term(r3),t
	BNE edi38
	clr -(sp)
	mov cur(r5),-(SP)
	mov r3,-(SP)
	mov s(r5),-(SP)
      jsr pc,change
	add #006,sp
	mov r0,(sp)
	cmp (sp)+,#0
	BNE edi41
	mov #crlf,r0
	JSR PC,outstr
	mov r3,r0
	ADD #2,r0
	JSR PC,outstr
	mov t,-(SP)
      jsr pc,outterm
  tst (sp)+
	JMP edi44
edi41=.			; 
	BR edi46
edi45=.
	.ASCIZ _%c deleted_
	.EVEN
edi46=.
	mov r0,-(sp)
	mov r1,-(sp)
	mov t,-2.(r5)
	ADD #cntl,-2.(r5)
	mov -2.(r5),-(SP)
	mov #edi45,-(SP)
	mov #$buf$,-(SP)
      jsr pc,sprint
	add #006,sp
	mov #$buf$,-(sp)
	jsr pc,$type$
	mov (sp)+,r1
	mov (sp)+,r0
edi44=.			; 
edi43=.
	inc supp(r5)
	JMP edi37         ;break
	JMP edi47
edi38=.			; 
	BR edi49
edi48=.
	.ASCIZ __
	.EVEN
edi49=.
	mov #edi48,-(SP)
	mov t,-(SP)
	mov lh(r5),-(SP)
      jsr pc,stuff
	add #006,sp
edi47=.			; 
edi40=.
	JMP edi36		;Repeat loop
edi37=.
	rts pc
	$auto$=$auto$-<2>
len=	$auto$
	$auto$=$auto$-<2>
del=	$auto$
	$auto$=$auto$-<84.>
scratch=	$auto$
	$auto$=$auto$-<2>
t1=	$auto$
	$auto$=$auto$-<2>
t2=	$auto$
	$auto$=$auto$-<2>
blen=	$auto$
s=10.
buffer=12.
cur=14.
change::
	jsr r0,$$csav
	add #$auto$,sp
	$auto.=$auto$
	$auto$=$temp$
        addrsc=r4
        buf=r3
	clr -(sp)
	mov s(r5),-(SP)
      jsr pc,strlen
  tst (sp)+
	mov r0,(sp)
	cmp (sp)+,#1
	BNE edi50
	CMPB @s(r5),delim
	BNE edi53
	cmp buffer(r5),cur(r5)
	BEQ edi56
	mov buffer(r5),-(SP)
      jsr pc,delete
  tst (sp)+
	mov r0,-2.(r5)
	mov -2.(r5),-(SP)
      jsr pc,release
  tst (sp)+
	mov #-1,r0
	jmp $$cret
edi56=.			; 
edi58=.
edi53=.			; 
edi55=.
edi50=.			; 
edi52=.
	mov #scratch,-(SP)
	ADD R5,(SP)	;and compute address of scratch
	mov (SP)+,addrsc
	mov s(r5),-(SP)
      jsr pc,strlen
  tst (sp)+
	mov r0,len(r5)
	mov #1,-(SP)
	mov #delim,-(SP)
	mov s(r5),-(SP)
      jsr pc,pos
	add #006,sp
	mov r0,del(r5)
	mov buffer(r5),buf
	ADD #string,buf
	mov buf,-(SP)
      jsr pc,strlen
  tst (sp)+
	mov r0,blen(r5)
	tst del(r5)
	BNE edi59
	clr -(sp)
	mov blen(r5),(sp)
	ADD len(r5),(sp)
	cmp (sp)+,#maxline.
	BGT edi62
	clr -(SP)
	mov s(r5),-(SP)
	mov buf,-(SP)
      jsr pc,cat
	add #006,sp
	JMP edi65
edi62=.			; 
	JSR PC,toolong
edi65=.			; 
edi64=.
	JMP edi61
edi59=.
	cmp del(r5),#1
	BNE edi66
	clr -(sp)
	mov len(r5),(sp)
	ADD blen(r5),(sp)
	DEC (sp)
	cmp (sp)+,#maxline.
	BGT edi69
	clrb scratch(r5)
	clr -(SP)
	mov buf,-(SP)
	mov s(r5),-2.(r5)
	INC -2.(r5)
	mov -2.(r5),-(SP)
	mov #scratch,-(SP)
	ADD R5,(SP)	;and compute address of scratch
      jsr pc,cat
	add #010,sp
	mov #scratch,-(SP)
	ADD R5,(SP)	;and compute address of scratch
	mov buf,-(SP)
      jsr pc,scopy
  cmp (sp)+,(sp)+
	JMP edi72
edi69=.			; 
	JSR PC,toolong
edi72=.			; 
edi71=.
	JMP edi73
edi66=.			; 
	mov s(r5),r2
	ADD del(r5),r2
	DEC r2
	clrb (r2)
	mov #1,-(SP)
	mov s(r5),-(SP)
	mov buf,-(SP)
      jsr pc,pos
	add #006,sp
	mov r0,r2
	tst r2
	BNE edi74
	JSR PC,creturn
	BR edi78
edi77=.
	.ASCIZ _I can't find `%s'_
	.EVEN
edi78=.
	mov r0,-(sp)
	mov r1,-(sp)
	mov s(r5),-(SP)
	mov #edi77,-(SP)
	mov #$buf$,-(SP)
      jsr pc,sprint
	add #006,sp
	mov #$buf$,-(sp)
	jsr pc,$type$
	mov (sp)+,r1
	mov (sp)+,r0
	JMP edi79
edi74=.			; 
	mov s(r5),t1(r5)
	ADD del(r5),t1(r5)
	mov buf,t2(r5)
	mov s(r5),-(SP)
      jsr pc,strlen
  tst (sp)+
	ADD r0,t2(r5)
	ADD r2,t2(r5)
	DEC t2(r5)
	clr -(sp)
	mov t1(r5),-(SP)
      jsr pc,strlen
  tst (sp)+
	mov r0,(sp)
	mov t2(r5),-(SP)
      jsr pc,strlen
  tst (sp)+
	ADD r0,(sp)
	ADD r2,(sp)
	cmp (sp)+,#maxline.
	BGT edi80
	BR edi83
edi80:	JMP edi84
edi83:
	mov r2,-2.(r5)
	DEC -2.(r5)
	mov -2.(r5),-(SP)
	mov #1,-(SP)
	mov buf,-(SP)
	mov #scratch,-(SP)
	ADD R5,(SP)	;and compute address of scratch
      jsr pc,seg
	add #010,sp
	clr -(SP)
	mov t2(r5),-(SP)
	mov t1(r5),-(SP)
	mov #scratch,-(SP)
	ADD R5,(SP)	;and compute address of scratch
      jsr pc,cat
	add #010,sp
	mov #scratch,-(SP)
	ADD R5,(SP)	;and compute address of scratch
	mov buf,-(SP)
      jsr pc,scopy
  cmp (sp)+,(sp)+
	JMP edi85
edi84=.			; 
	JSR PC,toolong
edi85=.			; 
edi82=.
edi79=.			; 
edi76=.
edi73=.			; 
edi61=.
	clr r0
	jmp $$cret
toolong:
	JSR PC,creturn
	BR edi87
edi86=.
	.ASCIZ _Line too long_
	.EVEN
edi87=.
	mov r0,-(sp)
	mov r1,-(sp)
	mov #edi86,-(SP)
	mov #$buf$,-(SP)
      jsr pc,sprint
  cmp (sp)+,(sp)+
	mov #$buf$,-(sp)
	jsr pc,$type$
	mov (sp)+,r1
	mov (sp)+,r0
	rts pc
$temp$=-4.
.END 
