/ 
/ 
/                   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 #12
/
/ COPYRIGHT 1970,1971 DIGITAL EQUIPMENT CORP., MAYNARD MASS.
/
/ MCR FUNCTION -- SCHEDULE	14 APR 71	H. KREJCI
/
/ TASK NAME:  "...SCH"  TO SCHEDULE A TASK IN TERMS OF TIME OF
/ DAY (HH:MM:SS), WITH OPTIONAL RESCHEDULING, AND OPTIONAL RUN
/ PRIORITY SPECIFICATION.
/
/ THE FIRST LINE OF COMMAND INPUT FOR ANY MCR FUNCTION IS
/ READ BY THE RESIDENT MCR TASK ("...MCR").  FOR THE "SCHEDULE"
/ FUNCTION, THERE IS ONLY ONE LINE OF COMMAND INPUT, AND ITS
/ SYNTAX IS AS FOLLOWS:
/
/	SYNTAX = "SCH"$<NBC><BREAK CHAR><TASK NAME>
/		 <BREAK CHAR><TIME>
/		 (<BREAK CHAR><RESCHEDULE>/NUL)
/		 (<BREAK CHAR><PRIORITY>/NUL) (<CR>/<AM>)
/	    <BREAK CHAR> = " "/","
/	    <TASK NAME> = 1-6 ALPHANUMERIC CHARACTERS
/	    <TIME> = <DV>":"<DV>":"<DV>
/	    <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 ("...SCH"), FLUSHES CHARACTERS
/ THRU THE FIRST BREAK CHARACTER, REQUESTS  "...SCH",  AND EXITS.
/
/ THE TASK  "...SCH"  PROCESSES THE REMAINDER OF THE LINE AND, IF
/ REQUEST IS VALID, ISSUES AN APPROPRIATE "SCHEDULE" DIRECTIVE.
/
/ 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 'SCHEDULE'
/
MCRRI=171
FAC=174
X10=10
/
SCH	LAW	-7	/SETUP TO FETCH TASK NAME AND STORE
	DAC	CNT	/SIX CHARS (ZERO RIGHT FILL) IN
	LAC	(SCHCPB+1)  /SCHEDULE CPB.
	DAC*	(X10)
/
SCHN1	JMS*	(FAC)	/FETCH CHAR
	SAD	(054)	/COMMA?
	JMP	SCHN2	/YES -- ZERO REMAINING CHARS
	SAD	(040)	/NO -- BLANK?
	JMP	SCHN2	/YES -- ZERO REMAINING CHARS
	SAD	(015)	/NO -- CAR RTN?
	JMP	ERR1	/YES -- ERROR
	SAD	(175)	/NO -- ALTMODE?
	JMP	ERR1	/YES -- ERROR
	DAC*	X10	/NO -- STORE CHAR
	ISZ	CNT	/SEVENTH CHAR?
	JMP	SCHN1	/NO -- NEXT CHAR
	JMP	ERR1	/YES -- ERROR
/
SCHN2	DZM*	X10	/ZERO FILL REMAINING CHARACTERS
	ISZ	CNT
	JMP	SCHN2
/
	LAC	SCHCPB+4 /TASK NAME HAS BEEN FETCHED AND
	LRS	6	 /STORED IN 'SCHCPB+2' THRU 'SCHCPB+7'.
	LAC	SCHCPB+3 /PACK INTO TWO WORDS AND STORE IN
	LRS	6	 /'SCHCPB+2' & 'SCHCPB+3'.
	LAC	SCHCPB+2
	LLS	14
	DAC	SCHCPB+2
	LAC	SCHCPB+7
	LRS	6
	LAC	SCHCPB+6
	LRS	6
	LAC	SCHCPB+5
	LLS	14
	DAC	SCHCPB+3
/
	JMS	FNB	/FETCH HOURS & BREAK CHAR
	JMS	CMP	/ERR IF HOURS OUT OF RANGE (0-23)
	00
	27
	JMP	ERR1
	DAC	SCHCPB+4
	JMS	CLX	/ERR IF NOT A COLON BREAK
/
	JMS	FNB	/FETCH MINUTES & BREAK CHAR
	JMS	CMP	/ERR IF SECONDS OUT OF RANGE (0-59)
	00
	73
	JMP	ERR1
	DAC	SCHCPB+5
	JMS	CLX	/ERR IF NOT A COLON BREAK
/
	JMS	FNB	/FETCH SECONDS & BREAK CHAR
	JMS	CMP	/ERR IF SECONDS OUT OF RANGE (0-59)
	00
	73
	JMP	ERR1
	DAC	SCHCPB+6
