	.title	srda
	.globl	srda, crda
	.mcall	gtsk$s, srda$s, ustp$s, astx$s
ap=r5				; arguement pointer
new=2				; offset from ap for new ast address
old=4				; same for old
buf:	.blkb	32.
astcnt:	.word	0
curast:	.word	0
srda::
	tst	astcnt		; see if done ast yet
	bne	10$		; yes we have
	gtsk$s	#buf		; get current task name in buf
	mov	#1,astcnt	; non-zero value implies initialization done
10$:
	mov	@new(ap),r0	; get new ast address
	bne	20$		; if != 0, user specified address
	mov	#cntast,r0	; user wishes unstop ast
20$:
	mov	curast,@old(ap)	; return old ast address
	mov	r0,curast	; save curent ast address
	srda$s	r0		; establish new ast
	return
crda::
	mov	@new(ap),r0	; get new ast address
	mov	r0,curast	; update current ast address
	beq	30$		; if == 0, turn off ast's
	srda$s	r0		; re-establish old ast address
	br	40$
30$:
	srda$s			; turn off ast's
40$:
	return
cntast:
	ustp$s	#buf		; unstop current task
	astx$s			; dismiss current ast
	.end
