	.TITLE *** THE SLICE MCR FUNCTION ***
/ 
/ 
/                   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) 1976, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/ 
/ 
/ EDIT #8	AUG. 30 1974	M. HEBENSTREIT
/ EDIT #9	MAY  14, 1976	M. HEBENSTREIT (MA CHANGES)
/
/ THIS MCR FUCNTION CAN BE USED TO TURN TIME SLICING ON OR OFF.
/ WHEN TIME SLICING IS TURNED ON PARAMETERS IN THE EXEC ARE SET TO
/ INDICATE THE TIME SLICING TIME AND THE PRIORITY RANGE.
/ NO TASK'S STATUS IS CHANGED DURING THE EXECUTION OF THIS TASK.
/ 
/ THE COMMAND STRING FORMAT IS:
/ 
/	MCR>SLICE XXX-YYY ZZZ$
/	      OR
/	MCR>SLICE XXX ZZZ$
/ 
/ TO TURN TIME SLICING ON. WHERE XXX AND YYY ARE 3 DIGIT DECIMAL
/ NUMBERS INDICATING THE PRIORITY RANGE AND ZZZ IS THE NUMBER OF
/ TICKS (IN DECIMAL NOTATION) A TASK SHOULD REMAIN AT AT THE
/ TOP OF THE TIME SLICING BAND IN THE ATL.
/ NOTE THAT THE LOWEST PRIORITY IN THE RANGE MUST BE
/ GREATER THAN OR EQUAL TO 100. THAT IS AAA>=100.
/ 
/ TO TURN TIME SLICING OFF:
/  
/	MCR>SLICE OFF$
/ 
/ IN ALL OF THE COMMAND STRINGS ABOVE $ INDICATES A LINE TERMINATOR.
/ 
/ 
.ENB=705521	/ENABLE INTERRUPTS
.INH=705522	/INHIBIT INTERRUPTS
ATL=244		/ADDRESS OF ATL LISTHEAD
FAC=174		/ADDRESS OF FETCH-A-CHARACTER SUBROUTINE
MCRRI=171	/MCR FLAG ADDRESS
SLITIM=315	/ADDRESS OF THE FLAG USED TO INDICATE IF
			/TIME SLICING IS ON OR OFF. IF OFF THE
			/WORD CONTAINS 0. IF ON THE WORD CONTAINS
			/THE 2'S COMP. OF THE SLICING TIME IN
			/TICKS.
SLIHR=316	/ADDRESS OF THE WORD USED TO STORE
			/THE HIGHEST PRIORITY IN THE TIME
			/SLICING RANGE.
SLILR=317	/ADDRESS OF THE WORD USED TO STORE THE
			/2'S COMP. OF THE LOWEST PRIORITY IN THE
			/TIME SLICING RANGE.
