/ 
/ 
/                   FIRST PRINTING, FEBRUARY 1974
/ 
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
/ CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
/ AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
/ SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
/ DOCUMENT.
/ 
/ THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
/ NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
/ A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
/ INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
/ USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
/ VIDED IN WRITING BY DIGITAL.
/ 
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/ FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
/ MENT THAT IS NOT SUPPLIED BY DIGITAL.
/ 
/ COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/ EDIT #11
/
/ COPYRIGHT 1973 DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/ TDV FUNCTION -- EXECUTE FOR BATCH	16 JAN 74	M. HEBENSTREIT
/
/ TASK NAME  "XQT..."   TO EXECUTE A TASK WITH OPTIONAL
/ RUN PRIORITY AND PARTITION SPECIFICATION.
/
/ THE COMMAND STRING IS AS FOLLOWS:
/
/	TDV>XQT TSKNAM LUN (PARTITION) (PRIORITY)$
/ 
/ 	WHERE ARGUMENTS IN PARENTHESIS ARE OPTIONAL AND $ IS A TERMINATOR
/
/
 .TITLE *** TDV FUNCTION 'EXECUTE' ***
/
X10=10
IDX=ISZ
/
BEGIN	CAL	RDTDV	/READ THE TDV BUFFER
	LAC	EV
	SPA
	JMP	ERR2	/READ WAS NO GOOD -- ERROR
	JMS	FAC	/LOOK FOR THE 1ST SPACE
	SAD	(40	/SPACE?
	JMP	REQ	/YES -- DECODE THE LINE
	SAD	(15	/NO -- CARRIAGE RETURN?
	JMP	ERR1	/YES -- FORMAT ERROR
	SAD	(175	/NO -- ALTMODE?
	JMP	ERR1	/YES -- ERROR
	JMP	.-7	/NO -- READ ANOTHER CHAR
/ 
REQ	CLA		/CLEAR AC AS A FLAG TO 'NAME'
	JMS	NAME	/GET THE TASK NAME
	JMP	ERR1	/RETURN HERE ON AN ERROR
	DAC	REQCPB+2	/RETURN HERE IF OK -- STORE THE NAME
	LACQ
	DAC	REQCPB+3
	PLA		/GET THE BREAK CHARACTER
	SAD	(40	/WAS IT A SPACE?
	SKP
	JMP	ERR1	/NO -- FORMAT ERROR
	CLA		/YES -- CLEAR AC AS A FLAG TO 'NUMBER'
	JMS	NUMBER	/GO GET A LUN
	JMP	ERR1	/RETURN HERE ON AN ERROR
	DAC	SVBKCH	/SAVE THE BREAK CHAR
	LACQ		/GET LUN INTO AC
	DAC	REQCPB+5
	LAC	SVBKCH	/EXAMINE THE BREAK CHAR
	SAD	(40	/SPACE?
	JMP	CD1	/YES -- THEN THERE MAY BE MORE DATA
CD2	SAD	(15	/NO -- CARRIAGE RETURN?
	SKP		/YES
	SAD	(175	/NO -- ALTMODE?
	SKP
	JMP	REQ1+1	/NO -- MUST BE DATA
	JMP	EXT1	/YES -- GO EXECUTE THE TASK
CD1	JMS	FAC	/LOOK FOR THE 1ST NON-SPACE
	SAD	(40
	JMP	.-2
	DAC	SVBKCH	/SAVE THE CHAR.
	JMP	CD2	/CHECK FOR THE END-OF-LINE
REQ1	CLA		/CLEAR AC AS A FLAG FOR 'NAME'
	JMS	NAME	/TRY TO GET A PARTITION NAME
	JMP	REQ2	/RETURN HERE ON POSSIBLE ERROR -- MAYBE TTY
			/INPUT WAS REALLY A PRIORITY.
	DAC	REQCPB+6	/RETURN HERE IF OK -- SAVE PART. NAME
	LACQ
	DAC	REQCPB+7
	PLA		/PICK UP THE BREAK CHAR
	SAD	(40	/SPACE?
	JMP	REQ2-1	/YES -- THERE MUST BE A PRIORITY GIVEN
	SAD	(15	/NO -- CARRIAGE RETURN?
	SKP		/YES
	SAD	(175	/NO -- ALTMODE?
	SKP
	JMP	ERR1	/NO -- FORMAT ERROR
	DAC	SVBKCH	/YES -- SAVE THE BREAK CHARACTER
	JMP	EXT1	/GO EXECUTE THE TASK
/ 
	CLA		/CLEAR AC AS A FLAG TO 'NUMBER'
REQ2	JMS	NUMBER	/GO GET A PRIORITY
	JMP	CDERR	/RETURN HERE ON AN ERROR OR NO DATA
	DAC	SVBKCH	/SAVE THE BREAK CHAR
	LACQ		/GET THE NUMBER INTO THE AC
	AAC	-1	/TEST THAT 1<PRIORITY<=512
	SPA
	JMP	ERR1
	LACQ
	TAD	(-1001
	SMA
	JMP	ERR1
	LACQ		/NUMBER IS OK SO SAVE IT
	DAC	REQCPB+4
	LAC	SVBKCH	/LOOK FOR THE LINE TERMINATOR
	SAD	(175
	SKP
	SAD	(15
	SKP
	JMP	ERR1
	JMP	EXT1	/GO 'EXECUTE' THE TASK
CDERR	SAD	(15	/CHECK FOR NO DATA
	SKP
	SAD	(175
	SKP
	JMP	ERR1	/ERROR -- CHAR NOT A TERMIN.
	DAC	SVBKCH	/NO ERROR -- SAVE LINE TERM.
	JMP	EXT1
/ 
ERR1	JMS	TYPE
	MES2
	JMP	EXT2
/
ERR2	JMS	TYPE
	MES7
	JMP	EXT2
/
/ SUBROUTINE NUMBER -- READ A DECIMAL NUMBER OF UP TO 3 DIGITS
/			OFF THE MCR TTY.
/ 
/ ALTERED REGISTERS: AC AND MQ
/ 
/ CALLING SEQUENCE:
/		CLA			/CLA IF 1ST CHAR NOT IN AC
/		JMS	NUMBER
/		JMP	???	/RETURN HERE IF 1ST CHARACTER
/				/AFTER A BUNCH OF SPACES IS NOT
/				/A DECIMAL DIGIT WITH THE CHARACTER
/				/IN THE AC.
/		???	???	/RETURN HERE IF 1ST CHARACTER
/				/AFTER A BUNCH OF SPACES IS A DECIMAL
/				/DIGIT WITH THE BREAK CHARACTER IN THE
/				/AC AND THE NUMBER IN THE MQ.
/ 
NUMBER	0
	DAC	SAVAC		/SAVE AC TEMP
	LAW	-3		/SET DIGIT COUNTER
	DAC	COUNT
	DZM	NUM		/ZERO PREVIOUS RESULTS
	CLC			/SET A FLAG TO INDICATE THAT SPACES
	DAC	NUMFLG		/ARE NOT BREAK CHARACTERS YET.
	LAC	SAVAC		/WAS A CHAR IN THE AC ON ENTRY?
	SNA
NUM1	JMS*	(FAC		/GET A CHARACTER
	SAD	(40		/WAS THE CHARACTER A SPACE?
	JMP	NUMSPC		/YES
	DZM	NUMFLG		/NO -- CLEAR FLAG TO INDICATE THAT ANY
				/SPACES ENCOUNTERED SHOULD BE USED AS
				/BREAK CHARACTERS.
	DAC	NUMT		/SAVE IT TEMPORARILY
	AAC	-60		/IS IT A DIGIT?
	SPA
	JMP	NUM2		/NO -- EITHER A BREAK OR AN ERROR
	DAC	CHAR		/SAVE THE POTENTIAL DIGIT
	AAC	-12
	SMA
	JMP	NUM2		/NO -- EITHER A BREAK OR AN ERROR
	LAC	NUM		/YES -- PICK UP THE REAL NUMBER
				/THAT HAS ALREADY BEEN CONSTRUCTED
	CLL
	MUL			/MULTIPLY IT BY 10 DECIMAL
	12
	LACQ			/GET RESULT INTO AC
	TAD	CHAR		/ADD THE DIGIT JUST READ
	DAC	NUM		/SAVE THE RESULTING DECIMAL NUMBER
	ISZ	COUNT		/HAVE 3 DIGITS BEEN READ?
	JMP	NUM1		/NO -- READ SOME MORE
	JMS*	(FAC		/YES -- READ A BREAK CHARACTER
NUM3	DAC	CHAR		/SAVE THE CHARACTER TEMPORARILY
	IDX	NUMBER		/PREPARE TO RETURN AT JMS+2
	LAC	NUM		/PICK UP THE DECIMAL NUMBER
	LMQ			/STORE IT IN THE MQ
	LAC	CHAR		/GET THE BREAK CHAR INTO THE AC
	JMP*	NUMBER		/RETURN AT JMS+2
NUM2	LAW	-3		/CHARACTER IS EITHER A BREAK OR ERROR
	SAD	COUNT		/IF THIS WAS THE 1ST CHARACTER READ
				/ITS AN ERROR. OTHERWIZE ITS A BREAK.
	JMP	NUMERR		/ERROR
	LAC	NUMT		/BREAK -- GET THE CHARACTER INTO AC
	JMP	NUM3
NUMERR	LAC	NUMT		/ERROR SO GET CHARACTER INTO AC
	JMP*	NUMBER		/AND RETURN AT JMS+1
NUMSPC	LAC	NUMFLG		/CHAR. WAS A SPACE -- IS IT A BREAK CHAR.?
	SZA
	JMP	NUM1		/NO -- THE SPACE SHOULD BE IGNORED
	LAC	(40		/YES -- TREAT THE SPACE AS A BREAK CHAR.
	DAC	NUMT
	JMP	NUM2
/
/ SUBROUTINE NAME -- READ A NAME OF UP TO 6 CHARACTERS FOR THE TTY
/ 
/ CALLING SEQUENCE:
/		CLA		/OPTIONAL -- IF AC IS NON-ZERO ON
/				/ENTRY TO SUBROUTINE THE FIRST CHAR
/				/OF THE NAME IS ASSUMED TO BE IN AC
/		JMS	NAME
/		JMP	???	/RETURN HERE ON AN ERROR E.G. FIRST
/				/CHAR MUST NOT BE A NUMBER
/		???	???	/RETURN HERE IF OK -- AC HAS 1ST HALF
/				/OF NAME, MQ 2ND HALF AND BREAK CHAR
/				/IS IN THE LR.
/ 
NAME	0
	DAC	SAVAC	/SAVE THE AC
	LAW	-6	/SET UP COUNT OF CHAR
	DAC	COUNT
	CLC		/SET THE SPACE FLAG -- SPACES ARE NOT BREAKS YET
	DAC	NUMFLG
	DZM	TABLE	/CLEAR OUT THE 6 WORD CHAR TABLE
	DZM	TABLE+1
	DZM	TABLE+2
	DZM	TABLE+3
	DZM	TABLE+4
	DZM	TABLE+5
	LAC	(TABLE-1	/SET X10 TO ACCESS TABLE
	DAC*	(X10
	LAC	SAVAC	/PICK UP VALUE OF AC ON ENTRY
	SNA		/IF NON-ZERO DON'T READ 1ST CHAR
NAME1	JMS*	(FAC	/READ A CHAR
	SAD	(40	/SPACE?
	JMP	NAMESP	/YES -- SEE IF ITS A BREAK OR NOT
	DZM	NUMFLG	/CLEAR FLAG -- SPACES ARE NOW BREAKS
	DAC	CHAR	/SAVE THE CHAR
	LAC	COUNT	/IF THIS IS THE 1ST CHAR -- CHECK TO SEE THAT
	SAD	(-6	/ITS NOT A NUMBER
	SKP
	JMP	NAME2	/NOT THE 1ST CHAR
	LAC	CHAR	/1ST CHAR -- IS IT A DIGIT?
	AAC	-60
	SPA
	JMP	NAME2	/NO -- CONTINUE
	AAC	-12	/MAYBE -- LETS DO SOME MORE CHECKING
	SMA
	JMP	NAME2	/NO -- CONTINUE
NAMERR	LAC	CHAR	/YES -- ERROR, RETURN AT JMS+1 WITH CHAR IN AC
	JMP*	NAME
NAME2	LAC	CHAR
	SAD	(15	/IS CHAR A CARRIAGE RETURN?
	JMP	NAME4	/YES -- HANDLE TERMINATORS SPECIALLY
	SAD	(175	/NO -- ALTMODE?
	JMP	NAME4	/YES
	AND	(77
	DAC*	X10	/NO -- SAVE THE CHAR IN THE TABLE
	ISZ	COUNT	/HAVE WE LOOKED AT 6 CHARS?
	JMP	NAME1	/NO -- EXAMINE ANOTHER
	JMS*	(FAC	/YES -- READ A BREAK CHAR
NAME4	PAL		/SAVE THE BREAK CHAR
	CLL
	LAC	TABLE+3	/CONSTRUCT THE NAME IN SIXBIT
	ALS	14
	DAC	SAVAC
	LAC	TABLE+4
	ALS	6
	TAD	SAVAC
	TAD	TABLE+5
	LMQ		/SAVE 2ND HALF OF NAME IN MQ
	LAC	TABLE
	ALS	14
	DAC	SAVAC
	LAC	TABLE+1
	ALS	6
	TAD	SAVAC
	TAD	TABLE+2
	IDX	NAME	/PREPARE TO RETURN AT JMS+2
	JMP*	NAME
NAMESP	LAC	NUMFLG	/ARE SPACES BREAKS?
	SZA
	JMP	NAME1	/NO -- READ ANOTHER CHAR
	LAC	(40	/YES --THE SPACE IS A BREAK
	JMP	NAME4
/ 
EXT1	CAL	SPY	/FIND OUT IF BATCH IS RUNNING.
	LAC	SPY+3
	SZA
	JMP	EXT12	/BATCH IS RUNNING
	LAC	REQCPB+4 /BATCH ISN'T RUNNING -- WAS A PRIO GIVEN?
	SZA
	JMP	EXT13	/YES -- A PRIO GIVEN
	.DEC
	LAC	(401	/REQ TDC AT 401
	DAC	REQTDC+4
	JMP	EXT11	/GO EXECUTE THE TASK
EXT13	SAD	(512	/SET TDC'S PRIO
	SKP		/TO 1 MORE THAT PRIO GIVEN
	IAC		/IF POSSIBLE
	DAC	REQTDC+4
	JMP	EXT11	/GO EXECUTE THE TASK
EXT12	LAC	(400	/EXECUTE THE TASK AT 400 IN TDV PART.
	DAC	REQCPB+4
	IAC
	DAC	REQTDC+4 /AND TDC AT 401
	.OCT
	LAC	(240426
	DAC	REQCPB+6
	DAC	REQTDC+6
	DZM	REQCPB+7
	DZM	REQTDC+7
EXT11	CAL	REQCPB
	CAL	WAITEV
	LAC	EV	/GET EVENT VARIABLE
	SMA		/JUMP IF REJECTED
	JMP	EXT1A	/OK NO ERRORS
	SAD	(-201)	/TASK NOT IN SYSTEM ERROR
	JMP	MESA
	SAD	(-202)	/TASK ACTIVE
	JMP	EXT2
	SAD	(-204)	/TASK DISABLED
	JMP	MESC
	SAD	(-212	/PARTITION LOST THRU RECONF.
	JMP	MESB
	JMS	TYPE	/POOL EMPTY
	MES6
	JMP	EXT2
MESA	JMS	TYPE
	MES3
	JMP	EXT2
MESB	JMS	TYPE
	MES4
	JMP	EXT2
MESC	JMS	TYPE
	MES5
	JMP	EXT2
EXT1A	LAC	SVBKCH
	SAD	(15
	CAL	REQTDC	/EXECUTE TDC 
	CAL	(10)	/RETURN
EXT2	CAL	TDCREQ	/THERE WAS AN ERROR SO REQUEST TDC
	CAL	(10
/
REQTDC	34		/CALL TDC DIRECTIVE
	0
	.SIXBT	'TDC'
	.SIXBT	"@@@"
	0
	1
	0
	0
REQCPB	34	/FUNCTION CODE
	EV	/EVENT VARIABLE ADR
	0	/TASK NAME (FIRST HALF)
	0	/TASK NAME (SECOND HALF)
	0	/PRIO
	0	/LUN
	0	/PART.
	0	/NAME
TDCREQ	1
	0
	.SIXBT "TDC"
	.SIXBT "@@@"
	0
SPY	31
	0
	147
	0
	0	/PRIORITY
	0	/LUN
	0	/PARTITION NAME (FIRST HALF)
	0	/PARTITION NAME (SECOND HALF)
/
/	FAC -- SUBROUTINE TO FETCH A CHARACTER FROM 5/7 ASCII LINE BUFFER 'FACLB'.
/	CHARACTERS ARE NOT FETCHED BEYOND TERMINAL CHARACTERS
/
FAC	0
	LAC*	FACCBX	/FETCH NEXT UNPACKED CHARACTER FROM 'FACCB'
	SMA		/WAS CHARACTER BUFFER (FACCB) EMPTY?
	JMP	FAC2	/NO -- TEST FOR TERMINAL CHARACTER
	LAC	(FACCB-1)	/YES -- REFIL 'FACCB'
	DAC	FACCBX
	LAC*	FACLBX	/(FIRST HALF OF WORD PAIR)
	ISZ	FACLBX
	LMQ
	CLA!CLL
	JMS	FACUPS	/(FIRST CHAR)
	JMS	FACUPS	/(SECOND CHARACTER
	JMS	FACUPS	/(FIRST FOUR BITS OF THIRD CHARACTER)
	LAC*	FACLBX	/(SECOND HALF OF WORD PAIR)
	ISZ	FACLBX
	LRS	17	/(LAST THREE BITS OF THIRD CHAR)
	XOR*	FACCBX
	DAC*	FACCBX
	CLA
	JMS	FACUPS	/(FORTH CHAR)
	JMS	FACUPS	/(FIFTH CHAR)
	LAC	(FACCB)	/RESET CHAR BUF INDEX
	DAC	FACCBX
	LAC*	FACCBX	/FETCH FIRST CHAR FROM BUFFER
FAC2	SAD	(015)	/IF TERMINAL CHARACTER, (CR OR AM)
	JMP*	FAC	/RETURN WITH CHAR IN AC BUT DO NOT
	SAD	(175)	/AUGMENT CHAR BUF INDEX (REPEATED CHAR)
	JMP*	FAC	/OF FAC WILL RETURN THE TERMINAL CHARACTER)
/
	ISZ	FACCBX	/NON-TERMINAL CHARACTER -- AUGMENT CHARACTER
	JMP*	FAC	/BUFFER INDEX AND RETURN WITH CHAR IN AC
/
FACUPS	0		/UNPACKING SUBROUTINE -- AC & LINK MUST BE
	LLS	7	/CLEARED, NEXT CHAR MUST BE IN HIGH ORDER
	ISZ	FACCBX	/MQ, 'FACCBX' MUST POINT TO WORD PRECEEDING
	DAC*	FACCBX	/CHAR TO BE STORED.
	CLA		/CHAR IS SHIFTED INTO AC (LOW ORDER BITS
	JMP*	FACUPS	/OF THIRD CHAR ARE ZERO BECAUSE LINK IS
		/ZERO), STORED, 'FACCBX' IS LEFT POINTING TO 
		/CHAR, AND AC IS CLEARED (LINK IS ALSO LEFT CLEARED
FACLBX	FACLB+2	/LINE BUFFER INDEX
FACCBX	FACCB+5	/CHARACTER BUFFER INDEX
FACCB	.BLOCK	5	/CHARACTER BUFFER (5 IMAGE ALPHA CHARS)
	-1		/END OF 'FACCB' INDICATOR
/
FACLB	.BLOCK	22	/BUFFER FOR ASCII LINE
	.ASCII	<15>	/TERMINATOR IN CASE OF TRUNCATED LONG LINE
/
/	TYPE -- SUBROUTINE TO TYPE THE MESSAGE WHOSE ADDRESS FOLLOWS THE JMS
/
TYPE	0
	LAC*	TYPE
	DAC	TYPCPB+4
	ISZ	TYPE
/
	CAL	TYPCPB	/MAKE TYPE CPB REQUEST
/
	CAL	WAITEV	/WAIT FOR TTY TO FINISH
	JMP*	TYPE	/RETURN
/
WAITEV	20	/WAITFOR
	EV	/EVENT VARIABLE ADDRESS
/
TYPCPB	2700
	EV
	15
	2
	XX
EV	0
RDTDV	37	/READ TDV
	EV
	FACLB	/LINE BUFFER
	22	/SIZE OF BUFFER
/
MES2	2; 0; .ASCII	"EXE-SYNTAX ERR"<15>
MES3	2; 0; .ASCII	"EXE-TASK NOT IN SYSTEM"<15>
MES4	2; 0; .ASCII	"PARTITION LOST THRU RCF"<15>
MES5	2; 0; .ASCII	"EXE-TASK DISABLED"<15>
MES6	2; 0; .ASCII	"EXE-POOL EMPTY"<15>
MES7	MES8-MES7/2*1000+2
	0
	.ASCII	"EXE-TDV ERR"<15>
MES8=.
/
CHAR	0
COUNT	0
NUM	0
NUMFLG	0
NUMT	0
SAVAC	0
SVBKCH	0
TABLE	.BLOCK 6
	.END	BEGIN
