/ 
/ 
/                   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 #10
/
/ COPYRIGHT 1970,1971 DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/ MCR FUNCTION -- RUN 	14 APR 71	R. MCLEAN
/
/ TASK NAME "...RUN"  TO RUN A TASK IN TERMS OF A DELTA TIME
/ FROM NOW, WITH OPTIONAL RESCHEDULING, AND OPTIONAL RUN
/ PRIORITY SPECIFICATION.
/
/ THE FIRST LINE OF THE COMMAND INPUT FOR ANY MCR
/ FUNCTION IS READ BY THE RESIDENT MCR TASK ("...MCR").
/ FOR THE "RUN" FUNCTION, THERE IS ONLY ONE LINE OF 
/ COMMAND INPUT, AND IT'S SYNTAX IS AS FOLLOWS:
/
/	SYNTAX = 'RUN'$<NBC><BREAK CHAR><TASK NAME>
/		<BREAK CHAR><DELTA TIME>
/		(<BREAK CHAR><RESCHEDULE>/NUL)
/		(<BREAK CHAR><PRIORITY>/NUL)(<CR>/AM>)
/
/	<BREAK CHAR> = " "/","
/	<TASK NAME> = 1-6 ALPHANUMERIC CHARACTERS
/	<DELTA TIME> = <DV>("H"/"M"/"S"/"T")
/	<RESCHEDULE> = <DV>("H"/"M"/"S"/"T")
/	<PRIORITY> = <DV>
/		<DV> = DECIMAL VALUE
/	<CR> = CAR RTN
/	<AM> = ALTMODE
/	<NBC> = NON BREAK CHARACTER
/	$ -- "ANY NUMBER OF, INCLUDING ZERO"
/	NUL -- THE EMPTY SET
/
/ THE RESIDENT MCR READS A LINE, FETCHES THE 
/ FIRST THREE CHARACTERS TO FORM THE MCR FUNCTION TASK
/ NAME ("...RUN"), FLUSHES CHARACTERS THRU THE FIRST
/ BREAK CHARACTER, REQUESTS "...RUN" , AND EXITS
/ THE TASK "...RUN" PROCESSES THE REMAINDER OF THE LINE
/ AND IF THE REQUEST IS VALID, ISSUES AN APPROPRIATE "RUN"
/ DIRECITVE
/
/ IF THE COMMAND INPUT LINE IS TERMINATED BY A CAR RTN.
/ THE RESIDENT MCR TASK IS REQUESTED, AND THE FUNCTION TASK EXITS.
/
/ IF THE COMMAND INPUT LINE IS TERMINATED BY AN ALTMODE, THE
/ FUNCTION TASK EXITS WITHOUT REQUESTING "...MCR". A ^C TYPEIN
/ IS THEN NECESSARY TO RE-ESTABLISH MCR DIALOGUE.
/
 .TITLE *** MCR FUNCTION 'RUN'
/
MCRRI=171
FAC=174
X10=10
/
RUN	LAW	-7	/SET UP TO FETCH TASK NAME AND STORE
	DAC	CNT	/SIX CHARACTERS (ZERO RIGHT FILL) IN
	LAC	(RUNCPB+1)	/ RUN CAL PARAMETER BLOCK
	DAC*	(X10)
RUNN1	JMS*	(FAC)	/FETCH A CHARACTER
	SAD	(054)	/IS IT A , ?
	JMP	RUNN2	/YES -- ZERO REMAINING CHARACTERS
	SAD	(040)	/NO -- IS IT A BLANK?
	JMP	RUNN2	/YES -- ZERO REMAINING CHARACTERS
	SAD	(015)	/NO -- IS IT A CAR RTN?
	JMP	ERR1	/YES -- ERROR
	SAD	(175)	/NO -- IS IT AN ALTMODE?
	JMP	ERR1	/YES -- ERROR
	DAC*	X10	/OK -- STORE CHARACTER
	ISZ	CNT	/ARE THERE 7 CHARACTERS IN NAME
	JMP	RUNN1	/NO -- FETCH ANOTHER
/
ERR1	JMS	TYPE	/YES -- SYNTAX ERROR
	MES1
	JMP	ABTEXT	/EXIT AND CALL MCR
/
RUNN2	DZM*	X10	/CLEAR THE REST OF THE TASK NAME
	ISZ	CNT	
	JMP	RUNN2