SLICNT=320	/TIME SLICING ISZ TICK COUNTER
IDX=ISZ		/USED WHEN THE INTENTION IS NEVER TO SKIP
/ 
START	LAC	(START		/COMPUTE THE XR ADJUSTMENT FACTOR
	AND	(070000
	TCA
	DAC	XADJ		/STORE THE ADJUSTMENT FACTOR IN XADJ
	JMS	NUMBER		/READ A DECIMAL NO. FROM CONSOLE
	JMP	ENDSLI		/RETURN HERE IF A POSSIBLE ERROR
				/WAS DETECTED.
	DAC	TEMP		/RETURN HERE IF NO ERROR -- SAVE THE
				/BREAK CHARACTER TEMPORARILY.
	LAC*	(SLITIM		/IS TIME SLICING ON ALREADY?
	SZA
	JMP	ERR3		/YES -- ERROR
	LAC	TEMP		/NO -- PICK UP BREAK CHAR. AGAIN
	SAD	(40		/WAS THE BREAK CHAR. A SPACE
	JMP	ONEPRI		/YES -- THEN ONLY ONE PRIO IN RANGE
	SAD	(55		/WAS BREAK CHAR. A MINUS?
	SKP
	JMP	ERR1		/NO -- FORMAT ERROR
	LACQ			/YES -- SAVE THE LOW PRIORITY
	DAC	LOWPRI
	JMS	NUMBER		/GET THE HIGH PRIORITY
	JMP	ERR1		/RETURN HERE ON AN ERROR
	LACQ			/RETURN HERE ON NO ERROR AND STORE
	DAC	HIPRI		/THE HIGH PRIORITY
	JMP	GETTIM		/GET READY TO GET THE NO. OF TICKS
ONEPRI	LACQ			/ONLY ONE PRIORITY WAS SPECIFIED SO
	DAC	LOWPRI		/STORE IT IN BOTH LOCATIONS.
	DAC	HIPRI
GETTIM	JMS	NUMBER		/GET THE NUMBER OF TICKS
	JMP	ERR1		/RETURN HERE ON AN ERROR
	DAC	TERM		/RETURN HERE IF OK AND STORE THE
				/BREAK CHARACTER.
	LACQ			/NOW PICK UP THE NO. OF TICKS
	SNA			/NO. OF TICKS IS ZERO?
	JMP	ERR4		/YES -- ERROR
	DAC	TIME		/NO -- SAVE THE NO. OF TICKS PER QUANTA
	LAC	TERM		/WAS THE BREAK CHAR A LINE TERM?
	SKP
	JMS*	(FAC		/READ A CHAR OFF CONSOLE TTY
	SAD	(175		/ALTMODE?
	SKP			/YES
	SAD	(15		/CARRIAGE RETURN?
	SKP			/YES
	JMP	.-5		/NO -- LOOK AT NEXT CHARACTER
/ 
	LAC	LOWPRI		/TEST THAT LOWPRI IS >=100 (10)
	.DEC
	AAC	-100
	.OCT
	SPA
	JMP	ERR2		/IT'S NOT SO THAT'S AN ERROR.
	LAC	(-1001		/IS HIPRI <= 512?
	TAD	HIPRI
	SMA
	JMP	ERR2		/NO -- THAT'S AN ERROR
	LAC	LOWPRI		/IS 0<LOWPRI<=HIPRI?
	SNA
	JMP	ERR2		/NO -- ERROR
	TCA
	TAD	HIPRI
	SPA
	JMP	ERR2		/NO -- ERROR
	LAC	LOWPRI		/YES -- STORE 2'S COMP OF LOWPRI
	TCA
	DAC*	(SLILR
	LAC	HIPRI		/STORE THE HIGH PRIORITY
	DAC*	(SLIHR
	LAC	TIME		/TURN SLICING ON BY SETTING
	.INH			/THE TICKS PER QUANTA AND 
	DAC*	(SLITIM		/THE ISZ COUNTER NON-ZERO.
	TCA
	.ENB
	DAC*	(SLICNT
/
ALLDON=.
EXIT	LAC	TERM		/EXIT ACCORDING TO TERMINATOR
	SAD	(175
	JMP	.+3
EXITA	CAL	REQMCR
	CAL	(10
	DZM*	(MCRRI
	CAL	(10
/ 
/ COME HERE IF AN ERROR WAS FOUND IN THE FIRST DECIMAL NUMBER
/ WHICH WAS TYPED. MAYBE THE OPERATOR TYPED 'OFF' TO TURN
/ TIME SLICING OFF.
/ 
ENDSLI	SAD	(117		/WAS THE CHARACTER AN O?
	SKP
	JMP	ERR1		/NO -- FORMAT ERROR
	JMS*	(FAC		/YES -- GET NEXT CHAR.
	SAD	(106		/IS IT AN F?
	SKP
	JMP	ERR1		/NO -- FORMAT ERROR
	JMS*	(FAC		/YES -- GET NEXT CHAR
	SAD	(106		/F?
	SKP
	JMP	ERR1		/NO -- FORMAT ERROR
	JMS*	(FAC		/YES -- LOOK FOR LINE TERMINATOR
	SAD	(15
	SKP
	SAD	(175
	SKP
	JMP	.-5
	DAC	TERM		/SAVE THE TERMINATOR
/
	.INH
	DZM*	(SLITIM		/ZERO SLITIM TO INDICATE THAT
				/TIME SLICING IS OFF!
	.ENB
	JMP	ALLDON		/GO EXIT
	.EJECT
/ 
/ VARIABLES, MESSAGES, AND CPBS
/
MSG1	MSG2-MSG1/2*1000
	0
	.ASCII "FORMAT ERROR"<15>
MSG2	MSG3-MSG2/2*1000
	0
	.ASCII "ILLEGAL PRIORITY"<15>
MSG3	MSG4-MSG3/2*1000
	0
	.ASCII "TIME SLICING IS ALREADY ON"<15>
MSG4	EV-MSG4/2*1000
	0
	.ASCII "TICKS MUST BE NON-ZERO"<15>
EV	0
HOLDUP	0
LOWPRI	0
HIPRI	0
TIME	0
XADJ	0
TERM	0
TEMP	0
FIRST	0
NUMT	0
CHAR	0
NUM	0
COUNT	0
NUMFLG	0
/ 
WRITE	2700
	EV
	3
	2
	XX
WAIT	20
	EV
REQMCR	1
	0
	.SIXBT "..."
	.SIXBT "MCR"
	0
	.EJECT
/ 
/ MISC ROUTINES AND SUBROUTINES
/
ERR4	LAC	(MSG4	/TICKS MUST BE NON-ZERO
	SKP
ERR3	LAC	(MSG3	/T.S. IS ALREADY ON
	SKP
ERR1	LAC	(MSG1	/FORMAT ERROR ROUTINE
	SKP
ERR2	LAC	(MSG2	/ILLEGAL PRIORITY ROUTINE
	DAC	WRITE+4
	CAL	WRITE
	CAL	WAIT
	LAC	(15
	DAC	TERM
	JMP	EXITA
/
/ SUBROUTINE SETXR -- ADJUST THE XR
/ 
/ ALTERED REGISTERS: AC AND XR
/ 
/ CALLING SEQUENCE:
/		LAC	ADDRESS
/		JMS	SETXR
/ 
SETXR	0
	TAD	XADJ
	PAX
	JMP*	SETXR
/
/ SUBROUTINE NUMBER -- READ A DECIMAL NUMBER OF UP TO 3 DIGITS
/			OFF THE MCR TTY.
/ 
/ ALTERED REGISTERS: AC AND MQ
/ 
/ CALLING SEQUENCE:
/		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
	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.
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
	.END
	DAC	TERM		/SAVE THE REAL LINE TERMINATOR
