	.TITLE VRCSPA
	.IDENT /070387/


;	File:[22,310]VRCSPA.MAC
;	Author: Jim Bostwick 2-Nov-83 
;	History:  Phil Hannay 6-Jan-83  Remove IDS variable from call site
;                   as it was mistakenly left in.
;		  Peter Stadick 17-apr-87 convert to VRCS from RCST
;
;	Last Edit: 3-JUL-1987 12:06:05 
;

.REM |

{------------------- Receive Data or Stop -----------------------------}

PROCEDURE VRCSPA(VAR Task_Name:Rad56; Var Buff:CH512 );
External;

{*USER*
 Pascal-3 procedure to receive a variable  512-byte data packet.
If no packet available, the task enters the 'STOPPED' state,
from which it returns only through an UNSTOP directive (USTP$).
If Task_Name[1]=0, then the first pending
receive data packet is returned, and Task_Name is set to the name
of the sender of that packet. If Task_Name is non-zero on entry, then
only packets sent by that task will be returned. In this case, an
I$DSW indicating 'no packet pending' means no packet FROM THE SPECIFIED
TASK is pending. 

Task_Name must be in RAD50 format.

The length of the data packet received is encoded in the $DSW. Subtract
two from the integer value of $DSW and this will be the number of words
received. 

This procedure directly implements executive directive VRCS$. 
Return status is available in $DSW.
} 

|

;
; Assemble with PASMAC.MAC as prefix file.
;

	.MCALL VRCS$S
	
	PROC VRCSPA
	PARAM TKN, ADDRESS	;TASK NAME IN RAD50
	PARAM BUFF, ADDRESS
	VAR IBUFF,258.*INTEGER	;INTERNAL BUFFER
	SAVE <R0, R1, R2, R3>
	BEGIN
  	MOV SP,R0		;R0=ORIGINAL STACK POINTER
	MOV R0,R1		;R1->RECEIVE BUFFER (INTERNAL)
	ADD #IBUFF,R1
	MOV TKN(SP),R2		;R2->TASK NAME
	MOV #256.,R3
	VRCS$S R2,R1,R3
	MOV (R1)+,(R2)+		;COPY TASK NAME
	MOV (R1)+,(R2)
	MOV BUFF(SP),R2		;COPY BUFFER
	MOV #512.,R0		;R0=BUFFER COUNT
3$:	MOVB (R1)+,(R2)+	;COPY TO EXTERNAL BUFFER
	SOB R0,3$	
4$:	ENDPR
	.END

