	.TITLE	PROGRAM2
	.IDENT	/000001/

;
; COPYRIGHT (C) 1978
; DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
;
; THIS SOFTWARE IS FURNISHED UNDER  A LICENSE FOR USE ONLY  ON  A
; SINGLE COMPUTER SYSTEM AND MAY BE  COPIED ONLY WITH  THE INCLU-
; SION OF  THE  ABOVE  COPYRIGHT NOTICE.  THIS SOFTWARE,  OR  ANY
; OTHER COPIES THEREOF, MAY NOT BE  PROVIDED  OR  OTHERWISE  MADE
; AVAILABLE TO ANY OTHER PERSON EXCEPT  FOR  USE  ON  SUCH SYSTEM
; AND TO  ONE WHO AGREES  TO  THESE LICENSE  TERMS.  TITLE TO AND
; OWNERSHIP OF THE SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.
;
; THE INFORMATION IN THIS SOFTWARE  IS  SUBJECT TO CHANGE WITHOUT
; NOTICE AND SHOULD NOT BE CONSTRUED  AS  A COMMITMENT BY DIGITAL
; EQUIPMENT CORPORATION.
;
; DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS
; SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY DEC.
;
;++
;
; FACILITY:
;
;	Test program for DA11-B Driver
;
; ABSTRACT:
;
;	This module is a slave program to drive one half of a DA11-B
;	interprocessor link. This program assigns the device and issues
;	a receive QIO. When the receive completes, this program issues
;	a transmit QIO. The loop repeats "n" times.
;
; AUTHOR:
;
;	C. Peters 18-SEP-78
;
;--

	.SBTTL	Data declarations

;
; External symbols
;

;
; Local symbols
;
device_desc:				; Descriptor for device name
	.ASCID	/DAB0:/

channel_index:				; Holds channel index number for
	.BLKW	1			; process I/O channel.

transmit_buffer:			; Buffer of data to transmit.
	.ASCII	/This is the answering slave./
transmit_length=.-transmit_buffer	; Length of transmit message.

receive_length=28			; Length of receive message.
receive_buffer:				; Buffer to receive data.
	.BLKB	receive_length		; Length of message received.
io_stat_block:				; I/O status block
	.BLKL	2

	.SBTTL	Master program code

;++
; START - Start a series of transmits and receives
;
; Functional description:
;
; Inputs:
;
;	none
;
; Outputs:
;
;	R0	- status code
;
;--

START:
	.WORD	0

;
; Assign the channel.
;

	$ASSIGN_S -			; Assign the device to a process
		DEVNAM=device_desc,-	; I/O channel. Specify device
		CHAN=channel_index	; name and location for channel
					; index.
	BLBC	R0,exit			; Exit on error.

;
; Create a loop counter, and go through a loop that issues ten receives
; and transmits.
;

	MOVL	#10,R5			; Set up loop counter.

LOOP:

;
; Issue a receive QIO request.
;

	$QIOW_S	CHAN=channel_index,-	; Specify a channel index number
		FUNC=#IO$_READPBLK,-	; a read function code, and
		IOSB=io_stat_block,-	; an I/O status block.
		P1=receive_buffer,-	; Parameters are the address of
		P2=#receive_length	; a buffer and its length.
	BLBC	R0,exit			; Exit on error.
	BLBC	io_stat_block,exit	; Exit on error.

;
; Issue a transmit QIO request.
;

	$QIOW_S	CHAN=channel_index,-	; Specify a channel index number
		FUNC=#IO$_WRITEPBLK,-	; a write function code, and
		IOSB=io_stat_block,-	; an I/O status block.
		P1=transmit_buffer,-	; Parameters are the address of
		P2=#transmit_length	; a buffer and its length.
	BLBC	R0,exit			; Exit on error.
	BLBC	io_stat_block,exit	; Exit on error.

;
; See whether the loop should continue.
;

	SOBGTR	R5,LOOP			; If 10 iterations have not yet
					; occurred, do another.

;
; Return with a success code.
;

	MOVZWL	#SS$_NORMAL,R0		; Load success status into R0.

;
; Return to caller.
;

exit:					; Error and success exit path.
	RET				; Return.

	.END	START
