/ 
/ 
/                   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 #7
/
/ COPYRIGHT 1973 DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/ MCR FUNCTION -- EXECUTE	16 OCT 73	M. HEBENSTREIT
/
/ TASK NAME  "...XQT"   TO EXECUTE A TASK WITH OPTIONAL
/ RUN PRIORITY AND PARTITION SPECIFICATION.
/
/ THE COMMAND STRING IS AS FOLLOWS:
/ 
/	MCR>XQT TSKNAM LUN (PARTITION) (PRIORITY)$
/ 
/	WHERE ARGUMENTS IN PARENTHESIS ARE OPTIONAL AND $ INDICATES
/	A LINE TERMINATOR.
/ 
 .TITLE *** MCR FUNCTION 'EXECUTE'
/
MCRRI=171
FAC=174
IDX=ISZ
X10=10
/
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	REQ1	/YES -- THEN THERE SHOULD BE MORE DATA
	SAD	(15	/NO -- CARRIAGE RETURN?
	SKP		/YES
	SAD	(175	/NO -- ALTMODE?
	SKP
	JMP	ERR1	/NO -- ERROR
	JMP	EXT1	/YES -- GO EXECUTE THE TASK
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	ERR1	/RETURN HERE ON AN ERROR
	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
/ 
ERR1	JMS	TYPE
	MES2
	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			/IF 1ST CHAR NOT IN AC CLA!
/		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 THE AC TEMPORARILY
	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 1ST CHAR IN 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	REQCPB	/ISSUE THE EXECUTE DIRECTIVE
	CAL	WAITEV
	LAC	EV
	SMA		/ANY ERRORS?
	JMP	EXT1A	/NO
	SAD	(-201	/TASK NOT IN SYSTEM
	JMP	MESA
	SAD	(-202	/TASK ACTIVE
	JMP	EXT1A
	SAD	(-204	/TASK DISABLED
	JMP	MESC
	SAD	(-212	/PARTITION LOST
	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	/GET TERMINATION CHARACTER
	SAD	(15)	/SKIP IF ALTMODE
	JMP	EXT2
	DZM*	(MCRRI
	CAL	(10
EXT2	CAL	REQMCR
	CAL	(10
/
REQMCR	1		/CALL MCR DIRECTIVE
	0
	.SIXBT	"..."
	.SIXBT	"MCR"
	0
REQCPB	34	/FUNCTION CODE
	EV	/EVENT VARIABLE ADR
	0	/TASK NAME (FIRST HALF)
	0	/TASK NAME (SECOND HALF)
	0	/PRIORITY
	0	/LUN
	0	/PARTITION NAME (FIRST HALF)
	0	/PARTITION NAME (SECOND HALF)
/
/	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
	3
	2
	XX
EV	0
/
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>
/
SVBKCH	0
COUNT	0
CHAR	0
NUM	0
NUMT	0
NUMFLG	0
SAVAC	0
TABLE	.BLOCK 6
	.END	REQ
