	.TITLE *** MCR FUNCTION TASK "ABORT"
/ 
/ 
/                   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 #6		10 JAN 72	C. PROTEAU
/			31 DEC 75	M. HEBENSTREIT
/
/ COPYRIGHT 1971, 1972 DIGITAL EQUIPMENT CORP., MAYNARD, MASS.
/
/ TASK, WHOSE NAME IS "...ABO", WHICH IS USED TO ABORT THE OPERATION
/ OF ANOTHER TASK.
/
/ THE FIRST LINE OF THE COMMAND INPUT FOR ANY MCR FUNCTION IS READ BY
/ THE RESIDENT MCR TASK ("...MCR"). FOR THE "ABORT" FUNCTION, THERE
/ IS ONLY ONE LINE OF COMMAND INPUT, AND ITS SYNTAX IS:
/
/	SYNTAX = 'ABO'$<NSC><SP><TASK NAME>(<CR>/<AM>)
/
/	$<NSC> = ANY NUMBER (INCLUDING 0) OF NON-SPACE CHARACTERS
/	<SP> = A SPACE CHARACTER
/	<TASK NAME> = 1 TO 6 ALPHANUMERIC CHARACTERS
/	<CR>/<AM> = CARRIAGE RETURN OR ALTMODE
/
/ THE RESIDENT MCR READS A LINE, FETCHES THE FIRST THREE CHARACTERS TO
/ FORM THE MCR FUNCTION TASK NAME ("...ABO"), FLUSHES CHARACTERS UP TO
/ THE FIRST BREAK CHARACTER, REQUESTS "...ABO", AND THEN EXITS. THE TASK
/ "...ABO" PROCESSES THE REMAINDER OF THE LINE AND, IF THE REQUEST IS
/ VALID, FORCES THE INDICATED TASK TO EXIT (BY ALTERING THE RESTART
/ ADDRESS IN THE TASK'S ACTIVE TASK LIST NODE). NOTE THAT IF THE
/ ABORTED TASK WAS ORIGINALLY ACTIVATED WITH A RESCHEDULE INTERVAL,
/ RESCHEDULING WILL CONTINUE AND IF THE TASK IS FIXED-IN-CORE, IT WILL
/ SO REMAIN.
/
/ THIS TASK, "...ABO", SHOULD BE INSTALLED TO RUN AT PRIORITY 1.
/ IT WILL NOT ABORT A TASK OF HIGHER PRIORITY THAN ITS OWN (I.E.,
/ PRECEDING IT IN THE ACTIVE TASK LIST).
/
/ IF THE COMMAND INPUT LINE IS TERMINATED BY A CARRIAGE RETURN, THE
/ RESIDENT MCR TASK IS REQUESTED AND THIS FUNCTION TASK EXITS.
/
/ IF THE COMMAND INPUT LINE IS TERMINATED BY AN ALTMODE, THE FUNCTION
/ TASK EXITS WITHOUT REQUESTING "...MCR". A CTRL C TYPEIN IS THEN
/ NECESSARY TO RE-ESTABLISH MCR DIALOGUE.
/
/ PARAMETERS DEFINED WITHIN THE RSX EXECUTIVE.
/
X10=10				/AUTOINCREMENT REGISTER 10.
R1=101				/GENERAL REGISTER #1.
R2=102				/GENERAL REGISTER #2.
NADD=107			/ENTRY POINT TO "ADD NODE TO DEQUE" SUBR.
NDEL=112			/ENTRY POINT TO "DELETE NODE FROM DEQUE" SUBR.
POOL=240			/LISTHEAD OF THE EMPTY NODE DEQUE.
MCRRI=171			/MCR "REQUEST INHIBIT" FLAG.
FAC=174				/MCR "FETCH-A-CHARACTER" SUBROUTINE.
CURTSK=135			/ATL NODE ADDRESS OF THE CURRENT ACTIVE TASK.
ATKL=244			/LISTHEAD OF THE ACTIVE TASK LIST.
A.N1=2				/ATL TASK NAME 1ST HALF OFFSET.
A.N2=3				/ATL TASK NAME 2ND HALF OFFSET.
A.SN=6				/ATL STL NODE ADDRESS.
A.TS=7				/ATL FLAGS & TASK STATUS WORD.
A.RA=10				/ATL TASK RESTART ADDRESS OFFSET.
STKL=242			/LISTHEAD OF THE SYSTEM TASK LIST.
S.DP=4				/STL FLAGS & DEFAULT PRIORITY.
S.N1=2				/STL TASK NAME 1ST HALF OFFSET.
S.N2=3				/STL TASK NAME 2ND HALF OFFSET.
IDX=ISZ				/USED WHEN THE SKIP IS NOT INTENDED.
LUN=3				/ERROR MESSAGE OUTPUT LUN.
/
ABO	LAC	(ABO)		/COMPUTE THE INDEX REGISTER ADJUSTMENT
	AND	(070000)	/FACTOR (NEGATIVE VALUE OF PAGE BITS FOR
	TCA			/THE PAGE IN WHICH THIS CODE IS LOCATED)
	DAC	XADJ		/TO COMPENSATE FOR ADDITION OF PAGE BITS
				/IN INDEXED MEMORY REFERENCE INSTRUCTIONS.
	LAW	-7		/SET UP TO FETCH THE TASK NAME (UP TO 6
	DAC	CNT		/CHARACTERS) FROM THE COMMAND INPUT LINE.
	LAC	(BUF-1)
	DAC*	(X10)
/
ABOFLP	JMS*	(FAC)		/FETCH A CHARACTER.
	DAC	CHAR
	SAD	(15)		/CARRIAGE RETURN?
	JMP	ABOENM		/YES.
	SAD	(175)		/ALTMODE?
	JMP	ABOENM		/YES.
	AAC	-41
	SPA
	JMP	ERR1		/SYNTAX ERROR -- CHAR < 41.
	AAC	-77
	SMA
	JMP	ERR1		/SYNTAX ERROR -- CHAR > 137.
	LAC	CHAR
	DAC*	X10		/STORE THE CHARACTER.
	ISZ	CNT
	JMP	ABOFLP
	JMP	ERR1		/SYNTAX ERROR -- TOO MANY CHARACTERS.
/
ABOENM	DZM*	X10		/FILL IN THE REMAINING CHARACTERS WITH 0.
	ISZ	CNT
	JMP	.-2
/
/ FORM THE TASK NAME AND STORE IT.
/
	LAC	BUF+2		/FORM THE FIRST HALF OF THE TASK NAME.
	LRS	6
	LAC	BUF+1
	LRS	6
	LAC	BUF+0
	SNA			/IS THE NAME NULL?
	JMP	ERR1		/YES -- SYNTAX ERROR.
	LLS	14		/NO.
	DAC	TN1
	LAC	BUF+5		/FORM THE SECOND HALF OF THE TASK NAME.
	LRS	6
	LAC	BUF+4
	LRS	6
	LAC	BUF+3
	LLS	14
	DAC	TN2
/
/ SEARCH THE ACTIVE TASK LIST FOR THE TASK TO BE ABORTED. SEARCH ONLY FOR
/ TASKS WHOSE PRIORITY IS LOWER THAN THAT OF THIS TASK ("...ABO"). WHILE
/ THE SCAN IS BEING MADE, NEW TASK ENTRIES MAY APPEAR IN THE LIST. BUT
/ THERE IS NO DANGER OF A TASK ENTRY BEING REMOVED, BECAUSE THAT CAN
/ HAPPEN ONLY IF THE TASK EXITS AND THAT CAN'T HAPPEN BECAUSE IT IS LOWER
/ IN PRIORITY THAN "...ABO".
/
/ SPECIAL CASE -- THE I/O RUNDOWN TASK, WHOSE NAME IS "IORD", MUST
/ NEVER BE ABORTED.
/
	LAC	TN1
	SAD	(111722)	/.SIXBT "IOR".
	SKP
	JMP	.+4
	LAC	TN2
	SAD	(040000)	/.SIXBT "D@@".
	JMP	ERR3		/TREAT "IORD" AS IF IT WERE INACTIVE.
/
	LAC*	(CURTSK)	/PICK UP THE ATL NODE ADDRESS OF "...ABO"
	TAD	XADJ		/AND START THE ATL SCAN FROM THERE.
	PAX
/
ATLSCN	LAC	0,X		/END OF ATL?
	SAD	(ATKL)
	JMP	INACTV		/YES -- TASK INACTIVE.
	DAC	ATLADR		/SAVE ATL ADDRESS.
	TAD	XADJ		/NO -- SET XR TO NEXT ATL NODE ADDRESS.
	PAX
	LAC	A.N1,X		/CHECK FOR TASK NAME.
	SAD	TN1
	SKP
	JMP	ATLSCN		/NOT IT -- TRY NEXT NODE.
	LAC	A.N2,X
	SAD	TN2
	SKP
	JMP	ATLSCN		/NOT IT.
/
/ TASK FOUND IN THE ACTIVE TASK LIST. CHECK TASK STATUS.
/
	LAC	A.TS,X
	SPA
	JMP	ABLOAD		/TASK IS LOADING -- SET START ADDR TO 300
	SAD	(1)
	JMP	STAT1		/STATUS 1.
/
/ STATUS 3 (WHEN TASK NOT LOADING) OR STATUS 4, 5, OR 6. FORCE TASK TO EXIT.
/
	LAC	(4)		/SET TASK STATUS TO INDICATE "READY TO RUN".
	DAC	A.TS,X
ABLOAD	LAC	(300		/SET START ADDR TO 300
	DAC	A.RA,X
	JMP	ABOXIT
/
/ STATUS 1 -- TASK WAITING FOR PARTITION TO FREE UP.
/
STAT1	LAC	A.SN,X		/SAVE TASK'S STL NODE ADDRESS.
	DAC	STLADR
	LAC	ATLADR		/DELETE NODE FROM THE ATL.
	DAC*	(R1)
	JMS*	(NDEL)		/(R1, R2, R6, XR & AC ARE ALTERED).
	LAC	(POOL)		/ADD NODE TO THE EMPTY POOL.
	DAC*	(R1)
	LAC	ATLADR
	DAC*	(R2)
	JMS*	(NADD)		/(R2, R6, XR & AC ARE ALTERED).
	LAC	STLADR		/SET THE STL NODE ADDRESS IN THE XR.
	TAD	XADJ
	PAX
	LAC	S.DP,X		/CLEAR BIT 0 IN THE FLAGS WORD TO INDI-
	AND	(377777)	/CATE THAT THE TASK IS INACTIVE.
	DAC	S.DP,X
/
/ EXIT. IF THE LINE TERMINATOR IS A CARRIAGE RETURN, "REQUEST" THE RESIDENT
/ MCR TASK BUT DON'T CLEAR "MCRRI".
/
ABOXIT	LAC	CHAR
	SAD	(15)		/CARRIAGE RETURN?
	CAL	REQMCR		/YES -- REQUEST "...MCR".
	LAC	CHAR
	SAD	(175)		/ALTMODE?
	DZM*	(MCRRI)		/YES -- CLEAR MCRRI.
	CAL	(10)		/EXIT.
/
/ THE TASK IS INACTIVE. SCAN THE SYSTEM TASK LIST TO SEE IF THE TASK
/ EVEN EXISTS. THERE'S NO DANGER OF THE STL ENTRY BEING REMOVED NOW
/ BECAUSE TASK REMOVAL IS HANDLED BY "...REM", WHICH IS AN MCR FUNCTION
/ JUST LIKE "...ABO" AND, THEREFORE, CANNOT BE RUNNING.
/
INACTV	LAC	(STKL)		/SET THE XR TO ADDRESS OF STL LISTHEAD.
	TAD	XADJ
	PAX
/
STLSCN	LAC	0,X		/END OF STL?
	SAD	(STKL)
	JMP	ERR2		/YES -- TASK NOT IN SYSTEM.
	TAD	XADJ		/NO -- SET XR TO ADDRESS OF NEXT STL NODE.
	PAX
	LAC	S.N1,X		/CHECK FOR TASK NAME.
	SAD	TN1
	SKP
	JMP	STLSCN		/NOT IT -- TRY NEXT NODE.
	LAC	S.N2,X
	SAD	TN2
	JMP	ERR3		/TASK FOUND IN STL.
	JMP	STLSCN		/NOT IT -- TRY NEXT NODE.
/
/ ERROR MESSAGES.
/
ERR1	LAC	(MES1)		/SYNTAX ERROR.
	SKP
ERR2	LAC	(MES2)		/TASK NOT IN SYSTEM.
	SKP
ERR3	LAC	(MES3)		/TASK NOT ACTIVE.
	DAC	TYPE+4
	CAL	TYPE		/TYPE ERROR MESSAGE.
	CAL	WAITFR
	CAL	REQMCR		/REQUEST THE MCR TASK.
	CAL	(10)		/EXIT.
/
MES1	004002; 0; .ASCII "ABO-SYNTAX ERR"<15>
MES2	006002; 0; .ASCII "ABO-TASK NOT IN SYSTEM"<15>
MES3	005002; 0; .ASCII "ABO-TASK INACTIVE"<15>
/
TYPE	2700			/"WRITE" CPB.
	EV
	LUN
	2			/IOPS ASCII.
	XX			/BUFFER ADDRESS.
/
WAITFR	20			/"WAITFOR" CPB.
	EV
/
REQMCR	1			/"REQUEST" CPB.
	0
	.SIXBT	"..."
	.SIXBT	"MCR"
	0			/USE ITS DEFAULT PRIORITY.
/
/ VARIABLE STORAGE.
/
EV	0			/EVENT VARIABLE.
XADJ	0			/INDEX REGISTER ADJUSTMENT FACTOR.
CHAR	0			/ASCII CHARACTER FETCHED FROM COMMAND.
CNT	0			/COUNTER.
TN1	0			/TASK NAME (FIRST HALF).
TN2	0			/TASK NAME (SECOND HALF).
ATLADR	0			/ADDRESS OF THE ACTIVE TASK LIST NODE.
STLADR	0			/ADDRESS OF THE SYSTEM TASK LIST NODE.
BUF	.BLOCK	7		/TEMPORARY BUFFER USED TO ASSEMBLE THE
				/TASK NAME FROM COMMAND INPUT.
/
	.END	ABO
