/ 
/ 
/                   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 -- SYN 	14 APR 71	R. MCLEAN
/
/ TASK NAME "...SYN" TO RUN A TASK IN TERMS OF SYNCRONIZING ON A CLOCK UNIT 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 "SYN" FUNCTION, THERE IS ONLY ONE LINE OF 
/ COMMAND INPUT, AND IT'S SYNTAX IS AS FOLLOWS:
/
/	SYNTAX = 'SYN'$<NBC><BREAK CHAR><TASK NAME><SYNC CHAR>
/		<BREAK CHAR><DELTA TIME>
/		(<BREAK CHAR><RESCHEDULE>/NUL)
/		(<BREAK CHAR><PRIORITY>/NUL)(<CR>/AM>)
/
/	<BREAK CHAR> = " "/","
/	<TASK NAME> = 1-6 ALPHANUMERIC CHARACTERS
/	<SYNC CHAR> = ("H"/"M"/"S")
/	<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 ("...SYN"), FLUSHES CHARACTERS THRU THE FIRST
/ BREAK CHARACTER, REQUESTS "...SYN" , AND EXITS
/ THE TASK "...SYN" PROCESSES THE REMAINDER OF THE LINE
/ AND IF THE REQUEST IS VALID, ISSUES AN APPROPRIATE "SYN"
/ 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 'SYNC'
/
MCRRI=171
FAC=174
X10=10
/
SYN	LAW	-7	/SET UP TO FETCH TASK NAME AND STORE
	DAC	CNT	/SIX CHARACTERS (ZERO RIGHT FILL) IN
	LAC	(SYNCPB+1)	/ SYN CAL PARAMETER BLOCK
	DAC*	(X10)
SYNN1	JMS*	(FAC)	/FETCH A CHARACTER
	SAD	(054)	/IS IT A , ?
	JMP	SYNN2	/YES -- ZERO REMAINING CHARACTERS
	SAD	(040)	/NO -- IS IT A BLANK?
	JMP	SYNN2	/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	SYNN1	/NO -- FETCH ANOTHER
ERR1	JMS	TYPE	/YES -- SYNTAX ERROR
	MES1
	JMP	ABTEXT	/EXIT AND CALL MCR
/
SYNN2	DZM*	X10	/CLEAR THE REST OF THE TASK NAME
	ISZ	CNT	
	JMP	SYNN2
/
	LAC	SYNCPB+4	/FORM TASK NAME FOR SYN CPB
	DZM	SYNCPB+4	/CLEAR NAME FROM REQEST
	LRS	6
	LAC	SYNCPB+3
	LRS	6
	LAC	SYNCPB+2
	LLS	14
	DAC	SYNCPB+2	/STORE FIRST HALF
	LAC	SYNCPB+7	/FORM SECOND HALF
	DZM	SYNCPB+7	/CLEAR WORD FOR OPTIONAL PARAMETERS
	LRS	6
	LAC	SYNCPB+6
	DZM	SYNCPB+6
	LRS	6
	LAC	SYNCPB+5
	LLS	14
	DAC	SYNCPB+3	/STORE SECOND HALF
	LAC	(SYNCPB+4)	/PICK UP ADDRESS OF SYNC CHARACTER LOCATION IN CPB
	DAC	INTPNT	/SAVE IT FOR STINT
	JMS*	(FAC)	/PICK UP A CHARACTER
	SAD	(124)	/IS IT A T (ILLEGAL FOR SYNC CHARACTER)
	JMP	ERR1	/YES -- ERROR
	JMS	STINT	/NO -- DECODE INTERVAL
	JMS*	(FAC)	/PICK UP BREAK CHARACTER
	SAD	(40)	/IS IT A SPACE?
	JMP	SYNDT	/YES -- OK
	SAD	(54)	/IS IT A COMMA?
	JMP	SYNDT	/YES -- OK
	JMP	ERR1	/NO -- SYNTAX ERROR
SYNDT	LAC	(SYNCPB+6)	/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 DELTA TIME
	DAC	SYNCPB+5	/STORE IT IN SYN CPB
	LAC	(SYNCPB+10)	/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	SYNEXT	/YES -- NO  RESCHEDULE
	JMS	STINT	/DECODE THE RESCHEDULE INTERVAL
	LAC	B1	/PICK UP NUMBER OF INTERVALS
	SNA		/ZERO IS NOT LEGAL
	JMP	ERR1
	DAC	SYNCPB+7	/STORE IT IN SYN 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
SYNEXT	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	SYNCPB+11	/PUT PRIORITY IN SYN CPB
SYNPRI	CAL	SYNCPB	/ISSUE SYN DIRECTIVE
	CAL	WAITEV	/WAIT FOR DIRECTIVE TO COMPLETE
	LAC	EV	/PICK UP EVENT VARIABLE
	SMA		/WAS THERE AN ERROR?
	JMP	SYNOK	/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
	JMP	MESC
	JMS	TYPE	/EMPTY POOL ERROR
	MES2
	JMP	ABTEXT	/ABNORMAL TERMINATION EXIT
MESA	JMS	TYPE	/EMPTY POOL ERROR
	MES3
	JMP	ABTEXT
MESB	JMS	TYPE	/TASK DISABLED MESSAGE
	MES4
	JMP	ABTEXT
MESC	JMS	TYPE	/PARTITION LOST?
	MES5
	JMP	ABTEXT
SYNOK	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 SYNPRI 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	SYNPRI	/GO EXECUTE SYN 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	SYNRH
	SAD	(115)	/"M"
	JMP	SYNRM
	SAD	(123)	/"S"
	JMP	SYNRS
	SAD	(124)	/"T"
	JMP	SYNRT
	JMP	ERR1	/SYNTAX ERROR
SYNRH	ISZ*	INTPNT
SYNRM	ISZ*	INTPNT
SYNRS	ISZ*	INTPNT
SYNRT	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	/WAIT FOR
	EV	/EVENT VARIABLE
/
REQMCR	1		/REQUEST ...MCR CPB
	0
	.SIXBT	"...MCR"
	0
/
SYNCPB	14	/FUNCTION
	EV	/EVENT VARIABLE
	0	/TASK NAME (FIRST HALF)
	0	/TASK NAME (SECOND HALF)
	0	/SYNC INTERVAL
	0	/SCHEDULE DELTA TIME
	0	/SCHEDULE UNITS
	0	/RESCHEDULE INTERVAL
	0	/INTERVAL UNITS
	0	/PRIORITY
/
MES1	2; 0; .ASCII	'SYN-SYNTAX ERR'<15>
MES2	2; 0; .ASCII	'SYN-EMPTY POOL'<15>
MES3	2; 0; .ASCII	'SYN-TASK NOT IN SYSTEM'<15>
MES4	2; 0; .ASCII	'SYN-TASK DISABLED'<15>
MES5	2; 0; .ASCII	"SYN-PART LOST"<15>
EV	0
CNT	0
BRKCH	0
INTPNT	0
B1	0
B2	0
	.END	SYN
