	.title	k11fix	fix attributes so rmscnv and pip can do ansi binaries
	.ident	/T9.0/

;	 Write  attribute entries for Kermit-11 tasks and save images
;	so that (1) F77 will read the files as fixed 512 direct files
;	and (2)  so RMSCNV and PIP can put them on ANSI tapes intact.
;	For RSTS/E only.
;
;
;	14-Nov-84  05:23:10  Brian Nelson

	.psect

list:	.word	10$,20$,30$,40$,50$,60$,70$,80$
10$:	.asciz	/in:k11.tsk/
20$:	.asciz	/in:k11nrs.tsk/
30$:	.asciz	/in:k11rsx.tsk/
40$:	.asciz	/in:k11pos.tsk/
50$:	.asciz	/in:k11xm.sav/
60$:	.asciz	/in:k11rt4.sav/
70$:	.asciz	/in:k11i31.tsk/
80$:	.asciz	/in:k11i32.tsk/
msg:	.asciz	/ updated/<15><12>
	.even

st:	mov	#list	,r4
10$:	tst	@r4
	beq	100$
	mov	(r4)+	,r0
	call	print
	call	fix
	tst	r0
	beq	20$
	movb	#errfq	,firqb+fqfun
	movb	r0	,firqb+4
	calfip
	clrb	firqb+37
	mov	#firqb+4,r0
	call	print
	br	30$
20$:	mov	#msg	,r0
	call	print
30$:	br	10$
100$:	.exit

fix:	mov	r0	,r1		; save address of string
10$:	tstb	(r0)+			; find the end of it
	bne	10$			; not yet
	sub	r1	,r0		; get the length
	dec	r0			; fix it
	mov	#xrb	,r2		; point to the xrb
	mov	r0	,(r2)+		; length
	mov	r0	,(r2)+		; length again
	mov	r1	,(r2)+		; address of the string
	clr	(r2)+			; not used
	clr	(r2)+			; not used
	clr	(r2)+			; not used
	clr	(r2)+			; not used
	call	clrfqb			; insure no defaults
	.fss				; parse it
	movb	firqb	,r0		; check for errors
	bne	100$			; oops
	movb	#opnfq	,firqb+fqfun	; open it up please
	movb	#2	,firqb+fqfil	; channel*2
	calfip				; do it
	movb	firqb	,r0		; success?
	bne	100$			; no
	mov	firqb+fqsiz,r3		; save file size
	call	clrfqb			; write attributes now
	mov	#firqb+fqfun,r0		; simple to do
	movb	#uu.atr	,(r0)+		; write attributes
	incb	(r0)+			; channel one
	movb	#6	,(r0)+		; word count
	mov	#1	,(r0)+		; FIXED
	mov	#1000	,(r0)+		; 512 byte records
	clr	(r0)+			;
	mov	r3	,(r0)+		; end of file mark
	clr	(r0)+			;
	mov	r3	,@r0		; next free block
	inc	@r0			;
	.uuo				; do it
	movb	firqb	,r0
	bne	100$
	call	clrfqb
	movb	#clsfq	,firqb+fqfun
	movb	#2	,firqb+fqfil
	calfip
	clr	r0
	
100$:	return


	

clrfqb:	mov	r0	,-(sp)
	mov	r1	,-(sp)
	mov	#40	,r0
	mov	#firqb	,r1
10$:	clrb	(r1)+
	sob	r0	,10$
	mov	(sp)+	,r1
	mov	(sp)+	,r0
	return

print:	mov	r0	,-(sp)
	mov	r1	,-(sp)
	mov	r2	,-(sp)
	mov	r0	,r1
10$:	tstb	(r0)+
	bne	10$
	sub	r1	,r0
	dec	r0
	mov	#xrb	,r2
	mov	r0	,(r2)+
	mov	r0	,(r2)+
	mov	r1	,(r2)+
	clr	(r2)+
	clr	(r2)+
	clr	(r2)+
	clr	(r2)+
	.write
	mov	(sp)+	,r2
	mov	(sp)+	,r1
	mov	(sp)+	,r0
	return


	.end	st