/
	LAC	RUNCPB+4	/FORM TASK NAME FOR RUN CPB
	LRS	6
	LAC	RUNCPB+3
	LRS	6
	LAC	RUNCPB+2
	LLS	14
	DAC	RUNCPB+2	/STORE FIRST HALF
	LAC	RUNCPB+7	/FORM SECOND HALF
	DZM	RUNCPB+7	/CLEAR WORD FOR OPTIONAL PARAMETERS
	LRS	6
	LAC	RUNCPB+6
	DZM	RUNCPB+6
	LRS	6
	LAC	RUNCPB+5
	DZM	RUNCPB+5
	LLS	14
	DAC	RUNCPB+3	/STORE SECOND HALF
	LAC	(RUNCPB+5)	/INTERVAL POINTER
	DAC	INTPNT	/SAVE FOR STINT
	JMS	FETCHN	/FETCH A NUMBER AND A LETTER, NUMBER IS IN B1 LETTER IS IN AC
	ISZ	CNT	/IS LETTER A CAR RTN OR ALTMODE?
	JMP	ERR1	/ YES-- ERROR
	JMS	STINT	/DECODE AND STORE INTERVAL H,M,S,T
	LAC	B1	/PICK UP INTERVAL TIME
	DAC	RUNCPB+4	/STORE IT IN RUN CPB
	LAC	(RUNCPB+7)	/SET UP FOR OPTIONAL INTERVAL POINTER
	DAC	INTPNT	/SAVE FOR STINT
	JMS	FETBK	/REMOVE BREAK CHARACTER
	JMS	FETCHN	/GET NEXT NUMBER AND LETTER COMBINATION
	ISZ	CNT	/IS LETTER A CAR RTN OR ALTMODE?
	JMP	RUNEXT	/YES -- NO  RESCHEDULE
	JMS	STINT	/DECODE THE RESCHEDULE INTERVAL
	LAC	B1	/PICK UP NUMBER OF INTERVALS
	SNA		/ZERO IS NOT LEGAL
	JMP	ERR1
	DAC	RUNCPB+6	/STORE IT IN RUN CPB
	JMS	FETBK	/REMOVE BREAK CHARACTER
	JMS	FETCHN	/FETCH PRIORITY
	ISZ	CNT	/IS BREAK CHARACTER AN ALTMODE OR CAR RTN?
	SKP		/YES-- CHECK FOR PRIORITY
	JMP	ERR1	/NO -- SYNTAX ERROR
RUNEXT	DAC	BRKCH	/SAVE BREAK CHARACTER AM, OR CAR RTN
	LAW	-1001	/YES -- CHECK VALIDITY OF PRIORITY
	TAD	B1	/IS IT GREATER THAN
	SMA	/512?
	JMP	ERR1	/YES -- SYNTAX ERROR
	LAC	B1	/CHECK LOWER LIMIT
	AAC	-1	/IS IT LOWER THAN 1
	SPA
	JMP	ERR1	/YES -- SYNTAX ERROR
	LAC	B1	/FETCH NUMBER
	DAC	RUNCPB+10	/PUT PRIORITY IN RUN CPB