/
	DZM	SCHCPB+7
	DZM	SCHCPB+10
	DZM	SCHCPB+11
/
	JMS	CRCX	/TEST FOR CR, AM, COMMA, OR SPACE BREAK
	JMP	ERR1	/NEITHER -- ERR
	JMP	SCHSCH	/CR OR AM -- NO RESCHEDULE OR PRIORITY IND
			/COMMA OR SPACE -- RESCHEDULING AND/OR
			/PRIORITY INDICATED
	DZM	SCHCPB+10 /FETCH PRIORITY OR RESCHEDULE INTERVAL
	JMS	FNB
	DAC	SCHCPB+7 /ASSUME RESCHEDULE & EXAMINE
	LAC	BCHAR	 /BREAK CHAR (INTERVAL UNITS)
	SAD	(110)	 /"H"?
	JMP	SCHRH	 /YES -- INDICATE HOURS (4)
	SAD	(115)	 /NO -- "M"?
	JMP	SCHRM	 /YES -- INDICATE MINUTES (3)
	SAD	(123)	 /NO -- "S"?
	JMP	SCHRS	 /YES -- INDICATE SECONDS (2)
	SAD	(124)	 /NO -- "T"?
	JMP	SCHRT	 /YES -- INDICATE TICKS (1)
	LAC	SCHCPB+7 /NO -- CHANGE ASSUMPTION TO PRIORITY
	DAC	SCHCPB+11 /AND CHECK MAGNITUDE.
	DZM	SCHCPB+7
	JMP	SCHPRX
/
SCHRH	ISZ	SCHCPB+10
SCHRM	ISZ	SCHCPB+10
SCHRS	ISZ	SCHCPB+10
SCHRT	ISZ	SCHCPB+10
/
	LAC	SCHCPB+7 /ERROR IF ZERO RESCHEDULE INTERVAL
	SNA
	JMP	ERR1
	JMS*	(FAC)	/GET BREAK CHAR FOLLOWING UNITS
	DAC	BCHAR
	JMS	CRCX	/TEST FOR CR, AM, COMMA, OR SPACE BREAK
	JMP	ERR1	/NEITHER -- ERR
	JMP	SCHSCH	/CR OR AM -- NO PRIORITY SPECIFIED
	JMS	FNB	/COMMA OR SPACE -- FETCH PRIORITY
SCHPRX	JMS	CMP
	0001
	1000
	JMP	ERR1
	DAC	SCHCPB+11
/
	JMS	CRCX
	JMP	ERR1
	JMP	SCHSCH
	JMP	ERR1
