	.TITLE	DCTEST
/
/  20 JUN 77 (005; PDH) ANNOUNCE EXIT MESSAGE
/  16 JUN 77 (003; PDH) CHANGE TO 'TIME' INTERVALS
/  15 JUN 77 (002; PDH) CHANGE TO INTERVALS OF 2 SECONDS
/  15 JUN 77 - PAUL HENDERSON
/
/  PROGRAM TO VERIFY THE ACTION OF THE DATA CHANNEL DEVICE, MAKING USE OF
/  A SEPARATE TASK WHICH IS SIMULATING THE ACTION OF AN EXTERNAL DEVICE.
/  THE TASK ALTERNATELY RECORDS A BLOCK OF 128 WORDS, THEN REPLAYS THE DATA.
/  THE DATA IS SUPPLIED BY THIS PROGRAM (WRITE OR PUT) ON ODD INTERVALS OF
/  TWO SECONDS, AND IS READ BACK (ALSO BY THIS PROGRAM) ON EVEN INTERVALS.
/  THIS PROGRAM IS ARANGED SO THAT IT ALWAYS BEGINS WITH A 'WRITE'.
/
/  THE PROGRAM DOES THE FOLLOWING:
/
/	1. 'MARK' TIME FOR 1 SECOND
/	2. ISSUE 'DATE' TO FIND OUT IF ODD OR EVEN INTERVAL
/	3. IF (ODD SECOND) THEN 4; ELSE 1
/	4. DO: FOR INDEX=1,20
/	5.   GENERATE DATA, WRITE
/	6.   READ, COMPARE DATA
/	7. ENDO
/	8. EXIT
/
	.DEC
DC=27		/ ARBITRARY LUN
	.OCT
INC=ISZ
TIME=10		/ 8 SECOND INTERVALS
/
DCTEST	JMS	FILL		/ PRE-FILL WRITE BUFFER
	LAW	-4
	DAC	INDEX		/ 20 TRANSFERS, THEN QUIT
	SNAP	0,0,WBUF,WBUF+177	/ LOOK AT WRITE BUFFER
/
DCT2	CAL	MARK1T
	CAL	WAITFR
	CAL	DATE
	LAC	SECOND
	AND	(TIME*2-1
	SAD	(TIME
	JMP	DCT2		/ NEVER BEGIN DURING A 'TIME' INTERVAL
/
EVEN	CAL	MARK1T
	CAL	WAITFR
	CAL	DATE
	LAC	SECOND
	AND	(TIME
	SZA
	JMP	WRITE		/ BEGIN OPERATION ON ODD INTERVAL
	JMP	EVEN
/
DCLOOP	JMS	FILL		/ FILL WRITE BUFFER WITH PATTERN
WRITE	CAL	DCPUT
	CAL	WAITFR
	SNAP	1,0,EV,EV	/ LOOK AT EVENT VARIABLE
/
/  READ BLOCK OF DATA, THEN COMPARE IT AGAINST PATTERN WRITTEN PREVIOUSLY.
/
READ	LAC	(200
	DAC	RCTBL+1		/ INITIALIZE WORD COUNT IN CONTROL TABLE
	CAL	DCGET
	CAL	WAITFR
	LAC	RCTBL+1		/ USE ACTUAL WORD COUNT
	PAL
	CLX
	DZM	ERRORS		/ ZERO ERROR COUNTER
COMPARE	LAC	RBUF,X
	SAD	WBUF,X
	SKP
	INC	ERRORS		/ COUNT NUMBER OF DATA ERRORS
	AXS	1
	JMP	COMPARE
/
	SNAP	2,0,WBUF,EV	/ DUMP OUT BOTH BUFFERS
/
	ISZ	INDEX
	JMP	DCLOOP
	CAL	WRMCR
	CAL	WAITFR
	CAL	(10		/ EXIT WHEN FINISHED
/
/  SUBROUTINE TO FILL THE 'WRITE' BUFFER WITH A RANDOM DATA PATTERN
/
FILL	XX
	CAL	DATE		/ GENERATE NEW 'SECOND' VARIABLE
	LAC	(200
	PAL
	CLX
	LAC	(525252		/ BEGIN WITH A CONSTANT
F1	TAD	SECOND		/ ADD A VARIABLE
	.DEC
	TAD	(1013		/ PLUS A PRIME NUMBER
	.OCT
	RAL			/ THEN MIX IT UP A LITTLE
	DAC	WBUF,X
	AXS	1
	JMP	F1
	JMP*	FILL
/
WBUF	.BLOCK	200
RBUF	.BLOCK	200
RCTBL	RBUF;	200
ERRORS;EV;INDEX
WCTBL	WBUF;	200
MARK1T	13;	EV; 1; 1	/ 1 TICK
WAITFR	20;	EV
DATE	24;	0; .BLOCK 5;SECOND
DCPUT	3100;	EV;	DC;	WCTBL
DCGET	3000;	EV;	DC;	RCTBL
WRMCR	2700;	EV;	3; 2; XITMSG
XITMSG	5002; 0; .ASCII '"DCTEST" HAS EXITTED'<15>
	.END	DCTEST
