	.TITLE	SDAT
	.IDENT	/02/
	.PSECT	.PROG.
	.ENABLE	LC
;
; P. Hays		25 May 79
; D. Conroy		 4 October 79
;
; Send data to another task.
; int sdat(task, buffer, efn)
; char *task; int buffer[]; int  efn;
;
; Sdat returns 0 if the directive is accepted; if rejected, the
; value of the directive status word is returned.
;
	.mcall dir$

; Definitions of offsets re stackframe pointer to input parameters:
a.efn = 16			; event flag number
a.buf = 14			; Address of input buffer
a.targ = 12			; Address of target task's name string

sdat::
	jsr	r0,$$csav	; Linkage
	sub	#12,sp		; Claim stack space in which to build DPB
	mov	sp, r2		; r2 <- address of DPB

	mov	a.efn(r5),10(r2); Store efn or NULL into DPB.
	mov	a.buf(r5),6(r2)	; Store buffer address into DPB.

	; Convert taskname to rad50 for the exec call
	mov	a.targ(r5), -(sp); Push address of user's string
	mov	#2, -(sp)	; Specify conversion of 2 words
	mov	r2, -(sp)	; Push address of taskname field in DPB
	add	#2, (sp)
	call	ator		; (from lb:[1,1]clib.olb)
	mov	r2, sp		; Pop args

	mov	(pc)+,(r2)	; Store 1st word of DPB:
	.byte	71., 5		; DIC = 71., DPB wordcount = 5 words.

	clr	r0		; Prepare to return NULL if directive accepted.
	dir$			; Call the exec.
	bcc	9$		;	Directive accepted	->

	mov	@#$dsw,r0	; If directive rejected, return dsw.
9$:
	jmp	$$cret		; Done

.end
