	.TITLE	rcst
	.enable lc
	.ident	/wrg/
	.PSECT	.PROG.
;
; P. Hays		25 May 79
; D. Conroy		 4 October 79
; Swiped from rcvd by Wayne R. Graves 23-Jul-80
;
; Receive data directive.
; int rcst(sender, buffer) char *sender; int buffer[];
;
; If the directive is accepted, the return value is 0;
; if not, the value of the directive status word is returned.
;
	.mcall dir$

; Define offsets re the stackframe to the user's arguments
a.snd = 12			; Input addr of taskname, or NULL
a.buf = 14			; Address of user's buffer

rcst::
	jsr	r0,$$csav
	sub	#10,sp		; Prepare space for the DPB
	mov	sp, r2		; r2 <- adress of DPB

	mov	a.buf(r5),6(r2)	; Enter the buffer addr to DPB

	mov	a.snd(r5),r0	; r0 <- ptr to ascii taskname
	bne	1$		; If name specified, go convert to rad50 ->
	clr	2(r2)		; otherwise, clear the name words in DPB
	clr	4(r2)
	br	2$
1$:
	; Convert ascii name to rad50 for the exec call
	mov	r0, -(sp)	; Push address of user's string
	mov	#2, -(sp)	; Specify 2 words to be converted
	mov	r2, -(sp)	; Push address of name field in DPB
	add	#2, (sp)
	call	ator		; (From lb:[1,1]clib.olb)
	mov	r2, sp		; Pop args
2$:
	mov	(pc)+,(r2)	; Load directive id code and wordcount
	.byte	139., 4
	clr	r0		; Clear for valid return
	dir$			; Call the executive rcst routine (he pops DPB)
	bcc	3$
	mov	@#$dsw,r0	; If error, return directive status word ->
3$:
	jmp	$$cret
.end