/
SCHSCH	CAL	SCHCPB	/ISSUE SCHEDULE DIRECTIVE
/
	LAC	EV	/WAS DIRECTIVE ACCEPTED?
	SMA
	JMP	EXT1	/YES -- EXIT
	SAD	(-204)	/IS TASK DISABLED?
	JMP	MESA
	SAD	(-212	/PARTITION LOST?
	JMP	MESB
	JMS	TYPE	/NO -- TYPE MESSAGE
	MES3
	JMP	CALMCR	/REQUEST MCR AND EXIT
MESA	JMS	TYPE	/PRINT TASK DISABLED MESSAGE
	MES4
	JMP	CALMCR	/REQUEST MCR AND EXIT
MESB	JMS	TYPE
	MES5
	JMP	CALMCR
/
EXT1	LAC	BCHAR	/IF CAR RTN TERMINATED INPUT LINE, REQUEST
	SAD	(015)	/RESIDENT MCR TASK & EXIT.  IF ALTMODE TERMIANTED
CALMCR	CAL	REQCPB	/INPUT LINE, CLEAR ^C REQUEST INHIBIT FLAG & EXIT
	SAD	(175)
	DZM*	(MCRRI)
	CAL	(10)
/
ERR1	JMS	TYPE	/TYPE ERR MESSAGE, REQUEST RESIDENT MCR TASK,
	MES2		/AND EXIT.
	CAL	REQCPB
	CAL	(10)
/
SCHCPB	2	/FUNCTION CODE
	EV	/EVENT VARIABLE ADR
	0	/TASK NAME (FIRST HALF)
	0	/TASK NAME (SECOND HALF)
	0	/HRS
	0	/MIN
	0	/SEC
	0	/RESCHEDULE INTERVAL
	0	/INTERVAL UNITS
	0	/PRIORITY
/
REQCPB	1
	0
	.SIXBT	"..."
	.SIXBT	"MCR"
	0
/
EV	0	/EVENT VARIABLE
CNT	0	/COUNTER
BCHAR	0	/BREAK CHAR BUF
/
/ FNB -- FETCH-NUMBER-AND-BREAK-CHARACTER SUBROUTINE
/ THE NUMBER IS LEFT IN AC.  THE BREAK CHARACTER IS LEFT IN 'BCHAR'.
/ 'JMP ERR1' IF NUMBER IS NOT ONE OR TWO DIGITS LONG.
/
FNB	0
	JMS	FDD	/FETCH DIGIT
	JMP	ERR1	/NON DECIMAL CHAR--ERROR
	DAC	B1	/SAVE FIRST DIGIT IN B1
/
FNB1	JMS	FDD	/FETCH DIGIT
	JMP	FNBX	/NON DECIMAL CHAR -- CONSIDER BREAK CHAR
	DAC	B2	/SAVE SECOND DIGIT IN B2
/
	LAC	B1
	CLL
	MUL
	12
	SZA
	JMP	ERR1	/OVERFLOW
	LACQ
	TAD	B2
	SZL
	JMP	ERR1	/OVERFLOW
	DAC	B1
	JMP	FNB1
/
FNBX	DAC	BCHAR	/SAVE BREAK CHAR IN 'BCHAR' AND
	LAC	B1	/EXIT WITH DECIMAL NUMBER IN
	JMP*	FNB	/AC
/
B1	0
B2	0
/
/ FDD -- FETCH DECIMAL DIGIT SUBROUTINE
/
FDD	0
	JMS*	(FAC)	/FETCH CHARACTER
	JMS	CMP	/DECIMAL?
	60
	71
	JMP*	FDD	/NO -- RETURN AT JMS+1 WITH CHARACTER IN AC
	AND	(17)	/YES -- RETURN AT JMS+2 WITH DIGIT IN AC
	ISZ	FDD
	JMP*	FDD
/
/ CMP -- COMPARE-AC-WITH-LIMITS SUBROUTINE
/
/ CALLING SEQUENCE:
/	JMS	CMP
/	LL	/LOWER LIMIT
/	UL	/UPPER LIMIT
/ RETURN AT JMS+3 IF WITHOUT LIMITS
/ RETURN AT JMS+4 IF WITHIN LIMITS (INCLUSIVE)
/ AC IS RESTORED
/
CMP	0
	DAC	CMPBF	/SAVE AC
	LAC*	CMP	/WITHIN LOWER LIMIT?
	ISZ	CMP
	TCA
	TAD	CMPBF
	SPA
	JMP	CMP1	/NO -- RETURN AT JMS+3
	LAC	CMPBF	/YES -- WITHIN UPPER LIMIT?
	TCA
	TAD*	CMP
	SMA		/NO -- RETURN AT JMS+3
	ISZ	CMP	/YES -- RETURN AT JMS+4
CMP1	ISZ	CMP
	LAC	CMPBF	/RESTORE AC
	JMP*	CMP	/RETURN
/
CMPBF	0
/
/ CLX -- COLON TEST.  ERROR IF BREAK CHARACTER IS NOT A COLON.
/
CLX	0
	LAC	BCHAR
	SAD	(072)
	JMP*	CLX
	JMP	ERR1
/
/ CRCX -- SUBROUTINE TO TEXT FOR CAR RTN, ALTMODE, COMMA, OR SPACE 'BCHAR'
/ RETURN AT JMS+1 IF NEITHER
/ RETURN AT JMS+2 IF CAR RTN OR ALTMODE
/ RETURN AT JMS+3 IF COMMA OR SPACE
/
CRCX	0
	LAC	BCHAR
	SAD	(054)
	JMP	CRCX1
	SAD	(040)
	JMP	CRCX1
	SAD	(015)
	JMP	CRCX2
	SAD	(175)
	JMP	CRCX2
	JMP*	CRCX
/
CRCX1	ISZ	CRCX
CRCX2	ISZ	CRCX
	JMP*	CRCX
/
/ TYPE -- SUBROUTINE TO TYPE THE MESSAGE WHOSE ADDRESS FOLLOWS THE JMS
/
TYPE	0
	LAC*	TYPE
	DAC	TYPCPB+4
	ISZ	TYPE
/
	CAL	TYPCPB
/
	CAL	WAITEV
	JMP*	TYPE
/
TYPCPB	2700
	EV
	3
	2
	XX
/
WAITEV	20	/WAIT FOR EVENT VARIABLE
	EV
/
MES2	2; 0; .ASCII	"SCH-SYNTAX ERR"<015>
MES3	2; 0; .ASCII	"SCH-TASK NOT IN SYSTEM"<015>
MES4	2; 0; .ASCII	"SCH-TASK DISABLED"<15>
MES5	2; 0; .ASCII	"SCH-PART LOST"<15>
/
	.END	SCH
