	.title	fmtpro
;+
;	subroutine fmtpro(protec, buf)
;-
ap=%5
protec=2
buf=4
	.psect	$r.roi,con,ro,rel,lcl,i
	.enabl	lsb
	.enabl	lc
chars:	.ascii	"dewr"
	.dsabl	lc
	.even
fmtpro::
	mov	@protec(ap),r1		; protection word
	mov	#20,r0			; initialize mask word
	mov	buf(ap),r2		; address of buffer
	mov	#3,r3			; initialize offset into chars
	br	20$			; no pipe on first pass
10$:
	movb	#'|,(r2)+		; copy separator
20$:
	bit	r0,r1			; see if bit is set
	beq	30$			; NO
	movb	#'-,(r2)+		; copy dash for no access
	br	40$
30$:
	movb	chars(r3),(r2)+		; copy access character
40$:
	clc				; shift mask bit left one bit
	rol	r0			; ...
	bcs	50$			; c set => all done
	dec	r3			; decrement offset into chars
	bge	20$			; if >= 0, continue
	mov	#3,r3			; initialize offset
	br	10$			; copy separator
50$:
	clrb	(r2)			; terminate with EOS
	return
	.end