RUNPRI	CAL	RUNCPB	/ISSUE RUN DIRECTIVE
	CAL	WAITEV	/WAIT FOR DIRECTIVE TO COMPLETE
	LAC	EV	/PICK UP EVENT VARIABLE
	SMA		/WAS THERE AN ERROR?
	JMP	RUNOK	/NO -- CONTINUE
	SAD	(-201)	/TASK NOT IN SYSTEM
	JMP	MESA	/GO PRINT ERROR MESSAGE
	SAD	(-204)	/IS TASK DISABLED?
	JMP	MESB	/YES PRINT DISABLED MESSAGE
	SAD	(-212	/PARTITION  LOST?
	JMP	MESC
	JMS	TYPE	/EMPTY POOL ERROR
	MES2
	JMP	ABTEXT	/ABNORMAL TERMINATION EXIT
MESA	JMS	TYPE	/NO PRINT EMPTY POOL ERROR
	MES3
	JMP	ABTEXT
MESB	JMS	TYPE	/PRINT TASK DISABLED MESSAGE
	MES4
	JMP	ABTEXT
MESC	JMS	TYPE
	MES5
	JMP	ABTEXT
RUNOK	LAC	BRKCH	/GET TERMINATOR CHARACTER
	SAD	(015)	/WAS IT A CAR RTN?
ABTEXT	CAL	REQMCR	/REQUEST ... MCR
	SAD	(175)	/WAS IT AN ALTMODE?
	DZM*	(MCRRI)	/YES CLEAR ^C INHIBIT SWITCH
	CAL	(10)	/EXIT
/
/ FETBK - REMOVES A BREAK CHARACTER AND CHECKS FOR  A CAR RTN
/          OR ALTMODE.  IF A CAR RTN OR ALTMODE IS FOUND RETURN
/           TO RUNPRI TO REQUEST FUNCTION.
/
FETBK	0
	DZM	B1	/CLEAR B1 TO SHOW NO NUMBER HAS BEEN READ
	JMS*	(FAC)
	SAD	(040)	/IS IT A BLANK
	JMP*	FETBK	/YES EXIT
	SAD	(054)	/IS IT A ,
	JMP*	FETBK	/YES, EXIT
	SAD	(15)	/IS IT AN ALTMODE?
	JMP	FETCR	/YES EXIT
	SAD	(175)	/IS IT AN ALTMODE?
	SKP
	JMP	ERR1	/NO SYNTAX ERROR
FETCR	DAC	BRKCH	/SAVE BREAK CHARACTER FOR EXIT
	JMP	RUNPRI	/GO EXECUTE RUN DIRECTIVE
/
/FETCHN -- FETCHES A NUMBER PLACES IT IN B1 THEN FETCHES A
/   LETTER OR CAR RTN OR ALTMODE AND EXITS.  CNT IS SET TO
/   ZERO IF A NUMBER IS FOUND
/
FETCHN	0
	DZM	CNT
	DZM	B1	/RESET B1
FETGET	JMS*	(FAC)	/CLEAR THE LINK FOR MUL
	CLL		/FETCH A CHARACTER
	SAD	(015)	/IS IT A CAR RTN?
	JMP*	FETCHN	/YES -- EXIT
	SAD	(175)	/IS IT AN ALTMODE?
	JMP*	FETCHN	/YES -- EXIT
	DAC	B2	/NO SAVE I, IT MAY BE A NUMBER
	AAC	-60	/SUBTRACT AN ASCII 0
	SPA		/IS IT GREATER OR EQUAL TO 0
	JMP	FETCXT	/NO IT MUST BE A LETTER
	AAC	-12	/SUBTRACT 10 TO SEE IF IT IS IN THE RANGE 0-9
	SMA		/IS IT A NUMBER?
	JMP	FETCXT	/NO IT MUST BE A LETTER
	AAC	12	/RESTORE 9
	DAC	B2	/SAVE NUMBER
	LAC	B1	/GET PREVIOUS NUMBER
	MUL		/MULTIPLY IT BY 10
	12
	SZA		/IS THERE OVERFLOW OF ONE WORD?
	JMP	ERR1	/YES SYNTAX ERROR
	LACQ
	TAD	B2
	DAC	B1	/SAVE NEW NUMBER
	JMP	FETGET	/FETCH NEXT CHARACTER
/
FETCXT	LAW	-1	/CLEAR ALTMODE OR CAR RTN SWITCH
	DAC	CNT
	LAC	B2	/GET LETTER
	JMP*	FETCHN	/EXIT
/
/ STINT -- DECODES INTERVAL LETTER AND INCREMENTS INTPNT
/          IT EXITS IF THE LETTER IS NOT LEGAL
/
STINT	0
	SAD	(110)	/"H"
	JMP	RUNRH
	SAD	(115)	/"M"
	JMP	RUNRM
	SAD	(123)	/"S"
	JMP	RUNRS
	SAD	(124)	/"T"
	JMP	RUNRT
	JMP	ERR1	/SYNTAX ERROR
RUNRH	ISZ*	INTPNT
RUNRM	ISZ*	INTPNT
RUNRS	ISZ*	INTPNT
RUNRT	ISZ*	INTPNT
	JMP*	STINT	/RETURN
/
/ TYPE -- SUBROUTINE TO TYPE THE MESSAGE WHOSE ADDRESS FOLLOWS THE JMS
/
TYPE	0
	LAC*	TYPE
	DAC	TYPCPB+4	/STORE ADDRESS OF MESSAGE
	ISZ	TYPE	/INCREMENT RETURN ADDRESS
/
	CAL	TYPCPB	/MAKE TYPE CPB REQUEST
/
	CAL	WAITEV	/WAIT FOR MESSAGE TO BE TYPED
	JMP*	TYPE	/RETURN
/
TYPCPB	2700
	EV
	3
	2
	0
/
WAITEV	20
	EV	/EVENT VARIABLE ADDRESS FOR WAITFOR
/
REQMCR	1		/REQUEST ...MCR CPB
	0
	.SIXBT	"...MCR"
	0
/
RUNCPB	3	/FUNCTION
	EV	/EVENT VARIABLE
	0	/TASK NAME (FIRST HALF)
	0	/TASK NAME (SECOND HALF)
	0	/SCHEDULE DELTA TIME
	0	/SCHEDULE UNITS
	0	/RESCHEDULE INTERVAL
	0	/INTERVAL UNITS
	0	/PRIORITY
/
MES1	2; 0; .ASCII	'RUN-SYNTAX ERR'<15>
MES2	2; 0; .ASCII	'RUN-EMPTY POOL'<15>
MES3	2; 0; .ASCII	'RUN-TASK NOT IN SYSTEM'<15>
MES4	2; 0; .ASCII	'RUN-TASK DISABLED'<15>
MES5	2; 0; .ASCII	"RUN-PART LOST"<15>
EV	0
CNT	0
BRKCH	0
INTPNT	0
B1	0
B2	0
	.END	RUN
