        .TITLE  MCR FUNTION TO ASSIGN A PARTITION TO A TASK
/
/ COPYRIGHT (C) 1975
/ DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
/
/ THIS SOFTWARE IS FURNISHED UNDER A LICENSE FOR USE ONLY
/ ON A SINGLE COMPUTER SYSTEM AND MAY BE COPIED ONLY WITH
/ THE INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS
/ SOFTWARE, OR ANY OTHER COPIES THEREOF, MAY NOT BE PRO-
/ VIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON
/ EXCEPT FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO
/ THESE LICENSE TERMS.  TITLE TO AND OWNERSHIP OF THE
/ SOFTWARE SHALL AT ALL TIMES REMAIN IN DEC.
/
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE
/ WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED AS A COM-
/ MITMENT BY DIGITAL EQUIPMENT CORPORATION.
/
/ DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY
/ OF ITS SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY
/ DEC.
/
	.EJECT
/  
/  EDIT #008        JUN. 19 75        M. HEBENSTREIT
/  
/  
/  THIS PROGRAM IS AN MCR FUNCTION TO CHANGE THE PARTITION OF AN
/  INACTIVE, NORMAL MODE TASK.  THE COMMAND FORMAT IS:
/         MCR>ASP PART0-TASK0$    OR
/         MCR>ASP PART0-TASK0,...,PARTN-TASKN$
/  WHERE PARTI IS THE NEW PARTITION FOR TASKI AND $ IS EITHER
/  AN ALTMODE (TO EXIT WITHOUT REQUESTING 'MCR') OR A CARRIAGE
/  RETURN (TO REQUEST 'MCR' AFTER THE FUNCTION IS COMPLETE.
/   
R1=101
R2=102
IDX=ISZ
STL=242
FAC=174
MCRRI=171
SNAM=123
PBDL=250
.INH=705522
.ENB=705521
/  
START	LAC	(START	/GET THE XR ADJUSTMENT
	AND	(70000
	TCA
	DAC	XRADJ	/SAVE IT
	JMS	GETNAM	/GET THE PARTITION NAME
        JMP     ERR01  /RETURN HERE IS ANY FORMAT ERRORS ARE DETECTED
        SAD     (137  /IS THE NEXT CHAR. A BACK ARROW?
        SKP
        JMP     ERR01  /NO -- THAT'S AN ERROR
        LAC     GN1  /YES -- STORE THE PARTITION'S NAME
        DAC     PARN1
        LAC     GN2
        DAC     PARN2
        JMS     GETNAM  /GET THE TASK'S NAME
        JMP     ERR01  /RETURN HERE ON ANY ERRORS
        DAC     TERM  /STORE THE TERMINATOR
	DZM	PRIO	/CLEAR THE PRIORITY
	SAD	(40	/WAS THE BREAK CHAR A SPACE?
	SKP
	JMP	ASP1	/NO -- PROCEED NORMALLY -- NO PRIO GIVEN
	JMS	NUMBER	/YES -- GO READ A PRIORITY
	JMP	ERR01	/RETURN HERE ON AN ERROR
	DAC	TERM	/SAVE THE BREAK CHAR.
	LACQ		/GET THE NUMBER
	SPA!SNA		/PRIO MUST BE POSITIVE AND NON-ZERO
	JMP	ERR01	/IT'S NOT -- ERROR
	TAD	(-1001	/PRIO<=512?
	SMA
	JMP	ERR01	/NO -- ERROR
	LACQ		/YES -- SAVE THE PRIORITY
	DAC	PRIO
ASP1    LAC     (PBDL  /FIND THE PARTITION'S PBVL NODE
        DAC*    (R1
        LAC     (PARN1
        DAC*    (R2
        JMS*    (SNAM
        JMP     ERR02  /CAN'T FIND PARTITION -- ERROR
        DAC     PARND  /SAVE THE ADDRESS OF PARTITON'S NODE
        LAC     (STL  /FIND THE TASK'S STL NODE
        DAC*    (R1
        LAC     (GN1
        DAC*    (R2
        JMS*    (SNAM
        JMP     ERR03  /CAN'T FIND STL NODE -- ERROR
        DAC     TSKND  /SAVE THE ADDRESS OF THE STL NODE
        JMS     SETXR
        LAC     4,X
        DAC     STATUS
        LAC     10,X
	AND	(777400
        DAC     SIZE
        LAC     11,X  /SEE IF TASK IS EXEC MODE
        AND     (100000
        SNA
        JMP     ERR04	/EXEC MODE TASK -- ERROR
        LAC     STATUS  /SEE IF TASK IS ACTIVE
        AND     (400000
        SZA  
	JMP	ERR05	/ACTIVE TASK -- ERROR
        LAC     STATUS  /SEE IF TASK IS FIXED IN CORE
        AND     (040000
        SZA
        JMP     ERR06	/FIXED TASK -- ERROR
        LAC     PARND  /SEE IF TASK WILL FIT IN ITS NEW PARTITION
	JMS	SETXR
        LAC     SIZE
        TCA
        TAD     5,X
        SPA
        JMP     ERR07	/TASK TOO LARGE FOR NEW PARTITION -- ERROR
        LAC     GN1  /TASK IS OK TO RELOCATE SO SET UP ENA. AND DISAB. CPB'S
        DAC     DISABL+2
        DAC     ENABLE+2
        LAC     GN2
        DAC     DISABL+3
        DAC     ENABLE+3
        CAL     DISABL  /DISABLE THE TASK
        CAL     WAIT
        LAC     EV
        SPA
        JMP     ERR08	/DISABLE ERROR
        LAC     TSKND  /PUT PART. BLK. NODE ADDR. IS TASK'S STL NODE
        JMS     SETXR
	.INH		/INHIBIT INTERRUPTS
        LAC     PARND
        DAC     5,X
	LAC	4,X	/CLEAR THE DISABLED DUE TO PART. BIT
	AND	(757777	/THAT'S BIT 4
	DAC	4,X
	LAC	PRIO	/WAS A PRIO GIVEN?
	SNA
	JMP	.+5	/NO
	LAC	4,X	/YES -- ENTER NEW PRIO
	AND	(776000
	TAD	PRIO
	DAC	4,X
	.ENB		/ENABLE INTERRUPTS
        CAL     ENABLE  /ENABLE THE TASK
        CAL     WAIT
        LAC     EV
        SPA
        JMP     ERR09	/ENABLE ERROR
TTEST   LAC     TERM  /LOOK AT TERMINATOR -- CR AND ALT EXIT - COMMA GO TO START
        SAD     (54	/COMMA?
        JMP     START	/YES
        SAD     (15	/NO -- CR?
        JMP      EXIT	/YES
        SAD     (175	/NO -- ALTMODE?
        JMP     EXIT	/YES
        SAD     (40	/NO -- SPACE?
        SKP	/YES
        JMP     ERR01	/NO -- FORMAT ERROR
        JMS*    (FAC	/GET NEXT CHARACTER
        DAC     TERM	/TEST FOR A TERMINATOR
        JMP     TTEST
        DAC     TERM
EXIT    LAC     TERM  /EXIT ACCORDING TO THE TERMINATOR
        SAD     (15
        CAL     REQMCR
        SAD     (175
        DZM*    (MCRRI
        CAL      (10
REQMCR  1	/REQUEST CPB FOR 'MCR'
        0
        .SIXBT "..."
        .SIXBT "MCR"
        0
WRITE   2700	/WRITE TO TTY CPB
        EV
        2
        2
        0
WAIT    20	/WAIT CPB
        EV
DISABL  21	/DISABLE CPB
        EV
        0
        0
ENABLE  22	/ENABLE CPB
        EV
        0
        0
EV      0	/PROGRAM VARIABLE AND TEMP. STORAGE
GN1     0
GN2     0
GNCNTR  0
GNNFLG  0
GNTEMP  0
PARND   0
PARN1   0
PARN2   0
TERM    0
TSKND   0
STATUS  0
SIZE    0
PRIO	0
XRADJ	0
/  
/  S.R. TO ADJUST THE XR
/  
SETXR   0
	TAD	XRADJ
        PAX
        JMP*    SETXR
/  
/  S.R. TO GET A NAME OFF INPUT LINE
/  RETURN AT JMS+1 IF ERRORS ARE DETECTED
/  RETURN AT JMS+2 IF NO ERRORS  -- GN1 AND GN2 HAVE NAME
/  
GETNAM  0
        DZM     GN1	/ZERO THE NAME
        DZM     GN2
        LAW     -6	/INIT. COUNT OF CHAR.
        DAC     GNCNTR
        CLC		/SET FLAG MEANING SPACES ARE LEGAL
        DAC     GNNFLG
GNAMRD  JMS*    (FAC	/GET A CHAR.
        DAC     GNTEMP	/SAVE IT TEMPORARILY
        SAD     (15	/IS IT A CR?
        JMP     GNAMT	/YES
        SAD     (175	/NO -- ALTMODE?
        JMP     GNAMT	/YES
        SAD     (40	/NO -- SPACE?
        JMP     GNNAMS	/YES
        SAD     (137	/NO -- BACK ARROW?
        JMP     GNAMT	/YES
        SAD     (54	/NO -- COMMA
        JMP     GNAMT	/YES
        AND     (77	/NO -- SAVE LOW SIX BITS OF ASCII
        DAC     GNTEMP
        DZM      GNNFLG	/CLEAR FLAG -- SPACES NOW ILLEGAL
        CLL
        LAC     GNCNTR	/WHICH NAME WORD AND WHAT POSITION SHOULD THIS CHAR BE IN?
        SAD     (-6
        JMP     GNAM6
        SAD     (-5
        JMP     GNAM5
        SAD     (-4
        JMP      GNAM4
        SAD     (-3
        JMP     GNAM3
        SAD     (-2
        JMP     GNAM2
GNAM1   LAC     GNTEMP	/6TH CHAR. -- 2ND WORD AND LAST 6 BITS
        TAD     GN2
        DAC     GN2
GNAM0   ISZ     GNCNTR	/END OF NAME?
        JMP     GNAMRD	/NO -- READ NEXT CHAR.
        JMS*    (FAC	/YES -- READ CHAR AND RETURN AT JMS+2
        ISZ      GETNAM
        JMP*    GETNAM
GNNAMS  LAC     GNNFLG	/CHAR. IS A SPACE -- CHECK LEGALITY
        SZA
        JMP     GNAMRD
GNAMT   LAC     GNNFLG	/CHAR IS A TERM -- CHECK FOR ERRORS
        SZA
        JMP     .+4
        LAC     GNTEMP	/NO ERRORS -- AC HAS CHAR.
        ISZ     GETNAM	/RETURN AT JMS+2
        JMP*    GETNAM
        LAC     GNTEMP	/ERROR -- RETURN AT JMS+1
        JMP*    GETNAM
GNAM2   LAC     GNTEMP	/STORE CHAR. IN MID 6 BITS OF WD. 2
        ALS     6
        JMP     GNAM1+1
GNAM3   LAC     GNTEMP	/STORE CHAR. IN 1ST 6 BITS OF WORD 2
        ALS     14
        JMP     GNAM1+1
GNAM4   LAC     GNTEMP	/STORE CHAR IN LAST 6 BITS OF WORD 1
        TAD     GN1
        DAC     GN1
        JMP     GNAM0
GNAM5   LAC     GNTEMP	/STORE CHAR IN MID 6 BITS OF WORD 1
        ALS     6
        JMP     GNAM4+1
GNAM6   LAC     GNTEMP	/STORE CHAR IN 1ST 6 BITS OF WORD 1
        ALS     14
        JMP     GNAM4+1
/
/ 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
/
COUNT	0
NUM	0
NUMFLG	0
NUMT	0
CHAR	0
/  
ERR01   LAC     (MSG1
        DAC     WRITE+4
        CAL     WRITE
        CAL     WAIT
        CLA
        JMP     EXIT+2
ERR02   LAC     (MSG2
        JMP     ERR01+1
ERR03   LAC     (MSG3
        JMP     ERR01+1
ERR04   LAC     (MSG4
        JMP     ERR01+1
ERR05   LAC     (MSG5
        JMP     ERR01+1
ERR06   LAC     (MSG6
        JMP     ERR01+1
ERR07   LAC     (MSG7
        JMP     ERR01+1
ERR08   LAC     (MSG8
        JMP     ERR01+1
ERR09   LAC     (MSG9
        JMP     ERR01+1
/  
MSG1    MSG2-MSG1/2*1000
        0
        .ASCII "FORMAT ERROR"<15>
MSG2    MSG3-MSG2/2*1000
        0
        .ASCII "CAN NOT FIND PBDL NODE"<15>
MSG3    MSG4-MSG3/2*1000
        0
        .ASCII "CAN NOT FIND STL NODE"<15>
MSG4    MSG5-MSG4/2*1000
        0
        .ASCII "EXEC MODE TASKS CANNOT BE RELOCATED"<15>
MSG5    MSG6-MSG5/2*1000
        0
        .ASCII "TASK IS ACTIVE"<15>
MSG6    MSG7-MSG6/2*1000
        0
        .ASCII "TASK IS FIXED IN CORE"<15>
MSG7    MSG8-MSG7/2*1000
        0
        .ASCII "PARTITION IS TOO SMALL"<15>
MSG8    MSG9-MSG8/2*1000
        0
        .ASCII "DISABLE ERROR"<15>
MSG9    MSG10-MSG9/2*1000
        0
        .ASCII "ENABLE ERROR"<15>
MSG10   0
          .END
