	.TITLE  SUPERVISOR
	.IODEV 1,2,3		/ASSIGN TTA TO DAT 1, LT1 TO DAT 2, LT2 TO DAT 3.
	.GLOBL SEMA1,SEMA2,SEMA3,SAVE1,SAVE2,SAVE3
	.GLOBL	PS,SEMA,SUPER,COUNT,STOR1
PS	XX
	DAC	SPOT	/INCREMENT WAIT-LIST SEMAPHORE
	ISZ*	SPOT
	SKP
	JMP*	PS	/SEMAPHORE WAS -1
	ISZ	SPOT	/GET WAIT-LIST ADDRESS
PS1	LAC	READY	/FIND DEVICE SAVE ADDRESS
	SZA
	JMS	DEC
	XCT*	PS	/IF READY-LIST EMPTY
	DAC	SPOT
	DZM*	SPOT	/MARK END OF CHAIN
	ISZ	SPOT
	LAC	PS	/SAVE RETURN ADDRESS
	DAC*	SPOT
	ISZ	SPOT
	LACQ		/SAVE MQ
	DAC*	SPOT
	ISZ	SPOT
	LAC*	(AUTO10	/SAVE AUTOINDEX REGISTERS
	DAC*	SPOT
	ISZ	SPOT
	LAC*	(AUTO11
	DAC*	SPOT
	ISZ	SPOT
	LAC*	(AUTO12
	DAC*	SPOT
	ISZ	SPOT
	LAC*	(AUTO13
	DAC*	SPOT
	ISZ	SPOT
	LAC*	(AUTO14
	DAC*	SPOT
	ISZ	SPOT
	LAC*	(AUTO15
	DAC*	SPOT
	ISZ	SPOT
	LAC*	(AUTO16
	DAC*	SPOT
	ISZ	SPOT
	LAC*	(AUTO17
	DAC*	SPOT
	LAC*	COUNT	/CHECK FOR COMPLETION OF INITIALIZATION
	SNA
	JMP	PSINC
	JMP	SUPER
PSINC	ISZ	PS
	ISZ	PS	/FIND RETURN ADDRESS IF COUNT 0
	JMP*	PS
SUPER	LAC	READY	/CHECK READY-LIST
	SNA
	JMP	SCAN	/READY-LIST EMPTY
	DAC*	(AUTO17	/RESTORE SAVED BUFFER
	LAC*	(AUTO17	/RESTORE ROUTINE
	DAC	SPOT
	JMS	INC
	DAC	PS	/RESTORE RETURN ADDRESS,
	RAL		/LINK,
	JMS	INC
	LMQ		/MQ,
	JMS	INC
	DAC*	(AUTO10	/AND AUTOINDEX REGISTERS.
	JMS	INC
	DAC*	(AUTO11
	JMS	INC
	DAC*	(AUTO12
	JMS	INC
	DAC*	(AUTO13
	JMS	INC
	DAC*	(AUTO14
	JMS	INC
	DAC*	(AUTO15
	JMS	INC
	DAC*	(AUTO16
	JMS	INC
	DAC*	(AUTO17
	JMP*	PS	/RETURN
INC	0		/INCREMENT SAVE AREA ROUTINE
	ISZ	SPOT
	LAC*	SPOT
	JMP*	INC
SCAN	LAC	SEMA1	/CHECK SEMAPHORE FOR DEVICE 1
	SPA
	JMP	SC1	/DEVICE 1 NOT USED
	.WAITR	1,SC1	/CHECK READY STATUS
	LAC	(SAVE1	/GET SAVE AREA ADDRESS
	JMS	VS
SC1	LAC	SEMA2	/CHECK DEVICE 2
	SPA
	JMP	SC2
	.WAITR	2,SC2
	LAC	(SAVE2
	JMS	VS
SC2	LAC	SEMA3	/CHECK DEVICE 3
	SPA
	JMP	SC3
	.WAITR	3,SC3
	LAC	(SAVE3
	JMS	VS
SC3	JMP	SUPER	/RECYCLE SUPERVISOR
DEC	0		/DECREMENT READY-LIST
	LAC*	READY
	DAC	READY
	JMP*	DEC
VS	XX
	DAC	BOX1	/GET SAVE AREA
	LAC	(SEMA	/DECREMENT WAIT-LIST SEMAPHORE
	DAC	SPOT
	LAW	-1
	TAD*	SPOT
	DAC*	SPOT
	SPA
	JMP*	VS	/NO DEVICE WAITING
	ISZ	SPOT
	LAC	SPOT
VS1	DAC	BOX	/FIND END OF WAIT-LIST
	LAC*	BOX
	SZA
	JMP	VS1
	LAC	BOX1	/CHAIN WAIT-LIST
	DAC*	BOX
	DZM*	BOX1
	LAC*	SPOT
	DAC	BOX
	LAC*	BOX
	DAC*	SPOT
	LAC	(READY	/GET READY-LIST
VS2	DAC	SPOT
	LAC*	SPOT	/FIND END OF READY-LIST
	SZA
	JMP	VS2
	LAC	BOX	/CHAIN READY-LIST
	DAC*	SPOT
	DZM*	BOX
	JMP*	VS	/RETURN
SPOT	0
BOX	0
BOX1	0
CMASK	007777
SEMA1	-1		
SEMA2	-1
SEMA3	-1
SEMA	-1; 0		/WAIT-LIST
READY	0		/READY-LIST
SAVE1	0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0
SAVE11	.BLOCK	40
SAVE12	1
SAVE13	2001
SAVE14	3001
SAVE15	1001
SAVE16	.BLOCK	755
SAVE2	0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0
SAVE22	.BLOCK	40
SAVE23	2
SAVE24	2002
SAVE25	3002
SAVE26	1002
SAVE27	.BLOCK	755
SAVE3	0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0
SAVE33	.BLOCK	40
SAVE34	3
SAVE35	2003
SAVE36	3003
SAVE37	1003
SAVE38	.BLOCK	755
AUTO10=10
AUTO11=11
AUTO12=12
AUTO13=13
AUTO14=14
AUTO15=15
AUTO16=16
AUTO17=17
G.MOVE	XX		/MOVE ROUTINE	/THIS ROUTINE NOT USED
	DAC	MOVES
	LAW	-1
	XCT*	G.MOVE
	DAC*	(AUTO10
	ISZ	G.MOVE
	LAW	-1
	XCT*	G.MOVE
	DAC*	(AUTO11
	ISZ	G.MOVE
	LAC*	AUTO10
	DAC*	AUTO11
	ISZ	MOVES
	JMP	.-3
	JMP*	G.MOVE
MOVES	XX
	.END
