	.TITLE +++ XVM/RSX EXECUTIVE VERSION 1B (PART 1) +++
/
/ COPYRIGHT (C) 1976
/ 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
P1EDTN=100214	/PART ONE [OF SOURCE FILE] EDIT NUMBER
/ 161	26-FEB-76 (RCHM)	BEGINNING OF MULTIACCESS	/(161)
/				CODING. FIRST EDIT SETS UP MA	/(161)
/				CONTROL WORDS IN SCOM, DEFINES	/(161)
/				THE NO MULTIACCESS CONDITIONAL	/(161)
/				AND CONDITIONALIZES TDV AND	/(161)
/				XFRCMD. THIS EDIT INSTALLS	/(161)
/				THE REQUEST MAPPED DIRECTIVE,	/(161)
/				THE QIO CHANGES NECESSARY TO	/(161)
/				USE LUN MAPPING, IMPLEMENT NEW	/(161)
/				IDLE STATUS FOR ODT, MAKE DTC	/(161)
/				EXTRACT TASK INFORMATION FROM	/(161)
/				PBDL, MAKE STATE 1 PROCESSING	/(161)
/				INITIALIZE PBDL FROM REQUEST	/(161)
/				NODE, CHANGE SHORT PARTITION	/(161)
/				BLOCK TO INCLUDE FLAG WORD FOR	/(161)
/				NEW DTC PROCESSING, ALSO CHANGE	/(161)
/				ALL TASKS USING THE SHORT PAR-	/(161)
/				TITION BLOCK, MODIFY IORD, EXIT	/(161)
/				VARIOUS TNTERM MESSAGE GENERATING/(161)
/				THINGS TO PLACE NODES ON TDV.EQ,/(161)
/				CONDITIONALIZE XFRCMD, INSTALL	/(161)
/				THE SINGLE UNIT ABORT CODE,	/(161)
/				MODIFY THE TTY HANDLER FOR TEST-/(161)
/				ING IT, MAKE THE NUMBER OF MA	/(161)
/				AND ASSEMBLY PARAMETER,		/(161)
/				INSTALL MCR TIMEOUT AS AN	/(161)
/				ASSEMBLY PARAMETER.		/(161)
/				MOVE MCR TO PAGE 1. MAKE SURE	/(161)
/				THAT THE RSX BOOTSTRAP CODE IS	/(161)
/				MODIFIED TO JMP INDIRECT THROUGH/(161)
/				R1.				/(161)
/ 162 	12-MAR-76 (RCHM)	MODIFY THE XQT DIRECTIVE FOR LUN/(162)
/				MAPPING. ALSO RESTRICT THE 	/(162)
/				SINGLE UNIT ABORT TO EXEC MODE 	/(162)
/				TASKS.				/(162)
/ 163	16-MAR-76 (RCHM)	DIDN'T GET THE SINGLE UNIT ABORT/(163)
/				RESTRICTION QUITE RIGHT.	/(163)
/ 164	16-MAR-76 (RCHM)	HAVE REQUEST CHECK THE RANGE OF	/(164)
/				THE LUN OFFSET IN THE MAPPED	/(164)
/				REQUEST. ALSO CHANGE DTC SO THAT/(164)
/				IT PROPERLY DECREMENTS THE LUN	/(164)
/				OFFSET SO THAT VIRTUAL LUN 2 	/(164)
/				GETS MAPPED INTO THE LUN	/(164)
/				REPRESENTED BY THE LUN OFFSET.	/(164)
/ 165	17-MAR-76 (RCHM)	FIX DMTQ SO THAT IT WILL NOT	/(165)
/				CHANGE THE TRANSFER PENDING	/(165)
/				IF IT IS CALLED FOR AN EXEC MODE/(165)
/				TASK.				/(165)
/ 166	18-MAR-76 (SCR)		MODIFY SKIP CHAIN LINKAGE TO TTY/(166)
/								/EAG:167
/ 167	19-MAR-76 (EAG)		ASSORTED MODIFICATIONS TO SPEED	/EAG:167
/				UP/SHORTEN/IMPROVE NADD, NDEL,	/EAG:167
/				PENP, PICK, ALAD, DLAD, SPRI,	/EAG:167
/				SNAM, AND IOCD.			/EAG:167
/				ADD NDELXR AND DQAB RE-ENTRANT	/EAG:167
/				ROUTINES.			/EAG:167
/				MODIFY CAL DISPATCH TO HANDLE	/EAG:167
/				INDIRECT AND/OR INDEXED CAL'S.	/EAG:167
/				MODIFY QUEUE I/O FOR REVISED	/EAG:167
/				SINGLE LUN ABORT AND TO NOT	/EAG:167
/				DECLARE A SIGNIFICANT EVENT	/EAG:167
/				IF HANDLER'S TRIGGER EVENT	/EAG:167
/				VARIABLE IS ALREADY NON-ZERO.	/EAG:167
/				REWRITE DQRQ, DQAB, AND DMTQ	/EAG:167
/				TO NOT CLOBBER SO MANY REGIS-	/EAG:167
/				TERS AND TO HANDLE MOST ABORT	/EAG:167
/				FUNCTIONS AUTOMATICALLY.	/EAG:167
/ 170	26-MAR-76 (SCR)		MINOR BUG FIX FOR 167		/(170)
/ 171	27-MAR-76 (SCR)		MINOR BUG FIX FOR 170		/(171)
/ 172	29-MAR-76 (RCHM)	TWO PROBLEMS WITH MULTIACCESS	/(172)
/				CODE.				/(172)
/				1. CLOCK MUST 0 LAST WORD OF REQ/(172)
/				   NODE TO AVOID SCREWING UP 	/(172)
/				   MAPPING.			/(172)
/				2. XFRCMD FORGOT TO ADD IN BASE	/(172)
/				   OF THE UCA AREA.		/(172)
/ 173	30-MAR-76 (RCHM)	EXEC MODE I/O RUNDOWN CHANGES.	/(173)
/				CHANGE S2 SO THAT IT WILL NOT	/(173)
/				HANG ON THE TASK ATTEMPTING TO	/(173)
/				CONSTRUCT AN I/O REQUEST TO THE	/(173)
/				DISK.				/(173)
/				CHANGE THE DEFINITION OF PENP	/(173)
/				SO THAT THE NODE ADDRESS IS	/(173)
/				IS RETURNED IN THE AC, R1, AND	/(173)
/				R2. THIS REMOVES A LOT OF CODE.	/(173)
/ 174	01-APR-76 (RCHM)	MAKE S2 TASK LOADING LOOK LIKE	/(174)
/				IT IS HAPPENING AT INTERRUPT	/(174)
/				LEVEL TO AVOID THE PROBLEMS WITH/(174)
/				VAJEX.				/(174)
/ 175	06-APR-76 (RCHM)	1. CHECK FOR INTERRUPT LEVEL I/O/(175)
/				   BEFORE ALLOWING LUN MAPPING	/(175)
/				   TO OCCUR.			/(175)
/				2. MODIFY UNMARK SCAN LOOP FOR	/(175)
/				   BETTER EFFICIENCY.		/(175)
/				3. MODIFY SOME COMMENTS TO	/(175)
/				   INCLUDE SOME OF THE NEW STUFF/(175)
/ 176	14-APR-76 (RCHM)	A BUG HAS APPEARED INVOLVING THE/(176)
/				MULTIPLE EXISTANCE OF A SMALL	/(176)
/				NODE. INCLUDE AN INTELLIGENT	/(176)
/				NODE SCANNER ON USER COMMAND	/(176)
/ 177	16-APR-76 (RCHM)	BUG IN THE XQT DIRECTIVE.	/(177)
/ 200	20-APR-76 (RCHM)	MORE OF 177.			/(200)
/ 201	27-APR-76 (RCHM)	CLEAN UP THE REST OF THE SCF	/(201)
/				INTERFACE BY NOT ALLOWING	/(201)
/				ASSEMBLY TIME NODE GENERATION IN/(201)
/				PAGE 1.				/(201)
/				ALSO TAKE OUT THE USRTAB	/(201)
/				ASSEMBLY PARAMETER.		/(201)
/								/EAG:202
/ 202	6-MAY-76 (EAG)		MODIFY QJOB DIRECTIVE FOR	/EAG:202
/				MULTIACCESS BATCH.  IN THE	/EAG:202
/				PROCESS, ADD SUBROUTINE		/EAG:202
/				"MAPLUN" AND MAKE Q I/O AND	/EAG:202
/				EXECUTE USE IT.			/EAG:202
/				ALSO ADD "L.ALL" SELECTIVE	/EAG:202
/				LISTING PARAMETER.		/EAG:202
/				ALSO FIX THE CONDITIONALS	/EAG:202
/				WHICH VERIFY THE LEGALITY OF	/EAG:202
/				VARIOUS CONDITIONAL ASSEMBLY	/EAG:202
/				PARAMETERS.			/EAG:202
/								/EAG:202
/ 203	13-MAY-76 (EAG)		TYPE IN SOME FIXES REQUESTED	/EAG:203
/				BY OTHER PEOPLE.  FIXES ARE TO	/EAG:203
/				EXECUTE AND REQUEST MAPPED	/EAG:203
/				DIRECTIVES.  ALSO DEFINE	/EAG:203
/				LOCATION "DEBUG" IN SCOM.	/EAG:203
/								/EAG:203
/ 204	14-MAY-76 (MJH)		CHANGE TIME SLICING ROUTINE AND
/				ASSOCIATED SCOM (320). ALSO FIX
/				BUG IN S.R. SCHINT AND TUNE
/				CONTEXT SWITCHING FOR NRM TASKS..
/ 205	17-MAY-76 (RCHM)	FIX A POSSIBLE BUG IN FIX	/(205)
/				AND A DEFINITE BUG IN XQT	/(205)
/				DIRECTIVES.			/(205)
/ 206	19-MAY-76 (RCHM)	INSTALL THE RSX LIGHT SHOW.	/(206)
/				ALSO MODIFY THE WAY QJOB KNOWS	/(206)
/				ABOUT THE MAXIMUM NUMBER OF	/(206)
/				JOBS IN THE QUE.		/(206)
/ 207	14-MAY-76 (RCHM)	THERE IS A SUBTLE PROBLEM WHICH	/(207)
/				EXISTS IF A JOB HAVING MORE THAN/(207)
/				ONE LUN ATTACHED TO THE SAME	/(207)
/				DEVICE. THE REVISION OF ATDT	/(207)
/				ALLOWS ONLY ONE LUN/DEVICE TO BE/(207)
/				ATTACHED TO EACH DEVICE.	/(207)
/ 210	30-JUL-76 (RCHM)	FIX COMMENTS IN QUEUOB DIRECTIVE/(210)
/				AND PROBLEM WITH VAJX.		/(210)
/ 211	09-AUG-76 (RCHM)	FIX RACE CONDITION BETWEEN	/(211)
/				TIME SLICER AND THE EXIT PROC-	/(211)
/				ESSER.				/(211)
/ 212 	12-AUG-76 (RCHM)	FIX ASSEMBLY PROBLEM WITH THE 	/(212)
/				"NOMAC" VERSION OF RSX.		/(212)
/ 213	27 APR 77 (JMW)		SAVE GUARD BIT WITH FP15 REG'S	/(213)
/	23 NOV 77 (PDH)		MAKE CHANGES TO ALLOW FOR I/O	/(213)
/				COUNT IN ACCOUNTING ROUTINES.	/(213)
/				READ ACSW'S AT SIGNIFICANT EVENT/(213)
/	19 DEC 77 (PDH)		HAVE TASK TIMING ROUTINE SAVE	/(214)
/				UIC AS WELL AS OTHER THINGS.	/(214)
/				ALSO LOOKS LIKE A GOOD IDEA TO	/(214)
/				ZERO THE I/O COUNT WHEN WE	/(214)
/				INITIATE A NEW TASK		/(214)
/ XVM/RSX		30-DEC-75		S. REESE
/                                               D. BREVIK
/						B. LACROUTE
/						R. MCLEAN
/						C. PROTEAU
/                                               H. KREJCI
/						B. DESIMONE
/          		         		D. VELTEN
/			         		M. HEBENSTREIT
/			       			S. ROOT
/						R. MUNROE
/
/ NOTE: ASSEMBLING RSX.P1 160 WITH RSX.P2 161 DEFINES
/	VERSION 1A OF THE XVM/RSX EXECUTIVE.
/ 
	.ABSP	NLD
/
/ CONDITIONAL ASSEMBLY PARAMETERS
/
	.IFUND L.ALL						/EAG:202
	.NOLST							/EAG:202
	.ENDC							/EAG:202
/								/EAG:202
	.DEC
	.IFUND .PASSN						/(161)
.PASSN=-1							/(161)
	.ENDC							/(161)
.PASSN=.PASSN+1							/(161)
	.IFUND MCRTMO						/(161)
MCRTMO=30		/ DEFAULT IS 30 SECOND MCR TIMEOUT	/(175)
	.ENDC							/(161)
	.IFPNZ MCRTMO						/(161)
	.IFNEG MCRTMO-15					/(161)
	.LST							/EAG:202
	.END MCR TIMEOUT INTERVAL MUST BE >= 15 SECONDS.	/(175)
	.ENDC							/(161)
	.ENDC							/(161)
	.IFZER .PASSN						/(161)
MCRTMO=MCRTMO*4		/ TIME OUT INTERVAL IN 1/4 SECONDS.	/(161)
	.ENDC							/(161)
	.IFUND MA.NLU						/(161)
MA.NLU=25		/ DEFAULT NUMBER OF MULTIACCESS LUNS.	/(161)
	.ENDC							/(161)
	.IFNEG MA.NLU-25					/(161)
	.LST							/EAG:202
	.END MA.NLU MUST BE >= 25 (DECIMAL)			/EAG:202
	.ENDC							/(161)
	.IFPOZ MA.LUN-512					/(161)
	.LST							/EAG:202
	.END MA.NLU MUST BE < 512 (DECIMAL)			/EAG:202
	.ENDC							/(161)
/
	.IFUND	NLU	/NUMBER OF LOGICAL (I/O) UNITS
NLU=64			/DEFAULT: 64
	.ENDC
	.IFNEG	NLU-22
	.LST							/EAG:202
	.END NLU MUST BE >= 22 (DECIMAL)			/EAG:202
	.ENDC
	.IFPNZ MA.NLU-NLU					/(161)
	.LST							/EAG:202
	.END NLU MUST BE >= MA.NLU				/EAG:202
	.ENDC							/(161)
/
	.IFUND	TTYS	/MAX NUMBER OF TTY'S
TTYS=6			/DEFAULT: 6
	.ENDC
	.IFNEG	TTYS-1
	.LST							/EAG:202
	.END TTYS MUST BE >= 1					/EAG:202
	.ENDC
	.IFPNZ	TTYS-17
	.LST							/EAG:202
	.END TTYS MUST BE <= 17 (DECIMAL)			/EAG:202
	.ENDC
/
	.IFUND	NDSZ	/LIST NODE SIZE
NDSZ=10
	.ENDC
	.IFNEG	NDSZ-10
	.LST							/EAG:202
	.END NDSZ MUST BE >= 10 (DECIMAL)			/EAG:202
	.ENDC
/
	.IFUND	DSKMA	/MAX NUMBER OF DSK I/O ATTEMPTS (IN CASE OF ERR)
DSKMA=8
	.ENDC
/
	.IFUND QJBLMT	/ MAXIMUM NUMBER OF JOBS QUEUE TO BATCH	/EAG:202
	.IFUND NOMAC	/ ONLY DEFINE IF MULTIACCESS.		/EAG:202
QJBLMT=15							/EAG:202
	.ENDC							/EAG:202
	.ENDC							/EAG:202
/								/EAG:202
	.IFDEF NOMAC						/EAG:202
	.IFDEF QJBLMT						/EAG:202
	.LST							/EAG:202
	.END QJBLMT IS INAPPLICABLE WITHOUT MULTIACCESS		/EAG:202
	.ENDC							/EAG:202
	.ENDC							/EAG:202
/								/EAG:202
	.OCT
/								/EAG:202
	.IFUND L.ALL						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
/
/ DEFINING 'NOXM' PRODUCES A VERSION IN WHICH THE CODE
/ OCCUPIED BY THE SHARE DIRECTIVE AND TASK TIMING ROUTINE
/ IS REPLACED BY SMALL NODES.
/
/ DEFINING 'NOMAC' PRODUCES A VERSION OF THE EXECUTIVE WHICH	/(161)
/ WILL HAVE THE OLD TDV AND XFRCMD PROCESSORS. THE LUN MAPPING	/(161)
/ FACILITY WILL STILL BE IN EXISTENCE BUT THE USER NUMBER	/(161)
/ PROCESSING WILL BE DISABLED.					/(161)
/								/(161)
/								/(161)
/ THE PARAMETER "MCRTMO" IS SET TO 0 TO CONDITIONILIZE OUT THE	/(161)
/ MCR TIMEOUT CODE. IF IT IS SET TO ANY POSITIVE NON-ZERO NUMBER/(161)
/ GREATER THAN 15 IT IS THEN THE NUMBER OF SECONDS BETWEEN	/(161)
/ CHARACTERS THAT THE USER IS ALLOWED BEFORE MCR TIME OUT OCCURS/(161)
/								/(176)
/ THE PARAMETER %QDBG WILL CAUSE EACH REFERENCE NADD, SPRI, AND	/(176)
/ THE CLOCK QUEUE ROUTINES TO VERIFY THAT THE NODE TO BE ADDED	/(176)
/ DOES NOT ALREADY EXIST IN ANY NODE POOL. IF IT DOES, THE	/(176)
/ DEBUGGING CODE WILL HALT. THIS CODE WILL DEGRADE THE 		/(176)
/ PERFORMANCE OF RSX CONSIDERABLY AND MAY NOT BE EFFECTIVE IN	/(176)
/ THE DISCOVERY OF TIMING HACKS. IT IS BEING INCLUDED AS A	/(176)
/ IN HOUSE TESTING MECHANISM AND IS NOT RECOMMENDED FOR GENERAL	/(176)
/ USE.								/(176)
/								/(161)
/ THE PARAMETER "QJBLMT" SPECIFIES THE MAXIMUM NUMBER OF BATCH	/EAG:202
/ JOBS WHICH MAY BE QUEUED AT ANY ONE TIME.  THIS PARAMETER	/EAG:202
/ IS APPLICABLE ONLY TO MULTIACCESS BATCH, AND MUST NOT		/EAG:202
/ BE DEFINED WHEN NOMAC IS DEFINED.  ITS DEFAULT VALUE IS	/EAG:202
/ 15 (DECIMAL), WHICH IMPLIES THAT 15 JOBS MAY BE IN THE	/EAG:202
/ QUEUE AT ANY ONE TIME.  EACH JOB REQUIRES 2 SMALL NODES	/EAG:202
/ WHILE IT IS QUEUED.  IF THIS PARAMETER IS SET ZERO OR		/EAG:202
/ NEGATIVE IT IMPLIES THAT NO JOBS MAY BE QUEUED, SO BATCH	/EAG:202
/ WILL BE EXCLUDED FROM THE EXECUTIVE.				/EAG:202
/								/EAG:202
/								/(206)
/ DEFINING THE PARAMETER "LIGHTS" WILL REPLACE THE EXISTING	/(206)
/ IDLE LOOP WITH A LIGHT SHOW WHICH DISPLAYS IN THE AC, MQ,	/(206)
/ XR, AND LR. THIS LIGHT SHOW IS MODIFIABBLE BY APPROPRIATE	/(206)
/ USE OF THE SCOM LOCATIONS "PATRN", "CENTR", "LMAGIC", "RIGHT"	/(206)
/ AND "LEFT". THE LIGHT SHOW ALGORITHM IS A COLLABRATION OF	/(206)
/ STEVE ROOT, DICK MUNROE, AND ED GARDNER.			/(206)
/								/(206)
 .TITLE *** SELECTIVE LISTING PARAMETERS
/
/ TO LIST ONLY SELECTIVE PORTION, DEFINE "L.SEL" AND ONE OR MORE OF THE
/ FOLLOWING PARAMETERS TO INDICATE DESIRED LISTING SECTIONS.
/
/	L.SCOM	SYSTEM COMMUNICATIONS AND INTERRUPT DISPATCH
/	L.DIR	SYSTEM DIRECTIVES
/	L.SER	SIGNIFICANT EVENT RECOGNITION AND SAVE & RESTORE
/	L.RER	RE-ENTRANT SYSTEM ROUTINES
/	L.MAC	MEMORY PROTECT, CLOCK INTERRUPT SERVICE,  
/		I/O RUNDOWN TASK, & TIME SLICING SUBROUTINE
/	L.MCR	MCR AND TDV DISPATCH ROUTINES
/	L.DSK	DISK DRIVER
/	L.TTY	MULTI-TTY HANDLER
/	L.LUN	LUN & ATTACH TABLES
/	L.SCF	SYSTEM COMFIGURATION ROUTINE
/
/ DEFINE "L.ALL" TO HAVE ENTIRE ASSEMBLY LISTED, INCLUDING	/EAG:202
/ CRUFT WHICH IS NORMALLY LEFT OUT.  DEFINING L.ALL OVERRIDES	/EAG:202
/ THE CONDITIONAL LISTING STUFF DESCRIBED ABOVE.		/EAG:202
/								/EAG:202
/ NORMALLY, CODE WHICH IS OF LITTLE OR NO INTEREST WILL NOT	/EAG:202
/ BE LISTED.  THIS CODE INCLUDES LITERALS, NODE POOLS, AND	/EAG:202
/ SOME CONDITIONALIZED CODE WHICH IS NOT BEING ASSEMBLED.	/EAG:202
/ IF THIS CODE IS TO BE LISTED, DEFINE THE PARAMETER "L.ALL".	/EAG:202
/ DEFINING THIS PARAMETER ALSO INHIBITS SELECTIVE LISTING --	/EAG:202
/ I.E., IT INHIBITS THE ACTION OF L.SEL DESCRIBED ABOVE.	/EAG:202
/								/EAG:202
	.IFUND	L.SEL
L.SCOM=0
L.DIR=0
L.SER=0
L.RER=0
L.MAC=0
L.MCR=0
L.DSK=0
L.TTY=0
L.LUN=0
L.SCF=0
	.ENDC
/
	.IFDEF L.ALL						/EAG:202
L.SCOM=0							/EAG:202
L.DIR=0								/EAG:202
L.SER=0								/EAG:202
L.RER=0								/EAG:202
L.MAC=0								/EAG:202
L.MCR=0								/EAG:202
L.DSK=0								/EAG:202
L.TTY=0								/EAG:202
L.LUN=0								/EAG:202
L.SCF=0								/EAG:202
	.ENDC							/EAG:202
/								/EAG:202
	.IFUND	L.SCOM
	.NOLST
	.ENDC
 .TITLE *** GLOSSARY
/
/   ATL		ACTIVE TASK LIST (DEQUE)
/   CPB		CAL PARAMETER BLOCK
/   EV		EVENT VARIABLE
/   EV ADR	ADDRESS OF EVENT VARIABLE
/   LUN		LOGICAL UNIT NUMBER
/   PBDL	PARTITION BLOCK DEFINITIONS (DEQUE)
/   PDVL	PHYSICAL DEVICE LIST (DEQUE)
/   SCDL	SYSTEM COMMON BLOCK DEFINITIONS (DEQUE)
/   SCOM	SYSTEM COMMUNICATIONS AREA
/   SCF		SYSTEM CONFIGURATION ROUTINE
/   STL		SYSTEM TASK LIST (DEQUE)
/   TDV.EQ	TASK DEVELOPMENT EXIT QUE (DEQUE)		/(161)
/   UCA		MULTIACCESS USER CONTEXT AREA			/(161)
	.TITLE *** API LEVEL USAGE
/
/ 1.  API INTERRUPTS FROM LEVELS 0-3 ORIGINATE FROM HARDWARE ONLY. THE TTY
/     HANDLER CHECKS FOR SERVICEABLE KEYBOARD AND PRINTER INTERRUPTS AT API
/     LEVEL 3 TO PREVENT GETTING INTERRUPTED IN THE MIDDLE OF THE TEST.
/     SIMILARLY, THE SYNCRONIZE,RUN,SCHEDULE,CANCEL,MARK, AND UNMARK CALS
/     ACTIVATE API LEVEL 3 TEMPORARILY DURING THEIR EXECUTION.
/
/ 2.  API LEVEL 4 IS ACTIVATED BY HARDWARE WHENEVER A CAL IS ISSUED
/     PROVIDED THAT NO HARDWARE API LEVELS ARE ACTIVE, I.E. API LEVELS 0-3.
/     HENCE, API LEVEL 4 IS ACTIVATED WHENEVER A TASK ISSUES A CAL.
/
/ 3.  API LEVEL 5 IS ACTIVE ONLY WHEN SCF IS CHECKING FOR THE RE-ENTRANT
/     ECO PACKAGE.
/
/ 4.  API LEVEL 6 IS USED TO DECLARE A SIGNIFICANT EVENT. WHEN NO TASK IS 
/     RUNNING (I.E. SYSTEM IS IDLE OR THE EXEC IS WORKING IN A RESTARTABLE
/     MODE, VIZ. SCANNING THE ATL) AND A SIGNIFICANT EVENT IS DECLARED BY
/     AN INTERRUPT SERVICE ROUTINE, THE EXEC DROPS TO API LEVEL 7 AND SCANS
/     THE ATL FROM THE TOP. WHEN A TASK IS RUNNING AND A SIGNIFICANT EVENT
/     IS DECLARED, THE TASK'S REGISTERS ARE SAVED AT API LEVEL 6, THEN THE
/     EXEC DROPS TO API LEVEL 7 AND SCANS THE ATL FROM THE TOP. DURING THE
/     ATL SCAN LEVEL 6 IS ACTIVATED AT S2, WHEN A NODE IS INSERTED INTO THE ATL,
/     AND AT S4 AND S5, WHEN A TASK IS DECLARED TO BE CURRENT. A TASK'S
/     REGISTERS ARE RESTORED AT API LEVEL 6 WHENEVER THE TASK RESUMES
/     EXECUTION.
/
/ 5.  API LEVEL 7 IS ACTIVE WHEN THE EXEC IS SCANNING THE ATL OR WHEN A
/     TASK IS RUNNING.
/
/ 6.  NO API LEVELS ARE ACTIVE (MAINSTREAM) WHEN THE SYSTEM IS IDLE.
/
 .TITLE *** FORMAT & CONVENTION DESCRIPTIONS
  
  
/ SYSTEM TASK LIST
/
/ THE SYSTEM TASK LIST (STL) IS A DIRECTORY OF TASKS IN THE SYSTEM.
/
/ THE SYSTEM TASK LIST IS MAINTAINED BY THE MCR (MONITOR
/ CONSOLE ROUTINE).  "INSTALL" ADDS ENTRIES, "REMOVE" REMOVES THEM.
/
/ THE STL IS SCANNED (FOR TASK NAME) BY THE "INSTALL" MCR FUNCTION,
/ AND BY THE "REQUEST" DIRECTIVE.  SINCE "INSTALL" AND "REMOVE" ARE
/ BOTH MCR FUNCTIONS AND RUN AT THE SAME PRIORITY LEVEL (AND NORMALLY
/ WITHIN THE SAME CORE PARTITION), THERE IS NO DANGER OF "REMOVE" 
/ REMOVING A NODE DURING AN STL SCAN BY "INSTALL".  ALSO, SINCE
/ "REQUEST" IS A DIRECTIVE (RUNS @ API-4) AND CANNOT BE INTERRUPTED
/ FOR TASK EXECUTION, THERE IS NO DANGER OF "REMOVE" REMOVING A
/ NODE DURING AN STL SCAN BY "REQUEST".
/
/ NOTE -- THE "DANGER" OF A SCAN BEING INTERRUPTED AND A NODE BEING
/ REMOVED IS THAT THE NODE THAT IS REMOVED COULD ALSO BE THE NODE
/ UNDER EXAMINATION IN THE SCAN.  NOT ONLY MIGHT THE NODE CONTENTS
/ BE ALTERED (THUS AFFECTING THE SCAN), BUT THE NODE MAY ALSO BE
/ ADDED TO ANOTHER DEQUE (VIZ., RETURNED TO THE POOL) AND THE SCAN
/ WOULD THEN CONTINUE THRU THE WRONG DEQUE!
/
/ EACH STL ENTRY CONSISTS OF A DEQUE NODE OF THE FOLLOWING FORMAT:
/
/ WORD	 CONTENTS
/
S.FP=0	/FORWARD LINKAGE
S.BP=1	/BACKWARD LINKAGE
S.N1=2	/TASK NAME (FIRST HALF)
S.N2=3	/TASK NAME (SECOND HALF)
S.DP=4	/FLAGS & DEFAULT PRIORITY
S.PB=5	/PARTITION BLOCK ADDRESS
S.DA=6	/DISK ADDRESS & UNIT (SEE NOTE BELOW)
S.DB=7	/SIZE OF RESIDENT CODE (DISK TRANSFER LENGTH)
S.TS=10	/TASK SIZE (SEE NOTE BELOW)
S.EP=11	/TASK ENTRY POINT
/
/ NOTES --
/
/ TASK NAME IS IN .SIXBT FORMAT (RIGHT FILLED WITH ZEROS)
/
/ FLAGS & DEFAULT PRIORITY WORD FORMAT
/   BIT-0  SET TO INDICATE "TASK IS ACTIVE"
/   BIT-1  SET TO INDICATE "REMOVE ON EXIT" 
/   BIT-2  SET TO INDICATE "TASK DISABLED"
/   BIT-3  SET TO INDICATE "TASK FIXED IN CORE"
/   BIT-4  SET TO INDICATE "PARTITION LOST IN RECONFIGURATION"
/   BIT-5  SET TO INDICATE "RECONFIGURATION IN PROGRESS"
/   BIT-6  SET TO INDICATE "TASK HAS EXITTED"
/   BIT-7  (UNUSED FLAG)
/   BITS 8-17  DEFAULT PRIORITY
/
/ THE "DISK ADDRESS" POINTS TO THE BEGINNING OF THE TASK'S 
/ IMAGE AS RECORDED ON THE DISK.
/ THE DISK UNIT (PLATTER) NUMBER IS OR'ED INTO THE LOW ORDER THREE
/ BITS OF THE ACTUAL DISK ADDRESS.
/
/ THE TASK SIZE REPRESENTS THE CORE REQUIRED TO RUN THE TASK.  FOR
/ AN EXEC MODE TASK WITH NO OVERLAYS THIS IS THE SAME AS WORD 'S.DB'.
/ FOR A NORMAL MODE TASK, DUE TO THE MEMORY PROTECT INCREMENT, THE
/ SIZE IS A MULTIPLE OF 400 OCTAL.
/ FOR NORMAL MODE TASKS BITS 10-13 OF 'S.TS', WHICH WOULD
/ ORDINARILY BE ZERO, ARE USED TO STORE THE MM REGISTER DATA.
/ THIS WORD WILL HAVE THE FOLLOWING FORMAT FOR NORMAL MODE TASKS:
/
/   BITS 0-9 -- TASK SIZE
/   BIT-10   -- RESERVED FOR RELOCATE DISABLE (NOT IMPLEMENTED)
/   BITS 11-12 -- SET IF TASK RUNS IN XVM MODE (WIDE INDIRECT ADDRESS)
/   BIT-13     -- SET IF TASK HAS IOT PERMISSION
/   BITS 14-17 -- UNUSED
/
/ THE ENTRY POINT WORD IS OF THE FOLLOWING FORMAT:
/   BIT-0 -- INITIAL LINK CONTENTS (ZERO IF THE TASK WAS BUILT NOT
/	     REQUIRING THE FLOATING POINT HARDWARE; 1 IF THE TASK
/	     REQUIRES THE EXISTENCE OF THE FP15)
/   BIT-1 -- PAGE/BANK MODE INDICATOR (0/1)
/   BIT-2 -- EXEC/NORMAL MODE INDICATOR (0/1)
/   BITS 3-17 -- TASK ENTRY POINT (ABSOLUTE ADDRESS IF EXEC MODE,
/                RELATIVE TO PARTITION BASE IF NORMAL MODE).
/
	.EJECT
/ ACTIVE TASK LIST
/
/ THE ACTIVE TASK LIST (ATL) IS A PRIORITY ORDERED LIST OF ACTIVE
/ TASKS.  AN ACTIVE TASK IS A TASK THAT HAS BEEN REQUESTED.
/ (AN ACTIVE TASK MIGHT NOT BE RUNNING BECAUSE:  IT IS NOT YET IN CORE,
/ A HIGHER PRIORITY TASK IS RUNNING, IT HAS ISSUED A "SUSPEND" OR "WAIT")
/ A TASK IS REQUESTED VIA THE "REQUEST" DIRECTIVE, OR IT IS SCHEDULED
/ (RUN, SCHEDULE, OR SYNC, DIRECTIVES) AND IS REQUESTED WHEN IT BECOMES DUE.
/
/ "REQUEST" INSERTS ATL NODES (PER PRIORITY), AND "EXIT" REMOVES ATL
/ NODES.
/
/ THE ATL IS SCANNED BY THE "REQUEST" DIRECTIVE (FOR PRIORITY), BY THE
/ "RESUME" DIRECTIVE (FOR TASK NAME), AND BY THE "EXECUTIVE" (TO EXAMINE 
/ TASK STATUS).  "EXIT" IS A DIRECTIVE WHICH MAY ONLY
/ BE ISSUED FROM A TASK (RUNS @ API-7).  I.E., AN "EXIT" CANNOT BE
/ ISSUED WHILE A "REQUEST" OR "RESUME" DIRECTIVE, OR THE "EXECUTIVE"
/ IS RUNNING.  THEREFORE, THERE IS NO DANGER OF "EXIT" REMOVING A NODE
/ DURING AN ATL SCAN BY "REQUEST", "RESUME", OR "EXECUTIVE".
/
/ EACH ATL ENTRY CONSISTS OF A DEQUE NODE OF THE FOLLOWING FORMAT:
/
/ THE FOLLOWING ATL NODE FORMAT IS ASSUMED BY:
/   THE 'REQUEST' CAL SERVICE ROUTINE AND THE CLOCK INTERRUPT SERVICE ROUTINE
/
/ WORD	 CONTENTS
/
A.FP=0	/FORWARD LINKAGE
A.BP=1	/BACKWARD LINKAGE
A.N1=2	/TASK NAME (FIRST HALF)
A.N2=3	/TASK NAME (SECOND HALF)
A.TP=4	/TASK PRIORITY
A.PB=5	/PARTITION BLOCK ADDRESS
A.SN=6	/STL NODE ADDRESS
A.TS=7	/FLAGS & TASK STATUS
A.RA=10	/START OR RESUMPTION ADDRESS
A.EV=11	/EVENT VARIABLE ADDRESS (TASK LOADING OR 'WAITFOR' DIRECTIVE)
	/ OR LUN OFFSET AND USER NUMBER.			/(161)
/
/ NOTES --
/
/ FLAGS (BITS 0-8)
/   BIT-0  TASK LOADING FLAG
/   BITS 1-8  (UNUSED)
/
/ TASK STATUS DEFINITIONS (BITS 9-17)
/   0 -- NOT TO BE RESCHEDULED
/   1 -- TASK IS DISK RESIDENT AND NEEDS PARTITION
/   2 -- PARTITION IS AVAILABLE, SETUP DISK READ REQUEST
/   3 -- WAITING FOR EVENT VARIABLE
/   4 -- TASK IS READY TO BE STARTED OR RESUMED (WAIT OR SUSPEND)
/   5 -- TASK IS RUNNING, IF INTERRUPTED ITS REGISTERS MUST BE RESTORED
/   6 -- TASK HAS BEEN [SELF] SUSPENDED
/   7 -- TASK EXECUTION HAS BEEN STOPPED FOR TIME SLICING
/
/ THE START OR RESUMPTION ADDRESS CONTAINS THE TASK ENTRY POINT FOR:
/ INITIAL ENTRY, RESTART AFTER WAIT, OR RESUME AFTER SUSPEND, AND
/ IS OF THE FOLLOWING FORMAT:
/   BIT-0 -- LINK CONTENTS
/   BIT-1 -- PAGE/BANK MODE INDICATOR (0/1)
/   BIT-2 -- EXEC/NORMAL MODE INDICATOR (0/1)
/   BITS 3-17 -- START OR RESUMPTION ADDRESS (ABSOLUTE IF EXEC MODE,
/                RELATIVE TO PARTITION BASE IF NORMAL MODE).
/
/ IF THE TASK IS IN STATE 1, I.E. WAITING FOR A PARTITION, THEN	/(161)
/ A.EV WILL CONTAIN THE LUN OFFSET (BITS 0-8) AND THE USER	/(161)
/ NUMBER (BITS 9-13) AS INITIALIZED BY A REQUEST MAPPED. FIX	/(161)
/ AND NORMAL REQUEST WILL ZERO THIS WORD.			/(161)
	.EJECT
/ CLOCK QUEUE
/
/ WHENEVER SOMETHING IS TO BE SCHEDULED AT SOME TIME IN THE
/ FUTURE (SCHEDULE, RUN, SYNC & MARK DIRECTIVES), AN ENTRY IS
/ MADE IN THE CLOCK QUEUE.  THE CLOCK QUEUE IS A STANDARD
/ DEQUE WITH ENTRIES CHRONOLOGICALLY MADE.  THE SCHEDULE
/ TIME IN ALL NODES, EXCEPT THE FIRST NODE, IS RELATIVE TO
/ THE PREVIOUS NODE.  THE SCHEDULE TIME IN THE FIRST NODE
/ IS RELATIVE TO "NOW" AND IS DECREMENTED AND EXAMINED
/ AT EACH CLOCK TICK.
/
/ CLOCK QUEUE NODES ARE OF THE FOLLOWING FORMAT:
/
C.FP=0	/FORWARD LINKAGE
C.BP=1	/BACKWARD LINKAGE
C.TI=2	/TYPE INDICATOR [TS,MT]
C.MD=3	/ UNUSED.						/(175)
C.PE=4	/PRIORITY [TS] OR EVENT VAR ADR [MT]
C.SP=5	/STL NODE ADR [TS] OR PARTITION BLOCK ADR [MT]
C.SS=6	/SCHEDULE INTERVAL SECONDS [TS,MT]
C.ST=7	/SCHEDULE INTERVAL TICKS [TS,MT]
C.RS=10	/RESCHEDULE INTERVAL SECONDS [TS]
C.RT=11	/RESCHEDULE INTERVAL TICKS [TS]
/
/		TS -- TASK SCHEDULING USAGE
/		MT -- MARK TIME USAGE
/
/ THE TYPE INDICATOR IS SET TO INDICATE THE FOLLOWING
/   0 -- TASK SCHEDULING WITH NO RESCHEDULING
/   1 -- TASK SCHEDULING WITH RESCHEDULING
/   5 -- MARK TIME
/   6 -- NULL NODE (RESULT OF CANCELLATION)
/
/ MODE INDICATOR (C.MD):					/(175)
/   FORMERLY 0 = EXEC MODE; NON-0 = NORMAL MODE			/(175)
/   CURRENTLY UNUSED.						/(175)
/
/ THE "SCHEDULE TICKS" IS ONLY ZERO WHEN A NODE IS TO "COME DUE"
/ AT THE SAME TIME AS THE PREVIOUS NODE.  IT IS NEVER GREATER
/ THAN THE NUMBER OF TICKS PER SECOND.  WHEN AN INTERVAL OF
/ MORE THAN ONE SECOND IS REPRESENTED, THE "SCHEDULE SECONDS"
/ INDICATES THE NUMBER OF ADDITIONAL SECONDS.  BOTH THE SCHEDULE
/ TICKS AND SECONDS ARE RECORDED AS TWO'S COMP NEGATIVE NUMBERS.
/ THIS FORMAT HAS BEEN ESTABLISHED FOR THE CONVENIENCE OF THE CLOCK
/ INTERRUPT SERVICE ROUTINE.
/
/ THE RESCHEDULE SECONDS & TICKS ARE THE SCHEDULE RESET VALUES
/ WHEN PERIODIC TASK RESCHEDULING HAS BEEN REQUESTED.  BOTH ARE
/ RECORDED AS POSITIVE NUMBERS.
/
/ NOTE: THE UNMARK AND CANCEL DIRECTIVES DO NOT REMOVE ENTRIES
/ FROM THE CLOCK QUEUE. ENTRIES ARE REMOVED ONLY BY THE CLOCK
/ INTERRUPT SERVICE ROUTINE WHEN A REQUEST COMES DUE.  THESE
/ DIRECTIVES ONLY NULLIFY CKQ ENTRIES.
/
	.EJECT
/ PARTITION BLOCK DESCRIPTION LIST
/
/ FOR EACH PARTITION IN THE SYSTEM, THERE IS A NODE (PBSZ WORDS LONG)
/ CONTAINING INFORMATION ABOUT THE PARTITION, THE TASK CURRENTLY RUNNING
/ IN THE PARTITION, AND A SAVE AREA FOR THAT TASK'S REGISTER CONTENTS
/ WHENEVER THE EXECUTIVE INTERRUPTS THE TASK.
/
/ THESE NODES ARE LINKED TOGETHER AS THE PARTITIONS BLOCK DESCRIPTION
/ LIST (PBDL) WITH LISTHEAD IN THE SYSTEM COMMUNICATION AREA.
/
/ ***************************************************************
/								*
/ NOTE -- ANY CHANGES TO THE FORMAT OF THE PARTITION BLOCK NODE *
/ MUST BE REFLECTED IN THE CODE IN "SCF" FOLLOWING SCF101	*
/ WHERE THE NODES ARE SET UP, AND IN THE RECONFIGURATOR.        *
/								*
/ ***************************************************************
/
/ THE FORMAT OF A PARTITION BLOCK IS AS FOLLOWS:
/
/ WORD	 	CONTENTS
/
P.FP=0		/FORWARD LINKAGE
		/BACKWARD LINKAGE
P.N1=2		/PARTITION NAME (FIRST HALF)
P.N2=3		/PARTITION NAME (SECOND HALF)
P.BA=4		/PARTITION BASE (ADDRESS)
P.SZ=5		/PARTITION SIZE
P.TS=6		/TASK SIZE
P.TP=7		/COUNT OF PENDING TRANSFERS TO THE PARTITION
P.FW=10		/FLAGS WORD
P.VS=11		/PARTITION'S VIRTUAL SIZE
P.BP=12		/0 OR 17-BIT ADDRESS OF 1ST I/O BUFFER IN THE PARTITION
		/ADDRESS OF 'SAV'
P.IC=14		/INTERRUPT 'CONNECT' LOCATION
		/'DBA' INSTRUCTION
		/JMS TO 'SAV' (JMS* .-3)
P.AC=17		/AC BUFFER
P.XR=P.AC+1	/XR BUFFER
P.LR=P.XR+1	/LR BUFFER  	**
P.MQ=P.LR+1	/MQ BUFFER  	**
P.SC=P.MQ+1	/SC BUFFER  	**
P.R1=P.SC+1	/R1 BUFFER	**
P.R2=P.R1+1	/R2 BUFFER	**
P.R3=P.R2+1	/R3 BUFFER	***
P.R4=P.R3+1	/R4 BUFFER	***
P.R5=P.R4+1	/R5 BUFFER
P.R6=P.R5+1	/R6 BUFFER
P.10=P.R6+1	/X10 BUFFER
P.11=P.10+1	/X11 BUFFER
P.12=P.11+1	/X12 BUFFER
P.13=P.12+1	/X13 BUFFER
P.14=P.13+1	/X14 BUFFER
P.15=P.14+1	/X15 BUFFER
P.16=P.15+1	/X16 BUFFER
P.17=P.16+1	/X17 BUFFER
P.20=P.17+1	/L20 BUFFER
P.SW=P.20+1	/SWITCH		****
P.MM=P.SW+1	/MM BUFFER
P.C1=P.MM+1	/XM CLOCK OVERFLOWS
P.C2=P.C1+1	/XM CLOCK TICKS
P.TC=P.C2+1	/TASK USE COUNT (POSITION RELIED ON BY REMOVE)	/(161)
P.UP=P.TC+1	/TASK USE COUNT POINTER
P.FB=P.UP+1	/EPA		******
		/FMA1		******
		/FMA2		******
P.FM=P.FB+3	/FMQ1		******
		/FMQ2		******
P.JE=P.FB+5	/JEA		******
P.IO=P.JE+1	/I/O COUNT LOCATION				/(213)
P.FE=P.FB+5
/
/ ** THIS AREA OF PARTITION BLOCK IS USED FOR AN EVENT VARIABLE AND
/    A DISK GET CONTROL TABLE WHEN LOADING A DISK RESIDENT TASK INTO
/    THE CORRESPONDING PARTITION.
/
P.EV=P.LR	/EVENT VARIABLE
P.DU=P.EV+1	/DISK UNIT
P.DA=P.DU+1	/DISK ADDRESS
P.CA=P.DA+1	/CORE ADDRESS
P.WC=P.CA+1	/WORD COUNT
/
/ *** THIS AREA OF PARTITION BLOCK IS USED TO ZERO THE TASK'S
/     PARTITION EXCEPT THE DISK LOAD AREA PRIOR TO TASK EXECUTION.
/
P.Z1=P.R3	/ZEROING POINTER (ALSO USED AS A FLAG)
P.Z2=P.Z1+1	/COUNTER FOR WORDS ZEROED
/
/ ****  THIS WORD IS A 'SKP' FOR PARTITION BLOCKS AND A 'NOP' FOR
/       INTERRUPT SERVICE ROUTINES.  IF AN INTERRUPT SERVICE ROUTINE
/       IS TO USE THE REGISTER SAVE ROUTINE, IT MUST HAVE AN ENTRY
/       AND A BUFFER IDENTICAL TO A PARTITION BLOCK BETWEEN THE
/       WORDS 'P.IC' AND 'P.SW'.  AFTER REGISTERS ARE SAVED FOR AN
/       INTERRUPT SERVICE ROUTINE, CONTROL IS TRANSFERRED TO THE WORD
/       FOLLOWING 'P.SW'.
/
P.IS=P.SW+1	/INTERRUPT SERVICE ROUTINE
/
/ ****** THIS BUFFER FOR THE FLOATING POINT UNIT EXISTS ONLY IN PARTITION
/        BLOCKS WHEN THE FLOATING POINT HARDWARE EXISTS.  THE JEA IS
/	 SET  UP INITIALLY (VIA THE 'SETJEA' DIRECTIVE).
/
PBSZ=P.IO-P.FP+1	/TOTAL SIZE OF PARTITION BLOCK (INC FP BUFFER) /(213)
PBFP=P.FE-P.FB+1	/SIZE OF FLOATING POINT REGISTER BUFFER
PBIB=P.20-P.AC+1	/SIZE OF REGISTER SAVE AREA FOR INTERRUPT SERVICE ROUTINES
PBMM=P.UP-P.MM+1	/SIZE OF XVM REGISTER AREA
/
/ NOTES --
/
/ THE TASK SIZE (WORD P.TS) IS THE AMOUNT OF A PARTITION AVAILABLE TO 
/ A TASK.  IT IS DETERMINED BY THE POSITION OF THE MEMORY PROTECT
/ BOUND REGISTER, AND MAY BE INCREASED BY THE 'RAISE BOUND' DIRECTIVE.
/
/ THE PARTITION'S VIRTUAL SIZE (WORD P.VS) IS SET EQUAL TO ITS ACTUAL
/ SIZE WHEN A TASK IS INITIALLY MADE ACTIVE. IT IS DECREASED WHENEVER
/ THE TASK ISSUES AN I/O DIRECTIVE TO PREALLOCATE I/O BUFFER SPACE TO
/ AN I/O HANDLER THAT USES BUFFERS FROM THE TOP OF A TASK'S PARTITION.
/ IT IS ALSO DECREASED WHENEVER SUCH A HANDLER ALLOCATES BUFFER SPACE
/ BEYOND THAT WHICH HAS ALREADY BEEN PREALLOCATED.
/ AFTER THE TASK HAS PREALLOCATED ALL THE LUNS IT INTENDS TO USE, IT
/ CAN INCREASE THE TASK SIZE (WORD P.TS), BY USE OF THE 'RAISE BOUND'
/ DIRECTIVE, NOT TO EXCEED THE PARTITION'S VIRTUAL SIZE.
/
/ THE WORDS P.C1 AND P.C2 ARE USED TO STORE THE XM CLOCK TICKS
/ FOR WHICH A TASK HAS RUN.  P.C1 GIVES THE NUMBER OF XM CLOCK
/ OVERFLOWS (1 UNIT REPRESENTS 2.62 SECONDS). P.C2 GIVES THE NUMBER
/ OF XM CLOCK TICKS BEYOND THOSE INDICATED BY P.C1.  EACH XM CLOCK
/ TICK REPRESENTS 10 MICROSECONDS.  THESE WORDS ARE MANIPULATED
/ IN SIGNIFICANT EVENT RECOGNITION AND WHEN THE TASK EXITS.
/
/ THE TASK USE COUNT (P.TC) GIVES THE NUMBER OF TASKS REFERENCING
/ THE PARTITITION.
/ THE TASK USE COUNT
/ IS INCREMENTED WHENEVER A TASK IS LOADED INTO THE PARTITION	/(161)
/ OR A SHARE DIRECTIVE IS INVOKED FOR THE PARTITION.
/ IT IS DECREMENTED BY UNFIX AND EXIT, AS WELL AS, SHARE.  WHENEVER
/ P.TC IS NON-ZERO TASKS WILL NOT BE ABLE TO LOAD INTO THE PARTITION.
/ HENCE THE LOW ORDER BITS OF P.TC CAN BE CONSIDERED THE 	/(161)
/ 'PARTITION OCCUPIED' FLAG.					/(161)
/ WHENEVER A TASK IS RUNNING IN THE PARTITION AND IS SHARING SOME
/ BLOCK OF MEMORY, THE TASK USE COUNT POINTER (P.UP) POINTS TO THE
/ TASK USE COUNT WORD OF THE BLOCK OF MEMORY BEING SHARED.
/
/ FLAG WORD BIT DESIGNATIONS:
/   BIT 0-8 -- SET TO THE LUN OFFSET FOR THE TASK USING THIS	/(161)
/	       PARTITION.					/(161)
/   BIT 9-13 -- SET TO THE USER NUMBER OF THE TASK USING THIS	/(161)
/		PARTITION.					/(161)
/   BIT 15 -- SET WHEN RECONFIGURATION IS IN PROGRESS
/   BITS 16-17 -- SET TO INDICATE:
/		NO SHARING ALLOWED (00)
/		READ ONLY SHARING ALLOWED (01)
/		SHARING ALLOWED WITHOUT RESTRICTION (10)
/
/
	.EJECT
/ PHYSICAL DEVICE NODES LIST
/
/ WHEN A LOGICAL I/O UNIT IS ASSIGNED TO A PHYSICAL UNIT, THE ADDRESS
/ OF A NODE DESCRIBING THE PHYSICAL DEVICE IS SET IN A LOGICAL UNIT
/ TABLE ENTRY CORRESPONDING TO THE LOGICAL "UNIT NUMBER" (LUN).
/ THESE NODES ARE LINKED TOGETHER AS THE PHYSICAL DEVICE LIST (PDVL)
/ WITH LISTHEAD IN THE SYSTEM COMMUNICATIONS AREA.
/
/ PHYSICAL DEVICE NODE FORMAT:
/
/ WORD	 CONTENTS
/
D.FP=0	/FORWARD LINKAGE
D.BP=1	/BACKWARD LINKAGE
D.N1=2	/DEVICE NAME (FIRST HALF)
D.N2=3	/DEVICE NAME (SECOND HALF) -- ALWAYS ZERO
D.AF=4	/DEVICE ATTACH FLAG
D.UN=5	/UNIT NUMBER
D.QF=6	/DEVICE REQUEST QUEUE (DEQUE LIST HEAD) FORWARD LINKAGE
D.QB=7	/DEVICE REQUEST QUEUE (DEQUE LIST HEAD) BACKWARD LINKAGE
D.TG=10	/TRIGGER EVENT VARIABLE ADDRESS
D.AI=11	/ASSIGN INHIBIT FLAG
/
/ NOTES --
/
/ THE DEVICE-ATTACH-FLAG IS SET NON-ZERO WHENEVER THIS DEVICE-UNIT IS
/ ATTACHED TO A TASK.  WHEN THE UNIT IS NOT ATTACHED, THIS WORD IS ZERO.
/ WHEN NON-ZERO, THIS FLAG POINTS TO A WORD IN THE ATTACH-FLAG-TABLE
/ WHICH CONTAINS THE ADDRESS OF THE TASK'S STL NODE. THE DEVICE-ATTACH-FLAG
/ IS SET BY THE 'ALAD' SUBROUTINE, AND CLEARED BY THE 'DLAD' SUBROUTINE,
/ BY THE 'DMTQ' SUBROUTINE, OR BY THE REASSIGN MCR FUNCTION TASK.
/
/ THE ASSIGN INHIBIT FLAG BIT 0 IS SET BY THE "REASSIGN" MCR FUNCTION
/ TO INDICATE THAT IT HAS REMOVED THE TRIGGER ADDRESS FROM
/ THE PHYSICAL DEVICE NODE AND HAS REQUESTED THE HANDLER TASK
/ TO EXIT.  THIS REQUEST IS AN I/O REQUEST NODE WITH AN
/ I/O FUNCTION CODE OF 777. BIT 1 MAY BE SET BY I/O HANDLER TASKS,
/ NOTABLY THE DISK FILE HANDLERS, TO SIGNAL "REASSIGN" THAT FILES ARE
/ OPEN. THIS FLAG IS CLEARED BY THE HANDLER TASK WHEN IT EXITS.
/ AFTER THE FLAG IS CLEARED, THE HANDLER MAY BE ASSIGNED (AND THE
/ HANDLER TASK MAY BE REQUESTED BY "REASSIGN".)
/
	.EJECT
/ SYSTEM COMMON BLOCK DEFINITIONS
/
/ THE NAME, BASE ADDRESS, AND SIZE, OF EACH SYSTEM COMMON BLOCK
/ IS DESCRIBED IN A NODE, AND THESE NODES ARE LINKED TOGETHER AS THE
/ SYSTEM COMMON BLOCK DESCRIPTIONS LIST (SCDL) WITH LISTHEAD IN THE
/ SYSTEM COMMUNICATIONS AREA.  THIS INFORMATION IS SET BY SCF FOR
/ USE BY 'INSTALL' (AND ANY OTHER TASK), BUT IS NOT NEEDED BY
/ THE EXECUTIVE.
/
/ NODE FORMAT:
/
/ WORD	 CONTENTS
/
B.FP=0	/FORWARD LINKAGE
B.BP=1	/BACKWARD LINKAGE
B.N1=2	/COMMON BLOCK NAME (FIRST HALF)
B.N2=3	/COMMON BLOCK NAME (SECOND HALF)
/	(UNUSED WORD)
B.BA=5	/BASE ADDRESS OF COMMON BLOCK
B.SZ=6	/SIZE OF COMMON BLOCK
/	(UNUSED WORD)
B.FW=10	/FLAGS WORD
B.TC=11	/TASK USE COUNT
/
/ B.FW AND B.TC HAVE THE SAME SIGNIFICANCE AS THE CORRESPONDING
/ WORDS FOR THE PBDL LIST.  THE BIT DESIGNATIONS ARE IDENTICAL.
/
	.EJECT
/ TASK ABORT NOTICE
/
/ WHEN A TASK IS ABORTED, A REQUEST TO LOG THE TASK NAME,
/ CAUSE OF TERMINATION, PC, AC, AND XR, IS QUEUED IN A DEQUE
/ TERMINATION NOTICE REQUEST LIST (TNRL) WITH LISTHEAD IN
/ THE SYSTEM COMMUNICATIONS AREA, AND A LOGGING TASK IS
/ REQUESTED. MESSAGES ARE ALSO QUEUED WHEN I/O RUNDOWN IS PERFORMED
/ BUT THE "TRANSFERS PENDING" COUNT NEVER REACHES ZERO.
/
/ NODE FORMAT:
/
	/FORWARD LINKAGE
	/BACKWARD LINKAGE
	/TASK NAME (FIRST HALF)
	/TASK NAME (SECOND HALF)
	/TERMINATION INDICATOR
	/PC AT TERMINATION; OR TRANSFERS PENDING COUNT
	/AC AT TERMINATION; OR NOTHING
	/XR AT TERMINATION; OR NOTHING
	/(UNUSED WORD)
	/(UNUSED WORD)
/
/ NOTES:
/
/ WORD 'T.TI' INDICATES THE CAUSE OF TERMINATION AS FOLLOWS:
/   1 -- MEMORY PROTECT ERR
/   2 -- NONEXISTENT MEMORY REF
/   3 -- BAD CAL
/   4 -- NON-0 TRANSFERS PENDING COUNT
/
	.EJECT
/ I/O RUNDOWN QUEUE
/
/ WHENEVER A TASK EXITS OR IS ABORTED AND ITS "TRANSFERS	/(176)
/ PENDING" COUNT IS NON-ZERO, THE TASK'S ATL (ACTIVE TASK LIST) NODE
/ IS INSERTED IN THIS QUEUE IN ORDER OF TASK PRIORITY AND THE SYSTEM'S
/ I/O RUNDOWN TASK, 'IORD', IS TRIGGERED TO SERVICE THE REQUEST. THE
/ QUEUE (IORDQ) HAS ITS LISTHEAD IN THE SYSTEM COMMUNICATIONS AREA.
/
/ NODE FORMAT IS IDENTICAL TO THAT FOR THE ACTIVE TASK LIST.
/
	.EJECT
/ POOL OF EMPTY LARGE NODES (LPOOL)
/ 
/ THIS DEQUE CONTAINS NODES FROM WHICH PBDL NODES CAN BE CONSTRUCTED
/ BY THE MCR RECONFIGURATOR. NO DATA IS STORED IN ANY OF THESE NODES.
/ ONLY WORDS 0 AND 1 (THE LINKAGE) HAVE ANY SIGNIFICANCE.
/ 
	.EJECT
/ SMALL NODE DESCRIPTOR LIST (SNDL)
/ 
/ THIS LIST INDICATES THOSE AREAS OF CORE DEDICATED TO SMALL
/ (10 DECIMAL WORD) NODES.
/
/	WORD 0  -- FORWARD LINKAGE
/	     1  -- BACKWARD LINKAGE
/	     2  -- NAME OF NODE 'PARTITION' (FIRST HALF)
/	     3  -- NAME OF NODE 'PARTITION' (SECOND HALF)
/	     4  -- BASE ADDRESS OF 'PARTITION'
/	     5  -- SIZE OF 'PARTITION'
/	     6  -- UNUSED
/	     7  -- UNUSED
/	     10 -- UNUSED
/	     11 -- UNUSED
/
	.EJECT
/ LARGE NODE DESCIPTOR LIST (LNDL)
/ 
/ THIS LIST IS USED TO INDICATE THOSE AREAS OF CORE USED TO STORE
/ LARGE NODES I.E. NODES FOR PARTITION DESCRIPTION.
/ 
/ THE FORMAT OF NODES IN THIS LIST IS IDENTICAL TO NODES IN THE SNDL.
/ 
	.EJECT
/ THE BATCH JOB LIST
/
/ REVISED FOR MULTIACCESS, 11-MAY-76 BY ED GARDNER
/
/ THE JOB QUEUE OR BATCH JOB LIST MAY HAVE ONE OF TWO FORMATS,
/ DEPENDING UPON WHETHER THIS IS A MULTIACCESS SYSTEM OR NOT.
/ BATCH HAS BEEN EXTENSIVELY REVISED FOR USE WITH MULTIACCESS.
/ HOWEVER, A NON-MULTIACCESS SYSTEM USES THE OLD BATCH UNALTERED.
/
	.IFUND L.ALL
	.NOLST
	.IFDEF L.SCOM
	.IFUND NOMAC
	.LST
/
/ THE FOLLOWING DESCRIPTION IS FOR MULTIACCESS SYSTEMS ONLY.
/
/ THE ENTRY INSERTED IN THE JOB QUEUE IS ACTUALLY COMPOSED OF
/ TWO SMALL NODES.  THE PRIMARY NODE IS THREADED INTO THE JOB
/ QUEUE PROPER, AND POINTS TO THE SECONDARY NODE.  THE FORMAT
/ OF THE PRIMARY NODE IS AS FOLLOWS:
/
/	(0)  FORWARD LINK
/	(1)  BACKWARD LINK
/	(2)  FILE
/	(3)  NAME
/	(4)  ADDRESS OF SECONDARY NODE
/	(5)  JOB ID OR SEQUENCE NUMBER
/	(6)  JOB INFO
/	(7)  JOB INFO
/	(10) DATE WHEN JOB WAS SUBMITTED (FORM:  YYMMDD)
/	(11) SSM (SECONDS-SINCE-MIDNIGHT) WHEN JOB WAS SUBMITTED
/
/ THE FORMAT OF THE SECONDARY NODE IS AS FOLLOWS:
/
/	(0)  COMMAND INPUT DEVICE AND UNIT
/	(1)  COMMAND INPUT UFD
/	(2)  LISTING OUTPUT DEVICE AND UNIT
/	(3)  LISTING OUTPUT UFD
/	(4)  LOGIN DEVICE AND UNIT
/	(5)  LOGIN UFD
/	(6)  UNUSED
/	(7)  UNUSED
/	(10) UNUSED
/	(11) UNUSED
/
/ FOR MORE DETAILS SEE THE 'QUEUE JOB' DIRECTIVE CODING.
/
	.NOLST
	.ENDC
	.IFDEF NOMAC
	.LST
/
/ THE FOLLOWING APPLIES ONLY TO NON-MULTIACCESS SYSTEMS.
/ 
/ THE JOB LIST IS USED TO QUEUE A BATCH JOB TO THE BATCH HANDLER.
/ NODES IN THIS LIST HAVE THE FOLLOWING FORMAT:
/ 
/	WORD  0 -- FORWARD LINKAGE
/	      1 -- BACKWARD LINKAGE
/	      2 -- FILE NAME (FIRST HALF)
/	      3 -- FILE NAME (SECOND HALF)
/	      4 -- PRIORITY
/	      5 -- LUNS
/	      6 -- JOB INFORMATION
/	      7 -- SPECIAL WORD 1
/	     10 -- SPECIAL WORD 2
/	     11 -- TIME IN SECONDS FROM MIDNIGHT
/
	.NOLST
	.ENDC
	.LST
	.ENDC
	.ENDC
/
	.EJECT
/ THE EXECUTE LIST
/
/ THIS LIST CONTAINS INFORMATION ON A TASK WHICH SHOULD BE INSTALLED
/ BY 'FININS' AND THEN REQUESTED. THIS LIST IS NEEDED TO IMPLEMENT THE
/ 'EXECUTE' FEATURE.
/ 
/ NODES IN THIS LIST HAVE THE FOLLOWING FORMAT:
/ 
/	WORD  0 -- FORWARD LINKAGE
/	      1 -- BACKWARD LINKAGE
/	      2 -- TASK NAME (FIRST HALF)
/	      3 -- TASK NAME (SECOND HALF)
/	      4 -- PRIORITY OR 0 IF NO DEFAULT PRIORITY
/	      5 -- LUN (ON WHICH THE CREATED FILE RESIDES)
/	      6 -- PARTITION NAME (FIRST HALF) OR 0 IF NONE GIVEN
/	      7 -- PARTITION NAME (SECOND HALF) OR 0 IF NONE GIVEN
/	     10 -- UNUSED
/	     11 -- UNUSED
/
	.EJECT
/ THE WTL LIST (FOR RASP)
/
/ THIS LIST IS USED BY RASP FOR JOB SWAPPING. NODES IN THIS LIST
/ ARE GENERATED WHEN RASP ORIENTED USER TASKS SWAP OUT OF MEMORY
/ AND ARE DELETED AUTOMATICALLY ON SUCCESSFUL TASK COMPLETION.
/ THE WTL LIST IS NOT EFFECTED BY ANY MCR FUNCTION OR SYSTEM
/ DIRECTIVE. NODES IN THIS LIST HAVE THE FOLLOWING FORMAT:
/
/	WORD  0 -- FORWARD LINKAGE
/	      1 -- BACKWARD LINKAGE
/	      2 -- LOGICAL TASK NAME (FIRST HALF IN ASCII)
/	      3 -- LOGICAL TASK NAME (SECOND HALF IN ASCII)
/	      4 -- DISK ADDRESS (HIGH BITS OR PLATTER)
/	      5 -- DISK ADDRESS (LOW 18 BITS)
/	      6 -- CORE ADDRESS
/	      7 -- CORE IMAGE LENGTH
/	     10 -- UNUSED
/	     11 -- UNUSED
/
	.EJECT
/ INPUT/OUTPUT REQUESTS
/
/ LISTS OF INPUT/OUTPUT REQUESTS USE WORDS 6 AND 7 OF A DEVICE'S PDVL
/ NODES AS LISTHEADS. THE Q-I/O DIRECTIVE INSERTS NODES INTO THE
/ APPROPRIATE LIST. THE I/O HANDLER IS RESPONSIBLE FOR REMOVING THE
/ NODES WHEN IT PROCESSES REQUESTS. THESE NODES HAVE THE FOLLOWING FORMAT:
/
/	WORD  0 -- FORWARD LINKAGE
/	      1 -- BACKWARD LINKAGE
/	      2 -- REQUESTOR'S STL NODE ADDRESS
/	      3 -- NORMAL/EXEC MODE INDICATOR
/	      4 -- TASK PRIORITY
/	      5 -- I/O FUNCTION CODE IN BITS 9-17 AND
/	           LUN IN BITS 0-8
/	      6 -- CPB WD 1 (EVENT VARIABLE ADDRESS)
/	      7 -- CPB WD 3 (UNIQUE TO CAL)
/	     10 -- CPB WD 4 (UNIQUE TO CAL)
/	     11 -- CPB WD 5 (UNIQUE TO CAL)
/
	.EJECT
/ TDV EXIT QUE NODES						/(161)
/								/(161)
/ IF A TASK IS BEING EXECUTED BY MULTIACCESS THEN UPON TASK	/(161)
/ TERMINATION, EITHER NORMAL OR ABNORMAL, A NODE WILL BE PLACED	/(161)
/ UPON TDV.EQ. THESE NODES ARE ONE OF TWO TYPES WHICH HAVE 	/(161)
/ BEEN DEFINED ABOVE. THEY ARE EITHER TNTERM NOTICES OR THE 	/(161)
/ TASK'S ATL ENTRY WITH THE FOLLOWING EXCEPTION. IF THE NODE	/(161)
/ IS AN ATL ENTRY THEN WORD 11 (8) OF THE NODE IS ZERO. IF THE	/(161)
/ NODE IS A TNTERM NOTICE THEN WORD 11 (8) IF THE NODE IS ONE.	/(161)
								/(161)
T.EC=11			/ TDV.EQ EXIT CODE.			/(161)
	.EJECT							/(161)
/ MULTIACCESS USER CONTEXT AREA					/(161)
/								/(161)
/ THE UCA IS A MECHANISM BY WHICH INFORMATIONIS PASSED BETWEEN	/(161)
/ PROCESSES IN TDV. THE EXECUTIVE MUST KNOW ABOUT CERTAIN	/(161)
/ OFFSETS INTO THIS AREA FOR THE PURPOSES OF XFRCMD.		/(161)
								/(161)
UC.LEN=100		/ LENGTH OF THE UCA.			/(161)
UC.UFD=6		/ OFFSET TO UFD NAME (UIC)		/(214)
UC.TB=16		/ OFFSET TO THE TERMINAL BUFFER.	/(161)
	.EJECT							/(161)
/ EVENT VARIABLE CONVENTIONS
/
/ THE FOLLOWING CONVENTIONS APPLY TO EVENT VARIABLES SET IN TASKS
/ BY THE SYSTEM:
/
/ POSITIVE VALUES SIGNAL SUCCESSFUL COMPLETION
/
/ ZERO INDICATES A REQUEST IS STILL PENDING
/
/ NEGATIVE VALUES INDICATE REJECTION OR UNSUCCESSFUL COMPLETION
/
/   -1	NO FLOATING POINT HARDWARE ON THIS MACHINE (SJ.)
/   -2	I/O REQUEST ABORTED					/EAG:167
/   -5	ILLEGAL HEADER WORD READ FROM DEVICE (DATA MODE
/	INCORRECT OR DATA VALIDITY BITS IMPROPERLY SET)  (DVH)
/   -6	UNIMPLEMENTED OR ILLEGAL FUNCTION (DVH)
/   -7	ILLEGAL DATA MODE (DVH)
/  -10	SOME FILE STILL OPEN BY SAME TASK ON SAME LUN (DVH)
/  -11	FILE NOT OPEN (DVH)
/  -12	DECTAPE ERROR (DVH)
/  -13	FILE NOT FOUND (DVH)
/  -14	DIRECTORY FULL (DVH)
/  -15	MEDIUM FULL (DVH)
/  -16	OUTPUT WORD-PAIR-COUNT OR INPUT-BUFFER-SIZE ERROR (DVH, TC.)
/  -17	READ/COMPARE ERROR (DVH)
/  -20	BACKSPACE ILLEGAL AT BEGINNING OF TAPE (DVH)
/  -21	END-OF-TAPE REACHED (DVH)
/  -23	INPUT WORD-PAIR-COUNT ERROR (DVH)
/  -24	LUN HAS BEEN REASSIGNED WHILE AN ATTACH OR
/	DETACH REQUEST WAS IN AN I/O REQUEST QUEUE (DVH)
/  -25	BUFFER PREALLOCATION UNSUCCESSFUL (DVH)
/  -26	ILLEGAL FUNCTION FOR A NORMAL MODE TASK (DVH, CI., DI.)
/  -27	NONEXISTENT DISK (RS09) UNIT NUMBER (DVH)
/  -30	AN OUT-OF-PARTITION I/O PARAMETER HAS BEEN SPECIFIED BY
/	A NORMAL MODE TASK (SJ., RS., DVH)
/  -31	I/O PARAMETER EXCEEDS COMMON BLOCK BOUNDS (DVH)
/  -32	NON-EXISTENT SYSTEM  COMMON OR PARTITION BLOCK (DVH, SHR.)
/  -33  UNIT DISMOUNTED OR DIRECTORY NOT INITIALIZED (DVH)
/  -34  DATA MISSED (DVH)
/  -35  ILLEGAL DEVICE CODE OR NON-EXISTENT DISK TYPE (DSK & DSA)
/  -36  NON-EXISTENT BLOCK NUMBER (DSK)
/  -50	RENAME ERROR -- FILE ALREADY EXISTS IN UFD (DVH)
/  -51	ILLEGAL TO READ A TRUNCATED FILE (DVH)
/  -52	INPUT FILE HAS NO END-OF-FILE RECORD (DVH)
/  -53	ILLEGAL (NULL) FILE NAME OR EXTENSION (DVH)
/  -54	THIS FILE IS ALREADY OPEN (DVH)
/  -55	THIS FILE IS ALREADY OPEN FOR MODIFICATION (DVH)
/  -56	NO I/O BUFFER AVAILABLE (DVH)
/  -57	SEQUENTIAL/RANDOM ACCESS FILE NAME CONFLICT (DVH)
/  -60	RANDOM ACCESS FILE SIZE ERROR (DVH)
/  -61	RANDOM ACCESS FILE ACCOUNTING INFORMATION ERROR (DVH)
/  -62	RANDOM ACCESS FILE SIZE ERROR. SIZE REQUESTED FOR THE RF DISK
/	IS NEGATIVE OR IS GREATER THAN 777 OCTAL BLOCKS (DVH)
/  -70	I/O PARAMETER ERROR (DVH)
/  -71	BUFFER CONNECT OR DISCONNECT ERROR (DVH)
/  -72	STOP I/O OR START I/O ERROR (DVH)
/  -73	ADD-TO-MEMORY OVERFLOW (DVH)
/   -77	VIOLATION OF RESTRICTED	(TC., SHR. SPYST. RC.)		/(161)
/	USAGE OF DIRECTIVE.					/(161)
/ -101	OUT OF RANGE LOGICAL UNIT NUMBER (IO. RC.)		/(161)
/ -102	UN-ASSIGNED LOGICAL UNIT NUMBER (IO. RC.)		/(161)
/ -103	NON-RESIDENT DEVICE HANDLER (IO. RC.)			/(161)
/ -104	CONTROL TABLE ARGUMENT ERROR (DVH SHR. SY. RN. SC. MT. SPY. & SPYST.)
/ -105	UNIT NUMBER OUT OF RANGE ( > 77 )	(QJOB.)		/EAG:202
/ -106	BATCH JOB QUEUE OVERFLOW		(QJOB.)		/EAG:202
/ -201	TASK NOT IN SYSTEM	(RQ. RQ.M XE. SC. RN. SY. DA.	/(161)
/				EA. FX. UF. CN. UM.)		/(161)
/ -202	TASK IS ACTIVE (RQ., RQ.M,XE., FX.) OR NOT ACTIVE (RS.)	/(161)
/ -203	CAL NOT TASK ISSUED (SC. RN. SY. MT. DVH SJ. PI. SPY. SPYST. QJOB.
/			     TC. TN. RB. SHR.)
/ -204	TASK IS DISABLED (RQ., RQ.M, XE., SC., RN., SY., FX.)	/(161)
/ -205	TASK NOT SUSPENDED (RS.)
/ -206	ILLEGAL TASK PRIORITY (RQ. RQ.M XE. SC. RN. SY.)	/(161)
/ -207	TASK ALREADY FIXED (FX.) OR NOT FIXED (UF.)
/ -210	PARTITION OCCUPIED (FX.)
/ -211	PARTITION NOT IN SYSTEM (.PI)
/ -212	STL NODE LOST PARTITION	(RQ. RQ.M RN. SY. XE. SC. FX.	/(161)
/	THRU RECONFIGURATION	EA.)				/(161)
/ -213	PARTITION OR SYSTEM	(RQ. RQ.M RN. SY. XE. SC. FX.	/(161)
/	COMMON IN PROCESS OF	EA. SHR.)			/(161)
/	RECONFIGURATION.					/(161)
/ -301	LINE NUMBER REJECTED (CI. DI.)
/ -302	LINE IS CONNECTED (CI.) OR NOT CONNECTED (DI.)
/  NNN	I/O HRDWR ERR, WHERE NNN IS THE DEV STATUS WORD (DVH)
/	[THE ERR FLAG IS REPRESENTED BY BIT-0, THEREFORE NNN<0]
/ -777	POOL IS EMPTY
/
/	DVH -- DEVICE HANDLER
/	IO. -- 'QUEUE I/O' DIRECTIVE
/	RC. -- 'SINGLE UNIT ABORT' DIRECTIVE			/(161)
/	RQ. -- 'REQUEST' DIRECTIVE
/	RQ.M-- 'REQUEST MAPPED' DIRECTIVE			/(161)
/	SC. -- 'SCHEDULE' DIRECTIVE
/	RN. -- 'RUN' DIRECTIVE
/	SY. -- 'SYNC' DIRECTIVE
/	CN. -- 'CANCEL' DIRECTIVE
/	MT. -- 'MARK' DIRECTIVE
/	RS. -- 'RESUME' DIRECTIVE
/	CI. -- 'CONNECT' DIRECTIVE
/	DI. -- 'DISCONNECT' DIRECTIVE
/	FX. -- 'FIX IN CORE' DIRECTIVE
/	UF. -- 'UNFIX' DIRECTIVE
/	DA. -- 'DISABLE' DIRECTIVE
/	EA. -- 'ENABLE' DIRECTIVE
/	PI. -- 'PARTITION INFORMATION' DIRECTIVE
/	TC. -- 'TRANSFER COMMAND' RESTRICTED DIRECTIVE
/	SJ. -- 'SET JEA REGISTER' DIRECTIVE
/	UM. -- 'UNMARK' DIRECTIVE
/	SPY. -- 'SPY' DIRECTIVE
/	SPYST. -- 'SPYSET' DIRECTIVE
/	QJOB. -- 'QUEUE JOB' DIRECTIVE
/	XE. -- 'EXECUTE' DIRECTIVE
/	RB. -- 'RAISE BOUND' DIRECTIVE
/	TN. -- 'TASK NAME' DIRECTIVE
/	SHR. -- 'SHARE' DIRECTIVE
/
	.EJECT
/ "SIGNIFICANT" EVENTS
/
/ THE FOLLOWING EVENTS ARE CONSIDERED "SIGNIFICANT EVENTS" AND
/ RESULT IN AN ACTIVE TASK LIST SCAN FROM-THE-TOP.
/
/   I/O REQUEST QUEUING
/
/   NORMAL I/O REQUEST COMPLETION (DEPENDENT UPON I/O HANDLER TASK)
/
/   A TASK REQUEST
/
/   A SCHEDULE REQUEST (SCHEDULE, RUN, OR SYNC) COMING DUE
/
/   A MARK TIME EXPIRATION
/
/   A TASK RESUMPTION (RESUME DIRECTIVE)
/
/   A TASK EXIT
/
 .TITLE *** MACRO DEFINITIONS
/
/ .RTL3 -- RAISE TO LEVEL THREE
/
	.DEFIN	.RTL3
	  LAC (400020)
	  ISA
	.ENDM
/
/ .RTL6 -- RAISE TO LEVEL SIX
/
	.DEFIN	.RTL6
	  LAC (400002)
	  ISA
	.ENDM
/
/ .SET6 -- TO DECLARE A "SIGNIFICANT EVENT" (REQUEST API-6 WHICH
/          WILL CAUSE AN ACTIVE TASK LIST SCAN "FROM THE TOP")
/
	.DEFIN	.SET6
	  LAC (401000)
	  ISA
	.ENDM
/
/ INTERRUPT [SERVICE ROUTINE] ENTRY -- "CONNECT LABEL"
/
	.IFUND L.ALL						/EAG:202
								/EAG:202
	.DEFINE	INTENTRY,I,LST
I	  0		/INTERRUPT "CONNECT" LOCATION
	  DBA
	  JMS SAVE	/IF FROM WITHOUT PAGE ZERO:  JMS* (SAV)
	  .NOLST						/EAG:202
	  .REPT PBIB
	  0
	  NOP		/INDICATES TRANSFER TO 'NOP+1' AFTER REG SAVE
	  ..FUDG LST						/EAG:202
	  ..DOIT						/EAG:202
	.ENDM
								/EAG:202
	.NOLST							/EAG:202
								/EAG:202
	.ENDC							/EAG:202
								/EAG:202
	.IFDEF L.ALL						/EAG:202
								/EAG:202
	.DEFINE	INTENTRY,I,LST
I	  0		/INTERRUPT "CONNECT" LOCATION
	  DBA
	  JMS SAVE	/IF FROM WITHOUT PAGE ZERO:  JMS* (SAV)
	  .REPT	PBIB
	  0
	  NOP		/INDICATES TRANSFER TO 'NOP+1' AFTER REG SAVE
	.ENDM
								/EAG:202
	.ENDC							/EAG:202
								/EAG:202
	.IFDEF L.SCOM						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
/
/ INTERRUPT [SERVICE ROUTINE] EXIT -- "CONNECT LABEL"
/
	.DEFIN	INTEXIT,I
	  LAC (I)
	  JMP RSR	/IF FROM WITHOUT PAGE ZERO:  JMP* (REST)
	.ENDM
/
/ SHORT PARTITION BLOCK (FOR TASKS THAT ARE ASSEMBLED AS A PART OF SYSTEM.)
/ AN EXPANDED 'SHPB' IS USED IN THE SYSTEM CONFIGURATION ROUTINE.
/ AN ABBREVIATED 'SHPB' IS USED IN THE TTY HANDLER		/(213)
/
	.IFUND L.ALL						/EAG:202
								/EAG:202
	.DEFIN	SHPB,LST
	  .NOLST						/EAG:202
	  0		/ WORD FOR TRANSFER PENDING COUNT.	/(173)
	  0		/ FLAG WORD FOR CONTEXT SWITCH.		/(161)
	  0		/ FILL WORD 1				/(161)
	  0		/ FILL WORD 2				/(161)
	  0		/ FILL WORD 3				/(161)
	  0		/INTERRUPT CONNECT LOCATION
	  DBA		/ENTER INDEX MODE
	  .IFPNZ	10000-.
	  JMS	SAVE
	  .ENDC
	  .IFNEG	7777-.
	  JMS*	(SAVE)
	  .ENDC
	  .REPT	PBIB
	  0
	  SKP		/INDICATES TRANSFER TO 'M1' AFTER REG SAVE
	  .REPT	PBMM
	  0
	  .REPT	PBFP
	  0
	0		/ WORD FOR I/O COUNT			/(213)
	  ..FUDG LST						/EAG:202
	  ..DOIT						/EAG:202
	.ENDM
								/EAG:202
	.NOLST							/EAG:202
								/EAG:202
	.ENDC							/EAG:202
								/EAG:202
	.IFDEF L.ALL						/EAG:202
								/EAG:202
	.DEFIN	SHPB,LST
	  0		/ WORD FOR TRANSFER PENDING COUNT.	/(173)
	  0		/ FLAG WORD FOR CONTEXT SWITCH.		/(161)
	  0		/ FILL WORD 1				/(161)
	  0		/ FILL WORD 2				/(161)
	  0		/ FILL WORD 3				/(161)
	  0		/INTERRUPT CONNECT LOCATION
	  DBA		/ENTER INDEX MODE
	  .IFPNZ	10000-.
	  JMS	SAVE
	  .ENDC
	  .IFNEG	7777-.
	  JMS*	(SAVE)
	  .ENDC
	  .REPT	PBIB
	  0
	  SKP		/INDICATES TRANSFER TO 'M1' AFTER REG SAVE
	  .REPT	PBMM
	  0
	  .REPT	PBFP
	  0
	0		/ WORD FOR I/O COUNT			/(213)
	.ENDM
								/EAG:202
	.ENDC							/EAG:202
								/EAG:202
	.IFDEF L.SCOM						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
/
/ ASCII TEXT LINE WITH HEADER
/
	.IFUND L.ALL						/EAG:202
								/EAG:202
	.DEFIN	TEXT,N,B,T,LST					/EAG:202
	  .NOLST						/EAG:202
MES@N	  .DSA M..@N-MES@N/2*1000+2
	  0
	  .ASCII :B:<T>
M..@N=.
	  ..FUDG  LST						/EAG:202
	  ..DOIT						/EAG:202
	.ENDM							/EAG:202
								/EAG:202
	.NOLST							/EAG:202
								/EAG:202
	.ENDC							/EAG:202
								/EAG:202
	.IFDEF L.ALL						/EAG:202
								/EAG:202
	.DEFIN	TEXT,N,B,T,LST
MES@N	  .DSA M..@N-MES@N/2*1000+2
	  0
	  .ASCII :B:<T>
M..@N=.
	.ENDM
								/EAG:202
	.ENDC							/EAG:202
								/EAG:202
	.IFDEF L.SCOM						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
/								/EAG:202
/ MACROS TO CONTROL LISTING OF SOME OF THE ABOVE		/EAG:202
/								/EAG:202
	.DEFIN	..FUDG,SYM					/EAG:202
								/EAG:202
	  .DEFIN ..DOIT						/EAG:202
	  .ENDM							/EAG:202
								/EAG:202
	.IFDEF SYM						/EAG:202
	  .DEFIN ..DOIT						/EAG:202
	  .LST							/EAG:202
	  .ENDM							/EAG:202
	.ENDC							/EAG:202
								/EAG:202
	.ENDM							/EAG:202
 .TITLE *** SYMBOLIC CONSTANT DEFINITIONS
/
	.DEC
LUN12=12
LUN13=13
D13=13
D24=24
D29=29
D31=31
D59=59
D60=60
D86400=86400
/
NDSZM2=NDSZ-2
NDSZMT=NDSZ-10
/
	.OCT
/
L1=1
L21=21
L41=41
/
CLON=700044	/CLOCK ON
LDMM=700024	/LOAD MM REGISTER FROM AC
RDMM=700032	/READ MM REGISTER INTO AC
RDCLK=701762	/READ XM CLOCK INTO AC AND RESET CLOCK REGISTER TO ZERO
MPSK=701701	/SKIP ON MEMORY PROTECT VIOLATION
MPSNE=701741	/SKIP ON NONEXISTENT MEMORY VIOLATION
MPCV=701702	/CLEAR PROTECT VIOLATION FLAG
MPCNE=701744	/CLEAR NONEXISTENT MEMORY REF FLAG
MPLR=701724	/LOAD RELOCATION REGISTER
MPLD=701704	/LOAD CORE ALLOCATION (SIZE) REGISTER
MPEU=701742	/ENTER USER (PROTECTED/RELOCATED) MODE
KSF=700301	/SKIP IF CONSOLE KYBD INT
TSF=700401	/SKIP IF CONSOLE TELEPRINTER INT
KRB=700312	/READ CONSOLE KYBD
KRS=700332	/READ FULL DUPLEX & SELECT READER
TLS=700406	/LOAD TTY PRINT BUF
TCF=700402	/CLEAR TTY PRINT FLAG
PSF=700201	/SKIP IF PAPER PUNCH INT
.INH=705522	/INHIBIT INTERRUPTS
.ENB=705521	/ENABLE INTERRUPTS
ECLA=641000	/EAE CLA INSTRUCTION
I=400000	/ FPP INDIRECT ADDRESS BIT			/(213)
UNDLD=713170	/UNNORM DOUBLE PRECISION FLOAT LOAD
UNSWQ=715270	/UNNORM SWAP FMA/FMQ
EST=713700	/EXTENDED INTEGER STORE
SJE=715600	/STORE JEA REGISTER
LJE=715400	/LOAD JEA REGISTER
ELQ=715100	/EXTENDED INTEGER LOAD FMQ
UNDST=713770	/UNNORM DOUBLE PRECISION FLOAT STORE
FPT=710314	/SKIP IF FLOATING POINT HARDWARE EXISTS
OAC=642000	/OR AC TO MQ
/
/ BECAUSE THE MACRO-15 ASSEMBLER CANNOT HANDLE "INST* (ADR),X" , THE
/ FOLLOWING "INDIRECT-INDEXED" MNEMONICS ARE DEFINED.
/
LACIX=LAC!030000
DACIX=DAC!030000
DZMIX=DZM!030000
SADIX=SAD!030000						/(207)
 .TITLE *** HARDWARE DEFINED REGISTERS
/
/ 00000 -- PI INTERRUPT RETURN PARAMETER STORAGE
/ 00004 -- AC SWITCH VALUE STORED AT SIGNIFICANT EVENT		/(213)
/ 00001 -- PI INTERRUPT TRANSFER (SET UP DURING BOOTSTRAPPING)
/ 00007 -- CLOCK REGISTER (INCREMENTED EACH TICK, INTERRUPT WHEN OVERFLOW)
/ 00010 -- AUTO-INCREMENT REGISTER X10
/ 00011 -- AUTO-INCREMENT REGISTER X11
/ 00012 -- AUTO-INCREMENT REGISTER X12
/ 00013 -- AUTO-INCREMENT REGISTER X13
/ 00015 -- AUTO-INCREMENT REGISTER X15
/ 00016 -- AUTO-INCREMENT REGISTER X16
/ 00017 -- AUTO-INCREMENT REGISTER X17
/ 00020 -- CAL RETURN PARAMETER STORAGE
/ 00021 -- CAL TRANSFER (SETUP DURING BOOTSTRAPPING)
/ 00022 -- DB99 TRANSMIT WC (2'S COMP WORD COUNT)
/ 00023 -- DB99 TRANSMIT CA (CURRENT WORD ADDRESS MINUS ONE)
/ 00024 -- DB99 RECEIVE WC
/ 00025 -- DB99 RECEIVE CA
/ 00026 -- UNASSIGNED DEVICE WC
/ 00027 -- UNASSIGNED DEVICE CA
/
ACSW=4		/ ACSW LOCATION					/(213)
/
	.LOC	00030
	740031	/DECTAPE WC
	000031	/DECTAPE CA
	740033	/MAGTAPE WC
	000033	/MAGTAPE CA
	0	/LINE PRINTER WC (NOT USED)
	0	/LINE PRINTER CA
	720037	/WORD COUNT FOR 24K OR GREATER (SCF AT 50000)
	000037	/RF DISK CA
/
/ THE WC & CA FOR DECTAPE, MAGTAPE, AND FIXED HEAD DISK ARE
/ SETUP FOR BOOTSTRAPPING.  A COLD START IMAGE READIN IS STARTED
/ AT LOC 30, AND THESE WC & CA'S CAUSE THE TRANSFER TO CONTINUE 
/ THRU THE SIXTH PAGE (24K) .
/
	.EJECT
	.LOC	040	/INTERRUPT TRAP LOCATIONS
/
	DBK			/SOFTWARE LEVEL 4
	JMP*	ITVTB+1		/SOFTWARE LEVEL 5   ****
	JMS*	L6TV		/SOFTWARE LEVEL 6
	DBK			/SOFTWARE LEVEL 7
	JMS*	ITVTB+4		/LINE 4 - DECTAPE
	JMS*	ITVTB+5		/LINE 5 - MAGTAPE
	JMS*	ITVTB+6		/LINE 6 -
	JMS*	ITVTB+7		/LINE 7 - UC15 UNICHANNEL DISK
	JMS*	ITVTB+10	/LINE 10- PAPER TAPE READER
	JMS*	ITVTB+11	/LINE 11- CLOCK OVERFLOW
	JMS*	ITVTB+12	/LINE 12- POWER FAIL
	JMS*	ITVTB+13	/LINE 13- PARITY ERR
	JMS*	ITVTB+14	/LINE 14- VP15 & VT15
	JMS*	ITVTB+15	/LINE 15- CARD READER
	JMS*	ITVTB+16	/LINE 16- LINE PRINTER
	JMS*	ITVTB+17	/LINE 17- A-D CONVERTER
	JMS*	ITVTB+20	/LINE 20- DB99A-DB98A
	JMS*	ITVTB+21	/LINE 21-
	JMS*	ITVTB+22	/LINE 22- DATAPHONE
	JMS*	ITVTB+23	/LINE 23- RS09  DISK
	JMS*	ITVTB+24	/LINE 24- RP02 DISK PACK
	JMS*	ITVTB+25	/LINE 25- PLOTTER
	JMS*	ITVTB+26	/LINE 26-
	JMS*	ITVTB+27	/LINE 27-
	JMS*	ITVTB+30	/LINE 30-
	JMS*	ITVTB+31	/LINE 31-
	JMS*	ITVTB+32	/LINE 32-
	JMS*	ITVTB+33	/LINE 33-
	JMS*	ITVTB+34	/LINE 34- LT19 OUTPUT
	JMS*	ITVTB+35	/LINE 35- LT19 INPUT
	JMS*	ITVTB+36	/LINE 36- DECTAPE (ADDITIONAL)
	JMS*	ITVTB+37	/LINE 37- DATAPHONE (ADDITIONAL)
/
/	**** AN API-5 INTERRUPT IS USED BY THE SYSTEM CONFIGURATION TASK
/	     TO TEST FOR THE "RE-ENTRANT ECO PACKAGE" -- THIS LOCATION
/	     IS SET TO A 'DBK' INSTRUCTION BY THE SYSTEM CONFIGURATION
/	     ROUTINE AFTER MAKING THE TEST.
 .TITLE *** SYSTEM COMMUNICATIONS AREA
/
/ SYSTEM COMMUNICATIONS AREA -- ABSOLUTELY REFERENCED SYSTEM
/ POINTERS AND PARAMETERS
/
	.LOC	100
/
	P1EDTN		/EDIT NUMBER
/
/ RE-ENTRANT SYSTEM CELLS
/
R1	FACLB		/R1, R2, R3, R4, R5, R6, X10, X11, X12, X13, X14, X15,
R2	JMP SAPI	/X16, X17, & LOC 20 ARE REGISTERS USED BY RE-ENTRANT
R3	JMP CALDSP	/ROUTINES, AND ARE REGISTERS ARE SAVED AND RESTORED BY
R4	L20		/THE SYSTEM'S SAVE & RESTORE FACILITY.	/EAG:167
R5	0		/(R1, R2, R3, & R4, ARE SETUP FOR BOOTSTRAP LOADING)
R6	0
X10=10
X11=11
X12=12
X13=13
X14=14
X15=15
X16=16
X17=17
L20=20
/
/ ENTRY TO RE-ENTRANT SYSTEM ROUTINES (VIA JMS)
/
/ SEE ALSO ENTRY POINT TO NDELXR, FOLLOWING DISK		/EAG:167
/ ALLOCATE/DEALLOCATE CONTROL TABLES.				/EAG:167
/								/EAG:167
NADD	0		/// ADD NODE TO DEQUE
	.INH		///					/EAG:167
	JMP	NADDE	///
/
NDEL	0		/// DELETE NODE FROM DEQUE
	.INH		///					/EAG:167
	JMP	NDELE	///
/
PENP	0		/// PICK EMPTY NODE FROM POOL
	.INH		///					/EAG:167
	JMP	PENPE	///
/
PICK	0		/// PICK NODE FROM A DEQUE
	.INH		///					/EAG:167
	JMP	PICKE	///
/
SNAM	0		/// SEARCH DEQUE FOR NAME
	LAC	.-1	///
	JMP	SNAME
/
SPRI	0		/// SEARCH DEQUE FOR PRIORITY AND INSERT
	LAC	.-1	/// NODE
	JMP	SPRIE
/
SAVE	0		/// SAVE REGISTERS OF INTERRUPTED PROGRAM
	.INH		///
	JMP	SAVV	///
/
REST	JMP	RSR	/ RESTORE REGISTERS AND RETURN TO
			/ INTERRUPTED PROGRAM (SCOM ENTRY
			/ IS PROVIDED FOR TASKS -- SYSTEM USES
			/ 'RSR'.)
/
/ CURRENT TASK POINTER
/
CURTSK	ATKL		/WHEN A TASK IS CURRENT (RUNNING), 'CURTSK' CONTAINS
			/THE ADDRESS OF THE ATL NODE FOR THE TASK.
/
/ SYSTEM PARAMETERS
/
CSIZE	57777		/MAX CORE ADDRESS (SCF SET)
DSIZE	-1		/MAX RF DISK UNIT NUMBER (SCF SET)  NEGATIVE NUMBER
			/INDICATES "COLD START IMAGE" (FOR "RSX RESTORE").
TPS	D60		/CLOCK TICKS PER SECOND (SCF SET)
CTPS	-D60		/2'S COMP TPS (SCF SET)
LUTP1	LUT		/POINTER TO BEGINNING OF LOGICAL UNIT TABLE
LUTP2	LUT+NLU-1	/POINTER TO END OF LOGICAL UNIT TABLE
AFTP1	AFT		/POINTER TO BEGINNING OF ATTACH-FLAG-TABLE
AFTP2	AFT+NLU-1	/POINTER TO END OF ATTACH-FLAG-TABLE
NTSCSE	D60		/NUMBER OF TICKS SEPARATING CLOCK-GENERATED
			/SIGNIFICANT EVENTS (SCF SET).
/
/ BATCH FLAGS WORD
/
BATWD	0		/ THIS WORD IS USED BY RSX BATCH	/EAG:202
			/ WHEN ZERO, BATCH IS NOT RUNNING.	/EAG:202
			/ WHEN NON-ZERO, BATCH IS RUNNING.	/EAG:202
			/ FURTHERMORE, WHEN NON-ZERO THIS	/EAG:202
			/ IS THE ADDRESS OF THE BATCH		/EAG:202
			/ CONTROL TABLE WITHIN THE BATCH	/EAG:202
			/ HANDLER.  FOR MORE INFORMATION,	/EAG:202
			/ SEE THE BATCH HANDLER.		/EAG:202
/
/ SYSTEM ERROR LOG
/
SE.EP	0		/REQUEST'S (CAL'S) REJECTED DUE TO EMPTY POOL
	0		/(UNUSED)
SE.DR	0		/DISK RE-TRIES
SE.DF	0		/DISK FAILURES
SE.AD	0		/TASK LOADING ABORTS DUE TO DISK FAILURE
SE.AP	0		/TASK SCHEDULE ABORTS DUE TO EMPTY POOL
/
/ END OF SYSTEM ERROR LOG
/
								/EAG:203
								/EAG:203
								/EAG:203
/								/EAG:203
/ DEBUG/NORMAL MODE SWITCH.  THE FOLLOWING LOCATION IS		/EAG:203
/ NORMALLY A NOP.  IT MAY BE MANUALLY CHANGED TO A SKP		/EAG:203
/ TO PUT THE SYSTEM IN "DEBUG" STATE.  EXEC MODE TASKS		/EAG:203
/ USE THIS LOCATION TO DETERMINE WHETHER THEY SHOULD		/EAG:203
/ OUTPUT MESSAGES DESCRIBING PECULAR (I.E., VERY UNUSUAL	/EAG:203
/ IN NORMAL OPERATION) CONDITIONS WHICH ARE NOT NECESSARILY	/EAG:203
/ ERRORS.  THIS FEATURE WILL NORMALLY BE USED ONLY BE		/EAG:203
/ DEC PERSONNEL OR OTHER ADVANCED SYSTEMS PROGRAMMERS.		/EAG:203
/								/EAG:203
								/EAG:203
DEBUG	NOP		/ DEBUG VS. NORMAL NODE SWITCH.		/EAG:203
								/EAG:203
/
								/(212)
	.IFUND QJBLMT						/(212)
	0		/ RESERVED.				/(212)
	.ENDC							/(212)
	.IFDEF QJBLMT						/(212)
MAXJOB	QJBLMT		/ MAXIMUM NUMBER OF JOBS ALLOWABLE IN	/(206)
			/ THE BATCH JOB QUEUE.			/(206)
	.ENDC							/(212)
								/(212)
/
/ TIME VALUES
/
SSM	0		/SECONDS SINCE MIDNITE
DSR	0		/DAYS RUNNING COUNT
/
TT	0		/TIME OF DAY -- TICKS,
SS	0		/   SECONDS, MINUTES, AND
MM	0		/   HOURS. (MUST BE IN THAT
HH	0		/   ORDER AND CONSECUTIVE)
/
MO	1		/DATE
DA	1		/    MONTH, DAY, YEAR
YR	106 
/
/ MCR COMMUNICATIONS
/
MCRRI	1		/MCR REQUEST INHIBIT FLAG --
			/ 0 -- ^C TYPEIN SHOULD RESULT IN AN MCR REQUEST
			/+1 -- ^C TYPEIN SHOULD NOT RESULT IN AN MCR REQUEST,
			/      AND HAS NOT BEEN ATTEMPTED.
			/-1 -- ^C TYPEIN SHOULD NOT RESULT IN AN MCR REQUEST,
			/      AND AT LEAST ONE TYPE IN HAS BEEN MADE.  THIS IS
			/      FOR MCR FUNCTIONS THAT ABORT ON ^C TYPEIN.
IFAC	0		/ENTRY TO: READ A LINE & INIT FAC SUBROUTINE
	JMP* (IFACE)						/(161)
FAC	0		/ENTRY TO: FETCH A CHARACTER
	JMP* (FACE)						/(161)
/
/ TTY HANDLER PARAMETERS
/
TTYNUM	1		/NUMBER OF TTY'S ON THE MACHINE (SCF SET)
TTYRQT	TTWD07		/REQUEST QUEUES TABLE ADDRESS (FOR SCF)
TTMCTT	0		/UNIT NUMBER OF TTY FROM WHICH A ^C TYPEIN 
			/CAN ESTABLISH MCR DIALOGUE.
TTTDTT	0		/UNIT NUMBER OF TTY FROM WHICH A ^T TYPEIN
			/CAN ESTABLISH TDV DIALOGUE.
	TTWD00		/TTY UNIT 0 STATUS REGISTER
	TTWD06		/TTY UNIT 0 OUTPUT REGISTER
	TTK.EV		/TTY UNIT 0 KEYBOARD EVENT VARIABLE
	TTYS		/MAXIMUM NUMBER OF TTYS
	TTTGEV		/TTY TRIGGER EVENT VARIABLE ADDRESS
/
/ DISK PARAMETERS
/
WARMFL	0		/WARM START FLAG -- SET TO 777777 BY "...SAV" PRIOR TO
			/SAVING SYSTEM IMAGE ON DISK. BIT 0 IS USED BY THE RF15
			/DISK I/O DRIVER. BIT 1 IS RESERVED FOR THE RP02 DISK
			/PACK. THE REMAINDER OF THE WORD IS UNUSED.
/
/ CONTROL TABLE USED BY RF DISK FILE HANDLER
/ TO ALLOCATE STORAGE ON THE RS09 DECDISK.
/ STORAGE IS DEALLOCATED BY THE MCR FUNCTION "SAV" (WHENEVER CALLED)
/ SO THAT THE SAVED IMAGE DOES NOT INDICATE ALLOCATED
/ BLOCKS WHICH COULD BE REUSED.
/
RFACTB	0		/NUMBER OF WORDS DESIRED & ACTUALLY GRANTED.
	0		/DISK PLATTER NUMBER.
	0		/DISK ADDRESS.
/
/ RASP SCOM REGISTERS.  COMMUNICATION FOR UFG TASK.
/
GRLINK	0		/PTR. TO 'BEGIN' BLOCK.
GRSDFL	0		/SHUT DOWN FLG. (0=SHUT DOWN).
GRQPTR	0		/PTR. TO RPLQ IN RASP'S 'UFG' TASK.
GRQFLG	0
/
/ END OF RASP SCOMS
/
/								/(161)
/ MULTIACCESS CONTROL REGISTERS.
/								/(161)
/ THE FOLLOWING 12 (8) WORDS CONTROL THE MULTIUSER TASK		/(161)
/ DEVELOPMENT FACILITY OF RSX. THEY BY IMPLICATION ALSO CONTROL	/(161)
/ THE LUN MAPPING FACILITY WHICH IS AVAILABLE AS A STANDARD	/(161)
/ FEATURE FOR RSX.						/(161)
/								/(161)
	.IFUND NOMAC						/(161)
TDV.EQ	.			/ DEQUE USED FOR NOTIFYING THE	/(161)
	.-1			/ TDV POLLER THAT A TASK HAS	/(161)
				/ TERMINATED, EITHER NORMALLY OR/(161)
				/ ABNORMALLY.			/(161)
								/(161)
MA.UCA	0			/ POINTER TO THE BEGINNING OF	/(161)
				/ THE USER CONTEXT AREA IN TDV.	/(161)
								/(161)
MA.LOF	0			/ LUN OFFSET. THIS CONSTANT IS	/(161)
				/ ADDED TO THE LUN SPECIFIED IN	/(161)
				/ EACH QIO DIRECTIVE.		/(161)
								/(161)
MA.UN	0			/ MULTIACCESS USER NUMBER USED	/(161)
				/ AN INDEX INTO THE UCA.	/(161)
								/(161)
MA.BLU	0			/ BEGINNING OF THE MULTIACCESS	/(161)
				/ RESERVED LUN SPACE.		/(161)
								/(161)
MA.ELU	0			/ END OF THE MULTIACCESS	/(161)
				/ RESERVED LUN SPACE		/(161)
								/(161)
MA.CT	0			/ MULTIACCESS CONTROL T FLAG	/(161)
				/ REGISTER.			/(161)
								/(161)
MA.CY	0			/ MULTIACCESS CONTROL Y FLAG	/(161)
				/ REGISTER.			/(161)
								/(161)
MA.CST	0			/ POINTER TO THE MULTIACCESS	/(172)
				/ CONTROL AND STATUS TABLE. THE	/(172)
				/ FORMAT OF THE TABLE IS	/(172)
				/ DETAILED IN THE RSX MANUAL.	/(172)
	.ENDC							/(161)
	.IFDEF NOMAC						/(161)
	.BLOCK 3		/ PUT MA.LOF IN SAME PLACE	/(161)
MA.LOF	0							/(161)
	.BLOCK 6		/ SIX SPARE WORDS		/(161)
	.ENDC							/(161)
XSIZE	0		/INDICATES TOP OF THE EXEC (SCF SET)
/								/(206)
/ PARAMETERS FOR THE RSX LIGHT SHOW.				/(206)
/								/(206)
PATRN	0		/ INITIAL SEED FOR THE LIGHT SHOW.	/(206)
CENTR	20		/ BIT SOURCE FOR CENTER OF PATTERN.	/(206)
LMAGIC	SWHA		/ INSTRUCTION NEEDED TO GENERATE MOST 	/(206)
			/ PATTERNS.				/(206)
/
/ HARDWARE EXISTENCE FLAGS
/
PRHDWE	NOP		/SET (SKP) IF PROTECT & RELOCATE HARDWARE EXIST (BY SCF)
FPHDWE	NOP		/SET (SKP) IF FLOATING POINT ARITHMETIC HARDWARE EXISTS (BY SCF)
/
/ POOL SIZE
/
PLSZ	0		/POOL SIZE (SCF SET, NOT USED)
/
/ DEQUE LIST HEADS
/
POOL	BPL		/POOL OF EMPTY NODES
	EPL
/
STKL	MCR		/SYSTEM TASK LIST
	SCF
/
ATKL	DSK		/ACTIVE TASK LIST
	SFG
/
CKQ	.		/CLOCK QUEUE
	.-1
/
PBDL	.		/PARTITION BLOCK DEFINITIONS LIST
	.-1
/
PDVL	DSK0		/PHYSICAL DEVICE LIST
	TT00
/
SCDL	.		/SYSTEM COMMON BLOCK DEFINITIONS LIST
	.-1
/
TNRL	.		/TERMINATION NOTICE REQUEST LIST
	.-1
/
IORDQ	.		/I/O RUNDOWN QUEUE
	.-1
/
WTL	.		/RASP-15'S "WAIT TASK LIST" USED FOR TASK SWAPPING.
	.-1
/
LPOOL	.		/POOL OF EMPTY LARGE NODES
	.-1
/
SNDL	.		/DEQUE OF SMALL NODE PARTITIONS
	.-1
/
LNDL	.		/DEQUE OF LARGE NODE PARTITIONS
	.-1
/
/ BEGIN EXECUTE AREA OF SCOM
/
EXECT	1		/EXECUTE CONTROL TABLE
	0
	.SIXBT "FIN"
	.SIXBT "INS"
EXELH	.		/EXECUTE LIST HEAD
	.-1
/
/ ABORT TASK
/
RETX	CAL	(10)	/"RE-ENTRANT TASK" -- USED TO EXIT ACTIVE TASKS
/
/ DISK EXISTANCE WORDS
/
SYSDSK	3		/SYSTEM DISK TYPE
RKDISK	-1		/POSITIVE IF UNICHANNEL DISK PRESENT
RPDISK	1		/POSITIVE IF RP02 DISK PACK PRESENT
			/(RKDISK AND RPDISK ARE EQUAL TO MAXIMUM UNIT #).
/
/ MISCELLANEOUS POINTERS AND PARAMETERS
/
LUFD1	LUNUFD		/POINTER TO BEGINNING OF LUN/UFD TABLE
LUFD2	LUNUFD+NLU-1	/POINTER TO END OF LUN/UFD TABLE
DUFD1	UFDDSK		/POINTER TO BEGINNING OF UFD/DISK TABLE
DUFD2	UFDDSK+20	/POINTER TO END OF UFD/DISK TABLE
DSAFLG	DSACPL		/ADDRESS OF FLAG FOR DSA, TO SHOW IF A BIT MAP'S IN CORE
REMBLK	0		/STARTING BLOCK FOR 'REMOVE' CHAIN OF DISK BLOCKS
TIMFLG	0		/FLAG SET TO ADDR OF TASK TIMING CONTROL
			/TABLE TO TURN TASK TIMING ON. ZEROED IF
			/TASK TIMING IS OFF.
/								/(206)
/ PARAMETERS FOR THE RSX LIGHT SHOW.				/(206)
/								/(206)
RIGHT	37700		/ MASK FOR BITS SHIFTED RIGHT.		/(206)
LEFT	760017		/ MASK FOR BITS SHIFTED LEFT.		/(206)
SLITIM	0		/2'S COMPLEMENT OF THE NUMBER OF TICKS A TIME
			/TIME SLICED TASK SHOULD BE ALLOWED TO RUN.
SLIHR	0		/HIGHEST SLICING PRIORITY
SLILR	0		/2'S COMPLEMENT OF LOWEST SLICING PRIORITY
SLICNT	0		/TICKS PER QUANTUM ISZ COUNTER (#204)
/
SPY1	SPY1			/ START OF THE SPY AREA (A	/(161)
				/ POINTER).			/(161)
SPY2	SPY2			/ END OF THE SPY AREA (A	/(161)
				/ POINTER)			/(161)
JOB1	.		/HEADER OF THE QUEUE JOB DEQUE
JOB2	.-1		/BACK POINTER TO THE QUEUE JOB DEQUE
/
/ RE-ENTRANT ROUTINES FOR I/O HANDLER TASKS
/
/ SEE ALSO ENTRY POINT TO DQAB, FOLLOWING DISK			/EAG:167
/ ALLOCATE/DEALLOCATE CONTROL TABLES.				/EAG:167
/								/EAG:167
ALAD	0		/// ATTACH LUN & DEVICE-UNIT TO INDICATED TASK
	LAC	.-1	///
	CLL			/ LINK=0 ==> ATTACH FUNCTION	/EAG:167
	JMP	ATDT
/								/EAG:167
	.BLOCK 1		/ FREE WORD			/EAG:167
/
DLAD	0		/// DETACH LUN & DEVICE FROM TASK
	LAC	.-1	///
	STL			/ LINK=1 ==> DETACH FUNCTION	/EAG:167
	JMP	ATDT
/								/EAG:167
	.BLOCK 1		/ FREE WORD			/EAG:167
/
DQRQ	0		/// DE-QUEUE AN I/O REQUEST
	LAC	.-1	///
	JMP	DQRQ1
/
VAJX	0		/// VERIFY AND ADJUST (TO 17-BITS) I/O TRANSFER
	LAC	.-1	/// PARAMETERS
	JMP	VAJX1
/
IOCD	0		/// TO DECLARE I/O REQUEST COMPLETED (DECREMENT TRANSFERS
	.INH		/// PENDING COUNT.			/EAG:167
	JMP	IOCD1	///
/
PABF	0		/// TO PREALLOCATE AN I/O BUFFER
	LAC	.-1	///
	JMP	PABF1
/
ALBF	0		/// TO ALLOCATE AN I/O BUFFER
	LAC	.-1	///
	JMP	ALBF1
/
DABF	0		/// TO DEALLOCATE AN I/O BUFFER
	LAC	.-1	///
	JMP	DABF1
/
DMTQ	0		/// TO DETACH A DEVICE AND TO
	LAC	.-1	/// EMPTY AN I/O REQUEST QUEUE
	JMP	DMTQ1	/OF ALL OF A TASK'S REQUESTS
/
/ ALLOCATE/DEALLOCATE CONTROL TABLES FOR DISK FILES HANDLERS
/ EXCEPT THE RF HANDLER. (THESE TABLES CORRESPOND TO RFACTB)
/
RPACT0	0		/ALLOCATE/DEALLOCATE CONTROL TABLES FOR:
	0		/UNIT 0 RP DISK PACK HANDLER.
	0
RPACT1	0		/UNIT 1 DISK PACK HANDLER
	0
	0
RPACT2	0		/UNIT 2 DISK PACK HANDLER
	0
	0
RPACT3	0		/UNIT 3 DISK PACK HANDLER
	0
	0
RPACT4	0		/UNIT 4 DISK PACK HANDLER
	0
	0
RPACT5	0		/UNIT 5 DISK PACK HANDLER
	0
	0
RPACT6	0		/UNIT 6 DISK PACK HANDLER
	0
	0
RPACT7	0		/UNIT 7 DISK PACK HANDLER
	0
	0
/
RKACT0	0		/ALLOCATE/DEALLOCATE CONTROL TABLES FOR:
	0		/UNIT 0 RK DISK FILE HANDLER
	0
RKACT1	0		/UNIT 1 RK DISK FILE HANDLER
	0
	0
RKACT2	0		/UNIT 2 RK DISK FILE HANDLER
	0
	0
RKACT3	0		/UNIT 3 RK DISK FILE HANDLER
	0
	0
RKACT4	0		/UNIT 4 RK DISK FILE HANDLER
	0
	0
RKACT5	0		/UNIT 5 RK DISK FILE HANDLER
	0
	0
RKACT6	0		/UNIT 6 RK DISK FILE HANDLER
	0
	0
RKACT7	0		/UNIT 7 RK DISK FILE HANDLER
	0
	0
/
/ ADDITIONAL RE-ENTRANT ROUTINE ENTRY POINTS			/EAG:167
/								/EAG:167
NDELXR	0			/// DELETE NODE TO WHICH XR	/EAG:167
	.INH			/// POINTS			/EAG:167
	JMP NDLXRE		///				/EAG:167
/								/EAG:167
DQAB	0			/// DE-QUEUE AN I/O REQUEST IF	/EAG:167
	.INH			/// AND ONLY IF IT IS AN ABORT	/EAG:167
	JMP DQAB1		///				/EAG:167
/								/EAG:167
 .TITLE *** API TRAP TRANSFER VECTOR TABLE
/
/ TABLE ENTRIES ARE MADE BY THE 'CONNECT' & 'DISCONNECT' DIRECTIVES.
/ THE LINE NUMBER (DECIMAL) USED WITH THESE DIRECTIVES IS INDICATED
/ IN SQUARE BRACKETS. 
/
ITVTB	0	/[--] SOFTWARE LEVEL 4
	SCF1	/[--] SOFTWARE LEVEL 5
L6TV	M0	/[--] SOFTWARE LEVEL 6
	0	/[--] SOFTWARE LEVEL 7
	EMGINT	/[04] DECTAPE
	EMGINT	/[05] MAGTAPE
	EMGINT	/[06]
	DSKRKI	/[07] UC15 UNICHANNEL DISK
	EMGINT	/[10] PAPER TAPE READER
	CLKINT	/[--] CLOCK OVERFLOW
	EMGINT	/[12] POWER FAIL
	EMGINT	/[13] MEMORY PARITY ERR
	EMGINT	/[14] VP15 & VT15
	EMGINT	/[15] CARD READER
	EMGINT	/[16] LINE PRINTER
	EMGINT	/[17] A-D CONVERTER
	EMGINT	/[20] DB99A-DB98A
	EMGINT	/[21]
	EMGINT	/[22] DATAPHONE
	DSKRFI	/[23] RF15 DISK
	DSKRPI	/[24] RP15  DISK PACK
	EMGINT	/[25] PLOTTER
	EMGINT	/[26]
	EMGINT	/[27]
	EMGINT	/[30] 
	EMGINT	/[31]
	EMGINT	/[32]
	EMGINT	/[33]
	TTYPI	/[--] LT19 OUTPUT
	TTYKI	/[--] LT19 INPUT
	EMGINT	/[36] DECTAPE (ADDITIONAL)
	EMGINT	/[37] DATAPHONE (ADDITIONAL)
	TTYPCT	/(166)[--] CONSOLE TTY PRINTER **
	TTYKCT	/(166[--] CONSOLE TTY KEYBOARD **
	EMGINT	/[42] PAPER TAPE PUNCH **
	MPKINT	/[--] MEMORY PROTECT VIOLATION **
ETVTB=.		/END OF TABLE
/
/ ** SIMULATED API INTERRUPTS.  PI INTERRUPTS RESULT IN API-3
/ INTERRUPTS, USE SKIP CHAIN TO DETERMINE INTERRUPTING DEVICE, AND
/ SIMULATE A 'JMS* TV'.
/
/ ENTRY FROM LOC 001 @ API-3
/
SAPI	DBA		/SET INDEX MODE
	ION		/(166)PI ENABLED AGAIN
	TSF		/(166)SKIP IF CONSOLE TTY PRINTER
	SKP		/(166) NOPE
	JMP*	ITVTB+40 /(166)TO INTRUPT SERVICE DIRECTLY
	KSF		/(166)CONSOLE TTY KEYBOARD?
	SKP		/(166) NO
	JMP*	ITVTB+41 /(166)GO DIRECTLY THERE
	DAC	SAPIB1	/SAVE AC
	MPSK		/MEMORY PROTECT VIOLATION?
	JMP	.+3
	LAC	ITVTB+43 /YES -- SELECT TV ADR
	JMP	SAPCC
	PSF		/NO -- PAPER TAPE PUNCH?
	JMP	.+3
	LAC	ITVTB+42 /YES -- SELECT TV ADR
	JMP	SAPCC
/
	NOP		/NO -- SPURIOUS PI INTERRUPT
	LAC	000	/TRY TO CLEAR VIA EMERGENCY 
	DAC	EMGINT	/INTERRUPT SERVICE ROUTINE
	LAC	SAPIB1
	JMP	EMGINT+1
/
SAPCC	DAC	SAPIB2	/COMMON CODE FOR SIMULATING API INTERRUPT
	LAC	000	/SIMULATE 'JMS TV'
	DAC*	SAPIB2
	ISZ	SAPIB2
	LAC	SAPIB1
	JMP*	SAPIB2
/
SAPIB1	0		/AC BUFFER
SAPIB2	0		/WORKING CELL
/
/ EMERGENCY INTERRUPT SERVICE ROUTINE FOR AN INTERRUPT ON A LINE
/ THAT HAS NOT BEEN "CONNECTED".  THIS ROUTINE SHOULD BE ABLE TO 
/ HANDLE INTERRUPTS FROM ALL DEVICES WHOSE INTERRUPTS CANNOT
/ BE CONTROLLED.  E.G., THOSE WHO INTERRUPT WHENEVER POWER IS
/ TURNED ON, OR A BUTTON IS PRESSED.
/
EMGINT	0
	700521		/CLEAR VP15A DISPLAY DONE FLAG IF SET
	SKP
	700722
/
	706721		/CLEAR CARD READER FLAG IF SET
	SKP
	706704
/
	NOP; SKP; NOP
	NOP; SKP; NOP
	NOP; SKP; NOP
	NOP; SKP; NOP
/
	DBR		/HOPEFULLY THE OFFENDING FLAG WAS CLEARED, EXIT
	JMP*	EMGINT	/EMERGENCY INTERRUPT SERVICE ROUTINE
/
	.LST
	.IFUND	L.DIR
	.NOLST
	.ENDC
 .TITLE *** CAL DISPATCH & RETURN
/
/ ALL CAL'S RESULT IN A TRANSFER TO 'CALDSP', REGARDLESS	/EAG:167
/ OF WHETHER THE CAL IS A NORMAL CAL OR AN INDIRECT CAL		/EAG:167
/ (CAL*).  THE TRANSFER IS VIA LOCATIONS 20 AND 21.		/EAG:167
/ LOCATION 20 IS INITIALIZED TO POINT TO ITSELF, SO THAT	/EAG:167
/ BOTH DIRECT AND INDIRECT (CAL*) CAL'S WILL TRAP THROUGH	/EAG:167
/ LOCATION 20.  THE CAL OPERAND IS EXPECTED TO BE A		/EAG:167
/ CAL PARAMETER BLOCK (CPB), AND SHOULD BE ADDRESSED BY THE	/EAG:167
/ CAL.  INDIRECT AND/OR INDEXED ADDRESSING IS ALLOWED AND WILL	/EAG:167
/ BE HANDLED CORRECTLY.  NOTE, HOWEVER, THAT INDIRECT CAL'S	/EAG:167
/ MUST BE TASK ISSUED -- THEY MAY NOT BE USED BY INTERRUPT	/EAG:167
/ ROUTINES.  THE FIRST WORD OF THE CAL PARAMETER BLOCK IS	/EAG:167
/ EXPECTED TO CONTAIN A CAL FUNCTION CODE IN BITS 12-17.	/EAG:167
/
/ CONTROL IS TRANSFERRED TO A "CAL SERVICE ROUTINE" WITH THE INDEX
/ REG (XR) AND THE AUTO INCREMENT REG X10 POINTING TO THE CAL PARAMETER BLOCK.
/ THE CAL SERVICE ROUTINE IS SELECTED BY THE DISPATCH TABLE 'CALDT' AND
/ THE FUNCTION CODE.
/
/ X11 IS SET ZERO IF CAL WAS ISSUED BY A TASK (AT API-7).  BITS 10-16
/ ARE SET TO INDICATE ACTIVE API LEVELS 0-6 (EXCLUDING API-4).
/
/ THE CAL EXIT ROUTINE 'CXDAC' EXPECTS X14 TO CONTAIN AN EVENT VARIABLE
/ ADDRESS, OR A ZERO IF AN EVENT VARIABLE WAS NOT SPECIFIED.  X14 IS SET
/ BY THE 'CPBRX' SUBROUTINE, WHICH IS CALLED BY ALL CAL'S THAT MAY RETURN
/ AN EVENT VARIABLE (ALL EXCEPT 'WAIT', SUSPEND' & 'EXIT').
/
/ THE CAL DISPATCH ROUTINE IS RE-ENTRANT, THUS CAL SERVICE ROUTINES
/ MAY BE REENTRANTLY CALLED. IT IS REENTRANT, HOWEVER, ONLY BY
/ VIRTUE OF THE FACT THAT INTERRUPT SERVICE ROUTINES WHICH MIGHT CAL
/ MUST SAVE AND RESTORE THE CONTENTS OF LOCATION 20.
/
/ EXIT FROM A CAL SERVICE ROUTINE IS VIA THE CAL EXIT ROUTINE 'CALEXT',
/ EXCEPT 'WAIT', 'SUSPEND', 'EXIT', AND SOMETIMES 'WAITFOR'.  (EACH OF
/ THESE RESET 'L20' TO HANDLE INDIRECT CAL'S CORRECTLY.)	/EAG:167
/
/ REGISTER USAGE: R1, R2, R3, R4, R5, X10, X11, L20, XR & AC	/EAG:167
/
/ "NORMAL MODE" CAL'S WITH ILLEGAL CPB OR EVENT VARIABLE	/EAG:167
/ ADDRESSES RESULT IN TASK TERMINATION.  A CAL INDIRECT		/EAG:167
/ FROM AN INTERRUPT SERVICE ROUTINE IS ILLEGAL, YET WILL	/EAG:167
/ NOT BE DETECTED.						/EAG:167
/
								/EAG:167
								/EAG:167
CALDSP	DBA		/SET INDEX MODE
	RPL		/SET X11 BITS 10-16 TO INDICATE ACTIVE
	AND	(366)	/API LEVELS 0-6.
	DAC	X11
/
	PXA			/ SAVE XR IN R3 IN CASE WE	/EAG:167
	DAC R3			/ HAVE AN INDEXED CAL.		/EAG:167
/								/EAG:167
	LAC L20			/ CONSTRUCT AN ADDRESS FIELD	/EAG:167
	RTL			/ MASK IN R2 -- 007777 IF IN	/EAG:167
	SZL!RAL			/ PAGE MODE, 017777 IF IN BANK	/EAG:167
	CLA!CMA!SKP		/ MODE.  ALSO LEAVE STATE	/EAG:167
	LAW 767777		/ OF USER/EXEC MODE BIT		/EAG:167
	AND (017777)		/ IN LINK.			/EAG:167
	DAC R2							/EAG:167
/								/EAG:167
	XOR (077777)		/ EXTRACT HIGH ORDER BITS (PAGE	/EAG:167
	AND L20			/ OR BANK BITS) FROM CAL RETURN	/EAG:167
	DAC R1			/ ADDRESS AND SAVE IN R1.	/EAG:167
/								/EAG:167
	LAC L20			/ COMPUTE THE 15-BIT CAL	/EAG:167
	AAC -1			/ INSTRUCTION VIRTUAL ADDRESS,	/EAG:167
	AND R2			/ CORRECTLY ADJUSTING FOR	/EAG:167
	XOR R1			/ BANK/PAGE WRAP AROUND.	/EAG:167
	SZL			/ SKIP IF EXEC MODE.		/EAG:167
	TAD CTBIAS		/ SET XR TO THE 17-BIT CAL	/EAG:167
	PAX			/ INSTRUCTION REAL (ABSOLUTE)	/EAG:167
				/ ADDRESS.			/EAG:167
/								/EAG:167
	LAC 0,X			/ TERMINATE TASK IF CAL INSTR.	/EAG:167
	AND (37777)		/ WAS OBJECT OF AN XCT INSTR.,	/EAG:167
	SAD 0,X			/ OR IF TASK EXECUTED A ZERO.	/EAG:167
	SNA!CLA!CMA		/ SKIP IF OK, LEAVE AC = -1.	/EAG:167
	JMP CALTT		/ JMP IF EITHER ERROR CHECK	/EAG:167
				/ FAILED.			/EAG:167
/								/EAG:167
	DAC R4			/ ASSUME CAL* (INDIRECT CAL).	/EAG:167
				/ SET INDIRECT FLAG (-1 ==>	/EAG:167
				/ INDIRECT CAL); NOTE THAT -1	/EAG:167
				/ HAS BEEN LEFT IN AC.		/EAG:167
	LAC 0,X			/ PICK UP CAL INSTRUCTION.	/EAG:167
	AND (17777)		/ MASK OUT INDIRECT BIT.	/EAG:167
	SAD 0,X			/ SKIP IF INDIRECT BIT WAS SET.	/EAG:167
	DZM R4			/ INDIRECT BIT CLEAR ==> DIRECT	/EAG:167
				/ CAL -- CLEAR INDIRECT FLAG.	/EAG:167
	DAC R5			/ SET R5 TO CAL INSTRUCTION	/EAG:167
				/ WITH INDIRECT BIT MASKED OUT.	/EAG:167
/								/EAG:167
/			NOTE:	THE NEXT TWO INSTRUCTIONS	/EAG:167
/				ARE EFFECTIVELY NOP'S WHEN	/EAG:167
/				THE TASK IS IN BANK MODE.	/EAG:167
/				THIS IS BECAUSE R2 WILL		/EAG:167
/				CONTAIN 17777.  THEREFORE,	/EAG:167
/				WHEN THE TASK IS IN BANK MODE,	/EAG:167
/				R3 WILL ALWAYS BE CLEARED.	/EAG:167
/								/EAG:167
	AND R2			/ MASK OUT INDEX BIT.		/EAG:167
	SAD R5			/ SKIP IF INDEX BIT SET.	/EAG:167
	DZM R3			/ INDEX BIT CLEAR -- ZERO	/EAG:167
				/ SAVED XR VALUE SO NO		/EAG:167
				/ INDEXING WILL BE DONE.	/EAG:167
	XOR R1			/ MERGE IN HIGH ORDER		/EAG:167
				/ ADDRESS BITS.			/EAG:167
	ISZ R4			/ INDIRECT CAL?  SKIP IF YES.	/EAG:167
	JMP CALD.0		/ JMP IF DIRECT CAL.		/EAG:167
	JMS CACAJ		/ CHECK ADDRESS AND RETURN	/EAG:167
				/ 17-BIT INDIRECT WORD ADDRESS	/EAG:167
				/ IN AC.			/EAG:167
	PAX			/ PICK UP CONTENTS OF INDIRECT	/EAG:167
	LAC 0,X			/ WORD (PERFORM INDIRECTION).	/EAG:167
CALD.0	TAD R3			/ PERFORM INDEXING.		/EAG:167
	JMS CACAJ		/ CHECK ADDRESS AND RETURN	/EAG:167
				/ 17-BIT CPB ADDRESS IN AC.	/EAG:167
	PAX			/ PUT THE CPB ADDRESS IN	/EAG:167
	DAC X10			/ XR AND X10.			/EAG:167
/								/EAG:167
	LAC 0,X			/ VERIFY THAT THE FIRST CPB	/EAG:167
	SNA			/ WORD IS NON-ZERO		/EAG:167
	JMP CALTT		/ JMP IF FIRST CPB WORD ZERO	/EAG:167
	AND (77)		/ EXTRACT CAL FUNCTION CODE	/EAG:167
	SNA!CLL			/ AND CHECK FOR QUEUE I/O	/EAG:167
				/ (ZERO) FUNCTION CODE.  ALSO	/EAG:167
				/ INITIALIZE LINK FOR FUNCTION	/EAG:167
				/ CODE RANGE CHECK BELOW.	/EAG:167
	JMP IO.			/ JMP IF CPB IS QUEUE I/O	/EAG:167
	TAD (-CALDTN+CALDT-1)	/ CPB FUNCTION CODE RANGE CHECK	/EAG:167
				/ SET LINK IF FUNCTION CODE IS	/EAG:167
				/ TOO LARGE.			/EAG:167
	AAC +CALDTN-CALDT+1	/ RESTORE CPB FUNCTION CODE IN	/EAG:167
				/ AC WITHOUT MODIFYING LINK.	/EAG:167
	SAD 0,X			/ VERIFY THAT CPB WORD ONE	/EAG:167
				/ CONTAINS ONLY THE FUNCTION	/EAG:167
				/ CODE, WITH NO HIGH ORDER BITS	/EAG:167
				/ SET.				/EAG:167
	SZL			/ COME HERE IF NO HIGH ORDER	/EAG:167
				/ BITS SET.  VERIFY CPB FUNC-	/EAG:167
				/ TION CODE WAS IN RANGE.	/EAG:167
	JMP CALTT		/ JMP IF CPB WORD ONE HAS HIGH	/EAG:167
				/ ORDER BITS SET OR IF CPB	/EAG:167
				/ FUNCTION CODE IS OUT OF RANGE	/EAG:167
	TAD (CALDT-1)		/ TRANSFER CONTROL THROUGH	/EAG:167
	DAC R2			/ DISPATCH TABLE TO DIRECTIVE	/EAG:167
	JMP* R2			/ PROCESSING ROUTINE WITH XR &	/EAG:167
				/ X10 POINTING TO THE CPB.	/EAG:167
/
/ CAL DISPATCH TABLE
/
/      DISPATCH INST   CODE    FUNCTION
/
			/00	QUEUE I/O REQUEST
CALDT	JMP	RQ.	/01	REQUEST TASK EXECUTION
	JMP	SC.	/02	SCHEDULE TASK EXECUTION
	JMP	RN.	/03	RUN TASK
	JMP	CN.	/04	CANCEL TASK SCHEDULING
	JMP	WT.	/05	WAIT FOR NEXT SIGNIFICANT EVENT
	JMP	SP.	/06	SUSPEND TASK EXECUTION
	JMP	RS.	/07	RESUME TASK EXECUTION
	JMP	EX.	/10	EXIT TASK
	JMP	CI.	/11	CONNECT INTERRUPT LINE
	JMP	DI.	/12	DISCONNECT INTERRUPT LINE
	JMP	MT.	/13	MARK TIME
	JMP	SY.	/14	SYNCHRONIZE TASK
	JMP	FX.	/15	FIX IN CORE
	JMP	UF.	/16	UN-FIX
	JMP	SJ.	/17	SET JEA REGISTER
	JMP	WF.	/20	WAIT FOR EVENT VARIABLE
	JMP	DA.	/21	DISABLE
	JMP	EA.	/22	ENABLE
	JMP	UM.	/23	UNMARK
	JMP	DT.	/24	DATE & TIME INFORMATION
	JMP	TN.	/25	TASK NAME INFORMATION
	JMP	PI.	/26	PARTITION INFORMATION
	JMP	RB.	/27	RAISE MEMORY PROTECT BOUND
	JMP	RASP.1	/30	CAL USED FOR RASP-15
	JMP	SPY.	/31	SPY
	JMP	SPYST.	/32	SPYSET
	JMP	QJOB.	/33	QUEUE JOB
	JMP	XE.	/34	EXECUTE
	.IFDEF	NOXM
	JMP	CALTT	/35
	.ENDC
	.IFUND	NOXM
	JMP	SHR.	/35	SHARE
	.ENDC
	JMP RQ.M	/36	REQUEST MAPPED TASK		/(161)
	JMP	TC.	/37	TRANSFER COMMAND [STRING] TO TDV FUNCTION
CALDTN=.			/ ALL OTHER FUNCTION CODES	/EAG:167
				/ FLAGGED ILLEGAL IN TEST	/EAG:167
				/ PRIOR TO DISPATCH.		/EAG:167
/
/ ROUTINES TO SET THE REQUESTOR'S EVENT VARIABLE AND EXIT FROM
/ A CAL.  AUTO INCREMENT REGISTER X10 IS EXPECTED TO CONTAIN
/ THE ADDRESS OF THE CAL PARAMETER BLOCK.  (X10 IS INCREMENTED.)
/
CX001	LAW	-1	/CAL ERR 01
	JMP	CXDAC
CX026	LAW	-26	/CAL ERR 26
	JMP	CXDAC
CX030	LAW	-30	/CAL ERR 30
	JMP	CXDAC
CX032	LAW	-32	/CAL ERR 32
	JMP	CXDAC
CX077	LAW	-77	/CAL ERR 77
	JMP	CXDAC
CX101	LAW	-101	/CAL ERR 101
	JMP	CXDAC
CX102	LAW	-102	/CAL ERR 102
	JMP	CXDAC
CX103	LAW	-103	/CAL ERR 103
	JMP	CXDAC
CX104	LAW	-104	/CAL ERR 104
	JMP	CXDAC
CX105	LAW	-105	/CAL ERR 105				/EAG:202
	JMP	CXDAC						/EAG:202
CX106	LAW	-106	/CAL ERR 106				/EAG:202
	JMP	CXDAC						/EAG:202
CX201	LAW	-201	/CAL ERR 201
	JMP	CXDAC
CX202	LAW	-202	/CAL ERR 202
	JMP	CXDAC
CX203	LAW	-203	/CAL ERR 203
	JMP	CXDAC
CX204	LAW	-204	/CAL ERR 204
	JMP	CXDAC
CX205	LAW	-205	/CAL ERR 205
	JMP	CXDAC
CX206	LAW	-206	/CAL ERR 206
	JMP	CXDAC
CX207	LAW	-207	/CAL ERR 207
	JMP	CXDAC
CX210	LAW	-210	/CAL ERR 210
	JMP	CXDAC
CX211	LAW	-211	/CAL ERR 211
	JMP	CXDAC
CX212	LAW	-212	/CAL ERR 212
	JMP	CXDAC
CX213	LAW	-213	/CAL ERR 213
	JMP	CXDAC
CX301	LAW	-301	/CAL ERR 301
	JMP	CXDAC
CX302	LAW	-302	/CAL ERR 302
	JMP	CXDAC
CX777	LAW	-777	/CAL ERR 777 -- OUT OF POOL,
	ISZ	SE.EP	/INCREMENT EMPTY POOL COUNT
	NOP
	JMP	CXDAC
CXPND	CLA!SKP		/REQUEST PENDING CAL EXIT
CXSUC	LAC	(+1)	/SUCCESSFUL COMPLETION CAL EXIT
CXDAC	DAC	R1	/CAL SERVICE EXIT -- SET EVENT VARIABLE (WHOSE ADR
	LAC	X14	/IS IN X14) TO THE CONTENTS OF AC.
	SNA		/ZERO EVENT VARIABLE ADDRESS IMPLIES NO ADDRESS
	JMP	CALEXT	/SPECIFIED
	PAX
	LAC	R1
	DAC	0,X
/
/ IF A CAL IS EXECUTED AT API LEVELS 7, 6, OR 5, API-4 IS SET
/ ACTIVE, AND A DEBREAK IS NECESSARY AT CAL EXIT.
/
CALEXT	RPL		/IS API LEVEL 3,2,1,OR 0 ACTIVE?
	AND	(360)
	SNA
	JMP	CALEX2	/NO -- EXIT A TASK ISSUED CAL
	RES		/YES -- EXIT AN INTERRUPT SERVICE ROUTINE ISSUED CAL
	JMP*	L20
/
CALEX2	LAC	L20	/SETUP 'L20' TO HANDLE A CAL INDIRECT.
	DAC	R1
	LAC	(L20)						/EAG:167
	DAC	L20
	DBR
	JMP*	R1
 .TITLE *** COMMON ROUTINES FOR CAL SERVICE
/
/ CACAJ -- RE-ENTRANT SUBROUTINE TO CHECK AND ADJUST (TO 17 BITS)
/ AN ADDRESS IN AC. 
/
/ IF AN ADDRESS FROM A "NORMAL MODE" TASK IS OUT OF RANGE,
/ THE TASK IS ABORTED.
/
/ R1, R2, & AC ARE ALTERED.
/
CACAJ	0		///
	.INH		///SAVE TEST ADDRESS IN R1 & RETURN ADDRESS IN R2
	DAC	R1	///
	.ENB		///
	LAC	CACAJ	///
	DAC	R2
/
	LAC	L20	/"NORMAL (USER) MODE"?
	RTL
	SMA
	JMP	CACAJ2	/NO -- DO NOT CHECK OR ADJUST
	LAC	CTSIZE	/YES -- COMPARE ADDRESS WITH MAX. TASK SIZE
	TCA		/AVAILABLE TO CURRENT (ISSUING) TASK.
	TAD	R1
	SMA		/TOO LARGE?
	JMP	CALTT	/YES -- ABORT TASK
	LAC	R1	/NO -- TOO SMALL?
	SPA
	JMP	CALTT	/YES -- ABORT TASK
	TAD	CTBIAS	/NO -- ADD RELOCATION BIAS TO ADDRESS
	JMP*	R2	/AND RETURN WITH ADJUSTED ADDRESS IN AC.
/
CACAJ2	LAC	R1	/CAL HAS BEEN ISSUED BY EITHER AN "EXEC
	JMP*	R2	/MODE" TASK, OR BY AN INTERRUPT SERVICE
			/ROUTINE (I.E., 'CTBIAS' HAS NO MEANING),
			/RETURN WITH ADDRESS IN AC.
/
/ CPBRX -- RE-ENTRANT SUBROUTINE TO CHECK THE RANGE OF A "NORMAL MODE"
/ TASK'S CAL PARAMETER BLOCKS.  IF A CPB EXTENDS BEYOND THE UPPER 
/ BOUND OF A TASK, THE TASK IS TERMINATED, AND CONTROL IS NOT 
/ RETURNED FROM 'CPBRX'.
/
/ IF CONTROL IS RETURNED FROM 'CBPRX', X14 & AC CONTAIN THE ADDRESS
/ (17-BITS) OF A REQUESTOR'S EVENT VARIABLE, OR ZERO IF AN EVENT
/ VARIABLE HAS NOT BEEN SPECIFIED.
/
/ THIS SUBROUTINE IS USED BY ALL CAL SERVICE ROUTINES FOR CAL'S
/ WITH CPB'S OF TWO OR MORE WORDS, BOTH TO VERIFY THE CPB RANGE,
/ AND TO PREPARE 'X14' FOR THE 'CXDAC' CAL EXIT.
/
/ THIS ROUTINE EXPECTS BOTH X10 & XR TO CONTAIN A 17-BIT CPB ADDRESS,
/ AND AC TO CONTAIN THE 2'S COMPLEMENT OF THE CPB SIZE.
/
/ R1, R2, R3, X14, & AC ARE ALTERED.
/
CPBRX	0		///
	.INH		///SAVE CPB SIZE IN R2 & RETURN ADDRESS IN R3
	DAC	R2	///
	.ENB		///
	LAC	CPBRX	///
	DAC	R3
/
	LAC	L20	/CAL ISSUED BY "EXEC MODE" TASK?
	RTL
	SPA
	JMP	CPBRX2
	LAC	1,X	/YES -- ASSUME CPB TO BE CORRECT AND SET X14
	DAC	X14
	JMP*	R3	/EXIT
/
CPBRX2	LAC	X10	/NO -- IS ENTIRE CPB WITHIN PARTITION?
	TCA
	TAD	R2
	TAD	CTBIAS
	TAD	CTSIZE
	SPA!SNA
	JMP	CALTT	/NO -- TERMINATE TASK
	LAC	1,X	/YES -- WAS AN EVENT VARIABLE SPECIFIED?
	SZA		/NO -- DO NOT ALTER OR CHECK EVENT VARIABLE "ADDRESS"
	JMS	CACAJ	/YES -- CHECK AND ADJUST (TO 17-BITS) EVENT VARIABLE
	DAC	X14	/SET X14 TO EVENT VARIABLE ADDRESS, OR TO ZERO IF
			/AN EVENT VARIABLE HAS NOT BEEN SPECIFIED.
	JMP*	R3	/EXIT
/
/ BAD CAL -- CREATE TASK TERMINATION NOTICE REQUEST AND EXIT TASK
/
CALTT	JMS	PENP	/PICK A NODE FROM THE POOL
			/(R1, R6, XR, & AC ARE ALTERED)
			/IS POOL EMPTY?
	JMP	CALTTX	/YES -- CAN'T PRINT MESSAGE.
	IAC		/SETUP X13 TO FILL NODE WITH TERMINATION 
	DAC	X13	/NOTICE INFORMATION.
	LAC	CURTSK	/SET TASK NAME
	PAX
	LAC	A.N1,X
	DAC*	X13
	LAC	A.N2,X
	DAC*	X13
	LAC	(3)	/SET TERMINATION INDICATOR (3 FOR CAL ADR)
	DAC*	X13
	LAC	L20	/SET ADDRESS OF CAL CAUSING VIOLATION (ACTUALLY
	DAC*	X13	/LINK, ADR MODE, PROTECT MODE, AND ADR
			/OF WORD FOLLOWING BAD CAL.
	.IFUND NOMAC						/(161)
	LAC MA.UN	/ CHECK FOR CURRENT TASK BEING MULTI	/(161)
	SNA		/ ACCESS JOB. AC >< 0 IF SO.		/(161)
	JMP CALTT1	/ NOT MULTIACCESS, GO GET TNTERM.	/(161)
	LAC R2		/ FETCH NODE ADDRESS.			/(161)
	PAX		/ PREPARE TO SET TNTERM NOTICE SWITCH	/(161)
	CLA!IAC		/ TNTERM FLAG IS 1.			/(161)
	DAC T.EC,X	/ SET EXIT CODE IN TNTERM NODE.		/(161)
	LAC (TDV.EQ)	/ FETCH LIST ADDRESS.			/(161)
	JMP CALTT2	/ GO JOIN COMMON CODE.			/(161)
CALTT1=.							/(161)
	.ENDC							/(161)
	LAC	(TNRL)	/ADD NODE TO TERMINATION NOTICE REQUEST LIST
CALTT2	DAC R1		/ SET UP PROPER LIST ADDRESS FOR NADD	/(161)
	JMS	NADD	/(R2, R6, XR, & AC ARE ALTERED)
	.IFUND NOMAC						/(161)
	LAC MA.UN	/ SKIP REQUEST TO TNTERM IF TASK IS RUN	/(161)
	SNA		/ BY MULTIACCESS.			/(161)
	.ENDC							/(161)
	CAL	RQTTN	/REQUEST THE TASK TERMINATION NOTICE TASK.
/
CALTTX	LAC	(RETX)	/EXIT TASK
	DAC	L20
/
	JMP	CALEXT	/EXIT CAL SERVICE
/
/ SSTL -- RE-ENTRANT SUBROUTINE TO SCAN THE SYSTEM TASK
/ LIST FOR A TASK-NAME IN A CAL PARAMETER BLOCK.  THIS
/ SUBROUTINE IS TO BE CALLED FROM A CAL SERVICE ROUTINE,
/ WHERE X10 CONTAINS THE CPB ADDRESS (SET BY CAL DISPATCH).
/
/ IF THE TASK-NAME IS FOUND, CONTROL IS RETURNED AT JMS+1
/ WITH THE STL NODE ADDRESS IN AC.
/
/ IF THE TASK-NAME IS NOT FOUND, CONTROL IS RETURNED AT
/ 'CX201' WHICH SETS THE REQUESTOR'S EVENT VARIABLE TO -201
/ AND EXITS FROM THE CAL SERVICE ROUTINE.
/
/ REGISTERS ALTERED:
/    R1, R2, R3, R6, X17, XR, & AC
/
SSTL	0		///SAVE RETURN ADDRESS
	LAC	.-1	///
	DAC	R3
	LAC	X10	/SET NAME-DOUBLE-WORD ADR IN R2
	AAC	+2	/AND STL LISTHEAD ADR IN R1
	DAC	R2
	LAC	(STKL)
	DAC	R1
	JMS	SNAM	/SCAN STL FOR NAME
			/(R1, R2, R6, X17, XR, & AC ARE ALTERED)
			/NAME FOUND?
	JMP	CX201	/NO -- SET EVENT VAR TO -201 & EXIT CAL SERVICE
	JMP*	R3	/YES -- RETURN WITH STL NODE ADR IN AC
	.TITLE     MAPLUN -- CONVERT VIRTUAL LUN TO ABSOLUTE LUN
 
 
 
 
/
/ WRITTEN 6-MAY-76 BY ED GARDNER
/
/ THIS ROUTINE ACCEPTS A VIRTUAL LUN IN THE LOW 9 BITS OF THE
/ AC.  THE HIGH 9 BITS OF THE AC ARE IGNORED.  THE STATUS OF LUN
/ MAPPING IS CHECKED, AND THE LUN CONVERTED AS APPROPRIATE.
/ APPROPRIATE LUN RANGE CHECKS ARE MADE.
/
/ THIS ROUTINE IS REENTRANT BY VIRTUE OF BEING
/ NON-INTERRUPTABLE.
/
/ CALLING SEQUENCE:
/	LAC < VIRTUAL LUN >
/	JMS MAPLUN
/
/ RETURN AT JMS+1 IF SUCCESSFUL WITH ABSOLUTE LUN IN AC, XR, AND X16.
/ TRANSFER TO CX101 IF LUN IS OUT OF RANGE.
/
/ REGISTERS ALTERED:
/	AC, X16, XR, LINK
/
 
 
MAPLUN	0
	.INH			/// MAKES US REENTRANT.
	AND (777)		/// MASK OUT LUN.
	AAC -1			/// ADJUST TO ZERO ORIGIN.
	SNA!CLL			/// CHECK FOR LUN 1.
	JMP MPLN.B		/// JMP IF LUN 1.
	DAC X16			/// TEMPORARY SAVE.
	LAC X11			/// CHECK IF LUN MAPPING IN
	SNA!CLA!CLL		/// EFFECT.  INT. CAL => NO.
	SAD MA.LOF		/// MA.LOF = 0 => NO.
	JMP MPLN.A		/// JMP IF MAPPING DISABLED.
	LAW -MA.NLU		/// VERIFY VIRTUAL LUN IS
	TAD X16			/// WITHIN MAPPED LUN SPACE.
	SZL!CLL			/// SKIP IF OK.
	JMP MPLN.X		/// JMP IF LUN OUT OF RANGE.
	LAC MA.LOF		/// PICK UP MAPPING FACTOR.
MPLN.A	TAD X16			/// FORM ABSOLUTE LUN.
MPLN.B	TAD (-NLU)		/// VERIFY WITHIN RANGE.
	SZL!IAC			/// SKIP IF OK AND RESTORE
				/// ONE AS ORIGIN.
	JMP MPLN.X		/// JMP IF LUN OUT OF RANGE.
	TAD (NLU)		/// RESTORE LUN.
	PAX			/// PUT IN XR.
	DAC X16			/// SAVE IN X16
	.ENB			///
	JMP* MAPLUN		///
				///
				///
/ COME HERE IF LUN OUT OF RANGE	///
				///
MPLN.X	.ENB			/// SET EVENT VARIABLE TO -101.
	JMP CX101		///
	.TITLE *** 'QUEUE I/O' DIRECTIVE
/
/ THIS DIRECTIVE INSTRUCTS THE SYSTEM TO PLACE AN I/O REQUEST
/ FOR AN INDICATED DEVICE IN A QUEUE OF REQUESTS FOR THAT
/ DEVICE UNIT.  A SIX WORD CAL PARAMETER BLOCK (CPB) OF THE
/ FOLLOWING FORMAT IS USED.
/
/	CPB	(0) I/O FUNCTION CODE IN BITS 3-11 AND
/		    CAL FUNCTION CODE (00) IN BITS 12-17.
/		(1) EVENT VARIABLE ADDRESS
/		(2) LOGICAL UNIT NUMBER
/		(3) ---
/		(4) ---
/		(5) ---
/
/ IF THE DIRECTIVE IS REJECTED, THE EVENT VARIABLE (IF SPECIFIED) IS
/ SET TO ONE OF THE FOLLOWING NEGATIVE VALUES TO INDICATE REJECTION
/ AND THE REASON:
/
/	-101	OUT OF RANGE LUN
/	-102	UNASSIGNED LUN
/	-103	HANDLER NOT RESIDENT
/	-777	EMPTY POOL
/
/ IF THE DIRECTIVE IS ACCEPTED, THE EVENT VARIABLE, IF SPECIFIED,
/ IS CLEARED (ZEROED) AND LEFT FOR THE HANDLER TASK TO SET NON-
/ ZERO, A REQUEST NODE IS FORMED AND ENTERED INTO THE UNIT'S
/ REQUEST QUEUE PER REQUESTOR PRIORITY, AND THE HANDLER TASK
/ IS "TRIGGERED" TO SIGNAL THE FACT THAT A REQUEST HAS BEEN MADE.
/ THE DEVICE QUEUE (DEQUE) LISTHEAD AND THE TRIGGER EVENT VARIABLE
/ ADDRESS ARE IN THE PHYSICAL DEVICE NODE FOR THE DEVICE UNIT
/ TO WHICH THE INDICATED LOGICAL UNIT NUMBER IS ASSIGNED.
/ THE FORMAT OF THE REQUEST NODE IS AS FOLLOWS:
/
/	(0)  FORWARD LINKAGE
/	(1)  BACKWARD LINKAGE
/	(2)  REQUESTOR'S STL NODE ADDRESS
/	(3)  NORMAL/EXEC MODE INDICATOR
/	(4)  TASK PRIORITY (TO BE CHANGED!)
/	(5)  I/O FUNCTION CODE IN BITS 9-17, AND
/	     LUN IN BITS 0-8.
/	(6)  CPB WD 1 -- EVENT VARIABLE ADDRESS
/	(7)  CPB WD 3 -- (UNIQUE TO CAL)
/	(10) CPB WD 4 -- (UNIQUE TO CAL)
/	(11) CPB WD 5 -- (UNIQUE TO CAL)
/
/ IF AN I/O REQUEST IS QUEUED BY AN INTERRUPT SERVICE ROUTINE, ZERO IS
/ USED IN PLACE OF AN STL NODE ADDRESS.
/
/ IF AN I/O REQUEST IS QUEUED BY A "NORMAL MODE" TASK, ITS PARTITION
/ BLOCK ADDRESS IS SET IN THE MODE INDICATOR.  FOR AN "EXEC" MODE TASK,
/ THE MODE INDICATOR IS SET ZERO.
/								/EAG:167
/ IF THE I/O REQUEST IS AN ABORT REQUEST (I/O FUNCTION CODE	/EAG:167
/ 17), THREE VARIATIONS ARE EMPLOYED IN ITS HANDLING:		/EAG:167
/								/EAG:167
/   1.	THE REQUEST IS QUEUED IN THE PDVL NODE FOR UNIT ZERO	/EAG:167
/	(THE FIRST PDVL NODE FOR THIS DEVICE) RATHER THAN	/EAG:167
/	THE PDVL NODE ASSOCIATED WITH THE UNIT BEING ABORTED.	/EAG:167
/								/EAG:167
/   2.	THE REQUEST IS QUEUED WITH A PRIORITY OF ZERO,		/EAG:167
/	REGARDLESS OF THE ISSUEING TASK'S PRIORITY.		/EAG:167
/								/EAG:167
/   3.	BOTH BIT 3 AND BIT 0 (=440000) OF THE TRIGGER EVENT	/EAG:167
/	VARIABLE ARE SET.  BIT 0 ONLY (=400000) IS THE		/EAG:167
/	NORMAL CASE.						/EAG:167
/								/EAG:167
/ ABORTS ISSUED VIA THIS, THE NORMAL QUEUE I/O MECHANISM, ARE	/EAG:167
/ ABORTS FOR A SINGLE UNIT ONLY.  THE I/O RUNDOWN TASK ISSUES	/EAG:167
/ AN ABORT FOR ALL UNITS DIRECTLY; I.E., IT QUEUES THE REQUEST	/EAG:167
/ NODE ITSELF USING SPRI.  THE ABORT ALL UNITS REQUEST IS	/EAG:167
/ DISTINGUISHED FROM THE (TASK-ISSUED) ABORT SINGLE UNIT	/EAG:167
/ IN TWO WAYS:  1) THE I/O REQUEST NODE LUN FIELD CONTAINS	/EAG:167
/ ZERO RATHER THAN A LUN NUMBER, AND 2) BIT 2 ONLY (=100000)	/EAG:167
/ OF THE TRIGGER EVENT VARIABLE IS SET, RATHER THAN EITHER	/EAG:167
/ BIT 3 OR BIT 0 (=440000).  NOTE ALSO THAT ALL I/O		/EAG:167
/ HANDLERS MUST ACCEPT THE ABORT ALL UNITS VARIATION, WHEREAS	/EAG:167
/ THE ABORT SINGLE UNIT VARIATION IS OPTIONAL.			/EAG:167
/								/EAG:167
/								/EAG:167
/								/EAG:167
/ BEFORE THE APPROPRIATE BITS ARE SET IN THE HANDLER'S TRIGGER	/EAG:167
/ EVENT VARIABLE, A CHECK IS MADE TO SEE IF THE TRIGGER EVENT	/EAG:167
/ VARIABLE IS ZERO OR NOT.  IF THE TRIGGER EVENT VARIABLE IS	/EAG:167
/ ZERO, THE BITS ARE SET IN IT AND A SIGNIFICANT EVENT IS	/EAG:167
/ DECLARED.  IF THE TRIGGER EVENT VARIABLE IS ALREADY NON-ZERO,	/EAG:167
/ THE BITS ARE STILL SET BUT NO SIGNIFICANT EVENT IS DECLARED.	/EAG:167
								/EAG:167
								/EAG:167
/ CONTROL IS TRANSFERRED HERE BY THE CAL DISPATCH ROUTINE.
/ XR & X10 CONTAIN THE ADDRESS OF THE CAL PARAMETER BLOCK.
/
IO.	LAW -6		/ CHECK RANGE OF CPB AND SET UP X14	/(161)
	JMS CPBRX	/ WITH THE 17 BIT EV VARIABLE ADDRESS.	/(161)
/
	LAC 2,X		/ FETCH THE LUN NUMBER FROM THE CPB	/(161)
	JMS MAPLUN	/ MAP VIRTUAL LUN TO ABSOLUTE LUN AND	/EAG:202
			/ VERIFY LUN IS IN RANGE.  LEAVES	/EAG:202
			/ ABSOLUTE LUN IN AC, XR, AND X16.	/EAG:202
	LACIX (LUT-1)	/ IS LUN ASSIGNED -- I.E., DOES THE	/EAG:202
	SNA		/ LUT ENTRY CONTAIN A PDVL NODE ADDR.?	/EAG:202
	JMP	CX102	/NO -- SET EVENT VAR TO -102
	DAC	X12	/YES -- SAVE PHYSICAL DEVICE NODE ADR IN X12
	PAX		/IS HANDLER RESIDENT?
	LAC	D.TG,X
	SNA		/YES -- QUEUE I/O REQUEST
	JMP	CX103	/NO -- SET EVENT VARIABLE TO -103
/
/ VALID I/O CAL -- X10 CONTAINS THE CPB ADDRESS AND X12
/ CONTAINS THE PHYSICAL DEVICE ADDRESS NODE
/
	JMS PENP	/ PICK AN EMPTY NODE FROM THE POOL.	/(161)
			/(R1, R6, XR, & AC ARE ALTERED)
			/IS POOL EMPTY?
	JMP	CX777	/YES -- SET EVENT VARIABLE TO -777
	IAC		/ SETUP X13 TO FILL NODE.		/(173)
	DAC	X13
/
	LAC X10			/ SETUP XR TO ACCESS CPB, SO	/EAG:167
	PAX			/ WE CAN CHECK FOR ABORT (FUNC-	/EAG:167
	LAC (1700)		/ TION CODE 17).  THEN SET X15	/EAG:167
	SAD 0,X			/ TO APPROPRIATE TRIGGER EVENT	/EAG:167
	CLA!CMA!CLL!SKP		/ BITS -- 440000 IF ABORT,	/EAG:167
	SWHA!STL		/ 400000 OTHERWISE.		/EAG:167
	AND (440000)		/ ALSO, SETUP LINK AS ABORT	/EAG:167
	DAC X15			/ FLAG -- CLEAR LINK IF ABORT,	/EAG:167
	SZL			/ SET LINK OTHERWISE.		/EAG:167
	JMP IO.1C		/ JMP IF NOT ABORT		/EAG:167
/								/EAG:167
/			IMPORTANT NOTE:				/EAG:167
/								/EAG:167
/	A FLAG HAS BEEN PUT IN THE LINK WHICH IS CHECKED	/EAG:167
/	ABOUT 30 LINES BELOW.  INTERVENING INSTRUCTIONS		/EAG:167
/	MUST NOT MODIFY THE LINK!				/EAG:167
/								/EAG:167
	ISZ X12			/ THE I/O REQUEST IS AN ABORT	/EAG:167
	LAC* X12		/ SINGLE UNIT REQUEST -- SETUP	/EAG:167
	DAC R1			/ R1 TO DEVICE HANDLER NAME,	/EAG:167
	LAC PDVL		/ THEN SCAN PDVL FOR THE FIRST	/EAG:167
IO.1B	PAX			/ PDVL NODE FOR THIS DEVICE --	/EAG:167
	DAC X12			/ I.E. THE NODE FOR UNIT ZERO.	/EAG:167
	LAC D.N1,X		/ STORE THE ADDRESS OF EACH	/EAG:167
	SAD R1			/ NODE IN X12, SO THAT WHEN	/EAG:167
	JMP IO.1C		/ A MATCH IS FOUND X12 WILL	/EAG:167
	LAC D.FP,X		/ CONTAIN THE PDVL NODE		/EAG:167
	JMP IO.1B		/ ADDRESS			/EAG:167
								/EAG:167
								/EAG:167
IO.1C	LAC CURTSK	/ SET UP TO ACCESS CORRECT ATL NODE FOR	/(173)
	PAX		/ QI/O PARAMETERS.			/(173)
	LAC X11		/ WAS CAL ISSUED FROM A TASK?		/(173)
	SNA
	JMP	IO.2
	LAC (DUMA.TP-A.TP) / FETCH DUMMY STL NODE ADDRESS FOR	/(173)
	PAX		/ DUMMY PARAMETERS.			/(173)
IO.2	LAC	A.SN,X	/ FETCH THE STL NODE ADDRESS.		/(173)
	DAC*	X13	/(WD 2)
	LAC A.PB,X		/ FETCH PART. BLOCK ADR. FOR	/(173)
	DAC* X13		/ MODE IND. IN REQUEST		/(173)
	AAC +P.TP		/ USER MODE TASK -- INCREMENT	/EAG:167
	DAC R1			/ TRANSFERS PENDING COUNT	/EAG:167
	ISZ* R1							/EAG:167
	AAC	P.IO-P.TP	/ POINT TO I/O COUNT LOCATION	/(213)
	XCT	FPHDWE		/ SKIPS IF FP HARDWARE EXISTS	/(214)
	AAC	-PBFP		/ THIS NEVER HAPPENS AT UOW	/(214)
	DAC	R1						/(213)
	ISZ*	R1		/ INCREMENT I/O COUNT		/(213)
	NOP			/ IN CASE IT SKIPS (SHOULDN'T)	/(213)
/								/EAG:167
/			IMPORTANT NOTE:				/EAG:167
/								/EAG:167
/	THE NEXT LINE OF CODE CHECKS A FLAG WHICH WAS SAVED	/EAG:167
/	IN THE LINK ABOUT 30 LINES PREVIOUSLY.  INTERVENING	/EAG:167
/	INSTRUCTIONS MUST NOT MODIFY THE LINK!			/EAG:167
/								/EAG:167
	SZL!CLL!CLA	/ IS THIS AN ABORT FUNCTION?		/(173)
	LAC A.TP,X	/ NO, FETCH TASK PRIORITY.		/(173)
	DAC* X13	/ STORE TASK PRIORITY IN REQUEST BLOCK.	/(173)
	LAC	X10	/SETUP XR TO ACCESS CPB
	PAX
	LAC	0,X	/SET LUN & I/O FUNCTION CODE
	AND (077700)	/ MASK OUT I/O FUNCTION CODE		/EAG:202
	CLL!RAL		/ SHIFT TO HIGH 9 BITS OF AC.		/EAG:202
	RTL							/EAG:202
	XOR X16		/ MERGE LUN INTO LOW 9 BITS OF AC.	/EAG:202
			/ (LUN LEFT IN X16 BY CALL TO MAPLUN.)	/EAG:202
	SWHA		/ POSITION LUN AND FNC. CORRECTLY, THEN	/EAG:202
	DAC* X13	/ STORE IN WD 5 OF REQUEST NODE.	/EAG:202
/
	LAC	X14	/SET REQUESTOR'S EVENT VARIABLE ADDRESS
	DAC*	X13	/(WD 6)
/
	LAC	3,X	/SET CPB WORD 3
	DAC*	X13	/(WD 7)
/
	LAC	4,X	/SET CPB WORD 4
	DAC*	X13	/(WD 10)
/
	LAC	5,X	/SET CPB WORD 5
	DAC*	X13	/(WD 11)
/
	LAC X12		/ ADD NODE TO DEQ (LIST HEAD IN PHYSICAL/(161)
	AAC	D.QF	/DEVICE NODE) ORDERED BY PRIORITY.
	DAC	R1	/(R1, R2, R3, R6, XR, & AC ARE ALTERED)
	JMS	SPRI
/
	LAC	X12	/SET "TRIGGER" EVENT VARIABLE IN
	PAX		/HANDLER (ADDRESS IN PHYSICAL DEVICE
	LAC	D.TG,X	/NODE)
	PAX			/ POINT XR TO T. E. V.		/EAG:167
	.INH			/ GUARD AGAINST INTERRUPTS	/EAG:167
	LAC 0,X			/// PICK UP PREVIOUS TEV VALUE	/EAG:167
	CMA!CLL!SNA		/// COMPLEMENT TEV, AND SET	/EAG:167
	STL			/// LINK IF TEV WAS PREVIOUSLY	/EAG:167
				/// ZERO -- I.E. IF SIGNIFICANT	/EAG:167
				/// EVENT SHOULD BE DECLARED.	/EAG:167
				/// CLEAR LINK IF TEV IS	/EAG:167
				/// ALREADY NON-ZERO.		/EAG:167
	AND X15			/// FINISH PROCESS OF SETTING	/EAG:167
	XOR 0,X			/// APPROPRIATE BIT (FROM X15)	/EAG:167
	.ENB			/// IN THE TEV (TRIGGER EVENT	/EAG:167
	DAC 0,X			/// VARIABLE).			/EAG:167
	LAC (401000)		/ PREPARE TO DECLARE SIG. EVENT	/EAG:167
	SZL			/ DECLARE SIGNIFICANT EVENT IFF	/EAG:167
	ISA			/ LINK IS SET -- I.E. IF TEV	/EAG:167
				/ WAS PREVIOUSLY ZERO.		/EAG:167
	JMP	CXPND	/CLEAR EVENT VARIABLE AND EXIT CAL SERVICE ROUTINE 
 
/								/(173)
/ THE FOLLOWING WORDS MUST BE LEFT IN THE EXISTING ORDER. THEY	/(173)
/ ARE A DUMMY SET OF ATL NODE PARAMETERS WHICH EXIST ONLY TO	/(173)
/ MAKE THE EXEC AND NON-TASK I/O RUNDOWN SOLUTION COME OUT 	/(173)
/ CLEANLY.							/(173)
/								/(173)
 
DUMA.TP	1		/ DUMMY TASK PRIORITY FOR NON-TASK I/O	/(173)
DUMA.PB	DUMP.TP-P.TP	/ POINTER TO A DUMMY TRANSFER PENDING	/(173)
			/ WORD IN A PSUEDO PARTITION BLOCK.	/(173)
DUMA.SN	0		/ STL NODE FOR NON-TASK I/O.		/(173)
 
/ THE FOLLOWING WORD IS USED BY ALL NON-TASK I/O REQUESTS AS A	/(173)
/ COMMON TRANSFER PENDING COUNTER. EACH REQUEST WILL INCREMENT	/(173)
/ AND THE TERMINATION OF EACH TRANSFER WILL DECREMENT THIS WORD./(173)
 
DUMP.TP	0		/ DUMMY TRANSFER PENDING WORD.		/(173)
 .TITLE *** 'REQUEST' 'FIX' & 'REQUEST MAPPED' DIRECTIVES	/(161)
/
/ THE REQUEST DIRECTIVE INSTRUCTS THE SYSTEM TO MAKE A TASK ACTIVE
/ AT AN INDICATED SOFTWARE PRIORITY LEVEL.  A FIVE WORD CAL PARAMETER
/ BLOCK OF THE FOLLOWING FORMAT IS USED:
/
/	CPB	(0) FUNCTION CODE (01)
/		(1) EVENT VARIABLE ADDRESS
/		(2) TASK NAME (FIRST HALF)
/		(3) TASK NAME (SECOND HALF)
/		(4) PRIORITY (ZERO FOR DEFAULT PRIORITY)
/
/ IF THE DIRECTIVE IS REJECTED, THE EVENT VARIABLE (IF SPECIFIED) IS
/ SET TO ONE OF THE FOLLOWING NEGATIVE VALUES TO INDICATE REJECTION
/ AND THE REASON:
/
/	-201  TASK NOT IN SYSTEM
/	-202  TASK ALREADY (OR STILL) ACTIVE
/	-204  TASK IS DISABLED
/	-206  ILLEGAL TASK PRIORITY
/	-777  POOL EMPTY
/
/ IF THE DIRECTIVE IS ACCEPTED, IT IS EXECUTED AND THE EVENT VARIABLE
/ (IF SPECIFIED) IS SET TO POSITIVE ONE (+1).
/								/(161)
/ THE REQUEST MAPPED DIRECTIVE INSTRUCTS THE SYSTEM TO MAKE A	/(161)
/ TASK ACTIVE AND INSERT LUN MAPPING AND USER NUMBER INFORMATION/(161)
/ INTO THE ATL IN ADDITION TO THE SAME INFORMATION AS REQUEST	/(161)
/ A SIX WORD CAL PARAMETER BLOCK OF THE FOLLOWING FORMAT IS	/(161)
/ USED:								/(161)
/								/(161)
/	CPB	(0) FUNCTION CODE (36)				/(161)
/		(1) EVENT VARIABLE ADDRESS			/(161)
/		(2) TASK NAME (FIRST HALF)			/(161)
/		(3) TASK NAME (SECOND HALF)			/(161)
/		(4) PRIORITY (ZERO FOR DEFAULT PRIORITY)	/(161)
/		(5) LUN OFFSET AND USER NUMBER IN THE FORM	/(161)
/		    OOOUUX BITS 0 - 8 FOR OOO AND 9 - 13 FOR UU	/(161)
/								/(161)
/ IF THE DIRECTIVE IS REJECTED, THE EVENT VARIABLE (IF SPECIFIED)/(161)
/ IS SET TO ONE OF THE SAME VALUES AS PER REQUEST (SEE ABOVE)	/(161)
/								/(161)
/ IF THE DIRECTIVE IS ACCEPTED, IT IS EXECUTED AND THE EVENT	/(161)
/ VARIABLE (IF SPECIFIED) IS SET TO POSITIVE ONE (+1)		/(161)
/
/ THE FIX DIRECTIVE INSTRUCTS THE SYSTEM TO FIX A TASK IN CORE.
/ A FOUR WORD CAL PARAMETER BLOCK OF THE FOLLOWING FORMAT IS USED:
/
/	CPB	(0) FUNCTION CODE (15)
/		(1) EVENT VARIABLE ADDRESS
/		(2) TASK NAME (FIRST HALF)
/		(3) TASK NAME (SECOND HALF)
/
/ IF THE DIRECTIVE IS REJECTED, THE EVENT VARIABLE (IF SPECIFIED) IS
/ SET TO ONE OF THE FOLLOWING NEGATIVE VALUES TO INDICATE REJECTION
/ AND THE REASON:
/
/	-201	TASK NOT IN SYSTEM
/	-202	TASK IS ACTIVE
/	-204	TASK IS DISABLED
/	-207	TASK ALREADY FIXED
/	-210	PARTITION IS OCCUPIED
/	-777	EMPTY POOL
/
/ IF THE DIRECTIVE IS ACCEPTED, IT IS EXECUTED AND THE EVENT VARIABLE
/ (IF SPECIFIED) IS SET TO POSITIVE ONE (+1).  THE TASK
/ IS LOADED AS IF REQUESTED, EXCEPT THAT THE ENTRY POINT IS
/ AN EXIT DIRECTIVE IN THE EXECUTIVE.  HENCE, THE TASK IS LOADED
/ INTO CORE AND EXITS WITHOUT ALTERING ITS IMAGE, AND IS READY FOR
/ EXECUTION WITHOUT LOADING FROM THE DISK.
/
/ THE FOLLOWING REGISTER CONVENTIONS APPLY TO BOTH DIRECTIVES:
/
/	X10 -- CPB ADDRESS (SET BY CAL DISPATCH ROUTINE)
/	X11 -- INDICATOR, 0-REQUEST, 1-REQUEST MAPPED, 2-FIX	/(161)
/	X12 -- SPECIFIED PRIORITY OR ZERO (FROM CPB)
/	X13 -- GENERAL AUTO INCREMENT REGISTER
/	X15 -- LUN OFFSET & USER # (REQ. & REQ. MAPPED ONLY)	/(203)
/	R2 -- ADDRESS OF ACTIVE TASK LIST NODE.			/(173)
/	R3 -- ADDRESS OF SYSTEM TASK LIST ENTRY
/
/ REQUEST -- ENTRY FROM CAL DISPATCH, XR & X10 CONTAIN CPB ADR
/
RQ.	LAW	-5	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	LAC	4,X	/SAVE SPECIFIED PRIORITY (OR ZERO) IN X12
	JMS	RQ.PRI	/SAVE PRIORITY AND TEST IT FOR LEGALITY
RQ.1	DZM	X11	/INDICATE "REQUEST"
	DZM	X15	/CLEAR LUN OFFSET & USER #		/(203)
RQ.1A	JMS	SSTL	/SCAN STL FOR TASK NAME -- FOUND?	/(161)
			/NO -- SET E.V. TO -201 & EXIT CAL SERVICE
	DAC	R3	/YES -- SAVE STL NODE ADR IN R3
	PAX		/(XR POINTS TO STL NODE)
/
	.INH		///TASK ACTIVE, DISABLED,OR PARTITION TROUBLE
	LAC	S.DP,X	///
	AND	(530000)///
	SZA		///
	JMP	RF.E1	///YES - ERR  202,204,212,213
	LAC	S.DP,X	///NO -- FLAG TASK ACTIVE
	XOR	(400000)///
	.ENB		///
	DAC	S.DP,X	///
	JMS	PENP	/PICK AN EMPTY NODE FROM THE POOL
			/(R1, R6, XR, & AC ARE ALTERED)
			/IS POOL EMPTY?
	JMP	RF.E7	/YES -- CLEAR ACTIVE TASK FLAG
	JMP	RF.2	/NO -- TO COMMON CODE WITH NODE ADDRESS IN AC
/								/(161)
/ REQUEST MAPPED -- ENTRY FROM CAL DISPATCH, XR AND X10 CONTAIN	/(161)
/		    CPB ADDRESS.				/(161)
/								/(161)
RQ.M	LAW -6			/ CHECK RANGE OF CPB (NORMAL	/(161)
	JMS CPBRX		/ MODE) AND SET X14 TO 17 BIT	/(161)
				/ EVENT VARIABLE ADDRESS.	/(161)
	LAC 4,X			/ FETCH PRIORITY.		/(161)
	JMS RQ.PRI		/ SAVE IN X12 AND TEST FOR	/(161)
				/ VALIDITY.			/(161)
	LAW 777760		/ FETCH LUN OFFSET & USER #	/(203)
	AND 5,X							/(203)
	DAC X15			/ SAVE IN APPROPRIATE PLACE.	/(203)
	TAD (-2000)		/ NOW CHECK THAT LUN OFFSET IS	/(203)
				/ LEGITIMATE.  -2000 IS FUDGE	/(203)
	CLL			/ FACTOR TO MAKE 0 & 1 ILLEGAL.	/(203)
	TAD (MA.NLU-NLU-1*1000)	/ SET LINK IF LUN OFFSET OUT	/(203)
				/ OF RANGE.  THERE MUST BE ROOM	/(203)
				/ FOR A FULL MULTIACCESS		/(103)
				/ LUN SET.			/(203)
	SZL!CLA!IAC		/ SKIP IF OK & 1 ==> AC		/(203)
	JMP CX101		/ JMP IF OFFSET OUT OF RANGE	/(203)
	DAC X11			/ SET RQST MAPPED CODE IN X11.	/(203)
	JMP RQ.1A		/ GO REJOIN COMMON REQUEST CODE./(161)
/
/ FIX -- ENTRY FROM CAL DISPATCH, XR & X10 CONTAIN CPB ADR
/
FX.	LAW	-4	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	DZM	X12	/INDICATE DISK READ AT DEFAULT PRIORITY
	DZM X15		/ INDICATE NO MAP AND NO USER TO AVOID	/(205)
			/ SPURIOUS TASK TERMINATION INTO TDV.	/(205)
	LAC	(002)	/INDICATE "FIX"
	DAC	X11
	JMS	SSTL	/SCAN STL FOR TASK NAME -- FOUND?
			/NO -- SET E.V. TO -201 & EXIT CAL SERVICE
	DAC	R3	/YES -- SAVE STL NODE ADDRESS IN R3
	PAX		/(XR POINTS TO STL NODE)
/
	LAC	S.PB,X	/SET ADDRESS OF PARTITION BLOCK
	PAL		/NODE INTO LR AND SET THE ADDRESS
	AAC	+P.TC	/OF THE TASK USE COUNT WORD INTO R6
	DAC	R6
/
	.INH		///IS TASK ACTIVE, DISABLED, OR
	LAC	S.DP,X	///FIXED-IN-CORE OR PARTITION TROUBLE?
	AND	(570000)///
	SZA		///
	JMP	RF.E1	///YES - ERR 202,204,207,212,213
	LAC*	R6	///NO -- IS PARTITION AVAILABLE
	SZA		///
	JMP	RF.E2	///NO -- ERR 210
	ISZ* R6		///INCREMENT PARTITION OCCUPIED FLAG.	/(161)
	LAC	S.DP,X	///FIXED-IN-CORE.
	XOR	(440000)///
	DAC	S.DP,X	///
	PLX		///SET UP XR TO ACCESS PBDL
	.ENB		///ENABLE INTERRUPTS
	DZM	P.Z1,X	///INDICATE PARTITION NOT YET ZEROED
	DZM	P.C1,X	/ZERO TASK'S CLOCK VALUES
	DZM	P.C2,X
	DZM	P.IO,X		/ INITIALIZE I/O COUNT TO ZERO	/(214)
	JMS	PENP	/PICK AN EMPTY NODE FROM THE POOL
			/(R1, R6, XR, & AC ARE ALTERED)
			/IS POOL EMPTY?
	JMP	RF.E6	/YES -- CLEAR ACTIVE TASK FLAG AND
			/PARTITION OCCUPIED FLAG
			/NO -- TO COMMON CODE WITH NODE ADDRESS IN AC
/
/ COMMON CODE FOR REQUEST & FIX
/
RF.2	IAC		/ SETUP AUTO-INCREMENT REGISTER X13	/(173)
	DAC	X13	/TO FILL ATL NODE.
/
/ SETUP NODE FOR ENTRY IN ACTIVE TASK LIST
/
	LAC	R3	/(XR POINTS TO STL NODE)
	PAX
	LAC	S.N1,X	/TASK NAME (2 WORDS)
	DAC*	X13
	LAC	S.N2,X
	DAC*	X13
	LAC	X12	/PRIORITY INDICATED IN REQUEST?
	SNA		/YES -- USE REQUESTED PRIORITY
	LAC	S.DP,X	/NO -- USE DEFAULT PRIORITY
	AND	(001777)
	DAC*	X13
	LAC	S.PB,X	/MOVE PARTITION BLOCK ADDRESS
	DAC*	X13
	PXA		/SET STL NODE ADR
	DAC*	X13
/
	LAC X11		/ REQUEST, REQUEST MAPPED, OR		/(161)
	AAC -1		/ FIX?					/(161)
	SMA!SZA!IAC	/ AC <= 0 IF REQUEST OF MAPPED		/(161)
			/ REQUEST.				/(161)
	JMP	RF.F2
/
/ CODE FOR REQUEST
/
	LAC	S.DP,X	/IS TASK FIXED-IN-CORE?
	AND	(040000)
	SNA!CLA!IAC
	JMP	RF.2A	/NO -- SET TASK STATUS TO 1 (NEEDS PARTITION)
/
	LAC	S.EP,X	/YES -- IS TASK NORMAL MODE?
	RTL
	SPA!CLA!CMA
	LAW	-400	/YES -- AND OFF LOW ORDER BITS TO GET TASK SIZE
	AND	S.TS,X	/GET TASK SIZE
	PAL
	LAC	S.PB,X	/SET XR TO POINT TO PARTITION NODE
	PAX
	PLA
	DAC	P.TS,X	/SAVE TASK SIZE
	LAC	P.SZ,X	/INITIALIZE PARTITION'S VIRTUAL SIZE
	DAC	P.VS,X	/EQUAL TO ITS ACTUAL SIZE
	DZM	P.BP,X	/INDICATE NO BUFFERS YET IN PARTITION
	DZM	P.C1,X	/ZERO XM CLOCK VALUES HERE SINCE THE
	DZM	P.C2,X	/THE TASK WILL BE AT STATUS 4 AFTER REQ IS DONE
	DZM	P.IO,X		/ ALSO ZERO I/O COUNT HERE	/(214)
	LAC P.FW,X	/ MERGE LUN OFFSET AND USER # INTO	/(203)
	XOR X15		/ FLAGS WORD (P.FW) OF PBDL.  NORMALLY	/(203)
	DAC P.FW,X	/ DONE BY STATE ONE PROCESSING.		/(203)
	LAC	R3	/(XR POINTS TO STL NODE)
	PAX
	LAC	(4)	/SET TASK STATUS TO 4 (READY TO RUN)
/
RF.2A	DAC* X13	/ SET TASK STATUS WORD			/(161)
	LAC	S.EP,X	/SET ENTRY ADDRESS
	DAC*	X13
	JMP	RF.3	/TO COMMON CODE
/
/ CODE FOR FIX
/
RF.F2	DAC*	X13	/SET STATUS TO 2 (READY TO FIX)
	LAC	(RETX)	/SET "ENTRY ADDRESS" TO CAUSE EXIT
	DAC*	X13	/WITHOUT EXECUTION OF TASK
/
/ COMMON CODE FOR REQUEST & FIX
/
RF.3	LAC X15		/ FETCH LUN OFFSET & USER # IF REQUEST,	/(203)
			/ FETCH GARBAGE IF FIX.			/(203)
	DAC* X13	/ SET UP ATL WITH LUN OFFSET AND USER	/(161)
	LAC (ATKL)	/ ADD NODE TO ATL PER PRIORITY		/(161)
	DAC	R1	/(R1, R2, R3, R6, XR, & AC ARE ALTERED)
	JMS	SPRI
/
	.SET6		/DECLARE A SIGNIFICANT EVENT
/
	JMP	CXSUC	/SET EVENT VARIABLE TO +1 AND
			/EXIT CAL SERVICE ROUTINE
/
/ ***	CAL SERVICE EXIT WITH R4 CONTAINING THE ATL NODE ADDRESS
/	IS REQUIRED BY THE TDV DISPATCH TASK "TDV...".
/
/	TOP SIX BITS ARE CONVERTED, IN ORDER, TO ERRORS
/	202,201,204,207,212,213. NOTE BOTH 212,213 IS 213.
/
RF.E10	DBK
RF.E1	.ENB
	SPA!RTL
	JMP	CX202
	SZL!RAL
	JMP	CX201
	SZL!RAL
	JMP	CX204
	SZL!RAL
	JMP	CX207
	SPA
	JMP	CX213
	JMP	CX212
/
RF.E2	.ENB		///ERR 210
	JMP	CX210	///
/
RF.E6	LAC	R3	/ERR 777 -- OUT OF POOL (TASK HAS BEEN FLAGGED
	PAX		/ACTIVE & FIXED IN CORE, AND THE PARTITION
	LAC	S.DP,X	/HAS BEEN FLAGGED OCCUPIED)
	AND	(337777)
	DAC	S.DP,X
	LAC	S.PB,X
	PAX
	LAC	P.TC,X
	AAC	-1
	DAC	P.TC,X
	JMP	CX777
/
RF.E7	LAC	R3	/ERR 777 -- OUT OF POOL (TASK HAS BEEN
	PAX		/FLAGGED ACTIVE, CLEAR THIS FLAG)
	LAC	S.DP,X
	AND	(377777)
	DAC	S.DP,X
	JMP	CX777
/
/ SUBROUTINE RQ.PRI -- SAVE PRIORITY IN X12 AND TEST IT FOR LEGALITY
/
/	ENTER ROUTINE WITH AC=PRIORITY
/	RETURN AT JMS+1 IF OK, OTHERWISE JMP TO CX206 TO DECLARE ERROR
/
/	THIS SUBROUTINE IS ALSO USED BY SYNC, RUN, AND SCHEDULE.
/
/	AC IS MODIFIED
/
RQ.PRI	0
	DAC	X12	/SAVE THE PRIORITY IN X12
	SPA		/IS IT GREATER THAN ZERO?
	JMP	CX206	/NO -- SET E.V. TO -206
	TAD	(-1001	/YES -- IS IT GREATER THAN 512 DECIMAL?
	SMA
	JMP	CX206	/NO -- SET E.V. TO -206
	JMP*	RQ.PRI	/YES -- RETURN WITH AC ALTERED
 .TITLE *** 'TASK SCHEDULE' DIRECTIVES
/
/ THREE DIRECTIVES -- 'SCHEDULE', 'RUN', & 'SYNC' PROVIDE A MEANS OF
/ SCHEDULING A TASK TO RUN AT SOME TIME IN THE FUTURE, AT AN INDICATED
/ PRIORITY, AND WITH PERIODIC RESCHEDULING.  THEY DIFFER ONLY IN THE
/ WAY THE INITIAL "SCHEDULE INTERVAL" IS SPECIFIED.  A ZERO PRIORITY
/ MEANS DEFAULT PRIORITY.  A ZERO "RE-SCHEDULE INTERVAL" MEANS NO
/ RE-SCHEDULING.
/
/ THESE SCHEDULE DIRECTIVES MAY ONLY BE ISSUED BY A TASK (@ API-7).
/
/ THESE DIRECTIVES CONSTRUCT A CLOCK QUEUE NODE TO MAKE THE INDICATED
/ TASK ACTIVE, AND INSERT IT IN THE CLOCK QUEUE TO COME DUE AT THE
/ APPROPRIATE TIME.
/
/ THE "SCHEDULE" DIRECTIVE ALLOWS THE "SCHEDULE INTERVAL" TO BE
/ SPECIFIED BY INDICATING THE "TIME-OF-DAY" AT WHICH THE TASK IS
/ TO BE RUN.  A TEN WORD CAL PARAMETER BLOCK OF THE FOLLOWING
/ FORMAT IS USED:
/
/	CPB	(0)  FUNCTION CODE (02)
/		(1)  EVENT VARIABLE ADDRESS
/		(2)  TASK NAME (FIRST HALF)
/		(3)  TASK NAME (SECOND HALF)
/		(4)  HOURS (SCHEDULE TIME)
/		(5)  MINUTES
/		(6)  SECONDS
/		(7)  RE-SCHEDULE INTERVAL
/		(10) INTERVAL UNITS
/		(11) PRIORITY
/
/ IF THE DIRECTIVE IS REJECTED, THE EVENT VARIABLE (IF SPECIFIED) IS
/ SET TO ONE OF THE FOLLOWING NEGATIVE VALUES TO INDICATE REJECTION
/ AND THE REASON:
/
/	-104  CONTROL TABLE ERROR
/	-201  TASK NOT IN SYSTEM
/	-203  DIRECTIVE NOT TASK ISSUED
/	-204  TASK IS DISABLED
/	-206  ILLEGAL TASK PRIORITY
/	-777  EMPTY POOL
/
/ IF THE DIRECTIVE IS ACCEPTED, IT IS EXECUTED AND THE EVENT VARIABLE
/ (IF SPECIFIED) IS SET TO POSITIVE ONE (+1).
/
SC.	LAW	-12	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	LAC	X11	/WAS CAL TASK ISSUED?
	SZA
	JMP	CX203	/NO -- SET EVENT VARIABLE TO -203
	PXA		/YES -- SET X11 TO FETCH  RESCHEDULE
	AAC	+6	/INTERVAL (FROM CPB).
	DAC	X11
	DAC	X16	/SET UP X16 TO CHECK INTERVAL UNITS
	JMS	SCHINT	/GO CHECK INTERVAL UNITS
	LAC	11,X	/SET X12 TO PRIORITY (FROM CPB)
	JMS	RQ.PRI	/PUT PRIORITY IN X12 AND CHECK IT FOR LEGALITY
	LAC	4,X	/COMPUTE SECONDS FROM MIDNITE IN WHICH
	JMS	MX60	/TO SCHEDULE.
	TAD	5,X
	JMS	MX60
	TAD	6,X
	DAC	SCHDS
/
	.RTL3		/RAISE TO API-3
/
	LAC	SSM	//DETERMINE DELTA SECONDS FROM NOW
	TCA		//
	TAD	SCHDS	//
	SPA!SNA		//POSITIVE NON-ZERO DELTA?
	TAD	(D86400)//NO -- SCHEDULE TOMORROW
			//YES -- SCHEDULE TODAY
	AAC	-1	//NORMALIZE 'CQIDS' & 'CQIDT' FOR NON-ZERO
	DAC	SCHDS	//DELTA-TICKS, AND ADJUST SCHEDULE-DELTA FOR
	LAC	TT	//ELAPSED TIME SINCE LAST SECOND BOUNDARY.
	TCA		//
	TAD	TPS	//
	DAC	SCHDT	//
	JMP	SCH	//TO COMMON CODE
/
/ THE "RUN" DIRECTIVE ALLOWS THE SCHEDULE INTERVAL TO BE SPECIFIED
/ AS A "TIME FROM NOW".  A NINE WORD CAL PARAMETER BLOCK OF THE FOLLOWING
/ FORMAT IS USED:
/
/	CPB	(0)  FUNCTION CODE (03)
/		(1)  EVENT VARIABLE ADDRESS
/		(2)  TASK NAME (FIRST HALF)
/		(3)  TASK NAME (SECOND HALF)
/		(4)  SCHEDULE DELTA TIME
/		(5)  SCHEDULE UNITS
/		(6)  RE-SCHEDULE INTERVAL
/		(7)  INTERVAL UNITS
/		(10) PRIORITY
/
/ IF THE DIRECTIVE IS REJECTED, THE EVENT VARIABLE (IF SPECIFIED) IS
/ SET TO ONE OF THE FOLLOWING NEGATIVE VALUES TO INDICATE REJECTION
/ AND THE REASON:
/
/	-104  CONTROL TABLE ERROR
/	-201  TASK NOT IN SYSTEM
/ 	-203  DIRECTIVE NOT TASK ISSUED
/	-204  TASK IS DISABLED
/	-206  ILLEGAL TASK PRIORITY
/	-777  EMPTY POOL
/
/ IF THE DIRECTIVE IS ACCEPTED, IT IS EXECUTED AND THE EVENT VARIABLE
/ (IF SPECIFIED) IS SET TO POSITIVE ONE (+1).
/
RN.	LAW	-11	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	LAC	X11	/WAS CAL TASK ISSUED?
	SZA
	JMP	CX203	/NO -- SET EVENT VARIABLE TO -203
	PXA		/YES -- SET 'X15' TO FETCH SCHEDULE DELTA
	AAC	+3	/AND 'X11' TO PO	NT T RESCHEFUE(INTERVAL
	DAC	X15
	DQc	\1&	/SET UP X16 TO CHECK INTERVAL UNITS
	AAC	+2
	DAC	X11
	JMS	SCHINT	/CHECK SCHEDULE UNITS
	JMS	SCHINT	/CHECK RE-SCHEDULE UNITS
	LAC	10,X	/SET PRIORITY (FROM CPB) IN X12
	JMS	RQ.PRI	/SET PRIORITY INTO X12 AND CHECK IT FOR LEGALITY
	JMS	CTP	/CONVERT TIME PARAMETER (SET 'SCHDS' & 'SCHDT'
			/PER SCHEDULE DELTA)
	SNA		/IF SCHEDULE DELTA IS ZERO, SCHEDULE AT
	ISZ	SCHDT	/NEXT TICK BOUNDARY.
	.RTL3		/RAISE TO API-3
	JMP	SCH	//TO COMMON CODE
/
/ THE "SYNC" DIRECTIVE ALLOWS THE SCHEDULE INTERVAL TO BE INDICATED
/ BY SPECIFYING A CLOCK INTERVAL (HOURS, MINUTES, SECONDS, OR TICKS)
/ ON WHICH TO SYNCHRONIZE, AND A TIME INTERVAL FROM CLOCK UNIT
/ SYNCHRONIZATION.  A TEN WORD CAL PARAMETER BLOCK OF THE FOLLOWING 
/ FORMAT IS USED:
/
/	CPB	(0)  FUNCTION CODE (14)
/		(1)  EVENT VARIABLE ADDRESS
/		(2)  TASK NAME (FIRST HALF)
/		(3)  TASK NAME (SECOND HALF)
/		(4)  SYNCHRONIZATION UNITS
/		(5)  SCHEDULE DELTA TIME
/		(6)  DELTA UNITS
/		(7)  RE-SCHEDULE INTERVAL
/		(10) INTERVAL UNITS
/		(11) PRIORITY
/
/ IF THE DIRECTIVE IS REJECTED, THE EVENT VARIABLE (IF SPECIFIED) IS
/ SET TO ONE OF THE FOLLOWING NEGATIVE VALUES TO INDICATE REJECTION
/ AND THE REASON:
/
/	-104  CONTROL TABLE ERROR
/	-201  TASK NOT IN SYSTEM
/	-203  DIRECTIVE NOT TASK ISSUED
/	-204  TASK IS DISABLED
/	-206  ILLEGAL TASK PRIORITY
/	-777  EMPTY POOL
/
/ IF THE DIRECTIVE IS ACCEPTED, IT IS EXECUTED AND THE EVENT VARIABLE
/ (IF SPECIFIED) IS SET TO POSITIVE ONE (+1).
/
SY.	LAW	-12	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	LAC	X11	/WAS CAL TASK ISSUED?
	SZA
	JMP	CX203	/NO -- SET EVENT VARIABLE TO -203
	PXA		/YES -- SET 'X15' TO POINT TO SCHEDULE DELTA
	AAC	+4	/AND 'X11' TO POINT TO RESCHEDULE DELTA (IN CPB).
	DAC	X15
	DAC	X16	/SET UP X16 TO CHECK INTERVAL UNITS
	AAC	+2
	DAC	X11
	JMS	SCHINT	/CHECK DELTA UNITS
	JMS	SCHINT	/CHECK RE-SCHEDULE UNITS
	LAC	11,X	/SET X1" TO PRIORITY (FROM CPB)
	JMS	RQ.PRI	/SET PRIORITY INTO X12 AND CHECK IT FOR LEGALITY
	JMS	CTP	/CONVERT TIME PARAMETER (SET 'SCHDS' & 'SCHDT'
			/PER SCHEDULE DELTA)
	LAC	4,X	/SETUP R1 TO POINT TO APPROPRIATE CLOCK PARAMETER
	TAD	(TT-2)
	DAC	R1
/
	DZM	R2	/SETUP R2 TO ACCUMULATE THE SCHEDULE DELTA IN TICKS
/
	LAC	4,X	/SETUP TO DISPATCH PER SYNC UNITS
	JMS	SCHIN1	/CHECK LEGALITY OF SYNC UNITS
	TAD	(JMP SY.D)
	DAC	SY.D
/
	.RTL3		/RAISE TO API-3
SY.D	XX		//DISPATCH PER SYNC UNITS
	JMP	SY.T	//
	JMP	SY.S	//
	JMP	SY.M	//
	JMP	SY.H	//
/
/ SYNC ON HOUR -- SET R2 TO SCHEDULE DELTA TICKS
/     TICKS = (59-MM)*TPS*60 + (59-SS)*TPS + (TPS-TT)
/
SY.H	JMS	SY.S1	//R2 = R2 + (59-MM)*TPS*60
	JMS	MX60	//
	JMS	SY.S2	//
/
/ SYNC ON MINUTE -- SET R2 TO SCHEDULE DELTA TICKS
/     TICKS = (59-SS)*TPS + (TPS-TT)
/
SY.M	JMS	SY.S1	//R2 = R2 + (59-SS)*TPS
	JMS	SY.S2	//
/
/ SYNC ON SECOND -- SET R2 TO SCHEDULE DELTA TICKS
/     TICKS = (TPS-TT)
/
SY.S	LAC*	R1	//R2 = R2 + (TPS-TT)
	TCA		//
	TAD	TPS	//
	TAD	R2	//
	DAC	R2	//
/
SY.T=.	/SYNC ON TICK -- LEAVE R2 (SCHED DELTA TICKS) ZERO
/
/ R2 CONTAINS THE NUMBER OF TICKS TILL THE INDICATED SYNCHRONIZATION
/ TIME.  'SCHDS' & 'SCHDT' CONTAIN THE SCHEDULE DELTA TIME FROM THE
/ SYNCHRONIZATION TIME.
/
	LAC	SCHDT	//COMBINE THE DELTA TO SYNCHRONIZATION WITH THE
	TAD	R2	//DELTA FROM SYNCHRONIZATION
	LMQ		//
	CLA!CLL		//
	DIV		//
TPX1	D60		//SET TO CLOCK FREQ. BY SCF
	DAC	SCHDT	//
	LACQ		//
	TAD	SCHDS	//
	DAC	SCHDS	//
/
	LAC	SCHDT	//ZERO DELTA TICKS?
	SZA		//
	JMP	SCH	//NO -- TO COMMON CODE
	LAC	TPS	//YES -- "NORMALIZE" DELTA TICKS & SECONDS
	DAC	SCHDT	//
	LAW	-1	//
	TAD	SCHDS	//
	DAC	SCHDS	//
/
	JMP	SCH	//TO COMMON CODE
/
SY.S1	0
	.DEC
	LAW	-59
	.OCT
	TAD*	R1
	TCA
	CLL
	MUL
TPX2	D60		/SET TO CLOCK FREQ. BY SCF
	LACQ
	JMP*	SY.S1
/
SY.S2	0
	TAD	R2
	DAC	R2
	LAW	-1
	TAD	R1
	DAC	R1
	JMP*	SY.S2
/
/ SUBROUTINE SCHINT -- CHECK THE SCHEDULE OR RE-SCHEDULE UNITS
/                      THEY MUST BE BETWEEN 1 AND 4.
/
/	ON ENTRY X16 POINTS ONE LOCATION BEFORE THE NUMBER OF UNITS
/	RETURN AT JMS+1 IF OK, OTHERWISE JMP TO CX104 TO DECLARE ERROR
/
/	THIS ROUTINE IS USED BY SYNC, RUN, AND SCHEDULE
/
/	AC AND X16 ARE MODIFIED
/
SCHINT	0
	LAC*	X16	/GET THE NUMBER OF UNITS
	SNA		/ARE THERE ANY?
	JMP	SCHINX	/NO -- RETURN AFTER INCREMENTING X16 (#204)
	LAC*	X16	/YES -- GET THE UNITS
	JMS	SCHIN1	/GO CHECK TO SEE IF BETWEEN 1 AND 4
	JMP*	SCHINT	/RETURN
SCHINX	LAC*	X16	/INCREMENT X16 (#204)
	JMP*	SCHINT	/RETURN (#204)
/
/ SUBROUTINE SCHIN1 -- CHECK THAT AC IS BETWEEN 1 AND 4
/
/	ENTER WITH UNITS IN AC
/	RETURN AT JMS+1 IF OK, OTHERWISE JMP TO CX104 TO DECLARE ERROR
/
/	NO REGISTERS ARE MODIFIED
/
SCHIN1	0
	SPA!SNA		/IS AC (UNITS) >0?
	JMP	CX104	/NO -- SET E.V. TO -104
	AAC	-5	/YES -- SUBTRACT 5 SO LEGAL VALUES GO NEGATIVE
	SMA		/IS IT NEGATIVE?
	JMP	CX104	/NO -- SET E.V. TO -104
	AAC	5	/YES -- RESTORE AC TO INITIAL VALUE
	JMP*	SCHIN1	/RETURN
/
/
/ COMMON CODE FOR 'SCHEDULE', 'RUN' & 'SYNC' DIRECTIVES
/ ENTER AT API-3 WITH SCHEDULE DELTA REPRESENTED IN
/ 'SCHDS' & 'SCHDT', PRIORITY (FROM CPB) IN X12, AND X11
/ SETUP TO FETCH RESCHEDULE INTERVAL (FROM CPB).
/
SCH	LAC	X11	//SET 'X15' TO POINT TO RESCHEDULE INTERVAL
	DAC	X15	//
	LAC	(STKL)	//SCAN STL FOR TASK NAME -- FOUND?
	DAC	R1	//
	LAC	X10	//
	AAC	+2	//
	DAC	R2	//
	JMS	SNAM	//(R1, R2, R6, X17, XR, & AC ARE ALTERED)
	JMP	SCH201	//NO -- SET EVENT VARIABLE TO -201
	DAC	X13	//YES -- SAVE STL NODE ADR IN X13
	PAX		//SETUP XR TO ACCESS STL NODE
	LAC	S.DP,X	//IS TASK DISABLED OR FLAGGED TO BE REMOVED ON EXIT?
	AND	(330000	//OR IN PARTITION TROUBLE?
	SZA		//SKIP ON NONE OF ABOVE
	JMP	RF.E10	//DBK AND SORT OUT WHICH ERROR
/
SCH0	LAC	X12	//WAS A PRIORITY SPECIFIED?		/(173)
	SZA		//
	JMP	SCH1	//YES -- USE SPECIFIED PRIORITY
	LAC	S.DP,X	//NO -- USE DEFAULT PRIORITY
	AND	(001777)//
	DAC	X12	//
/
SCH1	JMS	PENP	//PICK AN EMPTY NODE FROM POOL
			//(R1, R6, XR, & AC ARE ALTERED)
			//POOL EMPTY?
	JMP	SCH777	//YES -- SET EVENT VARIABLE TO -777
	PAX		//SETUP XR TO FILL NODE FOR CLOCK QUEUE
/
	DZM	C.TI,X	//SET TYPE INDICATOR FOR "NO RESCHEDULING"
	LAC	X12	//SET PRIORITY LEVEL
	DAC	C.PE,X	//
	LAC	X13	//SET STL NODE ADDRESS
	DAC	C.SP,X	//
	LAC	SCHDS	//SET SCHEDULE DELTA SECONDS (FOR 'CQI')
	DAC	CQIDS	//
	LAC	SCHDT	//SET SCHEDULE DELTA TICKS (FOR 'CQI')
	DAC	CQIDT	//
	LAC*	X11	//RESCHEDULING SPECIFIED?
	SNA		//
	JMP	SCH2	//NO -- CLOCK QUEUE NODE IS FILLED
	ISZ	C.TI,X	//YES -- CHANGE TYPE TO "RESCHEDULING"
	JMS	CTP	//DETERMINE AND SET RESCHEDULE SECONDS
	LAC	SCHDS	//AND RESCHEDULE TICKS
	DAC	C.RS,X	//
	LAC	SCHDT	//
	DAC	C.RT,X	//
/
SCH2	JMS	CQI	//INSERT NODE IN CLOCK QUEUE
/
	DBK		//DROP FROM API-3 TO API-4, SET
	JMP	CXSUC	//EVENT VARIABLE TO +1 AND EXIT
			/CAL SERVICE ROUTINE
/
/ ERROR RETURNS -- DROP TO API-4 AND SET EVENT VARIABLE NEGATIVE
/
SCH201	DBK		//
	JMP	CX201	//
/
SCH777	DBK		//
	ISZ	SE.AP	//
	NOP
	JMP	CX777
 .TITLE *** 'MARK TIME' DIRECTIVE
/
/ THE MARK DIRECTIVE INSTRUCTS THE SYSTEM TO CLEAR (ZERO) AN EVENT
/ VARIABLE AND THEN TO SET IT AND DECLARE A SIGNIFICANT EVENT
/ IN AN INDICATED TIME INTERVAL.  A FOUR WORD CAL PARAMETER BLOCK OF
/ THE FOLLOWING FORMAT IS USED:
/
/	CPB	(0) FUNCTION CODE (13)
/		(1) EVENT VARIABLE ADDRESS
/		(2) DELTA (MAGNITUDE)
/		(3) DELTA (UNITS)
/
/ IF THE DIRECTIVE IS REJECTED THE EVENT VARIABLE IS SET TO ONE OF
/ THE FOLLOWING NEGATIVE VALUES TO INDICATE REJECTION AND THE REASON:
/
/	-104 -- CONTROL TABLE ERROR
/	-203 -- REQUEST NOT TASK ISSUED
/	-777 -- REQUEST NOT ACCEPTED (OUT OF POOL)
/
/ IF THE DIRECTIVE IS ACCEPTED, THE EVENT VARIABLE IS CLEARED AND
/ A REQUEST TO SET IT IS PLACED IN THE CLOCK QUEUE TO COME DUE AT THE
/ APPROPRIATE TIME.
/
/ ENTRY FROM CAL DISPATCH -- XR & X10 CONTAIN CPB ADDRESS
/
MT.	LAW	-4	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO 17-BIT EVENT VARIABLE ADDRESS.
/
	LAC	X11	/WAS CAL TASK ISSUED?
	SZA
	JMP	CX203	/NO -- SET EVENT VARIABLE TO -203
	PXA		/SET UP TO CHECK LIMITS ON UNIT VALUE
	AAC	+1	/X16 POINTS TO TIME PAIR -1
	DAC	X16
	JMS	SCHINT	/RETURNS IF INTERVAL OK, ELSE ERRORS OUT
	JMS	PENP	/YES -- PICK AN EMPTY NODE FROM POOL
			/(R1, R6, XR & AC ARE ALTERED)
			/POOL EMPTY?
	JMP	CX777	/YES -- SET EVENT VARIABLE TO -777
	PAL	 	/SAVE IN LR FOR NODE FILL.		/(173)
/
	LAC	CURTSK	/"EXEC" OR "NORMAL" MODE REQUESTOR?
	PAX
	LAC	A.PB,X	/"NORMAL" -- INCREMENT TRANSFERS PENDING
	PAX		/COUNT (IN PARTITION BLOCK).
	ISZ	P.TP,X
	NOP
/
	PLX		/SETUP XR TO FILL NODE
	DAC C.SP,X	/ SET UP PARTITION BLOCK ADDRESS.	/(173)
/
	LAC	(+5)	/SET CLOCK NODE TYPE INDICATOR
	DAC	C.TI,X
/
	LAC	X14	/SET EVENT VARIABLE ADR (17 BIT) IN NODE, AND
	DAC	C.PE,X	/CLEAR EVENT VARIABLE.
	AAC	-1
	DAC	X14
	DZM*	X14
/
	LAC	X10	/DETERMINE DELTA-SECONDS & DELTA-TICKS
	IAC
	DAC	X15
	JMS	CTP
	SNA		/IF ZERO DELTA-TIME, SET MARK AT NEXT
	ISZ	SCHDT	/TICK BOUNDARY.
	.RTL3		/RAISE TO API-3
	LAC	SCHDS	//SET 'CQIDS' & 'CQIDT' FOR CLOCK QUEUE INSERTION
	DAC	CQIDS	//
	LAC	SCHDT	//
	DAC	CQIDT	//
/
	JMS	CQI	//INSERT NODE IN CLOCK QUEUE
/
	DBK		//DROP FROM API-3 TO API-4
/
	JMP	CALEXT	/EXIT CAL SERVICE ROUTINE
  .TITLE *** SUBROUTINES FOR CLOCK QUEUE ENTRY
/
/ MX60 -- NON-RE-ENTRANT SUBROUTINE TO MULTIPLY AC BY SIXTY (DECIMAL).
/
MX60	0
	CLL
	MUL
	.DEC
	60
	.OCT
	LACQ
	JMP*	MX60
/
/ CTP -- NON-RE-ENTRANT SUBROUTINE TO CONVERT TIME PARAMETERS.  'X15' POINTS
/ TO THE WORD PRECEDING A WORD-PAIR CONTAINING A DELTA TIME & DELTA UNITS.
/ THIS DELTA TIME IS CONVERTED INTO DELTA TICKS & DELTA SECONDS APPROPRIATE
/ FOR CLOCK QUEUE NODE TIME PARAMETERS (DELTA-TICKS IS NON-ZERO UNLESS
/ DELTA-TIME IS ZERO).  THE OUTPUT IS STORED IN 'SCHDS' & 'SCHDT'.  AC
/ CONTAINS 'SCHDT' UPON EXIT.
/
CTP	0
	LAC*	X15	/FETCH DELTA-TIME
	SZA		/ZERO?
	JMP	CTP1
	CLA		/YES -- SET 'SCHDS' & 'SCHDT' TO ZERO AND
	DAC	SCHDS	/EXIT WITH AC=SCHDT
	DAC	SCHDT
	JMP*	CTP
CTP1	DAC	SCHDT	/NO -- SAVE TEMP IN 'SCHDT'
	LAW	-1	/FETCH DELTA UNITS AND USE 'SCHDS' AS A  
	TAD*	X15	/COUNTER SET TO: -3 FOR HOURS, -2 FOR MINUTES,
			/OR -1 FOR SECONDS.
	SNA		/TICKS?
	JMP	CTP2	/YES -- CONVERT DELTA TIME INTO TICKS & SECONDS
	TCA		/NO -- CONVERT DELTA TIME INTO SECONDS
	DAC	SCHDS
	LAC	SCHDT
	JMP	.+2
	JMS	MX60
	ISZ	SCHDS
	JMP	.-2
	AAC	-1	/NORMALIZE FOR NON-ZERO DELTA TICKS
	DAC	SCHDS
	LAC	TPS
	DAC	SCHDT
	JMP*	CTP	/EXIT WITH AC=SCHDT
/
CTP2	LAC	SCHDT	/CONVERT DELTA TIME INTO TICKS & SECONDS
	LMQ
	CLA!CLL
	DIV
TPX3	D60		/SET TO CLOCK FREQ. BY SCF
	DAC	SCHDT
	LACQ
	DAC	SCHDS
	LAC	SCHDT	/ZERO DELTA-TICKS?
	SZA
	JMP*	CTP	/NO -- EXIT WITH AC=SCHDT
	LAW	-1	/YES "NORMALIZE" FOR NON-ZERO DELTA-TICKS
	TAD	SCHDS
	DAC	SCHDS
	LAC	TPS
	DAC	SCHDT
	JMP*	CTP	/EXIT WITH AC=SCHDT
/
SCHDS	0		/SCHEDULE DELTA SECONDS
SCHDT	0		/SCHEDULE DELTA TICKS
/
/ CQI -- CLOCK QUEUE INSERTION ROUTINE -- NON-RE-ENTRANT SUBROUTINE
/ CALLED @ API-3 BY THE SCHEDULE, RUN, SYNC, AND MARK DIRECTIVES,
/ AND BY THE CLOCK INTERRUPT SERVICE ROUTINE.  BEFORE CALLING,
/ R2 MUST BE SET TO THE ADDRESS OF THE NODE TO BE INSERTED,
/ AND 'CQIDS' & 'CQIDT' MUST BE SET TO THE TIME FROM NOW
/ THAT THE NODE IS TO "COME DUE".  'CQIDT' (DELTA TICKS) SPECIFIES
/ AN INTERVAL UP TO ONE SECOND, AND 'CQIDS' (DELTA SECONDS)
/ INDICATES ADDITIONAL WHOLE SECONDS.  ('CQIDT' IS NEVER ZERO.)
/
/ "DELTA" REFERS TO THE TIME FROM NOW A NODE IS TO COME DUE.
/ "SCHEDULE" REFERS TO THE INTERVAL OF A NODE UNDER EXAMINATION.
/
CQI	0
	LAC	(CKQ)	/SETUP XR TO SCAN CLOCK QUEUE FROM LISTHEAD
	PAX
/
CQINN	LAC	C.FP,X	/END OF (OR EMPTY) DEQUE?
	SAD	(CKQ)
	JMP	CQIAN	/YES -- INSERT NODE
	PAX		/NO -- EXAMINE DEQUE NODE
	LAC	CQIDS	/IS DELTA SECONDS LESS THAN SCHEDULE SECONDS?
	TAD	C.SS,X
	SPA
	JMP	CQIAS	/YES -- ADJUST SCHEDULE INTERVAL AND INSERT
			/NODE BEFORE NODE UNDER EXAMINATION.
	SZA		/NO -- IS DELTA SECONDS GREATER THAN SCHEDULE SECONDS?
	JMP	CQIAD	/YES -- ADJUST DELTA (SECS & TICKS) AND EXAMINE
			/NEXT NODE.
	LAC	CQIDT	/NO -- DELTA & SCHEDULE SECONDS ARE EQUAL, IS
	TAD	C.ST,X	/DELTA TICKS LESS THAN SCHEDULE TICKS?
	SPA
	JMP	CQIAS	/YES -- ADJUST SCHEDULE INTERVAL AND INSERT
			/NODE BEFORE NODE UNDER EXAMINATION.
	DAC	CQIDT	/NO -- ADJUST DELTA (SECS & TICKS) AND EXAMINE
	DZM	CQIDS	/NEXT NODE.
	JMP	CQINN
/
CQIAD	DAC	CQIDS	/ADJUST DELTA (SECS & TICKS) PER SCHEDULE
	LAC	CQIDT	/INTERVAL, KEEPING DELTA TICKS POSITIVE
	TAD	C.ST,X	/AND NON-ZERO, AND EXAMINE NEXT NODE.
	DAC	CQIDT
	SMA!SZA
	JMP	CQINN
	TAD	TPS
	DAC	CQIDT
	LAW	-1
	TAD	CQIDS
	DAC	CQIDS
	JMP	CQINN
/
CQIAS	LAC	C.SS,X	/NODE IS TO BE INSERTED BEFORE NODE
	TAD	CQIDS	/UNDER EXAMINATION.  ADJUST SCHEDULE
	DAC	C.SS,X	/INTERVAL PER DELTA (SECS & TICKS), KEEPING
	LAC	C.ST,X	/SCHEDULE TICKS POSITIVE AND NON-ZERO, AND
	TAD	CQIDT	/BACKUP XR TO POINT TO THE PREVIOUS
	DAC	C.ST,X	/NODE (OR THE LIST HEAD).
	SPA
	JMP	CQIPB
	TAD	CTPS
	DAC	C.ST,X
	ISZ	C.SS,X
	NOP
CQIPB	LAC	C.BP,X
	PAX
/
CQIAN	PXA		/SET SCHEDULE SECONDS AND TICKS, AND
	DAC	R1	/INSERT NODE WHOSE ADDRESS IS IN
	LAC	R2	/R2 FOLLOWING THE NODE (OR LIST HEAD)
	PAX		/WHOSE ADDRESS IS IN XR.
	LAC	CQIDS
	TCA
	DAC	C.SS,X
	LAC	CQIDT
	TCA
	DAC	C.ST,X
	JMS	NADD	/(R2, R6, XR, & AC ARE ALTERED)
/
	JMP*	CQI	/SUBROUTINE EXIT
/
CQIDS	0		/DELTA SECONDS
CQIDT	0		/DELTA TICKS
 .TITLE *** 'CANCEL' AND 'UNMARK' DIRECTIVES
/
/ THE CANCEL DIRECTIVE INSTRUCTS THE SYSTEM TO CANCEL ANY SCHEDULE
/ REQUESTS (CLOCK QUEUE ENTRIES MADE BY SCHEDULE, RUN, OR SYNC
/ FOR AN INDICATED TASK.  A FOUR WORD CAL PARAMETER BLOCK OF THE
/ FOLLOWING FORMAT IS USED:
/
/	CPB	(0) FUNCTION CODE (04)
/		(1) EVENT VARIABLE ADDRESS
/		(2) TASK NAME (FIRST HALF)
/		(3) TASK NAME (SECOND HALF)
/
/ IF THE INDICATED TASK DOESN'T EXIST IN THE SYSTEM AND AN EVENT VARIABLE
/ HAS BEEN SPECIFIED, IT IS SET TO -201 TO INDICATE REJECTION OF THE
/ DIRECTIVE.  IF THE TASK IS IN THE SYSTEM, ALL SCHEDULING (NOT MARK
/ TIME) NODES IN THE CLOCK QUEUE FOR THE TASK ARE NULLIFIED, AND
/ THE EVENT VARIABLE IS SET TO POSITIVE ONE (+1).
/
/ ENTRY FROM CAL DISPATCH -- XR & X10 CONTAIN CPB ADDRESS
/
CN.	LAW	-4	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	JMS	SSTL	/SCAN STL FOR TASK NAME -- FOUND?
			/NO -- SET E.V. TO -201 & EXIT CAL SERVICE 
	DAC	X13	/YES -- SAVE STL NODE ADDRESS IN X13.
	LAC	(NOP)	/TASK SCHEDULE INDICATOR.
	JMP	CU.C	/TO COMMON CODE.
/
/ THE UNMARK DIRECTIVE INSTRUCTS THE SYSTEM TO CANCEL ANY MARK TIME RE-
/ QUESTS FOR AN INDICATED TASK. A FOUR-WORD CAL PARAMETER BLOCK OF THE
/ FOLLOWING FORMAT IS USED:
/
/	CPB	(0) FUNCTION CODE (23)
/		(1) EVENT VARIABLE ADDRESS
/		(2) TASK NAME (FIRST HALF)
/		(3) TASK NAME (SECOND HALF)
/
/ IF THE INDICATED TASK DOESN'T EXIST IN THE SYSTEM AND AN EVENT VARIABLE
/ HAS BEEN SPECIFIED, IT IS SET TO -201 TO INDICATE REJECTION OF THE
/ DIRECTIVE. IF THE TASK IS IN THE SYSTEM, ALL MARK TIME (NOT SCHEDULING)
/ NODES IN THE CLOCK QUEUE FOR THE TASK ARE NULLIFIED, AND THE EVENT
/ VARIABLE IS SET TO ONE (+1).
/
/ ENTRY FROM CAL DISPATCH -- XR & X10 CONTAIN CPB ADDRESS.
/
UM.	LAW	-4	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14 TO
	JMS	CPBRX	/THE 17-BIT EVENT VARIABLE ADDRESS.
/
	JMS	SSTL	/SCAN STL FOR TASK NAME -- FOUND?
			/NO -- SET E.V. TO -201 & EXIT CAL SERVICE.
	PAX		/YES -- GET PARTITION BLOCK ADDRESS AND
	LAC	S.PB,X	/SAVE IN X13.
	DAC	X13
	LAC	(SKP)	/MARK TIME INDICATOR.
/
/ COMMON CODE FOR 'CANCEL' AND 'UNMARK'.
/
CU.C	DAC	R1	/SAVE MARK VS. SCHEDULE INDICATOR.
/
	LAC	X11	/RAISE TO API-3 IF DIRECTIVE WAS TASK ISSUED
	SZA
	JMP	CU.1
	.RTL3
/
CU.1	LAC	(CKQ)	/SETUP TO SCAN CLOCK QUEUE
	PAX
/
CU.2	LAC	C.FP,X	/END OF DEQUE?
	SAD	(CKQ)
	JMP	CU.4	/YES -- DONE
	PAX		/NO -- SETUP TO EXAMINE NODE.
	LAC	C.SP,X	/DO STL OR PBDL NODE ADDRESSES MATCH?
	SAD	X13
	SKP		/ YES -- NULLIFY THE CLOCK Q NODE.	/(175)
	JMP	CU.2	/NO -- EXAMINE NEXT NODE
/
	XCT R1		/ SHOULD WE NULLIFY A MARK TIME?	/(175)
	JMP CU.3	/ NO.					/(175)
	PXL		/ SAVE CLOCK Q INDEX REGISTER.		/(175)
	PAX		/ SET UP TO ACCESS PBDL NODE.		/(175)
	LAC P.TP,X	/ FETCH TRANSFER PENDING COUNT.		/(175)
	SZA		/ WATCH OUT FOR SPURIOUS COUNTS.	/(175)
	AAC -1		/ DECREMENT FOR THE MARK TIME.		/(175)
	DAC P.TP,X	/ UPDATE THE TRANSFER PENDING COUNT.	/(175)
	PLX		/ RESTORE XR TO CLOCK Q.		/(175)
CU.3	LAC (6)		/ NULLIFY NODE.				/(175)
	DAC C.TI,X						/(175)
	JMP	CU.2	/EXAMINE NEXT NODE
/
CU.4	LAC	X11	/DROP FROM API-3 TO API-4 IF DIRECTIVE WAS TASK ISSUED
	SNA
	DBK
/
	JMP	CXSUC	/SET EVENT VAR +1 AND EXIT CAL SERVICE ROUTINE
/
 .TITLE *** 'WAIT', 'WAITFOR' & 'SUSPEND' DIRECTIVES
/
/ THREE SYSTEM DIRECTIVES FACILITATE SUSPENDING EXECUTION (TO ALLOW
/ LOWER PRIORITY TASKS TO RUN) AND RESUMING AT SOME FUTURE TIME.
/
/ THE 'WAITFOR' DIRECTIVE RELEASES PRIORITY UNTIL AN EVENT VARIABLE
/ IS SET AND A SIGNIFICANT EVENT IS DECLARED.
/ THE 'WAIT' DIRECTIVE RELEASES PRIORITY UNTIL THE NEXT SIGNIFICANT EVENT.
/ THE 'SUSPEND' DIRECTIVE RELEASES PRIORITY UNTIL A 'RESUME' DIRECTIVE.
/
/ THE 'WAITFOR' DIRECTIVE HAS A TWO WORD CPB OF THE FOLLOWING FORMAT:
/
/	CPB	FUNCTION CODE (20)
/		EVENT VARIABLE ADDRESS
/
/ BOTH 'WAIT' & 'SUSPEND' HAVE SINGLE WORD CPB'S:
/ 
/ 	CAL (5)   /WAIT
/
/ 	CAL (6)   /SUSPEND
/
/ ENTRIES FROM CAL DISPATCH -- XR & X10 CONTAIN CPB ADDRESS
/
WF.	LAW	-2	/CHECK RANGE OF CPB (NORMAL MODE) AND SET
	JMS	CPBRX	/XR & X14 TO THE 17-BIT EVENT VARIABLE
	PAX		/ADDRESS.
/
	LAC	0,X	/EXAMINE EVENT VARIABLE
	SZA		/CLEARED?
	JMP	CALEXT	/YES -- RETURN TO REQUESTOR
	LAC	(3)	/NO -- SET STATUS TO THREE
	JMP	WSCC	/TO COMMON CODE WITH STATUS IN AC
/
WT.	LAC	(4)	/'WAIT' -- STATUS FOUR
	JMP	WSCC	/TO COMMON CODE WITH STATUS IN AC
/
SP.	LAC	(6)	/'SUSPEND' -- STATUS SIX
			/TO COMMON CODE WITH STATUS IN AC
/
WSCC	DAC	R1	/COMMON CODE -- SAVE STATUS IN R1.
	LAC	X11	/WAS CALL ISSUED FROM A TASK?
	SZA		/YES -- SUSPEND EXECUTION
	JMP	CALEXT	/NO -- IGNORE CAL
	.INH
	LAC	CURTSK	///SETUP XR TO ACCESS ATL NODE
	PAX		///
	LAC	R1	///SET STATUS WORD IN ATL NODE
	DAC	A.TS,X	///
	LAC	X14	///SET EVENT VARIABLE ADDRESS
	DAC	A.EV,X	///
	LAC	L20	///SET RESUMPTION ADDRESS IN ATL
	DAC	A.RA,X	///
	LAC	(L20)	///RESET 'L20' TO EFFECT CAL INDIRECT	/EAG:167
	DAC	L20	///
	LAC	(M0)	///SET API-6 TRANSFER VECTOR TO INDICATE
	DAC	L6TV	///NO TASK RUNNING (NO REG SAVE).
	LAC	A.PB,X	///SET XR TO ACCESS PBDL NODE
	PAX		///
	CLL!CLA		///CLEAR LINK SO OVERFLOWS ARE DETECTED AND
			///CLEAR AC BECAUSE CLOCK REG. IS OR'D INTO AC
	RDCLK		///READ XM CLOCK REGISTER
	TAD	P.C2,X	///ADD TICKS TO RECORDED TICKS
	DAC	P.C2,X	///SAVE RESULT
	SZL		///WAS THERE AN OVERFLOW?
	ISZ	P.C1,X	///YES -- RECORD IT
	NOP		///NO -- CONTINUE
	.ENB		///
	DBK		///DROP FROM API-4 TO API-7 (CAL WAS TASK ISSUED)
	JMP	M2	///RESUME ACTIVE TASK LIST SCAN.
/
 .TITLE *** 'RESUME' DIRECTIVE
/
/ THE RESUME DIRECTIVE INSTRUCTS THE SYSTEM TO RESUME EXECUTION OF
/ A SUPEND'ED TASK.  A FIVE WORD CAL PARAMETER BLOCK OF THE FOLLOWING
/ FORMAT IS USED:
/
/	CPB	(0) FUNCTION CODE (07)
/		(1) EVENT VARIABLE ADDRESS
/		(2) TASK NAME (FIRST HALF)
/		(3) TASK NAME (SECOND HALF)
/		(4) RESUMPTION ADDRESS (BITS 0-2 IGNORED)
/
/ IF THE 'RESUMPTION ADDRESS' IS ZERO, THE TASK IS RESUMED
/ AT THE WORD FOLLOWING THE 'SUSPEND' CAL.
/
/ IF THE 'RESUMPTION ADDRESS' IS NON-ZERO AND THE TASK TO BE RESUMED IS
/ A NORMAL MODE TASK, THE RESUMPTION ADDRESS IS ASSUMED TO BE RELATIVE
/ TO THE PARTITION BASE.
/
/ A NORMAL MODE TASK IS NOT ALLOWED TO REQUEST THAT ANOTHER TASK BE
/ RESUMED AT AN ADDRESS OTHER THAN THE ONE FOLLOWING THE 'SUSPEND'.
/
/ IF THE DIRECTIVE IS REJECTED, THE EVENT VARIABLE (IF SPECIFIED) IS
/ SET TO ONE OF THE FOLLOWING NEGATIVE VALUES TO INDICATE REJECTION
/ AND THE REASON:
/
/	-30	OUT-OF-PARTITION PARAMETER (NORMAL MODE)
/	-202	TASK NOT ACTIVE
/	-205	TASK NOT SUSPENDED
/
/ IF THE DIRECTIVE IS ACCEPTED, IT IS EXECUTED AND THE EVENT VARIABLE
/ (IF SPECIFIED) IS SET TO POSITIVE ONE (+1).
/
/ ENTRY WITH CPB ADDRESS IN XR & X10
/
RS.	LAW	-5	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	LAC	4,X	/SAVE RESUMPTION ADDRESS (OR ZERO) IN X11
	DAC	X11
	LAC	X10	/SCAN ACTIVE TASK LIST FOR TASK NAME -
	AAC	+2	/(R1, R2, R6, X17, XR, & AC ARE ALTERED)
	DAC	R2
	LAC	(ATKL)
	DAC	R1
	JMS	SNAM	/TASK NAME FOUND IN ATL?
	JMP	CX202	/NO -- SET EVENT VARIABLE TO -202
	PAX		/YES -- ATL NODE ADDRESS TO XR
/
	LAC	X11	/WAS A RESUMPTION ADDRESS SPECIFIED?
	SNA
	JMP	RS.1	/NO.
/
	LAC	L20	/YES -- WAS THE REQUEST ISSUED FROM A NORMAL
	RTL		/MODE TASK?
	SPA
	JMP	CX030	/YES -- SET E.V. TO -30.
/
	LAC	X11	/MASK OFF THE MODE BITS.
	AND	(77777)
	DAC	X11
	LAC	A.RA,X	/ADD MODE BITS IN FORCE AT THE TIME THE 'SUSPEND'
	AND	(700000)/DIRECTIVE WAS EXECUTED.
	XOR	X11
	DAC	X11
/
RS.1	LAC	(6)
	.INH		/IS TASK SUSPENDED (STATUS=6)?
	SAD	A.TS,X	///
	JMP	RS.2	///YES.
	.ENB		///NO -- SET EVENT VARIABLE TO -205
	JMP	CX205	///
RS.2	LAC	X11	///WAS A RESUMPTION ADDRESS SPECIFIED?
	SZA		///NO -- RESUME AT WORD FOLLOWING 'SUSPEND' CAL
	DAC	A.RA,X	///YES -- SET RESUMPTION ADDRESS
	LAC	(4)	///SET TASK STATUS TO FOUR (4)
	.ENB		///ENABLE INTERRUPTS.
	DAC	A.TS,X	///
	.SET6		/DECLARE A SIGNIFICANT EVENT
	JMP	CXSUC	/SET EVENT VARIABLE TO +1, AND
			/EXIT CAL SERVICE ROUTINE
 .TITLE *** 'EXIT' DIRECTIVE
/
/ THE 'EXIT' DIRECTIVE MAY ONLY BE ISSUED FROM A TASK.
/
/ TASK IS REMOVED FROM THE ACTIVE TASK LIST. IF IT IS A NORMAL MODE TASK
/ AND IF THE "TRANSFERS PENDING" COUNT IN ITS PARTITION BLOCK IS NON-ZERO,
/ PUT THE ATL NODE IN THE I/O RUNDOWN DEQUE AND TRIGGER THE I/O RUNDOWN
/ TASK "IORD". IF NO TRANSFERS ARE PENDING OR IF IT IS AN EXEC MODE TASK
/ (FOR WHICH NO CHECKS ARE MADE), THE TASK IS IMMEDIATELY FLAGGED INACTIVE
/ IN THE SYSTEM TASK LIST AND, IF THE TASK IS NOT FIXED IN CORE, THE
/ PARTITION IS FREED. THEN, IN EITHER CASE, A SIGNIFICANT EVENT IS DECLARED
/ TO CAUSE A SCAN OF THE ACTIVE TASK LIST FROM THE TOP.
/
/ THIS DIRECTIVE ALSO CAN BE USED TO STORE TASK TIMING DATA
/ REFER TO THE TASK TIMING ROUTINE'S DESCRIPTION FOR MORE INFO.
/
EX.	LAC	X11	/WAS CAL ISSUED FROM A TASK?
	SZA		/YES -- EXIT TASK
	JMP	CALEXT	/NO -- IGNORE CAL
/
	LAC	(L20)	/RESET L20 TO EFFECT CAL INDIRECT	/EAG:167
	DAC	L20
/
	LAC	CURTSK	/DELETE NODE FROM ACTIVE TASK LIST.
	DAC	R1	/('R1' POINTS TO ACTIVE TASK LIST NODE)	/(211)
	DAC R2		/ SAVE POINTER TO ACTIVE NODE.		/(211)
	LAC* R1		/ FETCH FORWARD POINTER.		/(211)
	DAC CURTSK	/ MOVE CURTSK TO NEXT ENTRY IN LIST.	/(211)
			/ TO AVOID THE RACE WITH THE TIME SLICER/(211)
	JMS NDEL	/ NO REGISTERS ARE ALTERED. REMOVE THE	/(211)
			/ EXITTED TASK'S ATL NODE FROM THE ATL.	/(211)
/
	LAC R2		/ FETCH OLD CURTSK VALUE FROM R2.	/(211)
	.IFDEF NOMAC						/(161)
	SAD	TDVCTF	/CURRENT TDV FUNCTION?
	JMP	EX.5	/YES -- TDV FLAG MIGHT NEED TO BE CLEARED.
	.ENDC							/(161)
EX.2	PAX		/NO.
	LAC	A.SN,X	/STL NODE ADR
	PAX
	PXL		/SAVE STL NODE ADR FOR EX.3
	LAC	S.DP,X	/SET THE 'DONE' BIT
	AND	(773777
	XOR	(004000
	DAC	S.DP,X
	.IFUND	NOXM
	LAC	TIMFLG	/IS TASK TIMING ON?
	SZA
	JMP	EX.T0	/YES -- GO DO IT!
	.ENDC
EX.CON	LAC	S.PB,X	/PARTITION BLOCK ADR			/(173)
	PAX
	LAC	P.UP,X	/WAS THE EXITTING TASK SHARING CORE?
	SNA
	JMP	EX.7	/NO -- PROCEED
	DAC	R1	/YES -- SAVE ADDR OF SHARED BLOCK'S TASK USE COUNT
	.INH		///INHIBIT INTERRUPTS
	LAC*	R1	///GET THE TASK USE COUNT OF SHARED BLOCK'S NODE
	AAC	-1	///DECREMENT IT
	.ENB		///ENABLE INTERRUPTS
	DAC*	R1	///RESET THE VALUE
EX.7	LAC	P.TP,X	/TRANSFERS PENDING COUNT
	SNA
	JMP	EX.3	/NONE
/
	LAC	(IORDQ)	/I/O RUNDOWN DEQUE LISTHEAD
	DAC	R1
/ R2 IS ALREADY SE UP WITH THE CORRECT VALUE FROM ABOVE.	/(211)
	JMS	SPRI	/(R1, R2, R3, R6, XR & AC ARE ALTERED)
/
	CLC		/SET "IORD'S" TRIGGER EVENT VARIABLE.
	DAC	IORDTG
	JMP	EX.4
/
EX.3=.								/(161)
	.IFUND NOMAC						/(161)
	LAC MA.UN	/ IS THE CURRENT TASK A MULTIACCESS JOB?/(161)
	SNA		/ AC >< 0 IF YES.			/(161)
	JMP EX.3A	/ NO, TAKE NORMAL EXIT PROCESS.		/(161)
	LAC R2		/ FETCH ATL NODE ADDRESS.		/(211)
	PAX		/ SET UP TO ACCESS ATL NODE		/(161)
	DZM T.EC,X	/ SET EXIT NODE CODE FOR MULTIACCESS.	/(161)
	LAC (TDV.EQ)	/ FETCH PROPER LIST ADDRESS.		/(161)
	JMP EX.3B	/ REJOIN COMMON CODE.			/(161)
EX.3A=.								/(161)
	.ENDC							/(161)
	LAC	(POOL)	/RETURN ATL NODE TO POOL
EX.3B	DAC R1		/ SET UP PROPER POOL ADDRESS.		/(161)
/ R2 CONTAINS THE CORRECT VALUE FOR NADD FROM ABOVE.		/(211)
	PLX		/ SET STL NODE ADDR INTO XR.		/(161)
	JMS FREEUP	/ SUBROUTINE, USED ALSO BY "IORD" TO	/(161)
			/ FREE PARTITION IF TASK NOT FIXED IN	/(161)
			/ CORE AND TO SET TASK INACTIVE IN STL	/(161)
			/ NODE (AC XR LR ARE ALTERED)		/(161)
	JMS	NADD	/(R2, R6, XR, & AC ARE ALTERED)
/
EX.4	JMP	M1	/DECLARE NO TASK CURRENT, DEBREAK OUT
			/OF CAL LEVEL (API-4), AND SCAN ACTIVE TASK LIST
			/FROM THE TOP.  (NO CAL EXIT)
	.IFDEF NOMAC						/(161)
EX.5	LAC	TDVTAC	/IS TDV DISPATCHER WAITING TO SEND ANOTHER
	SZA		/COMMAND LINE TO THIS SAME TDV TASK?
	JMP	EX.6	/YES.
	DZM	TDVCTF	/NO -- CLEAR 'CURRENT TDV FUNCTION'. THIS TASK FORGOT
	CLA!IAC		/TO EXECUTE THE 'XFRCMD' DIRECTIVE.
	DAC	TDVEV2	/SET 'LINE MOVED' EV.
EX.6	LAC	R2						/(211)
	JMP	EX.2
	.ENDC							/(161)
/
/ REENTRANT SUBROUTINE "FREEUP" -- COMMON TO "EXIT" DIRECTIVE AND TO
/ "IORD" I/O RUNDOWN TASK. FREE'S A TASK'S PARTITION IF TASK NOT FIXED
/ IN CORE AND SETS TASK INACTIVE IN ITS STL NODE.
/
/ LINKAGE:
/   XR -- STL NODE ADDRESS
/   JMS FREEUP
/
/ EXIT CONDITIONS:
/   RETURN AT JMS+1 UNCONDITIONALLY
/
/ REGISTERS ALTERED:
/   XR, AC & LR							/(161)
/
FREEUP	0
	.INH		/ INHIBIT INTERRUPTS.
	LAC S.PB,X	///FETCH PARTITION BLOCK ADDRDSS.	/(161)
	PAL		///SALT IT AWAY IN LIMIT REGISTER.	/(161)
	LAC	S.DP,X	///FLAG TASK INACTIVE IN STL NODE
	AND	(377777)///
	DAC	S.DP,X	///
	AND	(040000)///FIXED IN CORE?
	PLX		///SET UP XR FOR CLEARING LUN MAPPING.	/(161)
	SZA		///
	JMP	FREEEX	///YES -- DON'T FREE PARTITION
	LAC	P.TC,X	///
	AAC	-1	///
	DAC	P.TC,X	///
FREEEX	LAC P.FW,X	///FETCH FLAGS WORD FROM PBDL		/(161)
	AND (7)		///CLEAR LUN MAPPING AND USER NUMBER.	/(161)
	DAC P.FW,X	///STORE NEW FLAG WORD IN PBDL		/(161)
	.ENB		///ENABLE INTERRUPTS.			/(161)
	JMP*	FREEUP	///
	.TITLE *** TASK TIMING ROUTINE ***
/
/ THIS ROUTINE ALLOWS USERS TO TIME THE TASKS IN THEIR SYSTEM.  TO USE
/ THIS FEATURE THE USER MUST INITIALIZE THE DATA BUFFERS, THE TASK TIMING
/ CONTROL TABLE, AND SET LOCATION 312 (HEREAFTER REFERRED TO AS
/ TIMFLG) TO POINT AT THE FIRST WORD OF THE CONTROL TABLE.  THE CONTROL
/ TABLE MUST HAVE THE FOLLOWING FORMAT:
/
/	WORD	NAME	CONTENTS
/	0	EV	TASK TIMING EVENT VARIABLE (ZERO INITIALLY)
/	1	START1	POINTER TO 1ST WORD OF BUFFER 1
/	2	END1	POINTER TO LAST WORD IN BUFFER 1
/	3	START2	POINTER TO 1ST WORD OF BUFFER 2
/	4	END2	POINTER TO LAST WORD IN BUFFER 2
/	5	PTR	POINTER TO NEXT FREE BUFFER ENTRY (MUST BE
/			EQUAL TO START1 INITIALLY)
/
/ WHEN TIMFLG IS SET, A TASK EXITS, AND THERE IS SUFFICINT ROOM IN A BUFFER
/ EXIT WILL FILL THE APPROPRIATE BUFFER ENTY WITH THE FOLLOWING DATA:
/
/	WORD	DATA
/	6*N	TASK NAME FIRST HALF				/(214)
/	6*N+1	TASK NAME SECOND HALF				/(214)
/	6*N+2	XM CLOCK OVERFLOWS				/(214)
/	6*N+3	XM CLOCK TICKS ABOVE OVERFLOW COUNT		/(214)
/	6*N+4	I/O COUNT					/(214)
/	6*N+5	UIC						/(214)
/
/ EXIT WILL TYPICALLY SET THE EVENT VARIABLE TO +1 WHEN BUFFER 1 IS FULL
/ AND +2 WHEN BUFFER 2 IS FULL. HOWEVER, EXIT EXPECTS THAT WHEN THE USER-
/ WRITTEN BUFFER DUMPING TASK HAS WRITTEN THE BUFFER'S CONTENTS TO
/ A MASS STORAGE DEVICE, IT WILL INDICATE THAT THE BUFFER HAS BEEN EMPTIED
/ BY ZEROING THE EVENT VARIABLE.  IF EXIT DECIDES A BUFFER IS FULL AND
/ THE OTHER BUFFER HAS NOT BEEN EMPTIED, IT WILL SET THE EVENT VARIABLE TO
/ -1.  IF ANOTHER TASK EXITS BEFORE THE BUFFER DUMPING TASK CAN DUMP THE
/ BUFFERS AND ZERO THE EVENT VARIABLE, EXIT WILL DECREMENT THE NEGATIVE
/ EVENT VARIABLE VALUE.  NOTE THAT EACH TIME EXIT MAKES A BUFFER ENTRY
/ IT WILL INCREMENT PTR BY 4 AND CHECK TO SEE IF THE BUFFER IS FULL. IF THE
/ BUFFER HAS BEEN FILLED AND THE EVENT VARIABLE IS ZERO, EXIT WILL SET
/ THE EVENT VARIABLE ACCORDING TO WHICH BUFFER WAS FILLED AND MAKE PTR
/ POINT TO THE FIRST WORD OF THE OTHER BUFFER.
/
	.IFUND	NOXM
EX.T0	PAX			/SET UP XR TO ACCESS CONTROL TABLE
	LAC	0,X		/GET THE EV
	SMA			/ALREADY MINUS?
	JMP	EX.T1		/NO -- PROCEED
	AAC	-1		/YES -- DECREMENT IT AGAIN (DATA LOST)
	DAC	0,X
	JMP	EX.TQ		/LEAVE TASK TIMING
/
/  EDIT #156
/
/  ASSUME THAT THE POINTER IS OUR PROPERTY; THEN IT
/  IS ALREADY SET UP CORRECTLY
/
EX.T1	LAW	-1		/SET UP X12 TO PUSH DATA
	TAD	5,X		/POINTER
	DAC	X12
EX.T3	PLX			/ROOM -- SET XR UP TO ACCESS STL
	LAC	S.N1,X		/STORE 1ST HALF OF TASK NAME
	DAC*	X12
	LAC	S.N2,X		/STORE 2ND HALF OF TASK NAME
	DAC*	X12
	LAC	S.PB,X		/GET ADDR OF PBDL NODE
	PAX			/SET UP XR TO ACCESS PBDL NODE
	CLL!CLA			/CLEAR LINK SO OVERFLOWS ARE DETECTED AND
				/CLEAR AC BECAUSE CLOCK IS OR'D INTO AC
	RDCLK			/READ XM CLOCK
	TAD	P.C2,X		/ADD TICK COUNT
	DAC	P.C2,X		/SAVE RESULT
	SZL			/WAS THER AN OVERFLOW?
	ISZ	P.C1,X		/YES -- BUMP OVERFLOW COUNT
	NOP			/NO
	LAC	P.C1,X		/STORE THE OVERFLOW COUNT
	DAC*	X12
	LAC	P.C2,X		/STORE THE XM TICK COUNT
	DAC*	X12
	LAC	P.IO,X		/ STORE I/O COUNT		/(213)
	DAC*	X12						/(213)
	LAC	MA.UN		/ GET MULTIACCESS USER NUMBER	/(214)
	SNA!CLL							/(214)
	JMP	EX.T4		/ ZERO MEANS NOT MULTIACCESS	/(214)
				/ TASK; SET UFD=0		/(214)
	AAC	-1		/ MAKE IN RANGE 0 TO N-1	/(214)
	MUL;	UC.LEN		/ CALCULATE OFFSET TO CURRENT UCA /(214)
	LACQ							/(214)
	TAD	MA.UCA		/ ADD IN BASE OF UCA		/(214)
	AAC	UC.UFD		/ THEN THE INTERNAL OFFSET	/(214)
	PAX			/ NO XR ADJUST FOR PAGE 0	/(214)
	LAC	0,X		/ GET UIC			/(214)
EX.T4	DAC*	X12		/ AND STORE IN TIMING BUFFER	/(214)
	LAC	TIMFLG		/GET ADDR OF CONTROL TABLE
	PAX			/SET UP XR TO ACCESS CONTROL TABLE
	LAC	X12		/EFFECTIVELY INCREMENT THE PTR
	IAC
	DAC	5,X
/
	LAC	2,X		/IS BUFFER 1 FULL?
	CLL!CMA			/IT IS IF X12 0-5 FROM END	/(213)
	TAD	X12		/MAKE COMBINED TEST ON 0-5	/(213)
	AAC	6						/(213)
	SNL!SMA!CLL		/SKIP IF NOT 0-5 FROM END	/(213)
	JMP	EX.T7		/DECLARE #1 FULL (LINK=0 FLAG)
	LAC	4,X		/IS BUFFER 2 FULL?
	CLL!CMA			/SAME TEST SEQUENCE
	TAD	X12
	AAC	6						/(213)
	SZL!SPA			/XCPT SKIP ON FULL HERE
	JMP	EX.TQ		/NONE FILLED, JUST EXIT
	LAC	1,X		/#2 FULL, RESTART ON #1
	SKP!CLL!CML		/SET LINK TO SHOW #2 FILLED
EX.T7	LAC	3,X		/#1 FULL, RESTART ON #2
	DAC	5,X		/NEW POINTER
	LAC	0,X		/CHECK IF OTHER BUFFER AVAILABLE
	SZA!RAL			/SKIP IF YES TO SET UP 1 OR 2 EV
	SKP!CLA!CMA		/OTHER BUFFER NOT READY, SET EV TO -1
	IAC			/MAKES 1 OR 2 FOR EV AS REQUIRED
	DAC	0,X		/SET EV
EX.TQ	PLX			/EXIT CODE, REESTABLISH XR
	JMP	EX.CON		/REJOIN MAIN EXIT CODE
/
	.ENDC
 .TITLE *** 'UNFIX' DIRECTIVE
/
/ THE UNFIX DIRECTIVE INSTRUCTS THE SYSTEM TO NULLIFY A FIX DIRECTIVE.
/ I.E., TO FREE A PARTITION.  IF A FIXED TASK IS ACTIVE WHEN AN 
/ UNFIX DIRECTIVE IS ISSUED, THE PARTITION WILL BE FREED WHEN THE 
/ TASK EXITS.  A FOUR WORD CAL PARAMETER BLOCK OF THE FOLLOWING
/ FORMAT IS USED:
/
/	CPB	(0) FUNCTION CODE (16)
/		(1) EVENT VARIABLE ADDRESS
/		(2) TASK NAME (FIRST HALF)
/		(3) TASK NAME (SECOND HALF)
/
/ IF THE DIRECTIVE IS REJECTED, THE EVENT VARIABLE (IF SPECIFIED) IS
/ SET TO ONE OF THE FOLLOWING NEGATIVE VALUES TO INDICATE REJECTION
/ AND THE REASON:
/
/	  -201	TASK NOT IN SYSTEM
/	  -207	TASK NOT FIXED
/
/ IF THE DIRECTIVE IS ACCEPTED, IT IS EXECUTED AND THE EVENT VARIABLE
/ (IF SPECIFIED) IS SET TO POSITIVE ONE (+1).
/
/ ENTRY FROM CAL DISPATCH -- XR & X10 CONTAIN CPB ADDRESS
/
UF.	LAW	-4	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	JMS	SSTL	/SCAN STL FOR TASK NAME -- FOUND?
			/NO -- SET E.V. TO -201 & EXIT CAL SERVICE
	PAX		/YES -- SETUP XR TO ACCESS STL NODE
	.INH		///
	LAC	S.DP,X	///IS TASK FIXED-IN-CORE?
	AND	(737777)///
	SAD	S.DP,X	///
	JMP	UN.E1	///NO -- ERR 207
	DAC	S.DP,X	///YES -- CLEAR FIXED-IN-CORE INDICATOR
	SPA		///IS TASK ACTIVE?
	JMP	UN.1	///YES -- PARTITION WILL BE FREED UPON EXIT
	LAC	S.PB,X	///NO -- FREE PARTITION
	PAX		///
	LAC	P.TC,X	///
	AAC	-1	///
	DAC	P.TC,X	///
UN.1	.ENB		///SUCCESSFUL COMPLETION SET EVENT
	JMP	CXSUC	///VARIABLE TO +1 AND EXIT CAL
			/  SERVICE ROUTINE.
/
UN.E1	.ENB		///
	JMP	CX207	///
 .TITLE *** 'DISABLE' & 'ENABLE' DIRECTIVES
/
/ THE DISABLE DIRECTIVE INSTRUCTS THE SYSTEM TO REJECT FURTHER
/ REQUEST, SCHEDULE, RUN, SYNC, OR FIX DIRECTIVES FOR AN INDICATED
/ TASK.
/ THE ENABLE DIRECTIVE INSTRUCTS THE SYSTEM TO NULLIFY A
/ DISABLE DIRECTIVE.
/ REDUNDANT DISABLE OR ENABLE DIRECTIVES HAVE NO EFFECT.  A FOUR
/ WORD CAL PARAMETER BLOCK OF THE FOLLOWING FORMAT IS USED:
/
/	CPB	(0) CAL FUNCTION CODE (21) FOR DISABLE (22) FOR ENABLE
/		(1) EVENT VARIABLE ADDRESS
/		(2) TASK NAME (FIRST HALF)
/		(3) TASK NAME (SECOND HALF)
/
/ IF THE INDICATED TASK DOES NOT EXIST IN THE SYSTEM, THE
/ EVENT VARIABLE, IF SPECIFIED, IS SET TO -201; OTHERWISE,
/ THE DIRECTIVE IS EXECUTED AND THE EVENT VARIABLE (IF SPECIFIED)
/ IS SET TO POSITIVE ONE (+1).
/
/ CONTROL IS TRANSFERRED TO 'EA.' OR 'DA.' BY THE CAL DISPATCH ROUTINE
/ WITH THE CPB ADDRESS IN XR & X10.
/
EA.	CLA!SKP		/ENABLE -- SETUP TO CLEAR BIT-2 OF STL NODE FLAGS WORD
DA.	LAC	(100000)/DISABLE -- SETUP TO SET BIT-2 OF STL NODE FLAGS WORD
/
	DAC	X11	/SAVE BIT-2 XOR WORD IN X11
/
	LAW	-4	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	JMS	SSTL	/SCAN STL FOR TASK NAME -- FOUND?
			/NO -- SET E.V. TO -201 & EXIT CAL SERVICE
	PAX		/YES -- SETUP XR TO ACCESS STL NODE
	LAC	X11	/SET UP DISABLE BIT IN LINK FOR LATER
	RAL
	RTL
	.INH		///
	LAC	S.DP,X	///
	AND	(677777)///
	XOR	X11	///
	.ENB		///
	DAC	S.DP,X	///
/
/	DESIGN DECISION, ON ENABLE, IF TASK IS STILL SUFFEREING
/	FROM A PARTITION TROUBLE, SEND EVENT VARIABLE 212,213
/	SO ENABLER DOES NOT THINK TASK CAN RUN!!
/
	AND	(30000	/TWO BITS PARTITION GONE, AND RECONF. IN PROGRESS
	SNA!SPA!SZL	/TOUGH!SKIPS WHEN PARTITION TROUBLE AND ENABLE
	JMP	CXSUC	/NONE OR ONE OF ABOVE, OK!
	JMP	RF.E1	/BOTH, NOT OK, ERROR EV.
 .TITLE *** 'CONNECT' & 'DISCONNECT' DIRECTIVES
/
/ THE CONNECT DIRECTIVE INSTRUCTS THE SYSTEM TO TRANSFER CONTROL
/ TO AN INDICATED LOCATION WHENEVER AN INTERRUPT OCCURS ON AN INDICATED
/ LINE.  A FOUR WORD CAL PARAMETER BLOCK OF THE FOLLOWING FORMAT IS
/ USED:
/
/	CPB	(0) FUNCTION CODE (11)
/		(1) EVENT VARIABLE ADDRESS
/		(2) INTERRUPT LINE NUMBER
/		(3) INTERRUPT TRANSFER ADDRESS
/
/ IF THE DIRECTIVE IS REJECTED, THE EVENT VARIABLE (IF SPECIFIED) IS
/ SET TO ONE OF THE FOLLOWING NEGATIVE VALUES TO INDICATE REJECTION
/ AND THE REASON:
/
/	-26	ILLEGAL FUNCTION FOR A NORMAL MODE TASK
/	-301	LINE NUMBER REJECTED
/	-302	LINE ALREADY CONNECTED
/
/ IF THE DIRECTIVE IS ACCEPTED, IT IS EXECUTED AND THE EVENT VARIABLE
/ (IF SPECIFIED) IS SET TO POSITIVE ONE (+1).
/
/ ENTER WITH CPB ADDRESS IN XR & X10
/
CI.	LAW	-4	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
	LAC	(EMGINT)/OLD CONNECT (R1) SHOULD BE 'EMGINT'
	DAC	R1
	LAC	3,X	/NEW CONNECT (R2) SHOULD BE CPB WD 3
	DAC	R2
	JMP	DI.C	/TO COMMON CODE
/
/ THE DISCONNECT DIRECTIVE INSTRUCTS THE SYSTEM THAT CONTROL IS
/ NO LONGER TO BE TRANSFERRED TO AN INDICATED LOCATION WHEN AN 
/ INTERRUPT OCCURS ON AN INDICATED LINE.  A FOUR WORD CAL
/ PARAMETER BLOCK OF THE FOLLOWING FORMAT IS USED:
/
/	CPB	(0) FUNCTION CODE (12)
/		(1) EVENT VARIABLE ADDRESS
/		(2) INTERRUPT LINE NUMBER
/		(3) PRESENT INTERRUPT TRANSFER ADDRESS
/
/ IF THE DIRECTIVE IS REJECTED, THE EVENT VARIABLE (IF SPECIFIED) IS
/ SET TO ONE OF THE FOLLOWING NEGATIVE VALUES TO INDICATE REJECTION
/ AND THE REASON:
/
/	-26	ILLEGAL FUNCTION FOR A NORMAL MODE TASK
/	-301	LINE NUMBER REJECTED
/	-302	LINE NOT CONNECTED AS INDICATED
/
/ IF THE DIRECTIVE IS ACCEPTED, IT IS EXECUTED AND THE EVENT VARIABLE
/ (IF SPECIFIED) IS SET TO POSITIVE ONE (+1).
/
/ ENTRY WITH CPB ADDRESS IN XR & X10
/
DI.	LAW	-4	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	LAC	3,X	/OLD CONNECT (R1) SHOULD BE CPB WD 3
	DAC	R1
	LAC	(EMGINT)/NEW CONNECT (R2) SHOULD BE 'EMGINT'
	DAC	R2
/
/ COMMON CODE FOR 'CONNECT' & 'DISCONNECT'
/
DI.C	LAC	X11	/WAS CAL TASK ISSUED?
	SZA
	JMP	DI.CL	/NO -- MUST BE EXEC MODE.
	LAC	CURTSK	/YES -- CHECK RESTART ADDRESS TO SEE IF IT'S
	PAX		/NORMAL MODE.
	LAC	A.RA,X
	RTL
	SPA
	JMP	CX026	/YES -- SET EV TO -26.
	LAC	X10	/NO -- RESTORE CPB POINTER IN XR.
	PAX
DI.CL	LAW	-4	/IS LINE NUMBER < 04 ?
	TAD	2,X
	SPA
	JMP	CX301	/YES -- ERR 301
	LAW	ITVTB-ETVTB /NO -- IS LINE NUMBER TOO LARGE?
	TAD	2,X
	SMA
	JMP	CX301	/YES -- ERR 301
	LAC	2,X
	SAD	(40)	/NO -- CONSOLE TTY PRINTER?
	JMP	CX301	/YES -- ERR 301
	SAD	(41)	/NO -- CONSOLE TTY KEYBOARD?
	JMP	CX301	/YES -- ERR 301
	SAD	(11)	/NO -- CLOCK OVERFLOW?
	JMP	CX301	/YES -- ERR 301
	SAD	(7)	/RK DISK?
	JMP	CX301	/YES -- ERR 301
	SAD	(23)	/NO, RF DISK?
	JMP	CX301	/YES -- ERR 301
	SAD	(24)	/NO, RP DISK?
	JMP	CX301	/YES -- ERR 301
	SAD	(34)	/NO -- LT19 PRINTERS LINE?
	JMP	CX301	/YES -- ERR 301
	SAD	(35)	/NO -- LT19 KEYBOARDS LINE?
	JMP	CX301	/YES -- ERR 301
	TAD	(ITVTB)	/NO -- SET R3 TO THE TRANSFER VECTOR ADDRESS
	DAC	R3
/
	.INH		/IS OLD CONNECT OKAY?
	LAC	R1	///
	SAD*	R3	///
	JMP	DT.C1	///
	.ENB		/NO -- SET EVENT VARIABLE TO -302
	JMP	CX302	/AND EXIT CAL SERVICE ROUTINE
/
DT.C1	LAC	R2	/YES -- SET NEW CONNECT, SET EVENT
	DAC*	R3	/VARIABLE TO +1, AND EXIT CAL
	.ENB		/SERVICE ROUTINE
	JMP	CXSUC
 .TITLE *** 'DATE & TIME INFORMATION' DIRECTIVE
/
/ THE DATE & TIME DIRECTIVE INSTRUCTS THE SYSTEM TO RETURN THE
/ THE CURRENT TIME & DATE.  AN EIGHT WORD CAL PARAMETER BLOCK
/ OF THE FOLLOWING FORMAT IS USED:
/
/	CPB	(0) FUNCTION CODE (24)
/		(1) EVENT VARIABLE ADDRESS
/		(2) MONTH BUFFER
/		(3) DAY BUFFER
/		(4) YEAR BUFFER
/		(5) HOURS BUFFER
/		(6) MINUTES BUFFER
/		(7) SECONDS BUFFER
/
/ THE EVENT VARIABLE (IF SPECIFIED) IS SET TO ONE (+1) AND
/ THE TIME AND DATE ARE SET IN THE THIRD THRU EIGHTH CPB WORDS.
/
DT.	LAW	-10	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	LAC	MO	/SET DATE & TIME IN CPB
	DAC	2,X
	LAC	DA
	DAC	3,X
	LAC	YR
	DAC	4,X
	LAC	HH
	DAC	5,X
	LAC	MM
	DAC	6,X
	LAC	SS
	DAC	7,X
/
	JMP	CXSUC	/SET EVENT VARIABLE TO ONE (+1) AND EXIT
			/CAL SERVICE ROUTINE.
 .TITLE *** 'TASK NAME INFORMATION' DIRECTIVE
/
/ THE TASK NAME DIRECTIVE INSTRUCTS THE SYSTEM TO RETURN THE NAME
/ OF THE ISSUING TASK.  A FOUR WORD CAL PARAMETER BLOCK OF THE
/ FOLLOWING FORMAT IS USED:
/
/	CPB	(0) FUNCTION CODE (25)
/		(1) EVENT VARIABLE ADDRESS
/		(2) TASK NAME BUFFER (FIRST HALF)
/		(3) TASK NAME BUFFER (SECOND HALF)
/
/ IF THE DIRECTIVE IS ISSUED FROM AN INTERRUPT SERVICE ROUTINE,
/ THE TASK NAME IS NOT AVAILABLE AND THE EVENT VARIABLE (IF
/ SPECIFIED) IS SET TO -203.  IF THE DIRECTIVE IS ISSUED FROM
/ A TASK, THE EVENT VARIABLE (IF SPECIFIED) IS SET AS SHOWN BELOW
/ AND THE TASK NAME IS SET IN CPB WORDS THREE & FOUR.
/
/ EVENT VARIABLE SETTINGS FOR SUCCESSFUL COMPLETION:
/
/	BIT 0 -- ZERO
/	BIT 1 -- SET IF FPP REQUIRED TO RUN TASK
/	BIT 2 -- SET IF TASK RUNS IN BANK MODE
/	BIT 3 -- SET IF TASK RUNS IN NORMAL MODE
/	BIT 4 -- ZERO (RESERVED FOR RELOCATE DISABLE)
/	BITS 5+6 -- SET IF TASK IS NORMAL MODE AND RUNS IN XVM MODE
/	            (ZERO IF TASK IS EXEC MODE)
/	BIT 7 -- SET IF TASK IS NORMAL MODE AND HAS IOT PERMISSION
/	         (ZERO IF TASK IS EXEC MODE)
/	BITS 8-17 -- TASK PRIORITY
/
TN.	LAW	-4	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO 17-BIT EVENT VARIABLE ADDRESS.
/
	LAC	X11	/WAS CAL TASK ISSUED?
	SZA
	JMP	CX203	/NO -- SET EVENT VARIABLE TO -203
	LAC	CURTSK	/YES -- SET NAME IN CPB
	AAC	+A.N1-1
	DAC	X12
	LAC*	X12
	DAC	2,X
	LAC*	X12
	DAC	3,X
/
	LAC	CURTSK	/GET THE ADDR OF TASK'S ATL NODE
	PAX		/SET UP XR TO ACCESS NODE
	LAC	A.SN,X	/GET ADDR OF STL NODE
	PAX		/SET UP TO ACCESS STL NODE
	LAC	S.DP,X	/GET PRIORITY AND OTHER DATA
	AND	(1777	/AND OFF OTHER DATA
	LMQ		/SAVE TASK PRIORITY IN MQ
	LAC	S.EP,X	/GET FLAGS AND START ADDR
	AND	(700000	/KEEP ONLY THE FLAGS
	CLL!RAR		/POSITION THE FLAGS
	OAC		/OR AC AND MQ AND PUT RESULT INTO MQ
	AND	(040000	/IS TASK NORMAL MODE?
	SNA
	JMP	TN.1	/NO -- IT'S EXEC MODE
	LAC	S.TS,X	/YES -- OBTAIN TASK SIZE AND MM DATA
	AND	(000360	/KEEP MM DATA
	ALS	6	/SHIFT INTO POSITION
TN.1	OMQ		/CONSTRUCT FINAL EV
/
	JMP	CXDAC	/SET EVENT VARIABLE AND EXIT
			/CAL SERVICE ROUTINE
 .TITLE *** 'PARTITION INFORMATION' DIRECTIVE
/
/ THE PARTITION INFORMATION DIRECTIVE INSTRUCTS THE SYSTEM TO
/ RETURN THE BASE ADDRESS AND PARTITION SIZE AS 17-BIT ABSOLUTE
/ ADDRESSES.
/
/ A FIVE WORD CPB OF THE FOLLOWING FORMAT IS USED:
/
/	CPB	(0) FUNCTION CODE (26)
/		(1) EVENT VARIABLE ADDRESS
/		(2) PARTITION NAME (FIRST HALF)
/		(3) PARTITION NAME (SECOND HALF)
/		(4) ADDRESS OF DOUBLE WORD AT WHICH TO RETURN BASE & SIZE
/
/ IF A PARTITION NAME IS NOT SPECIFIED (ZERO CPB WD 2), THE REQUESTOR'S
/ PARTITION NAME IS SET IN THE CPB.
/
/ IF AN EVENT VARIABLE IS SPECIFIED, IT IS SET AS FOLLOWS:
/
/     +1 -- DEFINITION RETURNED
/   -203 -- CAL NOT TASK-ISSUED
/   -211 -- NAMED PARTITION NOT IN SYSTEM
/
/ ENTER FROM CAL DISPATCH WITH CPB ADDRESS IN XR & X10
/
PI.	LAW	-5	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	LAC	X11	/WAS CAL TASK-ISSUED?
	SZA
	JMP	CX203	/NO -- SET EVENT VARIABLE TO -203.
/
	LAC	4,X	/CHECK BASE & SIZE BUFFER ADDRESSES, ADJUST
	PAL		/TO 17-BIT ADDRESSES, AND SETUP X15 TO STORE
	JMS	CACAJ	/THEM.
	AAC	-1
	DAC	X15
	PLA
	IAC
	JMS	CACAJ
/
	LAC	2,X	/WAS A PARTITION NAME SPECIFIED?
	SNA
	JMP	PI.2	/NO -- REQUESTOR'S PARTITION NAME IS IMPLIED
	LAC	(PBDL)	/YES -- SCAN PBDL FOR NAME MATCH
	DAC	R1
	PXA
	AAC	+2
	DAC	R2
	JMS	SNAM	/(R1, R2, R6, X17, XR, & AC ARE ALTERED)
			/PARTITION NAME MATCH FOUND?
	JMP	CX211	/NO -- SET REQUESTOR'S EVENT VARIABLE TO -211
	PAX		/YES -- RETURN PARTITION BASE & SIZE (VIA COMMON 
	JMP	PI.3	/WITH PBDL NODE ADDRESS IN XR).
/
PI.2	LAC	X10	/PARTITION NAME NOT SPECIFIED -- FETCH NAME
	IAC		/FROM PARTITION BLOCK AND SET IN CPB AND TRANSFER 
	DAC	X13	/TO COMMON CODE WITH PBDL NODE ADDRESS IN XR.
	LAC	CURTSK
	PAX
	LAC	A.PB,X
	PAX
	LAC	P.N1,X
	DAC*	X13
	LAC	P.N2,X
	DAC*	X13
/
PI.3	LAC	P.BA,X	/COMMON CODE TO RETURN PARTITION BASE & SIZE
	DAC*	X15	/(XR CONTAINS THE PBDL NODE ADDRESS).
	LAC	P.SZ,X
	DAC*	X15
	JMP	CXSUC	/SET EV TO +1 AND EXIT CAL SERVICE
 .TITLE *** 'SETJEA' DIRECTIVE
/
/ THIS DIRECTIVE INSTRUCTS THE SYSTEM TO SET UP THE JEA (JMS EXIT ADDRESS)
/ REGISTER IN THE FLOATING POINT HARDWARE AND TO SAVE THE ADDRESS IN
/ THE TASK'S PARTITION BLOCK NODE. THE JEA REGISTER,
/ CAN BE ALTERED IF THE TASK GIVES UP CONTROL VIA A 'CAL' (SUCH AS
/ WAITFOR). HOWEVER, ONE EXPECTS TO SET UP THE JEA ONLY ONCE; CONSE-
/ QUENTLY, 'SETJEA' IS A POSITIVE WAY TO SAVE THE JEA'S VALUE. THIS
/ DIRECTIVE IS USED BY THE FORTRAN OTS FLOATING POINT ERROR SUBROUTINE.
/ A THREE WORD CAL PARAMETER BLOCK (CPB) OF THE FOLLOWING FORMAT IS USED.
/
/	CPB	(0) FUNCTION CODE (17)
/		(1) EVENT VARIABLE ADDRESS
/		(2) JEA ADDRESS
/
/ IF THE DIRECTIVE IS REJECTED, THE EVENT VARIABLE (IF SPECIFIED) IS SET
/ TO ONE OF THE FOLLOWING NEGATIVE VALUES TO INDICATE THE REASON FOR
/ REJECTION:
/
/	-1	NO FP15 HARDWARE ON THIS MACHINE
/	-30	JEA ADDRESS OUTSIDE OF TASK PARTITION
/	-203	CAL NOT TASK-ISSUED
/
/ IF THE DIRECTIVE IS ACCEPTED, IT IS EXECUTED AND THE EVENT VARIABLE
/ (IF SPECIFIED) IS SET TO ONE (+1).
/
/ ENTRY FROM CAL DISPATCH WITH THE CPB ADDRESS IN XR & X10.
/
SJ.	LAW	-3	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO 17-BIT EVENT VARIABLE ADDRESS.
/
	LAC	X11	/WAS CAL TASK-ISSUED?
	SZA
	JMP	CX203	/NO -- SET EVENT VARIABLE TO -203.
/
	XCT	FPHDWE	/SKIP IF FP HARDWARE EXISTS.
	JMP	CX001	/NO -- SET EVENT VARIABLE TO -1.
/
	LAC	2,X	/SAVE UNRELOCATED JEA ADDRESS.
	DAC	R3
	LAC	CURTSK	/ATL NODE ADDRESS.
	PAX
	LAC	A.RA,X	/EXAMINE THE RESTART ADDRESS TO SEE IF THIS IS
	RTL		/AN EXEC MODE TASK.
	SMA
	JMP	SJ.1	/YES.
	LAC	A.PB,X	/NO -- PARTITION BLOCK ADDRESS.
	PAX
	LAC	R3	/UNRELOCATED JEA ADDRESS.
	TCA
	TAD	P.TS,X	/TASK SIZE.
	SPA
	JMP	CX030	/ERROR -- ADDRESS EXCEEDS TASK LIMITS.
	JMP	SJ.2
/
SJ.1	LAC	A.PB,X	/PARTITION BLOCK ADDRESS.
	PAX
SJ.2	LAC	R3
	DAC	P.JE,X	/SAVE JEA ADDRESS IN PARTITION BLOCK NODE.
	DAC	R1
	LJE		/LOAD THE JEA REGISTER.
	R1
	JMP	CXSUC	/EXIT CAL SERVICE ROUTINE.
  .TITLE *** 'RAISE BOUND' DIRECTIVE
/
/ THE RAISE BOUND DIRECTIVE INSTRUCTS THE SYSTEM TO RAISE THE
/ MEMORY PROTECT BOUND (IF NORMAL MODE) AS FAR AS POSSIBLE
/ (EITHER TO PARTITION TOP, OR BELOW THE LOWEST I/O
/ BUFFER), AND TO RETURN THE HIGHEST USABLE ADDRESS IN THE
/ REQUESTOR'S EVENT VARIABLE.  (IF IN NORMAL MODE, THE ADDRESS
/ RETURNED IS RELATIVE TO THE PARTITION BASE.)
/
/ A TWO WORD CPB OF THE FOLLOWING FORMAT IS USED:
/
/	CPB	(0)  FUNCTION CODE (27)
/		(1)  EVENT VARIABLE ADDRESS
/
/ IF AN EVENT VARIABLE IS SPECIFIED, IT IS SET AS FOLLOWS:
/
/	+N -- THE HIGHEST USABLE TASK ADDRESS (RELATIVE
/	      TO THE PARTITION BASE, IF NORMAL MODE)
/	-203 -- CAL NOT TASK-ISSUED
/
/ ENTRY FROM CAL DISPATCH WITH CPB ADDRESS IN XR & X10
/
RB.	LAW	-2	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	LAC	X11	/SET REQUESTOR'S EVENT VARIABLE TO -203
	SZA		/IF CAL WAS NOT TASK ISSUED.
	JMP	CX203
/
	LAC	CURTSK	/SET XR TO ADDRESS OF CURRENT TASK'S ATL NODE.
	PAX
/
/  START OF EDIT #157
/
	LAC	A.PB,X	/ADDRESS OF PARTITION BLOCK NODE
	PAL		/SAVE FOR LATER USE
	LAC	A.RA,X	/SET LINK FROM RESUMPTION ADDRESS TO INDICATE
	RTL		/EXEC OR NORMAL MODE TASK
	SMA!CLL!CLA!CMA	/SKIP IF NORMAL;CLEAR LLINK TO SHOW EXEC.
	JMP	RB.EX	/-1 SO AND,DAC WORKS LIKE LAC,DAC
	LAC	A.SN,X	/GET POINTER TO SYSTEM TASK SIZE
	PAX
	LAC	S.TS,X	/WHICH CONTAINS XVM FLAG IN LOW BITS
	AND	(140	/XVM BITS
	SZA!CLL!CML	/SKIP IF NOT XVM, LINK=1 FOR XVM JMP
	JMP	RB.XV	/XVM JUST AND OFF LOW BITS VIRT. ADDR.
	PLX		/XR POINT TO PARTITION BLOCK NODE
	LAC	(700000	/NON-XVM, LIMIT RAISE BOUND TO 32K!!!!
	TAD	P.VS,X	/CARRIES LINK TO 0 IF >=32K
	LAC	(100000	/32K DEFAULT IN CASE PARTITION TOO BIG
	SNL!CLL!CML	/SKIP IF SIZE OK, LINK=1 FOR NORM MODE
	JMP	RB.SZ	/SIZE TOO BIG, FORCE TO 32K
RB.XV	777400		/MASK TO FORCE TO 400 OCTAL BOUNDARY
RB.EX	PLX		/POINT XR TO PARTITION BLOCK NODE
	AND	P.VS,X	/MASK VIRTUAL SIZE TO PARTITION SIZE
RB.SZ	DAC	P.TS,X	/IN PLACE, LEAVING AC WITH SIZE; LINK
/			/0 IF EXEC MODE, 1 IF NORMAL. END OF #157
	SNL		/SKIP IF NORMAL MODE TASK.
	TAD	P.BA,X	/ADD PARTITION'S BASE ADDRESS.
	AAC	-1	/SIZE-1 = HIGHEST TASK ADDRESS.
/
	JMP	CXDAC
 .TITLE *** 'RASP-15' SPECIAL DIRECTIVE
/
/ THE RASP CAL ALLOWS VARIOUS USER TASKS TO ASK THE RASP SHARIBLE
/ LIBRARY MODULE (UFG) TO PROVIDE SERVICE.
/ 
/ THE CPB FOR THE CAL IS:
/ 
/	30	/CAL CODE 30
/	EVA	/EVENT VARIABLE ADDRESS
/ CODW	0	/FUNCTION CODE*512+NO. OF ARG.
/ ARG	0	/CONTAINS ADDR. OF LIST OF ARGS. IN .DA
/	0	/TEMP WORK
/	0	/AREA USED 
/	0	/BY UFG
/	0
/	0
/	0
/ 
/ THE EXEC CONTAINS TWO SIGNIFICANT INDICATORS.
/ GRSDFL WILL BE 0 IF RASP IS NOT RUNNING, HENCE THE RASP CAL IS ILLEGAL.
/ GRQPTR IS A POINTER TO A STACK OF 2 WORD ENTRIES IN UFG. EACH RASP
/ CAL PUTS TWO WORDS ON THIS LIST. THE END OF THE LIST IS DENOTED BY
/ A ZERO. IF EITHER CASE IS TRUE AN EV OF -103 IS RETURNED.
/ 
/ RASP PUTS CURTSK AND X10 ON THE RPLQ, THEN IT DECLARES A SIGNIFICANT
/ EVENT AND EXITS WITH A ZERO EV.
/ 
RASP.1	LAW	-12		/CHECK RANGE OF CPB
	JMS	CPBRX
	LAC	GRSDFL		/TEST FOR RASP RUNNING AND QUEUE NOT FULL
	SZA
	LAC*	GRQPTR
	SNA
	JMP	CX103		/RASP NOT RUNNING OR RPLQ OVERFLOW
	LAC	CURTSK		/PUT CURTSK AND X10 IN TABLE
	DAC*	GRQPTR
	IDX	GRQPTR
	LAC	X10
	DAC*	GRQPTR
	IDX	GRQPTR
	IDX	GRQFLG		/SET FLAG FOR UFG
	.SET6			/DECLARE A SIGN. EVENT
	JMP	CXPND		/ZERO EV AND RETURN
 .TITLE *** 'TRANSFER COMMAND' RESTRICTED DIRECTIVE
/
/ THE TRANSFER COMMAND DIRECTIVE INSTRUCTS THE SYSTEM TO TRANSFER
/ A LINE OF COMMAND INPUT FROM THE TDV DISPATCH ROUTINE'S LINE BUFFER
/ 'TDVLB' TO A TDV FUNCTION TASK'S BUFFER, AND SET 'TDVEV2' TO INDICATE
/ THAT THE TDV LINE BUFFER IS AVAILABLE.  THIS DIRECTIVE IS RESTRICTED
/ TO ONE ISSUANCE PER REQUESTED TDV FUNCTION TASK, AND ONLY TO THE TDV
/ FUNCTION TASK LAST REQUESTED.
/
/ A FOUR WORD CPB OF THE FOLLOWING FORMAT IS USED:
/
/	CPB	(0) FUNCTION CODE (37)
/		(1) EVENT VARIABLE ADDRESS
/		(2) TDV TASK BUFFER ADDRESS
/		(3) TDV TASK BUFFER SIZE
/
/ IF AN EVENT VARIABLE IS SPECIFIED, IT IS SET AS FOLLOWS:
/
/   +1 -- ALTMODE TERMINATED COMMAND STRING TRANSFERRED
/   +2 -- CAR RTN TERMINATED COMMAND STRING TRANSFERRED
/  -77 -- VIOLATION OF RESTRICTIVE USE
/  -16 -- BUFFER IN TDV FUNCTION TASK TOO SMALL
/ -203 -- DIRECTIVE NOT TASK ISSUED
/
/ ENTER FROM CAL DISPATCH WITH CPB ADDRESS IN XR & X10
/
TC.	LAW	-4	/CHECK RANGE OF CPB (NORMAL MODE) AND SET X14
	JMS	CPBRX	/TO THE 17-BIT EVENT VARIABLE ADDRESS.
/
	LAC	X11	/SET REQUESTOR'S EVENT VARIABLE TO -203
	SZA		/IF CAL WAS NOT TASK ISSUED.
	JMP	CX203
	.IFUND NOMAC						/(161)
	LAC MA.UN	/ IS THIS TASK FROM MULTIACCESS?	/(161)
	SNA!CLL		/ AC >< 0 IF YES.			/(161)
	.ENDC							/(161)
	.IFDEF NOMAC						/(161)
	LAC	TDVCTF	/IF REQUESTOR IS NOT THE "CURRENT TDV FUNCTION"
	SAD	CURTSK	/OR IF THE "CURRENT TDV FUNCTION" HAS ALREADY 
	SKP		/RECEIVED ITS COMMAND LINE, SET THE REQUESTOR'S
	.ENDC							/(161)
	JMP	CX077	/EVENT VARIABLE TO -77
/
	.IFUND NOMAC						/(161)
	AAC -1		/ DECREMENT FOR RANGE 0 TO N-1		/(161)
	MUL		/ CALCULATE THE NUMBER OF WORDS IN	/(161)
	UC.LEN		/ UCA TO THE CURRENT UCA.		/(161)
	LACQ		/ FETCH RESULT FROM MQ.			/(161)
	TAD MA.UCA	/ ADD IN BASE OF UCA AREA.		/(172)
	AAC UC.TB-1	/ SET UP X15 AND X16 FOR ACCESS TO BUFF	/(161)
	DAC X15		/					/(161)
	DAC X16		/					/(161)
	LAC* X16	/ FETCH WORD FROM BUFFER.		/(161)
	.ENDC							/(161)
	.IFDEF NOMAC						/(161)
	LAC	TDVLB+0	/SETUP X17 AS A 2'S COMPL LOOP COUNTER TO MOVE
	.ENDC							/(161)
	SWHA		/LINE TO FUNCTION TASK BUFFER. 
	RAL
	AND	(776)
	TCA
	DAC	X17
	TAD	3,X	/IS BUFFER LARGE ENOUGH?
	SMA
	JMP	TC.2	/YES -- CHECK RANGE OF BUFFER
	LAW	-16	/NO -- SET REQUESTOR'S EVENT VARIABLE TO -16
	DAC	TC.EV
	JMP	TC.3
/
TC.2	LAC	2,X	/CHECK BEGINNING OF FUNCTION TASK BUFFER (NORMAL
	JMS	CACAJ	/MODE), ADJUST TO 17-BIT ADDRESS, AND SETUP X16 AS 
	AAC	-1	/DESTINATION INDEX TO MOVE LINE.
	DAC	X16
/
	LAW	-1	/CHECK END OF BUFFER
	TAD	2,X
	TAD	3,X
	JMS	CACAJ
/
	.IFDEF NOMAC						/(161)
	LAC	(TDVLB-1) /SETUP X15 AS SOURCE INDEX FOR MOVE
	DAC	X15
	.ENDC							/(161)
/
	LAC*	X15
	DAC*	X16
	ISZ	X17
	JMP	.-3
	.IFUND NOMAC						/(161)
	CLA!IAC		/ SET REQUESTERS EV TO 1.		/(161)
	DAC TC.EV	/ UPON EXIT.				/(161)
	.ENDC							/(161)
/
	.IFUND NOMAC						/(161)
TC.3	.SET6		/ DECLARE A SIGNIFICANT EVENT.		/(161)
	.ENDC							/(161)
	.IFDEF NOMAC						/(161)
TC.3	DZM	TDVCTF	/CLEAR 'CURRENT TDV FUNCTION'
	ISZ	TDVEV2	/SET 'LINE MOVED' EVENT VARIABLE, AND DECLARE A
	.SET6		/SIGNIFICANT EVENT.
	.ENDC							/(161)
	LAC	TC.EV	/SET REQUESTOR'S EVENT VARIABLE PER 'TC.EV'
	JMP	CXDAC	/AND EXIT CAL SERVICE.
/
TC.EV	0		/EVENT VARIABLE TO BE RETURNED.  NORMALLY SET TO +1 OR +2
			/BY THE TDV DISPATCH TASK "TDV..." (+1 IF COMMAND STRING
			/IS ALTMODE TERMINATED, OR +2 IF CARRIAGE RETURN TERMINATED).
	.TITLE *** 'SPY' DIRECTIVE
/ 
/ THE 'SPY' DIRECTIVE ALLOWS A NORMAL MODE TASK TO EXAMINE CORE
/ MEMORY ANYWHERE.
/ 
/ A FOUR WORD CPB OF THE FOLLOWING FORMAT IS USED:
/ 	CPB	(0) FUNCTION CODE (31)
/		(1) EVENT VARIABLE ADDRESS
/		(2) ABSOLUTE ADDRESS OF WORD TO BE EXAMINED
/ 		(3) VALUE OF WORD ON ERROR FREE RETURN
/ 
/ IF AN EVENT VARIABLE IS SPECIFIED, IT IS SET AS FOLLOWS:
/ 
/   +1 -- OPERATION COMPLETED SUCCESSFULLY
/ -104 -- PARAMETER ERROR
/ -203 -- DIRECTIVE NOT TASK ISSUED
/ 
/ ENTER FROM CAL DISPATCH WITH CPB ADDRESS IN XR AND X10
/ 
SPY.	JMS	SPY.A	/CHECK FOR LEGALITY IN SPY AND SPYSET S.R.
	LAC	2,X	/IS THE ADDRESS POSITIVE?
	SPA
	JMP	CX104	/NO -- CONTROL TABLE ERROR
	TCA		/YES -- IS THE ADDRESS WITHIN CORE BOUNDS?
	TAD	CSIZE
	SPA
	JMP	CX104	/NO -- CONTROL TABLE ERROR
	LAC	2,X	/YES -- GET THE VALUE
	PAX
	LAC	0,X
	PAL		/SAVE THE VALUE IN LR TEMPORARILY
SPY.B	LAC	SPY.1	/RESTORE THE XR
	PAX
	PLA		/PUT VALUE INTO CPB
	DAC	3,X
	JMP	CXSUC	/RETURN EV +1
	.TITLE *** 'SPYSET' DIRECTIVE
/ 
/ THE 'SPYSET' DIRECTIVE ALLOWS NORMAL MODE TASKS TO MODIFY CORE
/ WITHIN THE BOUNDS SPECIFIED BY SPY1 AND SPY2.
/ 
/ A FOUR WORD CPB OF THE FOLLOWING FORM IS USED:
/ 
/ 	CPB	(0) FUNCTION CODE (32)
/		(1) EVENT VARIABLE
/		(2) ADDRESS RELATIVE TO SPY1
/		(3) VALUE TO BE DEPOSITTED
/ 
/ IF AN EVENT VARIABLE IS SPECIFIED, IT IS SET AS FOLLOWS:
/ 
/   +1 -- OPERATION COMPLETED SUCCESSFULLY
/  -77 -- VIOLATION OF RESTRICTIVE USEAGE OF DIRECTIVE
/         (SPY AREA ILL DEFINED)
/ -104 -- CONTROL TABLE ERROR
/ -203 -- DIRECTIVE NOT TASK ISSUED
/ 
/ ENTER FROM CAL DISPATCH WITH CPB ADDRESS IN XR AND X10
/
SPYST.	JMS	SPY.A	/CHECK LEGALITY IN SPY AND SPYSET S.R.
	LAC	SPY1	/CHECK THE DEFINITION OF THE SPY AREA
	SPA
	JMP	CX077
	TCA
	DAC	SPY.A
	LAC	SPY2	/CHECK THAT THE SPY AREA IS DEFINED
	SNA!SPA
	JMP	CX077	/IT'S NOT -- ERROR
	TAD	SPY.A
	SPA
	JMP	CX077
	LAC	3,X	/SAVE THE VALUE TO BE DEPOSITTED
	PAL
	LAC	2,X	/GET THE REAL ADDRESS
	SPA
	JMP	CX104	/ERROR IF RELATIVE ADDRESS IS NEGATIVE
	TAD	SPY1
	LMQ		/SAVE THE ABSOLUTE ADDRESS
	TCA
	TAD	SPY2	/ADDRESS MUST BE <=SPY2
	SPA
	JMP	CX104	/IT'S NOT -- ERROR
	LACQ		/GET THE ADDRESS BACK
	PAX		/DEPOSIT THE VALUE
	PLA
	DAC	0,X
	JMP	SPY.B	/RESTORE XR AND RETURN EV +1
/ 
/ SPY.A IS A SUBROUTINE USED IN SPY AND SPYSET.
/ THE RANGE OF THE CPB IS CHECKED AND THE XR IS
/ SAVED IN SPY.1, ALSO, CHECK THAT THE DIRECTIVE
/ WAS ISSUED BY A TASK.
/ RETURN IS AT JMS+1 IF NO ERROR IS DETECTED.
/ 
SPY.A	0
	LAW	-4	/CHECK THE RANGE OF THE CPB (NORMAL MODE)
	JMS	CPBRX
	LAC	X11	/WAS THE CAL TASK ISSUED?
	SZA
	JMP	CX203	/NO -- ERROR
	PXA		/SAVE THE XR IN SPY.1
	DAC	SPY.1
	JMP*	SPY.A
SPY.1	0		/TEMP STORAGE FOR XR DURING SPY AND SPYSET
 
 
 
	.IFUND L.ALL
	.NOLST
	.ENDC
	.IFUND NOMAC
	.IFDEF L.DIR
	.LST
	.ENDC
	.TITLE *** 'QUEUE JOB' DIRECTIVE (MULTIACCESS VARIATION)
 
 
 
 
/
/ REWRITTEN FOR MULTIACCESS, 6-MAY-76 BY ED GARDNER
/ 
/ THE QUEUE JOB DIRECTIVE PERMITS TASKS TO SUBMIT JOBS FOR
/ BATCH PROCESSING WHETHER OR NOT THE BATCH HANDLER IS
/ IN CORE. THIS DIRECTIVE ADDS A NODE TO THE JOB QUEUE WHICH
/ CONTAINS APPROPRIATE FIELDS FROM THE CPB PLUS OTHER
/ PERTINENT INFORMATION.
/ 
/ AN NINE WORD CPB OF THE FOLLOWING FORMAT IS USED:
/ 
/	(0)  FUNCTION CODE (33)
/	(1)  EVENT VARIABLE ADDRESS
/	(2)  FILE	( FILE NAME OF INPUT FILE )
/	(3)  NAME	( CONTAINING THE BATCH COMMANDS )
/	(4)  LUNS	( CMD INPUT LUN / LST OUTPUT LUN )
/	(5)  JOB INFO	( FLAGS AND TIME ESTIMATE )
/	(6)  JOB INFO	( CLASS AND MEMORY SIZE )
/	(7)  LOGIN DEVICE AND UNIT
/	(10) LOGIN UFD
/
/ THE NODE INSERTED IN THE JOB QUEUE IS ACTUALLY COMPOSED OF
/ TWO SMALL NODES.  THE PRIMARY NODE IS THREADED INTO THE JOB
/ QUEUE PROPER, AND POINTS TO THE SECONDARY NODE.  THE FORMAT
/ OF THE PRIMARY NODE IS AS FOLLOWS:
/
/	(0)  FORWARD LINK
/	(1)  BACKWARD LINK
/	(2)  FILE	( COPIED FROM CPB WORD 2 )
/	(3)  NAME	( COPIED FROM CPB WORD 3 )
/	(4)  ADDRESS OF SECONDARY NODE
/	(5)  JOB ID OR SEQUENCE NUMBER
/	(6)  JOB INFO	( COPIED FROM CPB WORD 5 )
/	(7)  JOB INFO	( COPIED FROM CPB WORD 6 )
/	(10) DATE WHEN JOB WAS SUBMITTED (FORMAT BELOW)
/	(11) SSM (SECONDS-SINCE-MIDNIGHT) WHEN JOB WAS SUBMITTED
/
/ THE FORMAT OF THE SECONDARY JOB QUEUE NODE IS AS FOLLOWS:
/
/	(0)  COMMAND INPUT DEVICE AND UNIT
/	(1)  COMMAND INPUT UFD
/	(2)  LISTING OUTPUT DEVICE AND UNIT
/	(3)  LISTING OUTPUT UFD
/	(4)  LOGIN DEVICE AND UNIT	( COPIED FROM CPB WORD 7 )
/	(5)  LOGIN UFD			( COPIED FFROM CPB WORD 10 )
/	(6)  UNUSED
/	(7)  UNUSED
/	(10) UNUSED
/	(11) UNUSED
/
/ THE FORMAT OF THE DATE (PRIMARY NODE, WORD 10) IS AS FOLLOWS:
/
/	YEAR (ZERO=1900)	BITS 0 - 8  (9 BITS)		/(210)
/	MONTH			BITS 9 - 12  (4 BITS)
/	DAY			BITS 13 - 17  (5 BITS)
/
/ THE NUMERICAL ENCODINGS OF YEAR, MONTH, AND DAY ARE IDENTICAL
/ TO THAT USED IN SCOM LOCATIONS YR, MO, AND DA.
/
/ THE DEVICE AND UNIT ARE ENCODED INTO A SINGLE WORD AS FOLLOWS.
/ THE TWO LETTER DEVICE NAME IS .SIXBT ENCODED INTO BITS 0 - 11.
/ THE UNIT NUMBER, WHOSE RANGE IS 0 TO 77 (OCTAL), IS IN BITS
/ 12 TO 17 (BINARY REPRESENTATION).  THE UFD IS ENCODED AS THREE
/ .SIXBT CHARACTERS, WHICH IS THE STANDARD REPRESENTATION.  IF
/ THE DEVICE FIELD OF THE DEVICE/UNIT WORD IS ZERO, THE DEVICE,
/ UNIT, AND UFD WORDS ARE IGNORED AND THE DEFAULT (WHATEVER THAT
/ MAY BE) IS USED.  NOTE THAT THE UFD WORD IS IGNORED.  IF THE
/ DEVICE IS PRESENT, BUT THE UFD WORD IS ZERO, THE DEFAULT UFD
/ WILL BE USED.
/
/ THE TWO JOB INFO WORDS ARE MERELY COPIED FROM THE CPB TO
/ THE JOB NODE.  THEIR MEANING IS DETERMINED BY THE OTHER
/ COMPONENTS OF BATCH.  SEE THE BATCH HANDLER AND THE QUEUE
/ TDV FUNCTION FOR MORE INFORMATION.
/
/ JOB'S ARE SEQUENTIALLY NUMBERED ON ANY GIVEN DAY, AND THIS
/ SEQUENCE NUMBER USED FOR THE JOB ID.  THE FIRST JOB QUEUED
/ ON ANY GIVEN DATE IS ASSIGNED JOB ID 1.  SUBSEQUENT JOBS
/ ARE ASSIGNED SEQUENTIAL NUMBERS.  WHENEVER THE DATE CHANGES,
/ THE JOB ID IS RESET TO 1.  THUS, THE JOB ID IS ONLY UNIQUE
/ WHEN USED IN CONJUNCTION WITH THE DATE OF SUBMITTAL.
/
/ THE MAXIMUM SIZE OF THE JOB QUEUE IS SPECIFIED BY THE
/ ASSEMBLY PARAMETER QJBLMT.  IF THAT NUMBER OF JOBS IS
/ ALREADY QUEUED, THIS DIRECTIVE WILL RETURN AN ERROR.
/ NOTE THAT IF QJBLMT IS NEGATIVE OR ZERO, NO JOBS MAY
/ BE QUEUED; THUS, THIS DIRECTIVE WILL NOT BE ASSEMBLED.
/
/ IF AN EVENT VARIABLE IS SPECIFIED, IT IS SET AS FOLLOWS:
/
/   >0 -- JOB SUCCESSFULLY QUEUED. EV VALUE IS JOB ID
/		OR SEQUENCE NUMBER.
/ -101 -- LUN OUT OF RANGE
/ -102 -- LUN NOT ASSIGNED
/ -105 -- DEVICE UNIT NUMBER OUT OF RANGE ( > 77 )
/ -106 -- JOB QUEUE OVERFLOW (TOO MANY JOBS QUEUED)
/ -777 -- POOL EMPTY
/
/ ENTER FROM CAL DISPATCH WITH THE XR AND X10 POINTING TO CPB
/
 
 
	.IFNOZ QJBLMT		/ IF NO JOBS MAY BE QUEUED,
 
QJOB.	LAW -11			/ VERIFY RANGE OR CPB,
	JMS CPBRX		/ GET EV ADDRESS, AND
	JMP CX106		/ GIVE ERROR UNCONDITIONALLY.
 
	.ENDC
 
 
 
	.IFPNZ QJBLMT
 
QJOB.	LAW -11			/ VERIFY RANGE OF CPB AND
	JMS CPBRX		/ SET X14 TO EV ADDRESS.
/
	LAC (R3-1)		/ SET UP POINTER TO R3,R4,R5,R6
	DAC X12			/ TO STORE DEVICES, UNITS, & UFDS.
/
	DZM R6			/ DEFAULT LST DEVICE = ZERO
/
	LAC 4,X			/ PICK UP LUN WORD.
	DAC X13			/ SAVE FOR LATER.
	SWHA			/ GET INPUT LUN IN POSITION.
/
QJOB.A	JMS MAPLUN		/ MAP AND RANGE CHECK LUN.
				/ LEAVES LUN IN AC, XR, X16.
/
	LACIX (LUNUFD-1)	/ PICK UP LUN'S UFD AND
	DAC* X12		/ SAVE IT IN R3 OR R5.
/
	LACIX (LUT-1)		/ PICK UP PDVL NODE ADDR.
	SNA			/ VERIFY LUN IS ASSIGNED.
	JMP CX102		/ JMP IF LUN NOT ASSIGNED.
	PAX			/ POINT XR TO PDVL NODE.
/
	LAW 777700		/ VERIFY DEVICE UNIT IS IN
	AND D.UN,X		/ RANGE -- I.E. THAT IT WILL
	SZA			/ FIT IN 6 BITS.
	JMP CX105		/ JMP IF UNIT OUT OF RANGE.
/
	LAW 777700		/ MASK OUT TWO LETTER DEVICE
	AND D.N1,X		/ NAME,
	XOR D.UN,X		/ AND MERGE IN UNIT NUMBER.
	DAC* X12		/ SAVE IN R4 OR R6.
/
	LAC X13			/ PICK UP SAVED LUN WORD.
	AND (777)		/ MASK OUT LST OUTPUT LUN.
	DZM X13			/ ZERO LUN FOR NEXT TIME.
	SZA			/ IF LUN IS ZERO, USE DEFAULT.
	JMP QJOB.A		/ JMP IF NOT DEFAULT LST LUN.
/
	LAC MAXJOB		/ FETCH MAXIMUM NUMBER OF	/(206)
	SNA!TCA			/ JOBS ALLOWABLE IN THE BATCH	/(206)
	JMP CX106		/ JOB QUE. IF ANY.		/(206)
				/ JOB LIMIT IS IN AC, PREPARE	/(206)
				/ TO SCAN THE JOB QUEUE		/(206)
	DAC X13			/ TO ENSURE LIMIT ISN'T
	LAC JOB1		/ EXCEEDED.
/
QJOB.B	SAD (JOB1)		/ REACHED END OF JOB QUEUE YET?
	JMP QJOB.C		/ JMP IF YES -- LIMIT NOT REACHED
	PAX			/ SCAN TO NEXT ENTRY IN QUEUE.
	LAC 0,X
	ISZ X13			/ COUNT # OF ENTRIES.
	JMP QJOB.B		/ JMP IF LIMIT NOT REACHED YET.
	JMP CX106		/ JMP IF LIMIT REACHED -- RETURN
				/ ERROR.
 
 
QJOB.C	JMS PENP		/ FETCH SECONDARY JOB QUEUE NODE.
	JMP CX777		/ JMP IF NONE AVAILABLE.
	AAC -1			/ SET UP X12 TO FILL IT.
	DAC X12
/
	LAC R4			/ FILL FIRST WORD OF SEC. NODE,
	DAC* X12		/ SO THAT X12 WILL CONTAIN
				/ NODE ADDRESS.
/
	JMS PENP		/ FETCH PRIMARY JOB QUEUE NODE.
	JMP QJOB.E		/ JMP IF NONE AVAILABLE.
	PAX			/ POINT XR TO PRI. NODE.
/
	ISZ X10			/ USE X10 TO FETCH CPB.
/
	LAC* X10		/ COPY FILE NAME TO PRI. NODE.
	DAC 2,X
	LAC* X10
	DAC 3,X
/
	ISZ X10			/ BUMP PAST LUN WORD.
/
	LAC* X10		/ COPY JOB INFO WORDS TO PRI. NODE.
	DAC 6,X
	LAC* X10
	DAC 7,X
/
	LAC X12			/ PUT SECONDARY NODE POINTER
	DAC 4,X			/ INTO PRIMARY NODE.
/
	LAC R3			/ COPY INPUT UFD INTO SEC. NODE.
	DAC* X12		/ (DEVICE & UNIT ALREADY THERE)
/
	LAC R6			/ COPY LISTING DEVICE, UNIT, AND UFD
	DAC* X12		/ INTO SECONDARY NODE.
	LAC R5
	DAC* X12
/
	LAC* X10		/ COPY LOGIN DEVICE, UNIT, AND UFD
	DAC* X12		/ INTO SECONDARY NODE.
	LAC* X10
	DAC* X12
/
	DZM* X12		/ ZERO UNUSED WORDS IN SEC. NODE.
	DZM* X12
	DZM* X12
	DZM* X12
/
	.INH			/// INHIBIT INTERRUPTS, SO TIME
				/// DOESN'T CHANGE WHILE WE'RE
				/// LOOKING AT IT.
/				///
	LAC SSM			/// STORE SSM INTO PRIMARY NODE.
	DAC 11,X		///
/				///
	LAC YR			/// CALCULATE TODAY'S DATE IN FORM
	CLL!RTL			/// YYMMDD.  YY IS YEAR IN
	RTL			/// NINE BITS, MM IS MONTH
	XOR MO			/// IN FOUR BITS, AND DD IS
	RTL			/// DAY IN 5 BITS.
	RTL			///
	RAL			///
	XOR DA			///
/				///
	DAC 10,X		/// SAVE DATE IN PRIMARY NODE.
/
	SAD QJOB.0		/// HAS DATE CHANGED SINCE LAST
	SKP			/// JOB WAS QUEUED?
	DZM QJOB.1		/// YES -- ZERO SEQUENCE #.
/				///
	DAC QJOB.0		/// UPDATE DATE LAST JOB WAS
				/// QUEUED.
/				///
	LAC QJOB.1		/// INCREMENT JOB SEQUENCE NO.
	ADD (400001)		/// WRAP AROUND FROM 377777 TO 1.
	AND (377777)		/// ENSURE ITS POSITIVE.
	.ENB			///
	DAC QJOB.1		/// AND UPDATE PERM. VALUE.
/
	DAC 5,X			/ STORE SEQ. NUMBER IN NODE
	DAC X10			/ ALSO SAVE FOR EV. VALUE.
/
	LAC (JOB1)		/ ENTER JOB INTO JOB QUEUE.
	DAC R1
	JMS NADD
/
	LAC X10			/ PICK UP JOB ID,
	JMP CXDAC		/ AND RETURN IT AS EV VALUE.
 
 
/ COME HERE IF WE CANNOT ALLOCATE A PRIMARY JOB QUEUE NODE.
/ WE RETURN THE SECONDARY NODE TO THE FREE POOL, THEN
/ RETURN AN EV VALUE OF -777.
 
QJOB.E	LAC X12			/ COPY SEC. NODE ADDR. TO R2.
	DAC R2
	LAC (POOL)		/ AND POINT R1 TO FREE POOL
	DAC R1			/ LISTHEAD.
	JMS NADD		/ RETURN NODE TO FREE POOL.
	JMP CX777		/ RETURN WITH ERROR -777.
 
 
 
QJOB.0	0			/ DATE LAST JOB WAS SUBMITTED.
				/ FORMAT IDENTICAL TO DATE STORED
				/ IN PRIMARY JOB QUEUE NODE, WORD
				/ 10.  DETAILED DESCRIPTION GIVEN
				/ ABOVE IN MODULE PREFACE.
 
QJOB.1	0			/ JOB ID OR SEQUENCE NUMBER FOR
				/ THE CURRENT DATE.
				/ SEE DISCUSSION IN MODULE PREFACE
				/ FOR DETAILS OF JUST WHAT THIS IS.
 
	.ENDC
 
 
	.IFUND L.ALL
	.NOLST
	.ENDC
	.ENDC
	.IFDEF NOMAC
	.IFDEF L.DIR
	.LST
	.ENDC
	.TITLE *** 'QUEUE JOB' DIRECTIVE (NON-MULTIACCESS VAR.)
/ 
/ THE QUEUE JOB DIRECTIVE PERMITS TASKS TO SUBMIT JOBS FOR
/ BATCH PROCESSING WHETHER OR NOT THE BATCH HANDLER IS
/ IN CORE. THIS DIRECTIVE ADDS A NODE TO THE JOB DEQUE WHICH
/ CONTAINS WORDS TWO THROUGH SEVEN OF THE CPB AS WELL AS
/ THE TIME IN SECONDS SINCE MIDNITE AND TASK PRIORITY
/ WHICH ISSUED THE DIRECTIVE.
/ 
/ AN EIGHT WORD CPB OF THE FOLLOWING FORMAT IS USED:
/ 
/	CPB	(0) FUNCTION CODE (33)
/		(1) EVENT VARIABLE
/		(2) FIL (INPUT FILE OF
/		(3) NAM BATCH COMMANDS)
/		(4) LUNS (INPUT LUN/OUTPUT LUN)
/ 		(5) JOB INFO (JOB CLASS/JOB TIME)
/		(6) SPECIAL WORD 1
/		(7) SPECIAL WORD 2
/
/ THE NODE INSERTED IN THE JOB DEQUE HAS THE FOLLOWING FORM:
/ 
/		(0) FORWARD LINK
/		(1) BACKWARD LINK
/		(2) FIL
/		(3) NAM
/		(4) PRIORITY OF TASK ISSUING DIRECTIVE
/			[TO BE CHANGED IN FUTURE]
/		(5) LUNS
/		(6) JOB INFO
/		(7) SPECIAL WORD 1
/		(10) SPECIAL WORD 2
/		(11) TIME IN SECONDS SINCE MIDNITE
/ 
/ IF AN EVENT VARIABLE IS SPECIFIED, IT IS SET AS FOLLOWS:
/
/   +N -- OPERATION SUCCESSFULLY COMPLETED (N IS SSM)
/ -203 -- DIRECTIVE NOT TASK ISSUED
/ -777 -- POOL EMPTY
/
/ ENTER FROM CAL DISPATCH WITH THE XR AND X10 POINTING TO CPB
/
QJOB.	LAW	-10	/CHECK THE RANGE OF THE CPB (NORMAL MODE)
	JMS	CPBRX
	LAC	X11	/WAS THE DIRECTIVE TASK ISSUED?
	SZA
	JMP	CX203	/NO -- ERROR
	PXA		/SAVE THE XR
	DAC	QJOB.1
	LAC	CURTSK	/GET THE ISSUING TASK'S PRIORITY
	PAX
	LAC	4,X
	LMQ		/SAVE PRIO.
	JMS	PENP	/GET A NODE FROM THE POOL
	JMP	CX777	/POOL EMPTY -- ERROR
	IAC		/INIT. X13 SO IT ACCESSES NODE
	DAC	X13
	LAC	QJOB.1	/RESTORE THE XR
	PAX
	LAC	2,X	/FIL
	DAC*	X13
	LAC	3,X	/NAM
	DAC*	X13
	LACQ		/PRIO.
	DAC*	X13
	LAC	4,X	/LUNS
	DAC*	X13
	LAC	5,X	/JOB INFO
	DAC*	X13
	LAC	6,X	/SPECIAL 1
	DAC*	X13
	LAC	7,X	/SPECIAL 2
	DAC*	X13
	LAC	SSM	/SECONDS SINCE MIDNITE.
	DAC*	X13
	DAC	QJOB.1
	LAC	(JOB1	/INSERT NODE
	DAC	R1
	JMS	NADD
	LAC	QJOB.1
	JMP	CXDAC	/RETURN EV OF +SSM
QJOB.1	0
 
 
 
	.IFUND L.ALL
	.NOLST
	.ENDC
	.ENDC
	.IFDEF L.DIR
	.LST
	.ENDC
	.TITLE *** 'EXECUTE' DIRECTIVE
/
/ THIS DIRECTIVE ALLOWS USERS TO STORE INFREQUENTLY USED TASK
/ IMAGES ON A USER DISK IN A CREATED FILE. THIS DIRECTIVE DIFFERS
/ FROM REQUEST IN THAT THE TASK NAMED IN THE CPB IS NOT REQUESTED
/ AT THE DIRECTIVE LEVEL. INSTEAD A NODE WITH MOST OF THE CPB
/ IS INSERTED INTO THE EXECUTE DEQUE AND A TASK CALLED 'FININS'
/ IS REQUESTED. FININS THEN FINISHES THE INSTALLATION AND
/ REQUESTS THE TASK. THE EV RETURNED TO THE TASK ISSUING
/ THIS DIRECTIVE INDICATES ONLY IF FININS CAN RUN. NO EV
/ IS RETURNED WHEN THE TASK NAMED IN THE CPB IS REQUESTED.
/ 
/ THE FORMAT FOR THE CPB IS AS FOLLOWS:
/ 
/	CPB	(0) FUNCTION CODE (34)
/		(1) EVENT VARIABLE
/		(2) TASK NAME (FIRST HALF)
/		(3) TASK NAME (SECOND HALF)
/		(4) PRIORITY 
/		(5) LUN
/		(6) PARTITION NAME (FIRST HALF) OR 0
/		(7) PARTITON NAME (SECOND HALF) OR 0
/
/
/ THE POSSIBLE EVENT VARIABLE VALUES ARE THE SAME AS FOR THE 'REQUEST'
/ DIRECTIVE.
/ 
/ 
/
XE.	LAW	-10		/CHECK THE RANGE OF THE CPB (NORMAL MODE)
	JMS	CPBRX
	DZM	X12		/ZERO THE PRIORITY GIVEN IN CPB
/								/EAG:202
	PXL		/ SAVE THE XR SINCE MAPLUN CLOBBERS IT.	/(205)
	LAC 5,X			/ FETCH LUN, MAP IF APPRO.,	/EAG:202
	JMS MAPLUN		/ RANGE CHECK, AND SAVE IN X16.	/EAG:202
				/ (MAPLUN MODIFIES AC,XR,X16)	/EAG:202
/								/EAG:202
	PLX		/ RESTORE THE XR.			/(205)
	LAW 17000	/ AND SET THE DEFER AND ALIAS BITS INTO	/(206)
			/ X16.					/(205)
	AND 5,X		/ FETCH FUNCTION BITS.			/(205)
	XOR X16		/ SET UP REAL LUN PLUS MAGIC BITS.	/(205)
	DAC X16		/ SAVE FOR LOADING THE NODE A LITTLE	/(205)
			/ LATER.				/(205)
								/(205)
	RTL		/ SHIFT DEFER BIT INTO LINK.		/(200)
	CML		/ SET UP FOR !'ED CONDITION IN SKIP.	/(200)
/								/(203)
	LAC 6,X			/ FETCH POSSIBLE EV ADDRESS.	/(203)
	SZL!SNA			/ SKIP IF IS EV ADDRESS.	/(203)
	JMP XE.A		/ JMP IF NOT EV ADDRESS.	/(203)
	JMS CACAJ		/ ADJUST EV ADDRESS.		/(203)
	PAX			/ CLEAR THE EV.			/(203)
	DZM 0,X							/(203)
XE.A	DAC X15			/ AND SAVE WHATEVER IT IS.	/(203)
/								/(203)
	JMS	PENP		/GET A NODE FROM THE POOL
	JMP	CX777		/RETURN HERE IF POOL EMPTY
	IAC
	DAC	X13		/SET UP X13 TO PUT DATA INTO NODE
	LAC X10			/ POINT XR TO CPB.		/(203)
	PAX							/(203)
	LAC	2,X		/GET THE TASK NAME
	DAC*	X13
	LAC	3,X
	DAC*	X13
	LAC	4,X		/GET THE PRIORITY
	DAC*	X13
/								/EAG:202
	LAC X16			/ GET THE LUN			/EAG:202
	DAC* X13		/ STORE INTO NODE.		/EAG:202
/								/EAG:202
	LAC X15		/ FETCH ADJUSTED EVENT VARIABLE ADDRESS	/(200)
			/ OR FIRST HALF OF PARTITION NAME.	/(200)
	DAC*	X13
	LAC	7,X
	DAC*	X13
	LAC	10,X		/STORE THE SECONDARY TASK NAME
	DAC*	X13
	LAC	11,X
	DAC*	X13
	LAC	(EXECT		/SET UP X10 SO REQUEST THINKS THAT
	DAC	X10		/THE TASK IS 'FININS'
	LAC	(EXELH		/PREPARE TO INSERT THE NODE
	DAC	R1
	JMS	SPRI		/INSERT THE NODE BY PRIORITY
	JMP	RQ.1		/GO INTO THE REQUEST CODE.
	.TITLE *** 'SHARE' DIRECTIVE ***
/
/ THE SHARE DIRECTIVE INITIALIZES THE MM REGISTER FOR A USER MODE TASK SO
/ THAT IT CAN SHARE CORE VIA XVM MEMORY MAPPING HARDWARE. IT CAN ALSO BE
/ USED TO STOP MEMORY SHARING IF AN ESAS LENGHT OF ZERO IS SPECIFIED.
/ THIS DIRECTIVE HAS NO EFFECT ON EXECUTIVE MODE TASKS.
/
/ THE CPB FOR THIS DIRECTIVE IS:
/
/	CPB	(0)	35	/CAL CODE (35)
/		(1)	EVA	/EVENT VARIABLE ADDRESS
/		(2)	NAME1	/1ST HALF OF NAME OF MEMORY BLOCK
/		(3)	NAME2	/2ND HALF OF NAME OF MEMORY BLOCK
/		(4)	OFFSET	/OFFSET FROM BASE  OF MEMORY BLOCK
/		(5)	LENGTH	/LEGNTH OF ESAS (BITS 1-17)  AND ACCESS
/				/TYPE DESIRED (BIT 0, SET IF WRITES DESIRED)
/
/ IF  AN EVENT VARIABLE IS SPECIFIED, IT IS SET AS FOLLOWS:
/
/	+1 -- OPERATION COMPLETED SUCCESSFULLY
/	-32 -- MEMORY BLOCK NOT IN PBDL OR SCDL OR DOES NOT ALLOW SHARING
/	-77 -- ACCESS TYPE DESIRED NOT CONSISTANT WITH THAT PERMITTED
/	-104 -- CONTROL TABLE ERROR
/	-203 -- CAL NOT TASK ISSUED
/	-213 -- RECONFIGURATION IN PROGRESS
/
/ ENTER FROM CAL DISPATCH WITH CPB ADDRESS IN XR AND X10
/
	.IFUND	NOXM
SHR.	LAW	-6		/CHECK THE RANGE OF THE CPB (NORMAL MODE)
	JMS	CPBRX		/AND SET X14 TO POINT AT EV
	LAC	X11		/WAS THE CAL TASK ISSUED?
	SZA
	JMP	CX203		/NO -- SET EV TO -203
	LAC	5,X		/YES -- SET ACCESS TYPE BIT INTO LINK
	RAL
	PXL			/SAVE THE XR
/
/ SCAN THE LIST OF PARTITIONS FOR NAMED MEMORY BLOCK
/
	LAC	(PBDL		/SET R1 TO LISTHEAD OF PBDL
	DAC	R1
	LAC	X10		/SET R2 TO POINT AT NAME GIVEN
	AAC	2
	DAC	R2
	JMS	SNAM		/SCAN THE LIST
	SKP			/RETURN HERE IF NOT FOUND
	JMP	SHR.PF		/RETURN HERE IF FOUND
/
/ SCAN THE LIST OF SYSTEM COMMONS FOR NAMED BLOCK OF MEMORY
/
	LAC	(SCDL		/SET R1 TO LISTHEAD OF SCDL
	DAC	R1
	LAC	X10		/SET R2 TO POINT AT NAME GIVEN
	AAC	2
	DAC	R2
	JMS	SNAM		/SCAN THE LIST
	JMP	CX032		/RETURN HERE IF NOT FOUND -- SET EV TO -32
/
/ SYSTEM COMMON FOUND -- SAVE PARAMETERS
/
	PAX			/SET UP XR TO ACCESS NODE
	AAC	B.TC		/GET ADDR OF TASK USE COUNT
	DAC	SHR.TC
	LAC	B.BA,X		/GET BASE ADDR
	DAC	SHR.BA
	LAC	B.SZ,X		/GET SIZE
	DAC	SHR.SZ
	LAC	B.FW,X		/GET FLAGS
	JMP	SHR.F		/GO REJOIN PARTITION CODE
/
/ PARTITION FOUND -- SAVE PARAMETERS
/
SHR.PF	PAX			/SET UP XR TO ACCESS NODE
	AAC	P.TC		/GET ADDR OF TASK USE COUNT
	DAC	SHR.TC
	LAC	P.BA,X		/GET BASE ADDR
	DAC	SHR.BA
	LAC	P.SZ,X		/GET SIZE
	DAC	SHR.SZ
	LAC	P.FW,X		/GET FLAGS
/
/ SAVE FLAGS AND CHECK SPECIFIED SIZE OF ESAS
/
SHR.F	AND	(7		/KEEP ONLY RELEVANT FLAGS
	LMQ			/SAVE IN MQ
	PLX			/RESTORE XR TO POINT AT CPB
	LAC	5,X		/GET SIZE OF ESAS
	AND	(377777
	SNA			/IS IT ZERO?
	JMP	SHR.OF		/YES -- TURN OFF SHARING
	SAD	(400		/NO -- CHECK LEGALITY OF SIZE
	JMP	SHR.00
	SAD	(1400
	JMP	SHR.01
	SAD	(7400
	JMP	SHR.10
	SAD	(17400
	SKP
	JMP	CX104		/NOT LEGAL -- SET EV TO -104
/
/ IF SHARING IS TO BE ENABLED, SET UP MM REGISTER BITS TO INDICATE:
/ SIZE OF ESAS, SHARING ON, AND READ/WRITE PRIVILAGES (IF APPLICABLE)
/
SHR.11	LAC	(16000		/SET SHARE AND ESAS=17400
	SKP
SHR.10	LAC	(14000		/SET SHARE AND ESAS=7400
	SKP
SHR.01	LAC	(12000		/SET SHARE AND ESAS=1400
	SKP
SHR.00	LAC	(10000		/SET SHARE AND ESAS=400
	SNL			/DOES TASK WISH TO WRITE INTO ESAS?
	XOR	(20000		/NO -- SET WRITE PROTECT
	DAC	SHR.MM		/YES -- SAVE IMAGE OF MM REGISTER
/
/ IF SHARING IS TO BE ENABLED, CHECK THE DESIRED ACCESS TYPE (DAT) WITH THE
/ ALLOWED ACCESS TYPE (AAT)
/
	LACQ			/GET THE FLAGS SHOWING AAT
	AND	(4		/EXTRACT THE RCF IN PROGRESS BIT
	SZA			/IS THIS MEMORY BLOCK BEING RCF'D?
	JMP	CX213		/YES -- SET THE EV TO -213
	LACQ			/NO -- RESTORE THE FLAGS WORD
	SNA			/ANY SHARING ALLOWED?
	JMP	CX032		/NO -- SET EV TO -32
	SAD	(2		/YES -- IS RD/WT OK?
	JMP	SHR.OK		/YES -- PROCEED
	SZL			/NO -- DOES TASK WANT TO WRITE INTO ESAS?
	JMP	CX077		/YES -- SET EV TO -77
/
/ CHECK LEGALITY OF OFFSET AND SIZE OF ESAS AGAINST SIZE AND BASE OF BLOCK,
/ THEN SET UP THE SHARED ADDRESS PART OF THE MM REGISTER IMAGE
/
SHR.OK	LAW	-400		/IS OFFSET AN INTEGRAL MULTIPLE OF 400?
	AND	4,X
	SAD	4,X
	SKP
	JMP	CX104		/NO -- SET EV TO -104
	LAC	5,X		/YES -- DOES SIZE OF ESAS + OFFSET EXCEED
	AND	(377777		/THE SIZE OF THE MEMORY BLOCK?
	TAD	4,X
	TCA
	TAD	SHR.SZ
	SPA
	JMP	CX104		/YES -- SET EV TO -104
	LAW	-400		/NO -- CALCULATE THE SHARED ADDRESS
	TAD	SHR.BA		/SUBTRACT 400 (FOR ISAS) FROM BASE OF BLOCK
	TAD	4,X		/ADD OFFSET
	CLL!RAL			/SHIFT ADDRESS INTO POSITION
	SWHA
	XOR	SHR.MM		/XOR IN OTHER DATA
	DAC	SHR.MM		/SAVE THE IMAGE OF THE MM REGISTER
	JMP	SHR.LD		/GO LOAD THE REGISTER
/
/ SPECIAL CASE -- TURN OFF SHARING
/
SHR.OF	DZM	SHR.MM		/SET UP MM REG. IMAGE 
	DZM	SHR.TC		/ZERO TASK USE COUNT POINTER
/
/ LOAD MM REGISTER AND SAVE THE IMAGE IN THE PBDL NODE
/
SHR.LD	LAC	CURTSK		/ACCESS TASK'S ATL NODE
	PAX
	LAC	A.PB,X		/ACCESS TASK'S PBDL NODE
	PAX
	LAC	P.MM,X		/GET OLD MM REGISTER IMAGE
	AND	(740000		/SAVE REL. DIS., IOT PERMISSION AND XVM MODE
	XOR	SHR.MM		/XOR IN NEW SHARE DATA
	LDMM			/LOAD THE REGISTER
	DAC	P.MM,X		/SAVE REGISTER IMAGE IN THE TASK'S PBDL NODE
/
/ IF TASK WAS SHARING DECREMENT THE TASK USE COUNT; IF TASK WILL BE SHARING
/ INCREMENT THE NEW TASK USE COUNT AND ENTER THE TASK USE COUNT POINTER
/
	LAC	SHR.TC		/IS SHARING GOING OFF?
	SNA
	JMP	SHR.NN		/YES
	ISZ*	SHR.TC		/NO -- BUMP THE TASK USE COUNT
	NOP
SHR.NN	LAC	P.UP,X		/GET OLD TASK USE COUNT POINTER
	DAC	R1		/SAVE IT
	LAC	SHR.TC		/ENTER THE NEW ONE
	DAC	P.UP,X
	LAC	R1		/WAS THE TASK SHARING?
	SNA
	JMP	CXSUC		/NO -- SET EV TO +1 AND EXIT
	LAW	-1		/YES -- DECREMENT THE TASK USE COUNT
	TAD*	R1
	DAC*	R1
	JMP	CXSUC		/SET EV TO +1 AND EXIT
/
SHR.MM	0			/MM REGISTER IMAGE
SHR.SZ	0			/SIZE OF SHARED MEMORY BLOCK
SHR.BA	0			/BASE OF SHARED MEMORY BLOCK
SHR.TC	0			/ADDR OF TASK USE COUNT FOR SHARED BLOCK
	.ENDC
/
	.LST
	.IFUND	L.SER
	.NOLST
	.ENDC
 .TITLE *** SIGNIFICANT EVENT RECOGNITION
/
/ WHENEVER A TASK IS NOT RUNNING, THE LEVEL SIX TRANSFER VECTOR ('L6TV')
/ CONTAINS THE ADDRESS OF 'M0'.
/
/ HENCE, WHEN A SIGNIFICANT EVENT IS DECLARED AND A TASK IS NOT
/ RUNNING (SYSTEM IS EITHER 'IDLE', OR EXECUTIVE IS WORKING IN A
/ RE-STARTABLE MODE. VIZ., SCANNING THE ACTIVE TASK LIST), CONTROL
/ IS TRANSFERRED TO 'M0+1' @ API-6.
/
/ WHENEVER A TASK IS RUNNING, THE LEVEL SIX TRANSFER VECTOR ('L6TV')
/ CONTAINS THE ADDRESS OF THE "INTERRUPT CONNECT LOCATION" IN THE
/ PARTITION BLOCK FOR THE CURRENT TASK'S PARTITION.
/
/ HENCE, WHEN A RUNNING TASK IS INTERRUPTED BY THE EXECUTIVE (BECAUSE
/ A SIGNIFICANT EVENT HAS BEEN DECLARED (VIA .SET6)), THE TASK'S
/ REGISTERS ARE SAVED IN THE TASK'S PARTITION'S PARTITION BLOCK
/ AND CONTROL IS TRANSFERRED TO 'M1' @ API-6 BY THE REGISTER
/ SAVE ROUTINE.
/
/ SPECIAL CASE -- WHEN A TASK EXIT'S, ITS NODE IS REMOVED FROM THE
/ ACTIVE TASK LIST, AND CONTROL IS TRANSFERRED DIRECTLY TO 'M1' @ API-4  
/ (REGISTERS ARE NOT SAVED).
/
M0	0		/A SIGNIFICANT EVENT HAS BEEN DECLARED
	JMP	M6	/AND NO TASK IS CURRENTLY RUNNING -- SCAN
			/ACTIVE TASK LIST FROM TOP.
/
M1	LAC	(M0)	/A SIGNIFICANT EVENT HAS BEEN DECLARED,
	DAC	L6TV	/AND A TASK HAS BEEN INTERRUPTED AND
			/ITS REGISTERS HAVE BEEN SAVED, OR A
			/TASK HAS EXIT'ED -- CHANGE THE LEVEL
			/SIX TRANSFER VECTOR TO INDICATE NO 
			/CURRENT TASK.
/
M6	DBK		/DROP TO API-7
	LAC	(400001)
	ISA
	LAS			/ READ AC SWITCHES AND		/(213)
	DAC	ACSW		/ SAVE FOR USER MODE 'SPY'	/(213)
/
/ SETUP TO SCAN ACTIVE TASK LIST FROM TOP (AT API-7)
/
	LAC	(ATKL)	/SET XR TO POINT TO FIRST NODE
	JMP	M4
/
/ M2 -- SCAN ACTIVE TASK LIST FROM CURRENT TASK DOWN.  THE SCAN
/ IS MADE AT LEVEL SEVEN SO THAT IT MAY BE RESTARTED BY A
/ SIGNIFICANT EVENT DECLARATION (.SET6).  
/
M2	LAC	CURTSK	/SET XR TO ACCESS NEXT NODE
M4	PAX
	LAC	A.FP,X
	SAD	(ATKL)	/END OF LIST?
	JMP	IDLE	/YES -- SYSTEM IS IDLE
	DAC	CURTSK	/NO -- RECORD NODE ADDRESS AS 'CURTSK'
	PAX
	LAC	A.TS,X	/DISPATCH ON TASK STATUS WITH
	AND	(777)	/XR POINTING TO ATL NODE
	TAD	(TSD)
	DAC	TSD
	JMP*	TSD
TSD	XX		/ATL NODE STATUS & ACTION TO BE TAKEN:
	JMP S1		/ 1 -- WAIT FOR PARTITION TO BECOME AVAILABLE
	JMP S2		/ 2 -- SET UP & EXECUTE DISK READ REQUEST
	JMP S3		/ 3 -- WAIT FOR NON-ZERO EVENT VARIABLE (PER ATL NODE)
	JMP S4		/ 4 -- START OR RESUME TASK
	JMP S5		/ 5 -- RESTORE TASK'S REGISTERS AND CONTINUE EXECUTION
	JMP M2		/ 6 -- CONTINUE ACTIVE TASK LIST SCAN
	JMP M2  	/ 7 -- CONTINUE ACTIVE TASK LIST SCAN
	JMP M2		/ 10 -- CONTINUE ACTIVE TASK LIST CAAN	/(161)
/
/ M5 -- ENABLE INTERRUPTS AND CONTINUE ACTIVE TASK LIST SCAN
/
M5	.ENB		///
	JMP	M2	///
/
/ IDLE -- LOOP WITH NO ACTIVE API LEVELS (CONSOLE API LIGHTS OUT)
/
IDLE	DBK		//
	.IFDEF LIGHTS						/(206)
IDLE.1	LAC (750000)	/ LOOP COUNT FOR DEFAULT NUMBER		/(206)
	DAC R1		/ OF CHANGES IN IDLE STATE.		/(206)
	LAC PATRN	/ FETCH THE PATTERN SEED.		/(206)
	CLL!CMA		/ INVERT THE PATTERN FOR THE BIT	/(206)
	AND CENTR	/ SOURCE CHECK.				/(206)
	XCT LMAGIC	/ USE THE MAGIC INSTRUCTION TO BUILD	/(206)
			/ THE NEXT STATE OF THE PATTERN.	/(206)
	DAC R2		/ SAVE THE NEW STATE OF THE SOURCE	/(206)
			/ FOR LATER.				/(206)
	LAC PATRN						/(206)
	AND RIGHT	/ CIRCULAR SHIFT RIGHT.			/(206)
	LMQ!LLS 21	/ PERFORM CIRCULAR RIGHT SHIFT.		/(206)
	XOR R2		/ CHANGE SOURCE.			/(206)
	DAC R2		/ SAVE FOR SOURCE OF LEFT HAND CHANGE.	/(206)
	LAC PATRN						/(206)
	AND LEFT	/ SET UP FOR LEFT CIRCULAR SHIFT.	/(206)
	LMQ!LLS 1						/(206)
	XOR R2		/ SORT OUT THE NEW SOURCE.		/(206)
	DAC PATRN	/ SAVE IT FOR NEXT ITERATION.		/(206)
	LMQ		/ STORE PATTERN IN DATA REGISTERS.	/(206)
	PAX							/(206)
	PAL							/(206)
	ISZ R1		/ LOOP FOR A WHILE UNTIL NEXT CHANGE.	/(206)
	JMP .-1							/(206)
	JMP IDLE.1	/ GO GENERATE NEXT STATE.		/(206)
	.ENDC							/(206)
	.IFUND LIGHTS						/(206)
	JMP	.
	.ENDC							/(206)
/
/ DTC -- DECLARE-TASK-CURRENT SUBROUTINE
/
/ ENTRY CONDITIONS:
/   XR -- ATL NODE ADDRESS
/
/ EXIT CONDITIONS:
/   RUNNING @ API-6
/   L6TV -- "CONNECT" LOCATION OF PARTITION BLOCK
/   AC -- "CONNECT LOCATION OF PARTITION BLOCK
/
DTC	0
	.RTL6		/RAISE TO API-6
	LAC	A.PB,X	//
	PXL		//SAVE ATL POINTER IN LIMIT REGISTER	/(161)
	PAX		//PUT PBDL POINTER INTO XR.		/(161)
	AAC +P.IC	//					/(161)
	DAC L6TV	//					/(161)
	LAW 17000	//FETCH AND MASK FOR LUN OFFSET		/(161)
	AND P.FW,X	//FETCH LUN OFFSET FROM FLAG WORD.	/(161)
	SWHA		//PUT LUN OFFSET INTO LOW 9 BITS.	/(161)
	SZA		//IS THERE A LUN OFFSET?		/(164)
	AAC -2		//YES, DECREMENT FOR PROPER LUN USAGE.	/(164)
	DAC MA.LOF	//SET UP SCOM WITH VALUE OF LUN OFFSET	/(161)
								/(161)
/ NOTE THAT IF THE USER ELECTS TO RUN WITHOUT MULTIACCESS, THE	/(161)
/ USER NUMBER FIELD OF THE FLAG WORD IS IGNORED.		/(161)
								/(161)
	.IFUND NOMAC						/(161)
	LAC P.FW,X	//FETCH FLAGWORD			/(161)
	AND (760)	//EXTRACT USER NUMBER			/(161)
	CLL!RTR		//SHIFT USER NUMBER INTO		/(161)
	RTR		//LOW BITS.				/(161)
	DAC MA.UN	//SET UP SCOM WITH USER NUMBER		/(161)
	.ENDC							/(161)
	LAC L6TV	//RESTORE VALUE OF AC FOR THE REST	/(161)
	PLX		//OF RSX, SAME FOR XR.			/(161)
	JMP*	DTC	//
/
	.EJECT
/ STATUS ONE -- A DISK RESIDENT TASK NEEDS ITS CORE PARTITION.
/
/ ENTRY AT API-7 WITH ATL NODE ADR IN XR
/
S1	LAC A.EV,X	/ FETCH THE LUN OFFSET AND USER NUMBER	/(161)
	LMQ		/ SAVE IT IN THE MQ FOR LATER.		/(161)
	LAC A.PB,X	/ SAVE XR IN LR AND POINT XR TO PBDL	/(161)
	PXL		/TO ACCESS PARTITION BLOCK
	PAX
	.INH		/(INHIBIT BECAUSE .SET6 WOULD RESTART ATL SCAN)
	LAC	P.TC,X	///IS PARTITION FREE  ?
	SZA!IAC		///SET UP USE COUNT, JUST IN CASE.	/(161)
	JMP	M5	///NO -- ENABLE INTERRUPTS & CONTINUE ATL SCAN
	DAC	P.TC,X	///
	DZM	P.Z1,X	///SHOW THAT PARTITION NOT YET ZEROED
	DZM	P.C1,X	///ZERO TASK TIMING CLOCK VALUE
	DZM	P.C2,X	///
	DZM	P.IO,X	///ZERO THE TASK I/O COUNT		/(214)
	DZM	P.UP,X	///ZERO THE TASK USE COUNT POINTER
	LAC P.FW,X	///FETCH THE FLAG WORD.			/(161)
	OMQ		///SET THE USER NUMBER AN LUN OFFSET IN	/(161)
	DAC P.FW,X	///THE FLAG WORD AND INITIALIZE PBDL.	/(161)
	PLX		///RESTORE XR TO POINT TO ATL NODE
	.ENB		///
	ISZ	A.TS,X	///CHANGE STATUS FROM ONE TO TWO
			/(.SET6 CAN NOW RESTART SCAN IF NECESSARY)
/
	.EJECT
/ STATUS TWO -- PARTITION IS AVAILABLE, SETUP & EXECUTE DISK READ REQUEST.
/
/ ENTRY AT API-7 WITH ATL NODE ADR IN XR
/
S2	PXL		/SAVE XR IN LR
	LAC	A.PB,X	/GET ADDRESS OF PBDL NODE
	PAX		/SET UP XR TO ACCESS PBDL
	LAC	P.Z1,X	/HAS THE ZEROING PROCESS BEGUN?
	SZA
	JMP	S2.F	/YES -- GO CONTINUE
	.RTL6		/NO -- RAISE TO API-6
	JMS	PENP	//PICK A NODE FROM POOL OF EMPTY NODES
			//(R1, R6, XR, AND AC ARE ALTERED)
	JMP	S2.E	//STAY AT STATUS TWO IF POOL IS EMPTY
/
	IAC		//SETUP X10 TO FILL EMPTY NODE
	DAC	X10	//
	PLX		//
								/(174)
/ MAKE THE LOADING OF TASKS LOOK LIKE IT IS BEING DONE BY AN	/(174)
/ INTERRUPT PROCESSOR. THIS ALLOWS THE CONTROL BLOCK FOR THE GET/(174)
/ TO BE ANYWHERE IN CORE REGARDLESS OF THE TASK MODE (EXEC/USER)/(174)
								/(174)
	DZM* X10	/ CLEAR THE STL NODE ADDRESS IN THE QIO	/(174)
	LAC DUMA.PB	/ REQUEST BEING GENERATED. SET UP DUMMY	/(174)
	DAC* X10	/ PBDL NODE ADDRESS FOR IOCD AND IT'S	/(174)
			/ FRIENDS.				/(174)
/								/(174)
	LAC	A.TP,X	//TASK PRIORITY
	DAC*	X10	//
	LAC	(30)	//'GET' FUNCTION CODE
	DAC*	X10	//
/
/ EVENT VARIABLE AND CONTROL TABLE ARE IN THE PARTITION BLOCK
/
	LAC	A.PB,X	//SET EVENT VARIABLE ADDRESS
	AAC	+P.EV	//
	DAC	A.EV,X	//
	DAC*	X10	//
	IAC		//
	DAC*	X10	//SET CONTROL TABLE ADDRESS
	LAC	A.SN,X	//GET DISK PARAMETERS FROM THE STL NODE
	PAX		//AND SAVE IN X11 & X12
	LAC	S.DA,X	//
	DAC	X11	//
	LAC	S.DB,X	//
	DAC	X12	//
	LAC	S.EP,X	// IS TASK EXEC MODE?
	RTL		//
	SMA!CLA		// IF SO CLEAR MM REGISTER
	JMP	S2.MM	// YES
	LAC	S.TS,X	//YES --GET MM REGISTER FLAGS AND
	AND	(360	//SAVE IMAGE OF MM REGISTER IN
	SWHA!CLL	//X13 FOR FUTURE USE
	RAL		//
S2.MM	DAC	X13	//
	LAC	S.PB,X	//SETUP TO ACCESS PARTITION BLOCK
	PAX		//
	DZM	P.EV,X	//CLEAR DISK READ EVENT VARIABLE
	LAC	X11	//SET DISK UNIT IN C.T.
	AND	(000377)//
	DAC	P.DU,X	//
	LAC	X11	//SET DISK ADDRESS IN C.T.
	AND	(777400)//
	DAC	P.DA,X	//
	LAC	P.BA,X	//SET CORE ADDRESS IN C.T.
	DAC	P.CA,X	//
	LAC	X12	//SET WORD COUNT IN C.T
	DAC	P.WC,X	//
	LAC	X13	//ENTER MM REGISTER IMAGE IN PBDL
	DAC	P.MM,X	//
/
	LAC	(DSKRQ) //INSERT NODE IN DISK REQUEST QUEUE
	DAC	R1
	JMS	SPRI	//(R1, R2, R6, XR, & AC ARE ALTERED)
/
	.INH		//INHIBIT INTERRUPTS.
	LAC*	(DSKTG	///TRIGGER DISK HANDLER TASK BY
	AND	(377777)///SETTING BIT 0 OF TRIGGER.
	TAD	(400000)///
	.ENB		///ENABLE INTERRUPTS.
	DAC*	(DSKTG	///
/
	PLX		//RESTORE XR FOR ACCESSING ATL NODE
	LAC	A.PB,X	//GET ADDR OF TASK'S PBDL NODE
	PAX		//SET UP XR TO ACCESS PBDL NODE
	LAC	P.SZ,X	//CALCULATE 2'S COMPLEMENT OF
	TCA		//NUMBER OF WORDS TO ZERO BY
	TAD	P.WC,X	//ADDING -PARTITION SIZE TO
	DAC	P.Z2,X	//WORD COUNT. SAVE IN P.Z2
	LAW	-1	//SET FLAG TO SHOW ZEROING IS
	TAD	P.BA,X	//OCCURRING
	TAD	P.SZ,X	//
	DAC	P.Z1,X	//
/
	PLX		//RESTORE XR
/			/(#160) REMOVE DBK HERE
	JMP	M6	/A SIGNIFICANT EVENT HAS OCCURRED -- WE JUST MADE
			/AN IO REQUEST
/
S2.E	DBK		//CONTINUE WITH SCAN.			/(173)
	JMP M2		//					/(173)
/
S2.F	LAC	P.Z2,X	/IS PARTITION ZEROING COMPLETE?
	SNA
	JMP	S2.DON	/YES
	TAD	P.Z1,X	/NO -- POINT X10 AT WORD TO ZERO
	DAC	X10
S2.FLP	DZM*	X10	/ZERO THE WORD
	ISZ	P.Z2,X	/IS ZEROING COMPLETE?
	JMP	S2.FLP	/NO -- GO ZERO ANOTHER WORD
S2.DON	PLX		/YES -- RESTORE THE XR
	LAC	(400003	/SET STATUS THREE WITH TASK LOAD FLAG
	DAC	A.TS,X	/PROCEED TO S3
/
	.EJECT
/ STATUS THREE -- WAIT FOR EVENT VARIABLE (LOADING OF DISK RES
/ TASKS, OR 'WAITFOR' DIRECTIVE)
/
/ ENTER AT API-7 WITH ATL NODE ADR IN XR
/
S3	.INH
	LAW	-1	///EVENT VARIABLE SET
	TAD	A.EV,X	///
	DAC	X10	///
	LAC*	X10	///
	DAC	X11	///SAVE EV IN X11 IN CASE IT IS DISK STATUS
	SNA		///
	JMP	M5	///NO -- ENABLE INTERRUPTS & CONTINUE ATL SCAN
	LAC	A.TS,X	///YES -- IS EXECUTIVE WAITING FOR A
	SMA		///TASK LOAD FROM DISK?
	JMP	S3.B	///NO -- SET STATUS FOUR
	LAC	X11	///YES -- DISK READ OKAY?
	SMA		///
	JMP	S3.A	///YES -- SET STATUS FOUR
	ISZ	SE.AD	///NO -- INCREMENT COUNT OF TASK LOAD ABORTS
	NOP		///DUE TO DISK READ ERRORS
	LAC	(RETX)	///AND ABORT TASK LOADING BY CHANGING
	DAC	A.RA,X	///START ADDRESS TO "RE-ENTRANT EXIT TASK".
S3.A	PXL		///SAVE ATL NODE ADR
	LAC	A.SN,X	///SET XR TO POINT TO STL NODE
	PAX		///
	LAC	S.EP,X	///IS THIS TASK NORMAL MODE?
	RTL		///(NEED TO FIND OUT IF MM BITS IN S.TS
	SPA!CLA!CMA	///SHOULD BE REMOVED BEFORE GETTING TASK SIZE)
	LAW	-400	///YES -- AND OFF MM BITS
	AND	S.TS,X	///NO -- GET TASK SIZE
	LMQ		///
	LAC	S.PB,X	///SET XR TO ADDRESS OF PARTITION BLOCK NODE
	PAX		///
	LACQ		///SAVE TASK SIZE IN PARTITION BLOCK NODE
	DAC	P.TS,X	///
	LAC	P.SZ,X	///SET PARTITION'S VIRTUAL SIZE EQUAL TO
	DAC	P.VS,X	///ITS ACTUAL SIZE
	DZM	P.BP,X	///INDICATE NO BUFFERS YET IN PARTITION
	PLX		///SET XR TO ATL NODE ADR
S3.B	LAC	(4)	///SET STATUS FOUR
	.ENB		///
	DAC	A.TS,X	///
	JMP	S4	/AND PROCESS STATUS FOUR
/
	.EJECT
/ STATUS FOUR -- TASK IS IN CORE AND READY FOR START OR RESUMPTION.
/
/ ENTRY AT API-7 WITH ATL ADR IN XR.
/
S4	JMS	DTC	/ DECLARE TASK CURRENT 
	ISZ	A.TS,X	//CHANGE STATUS FROM FOUR TO FIVE
			//
	LAC	A.RA,X	//FETCH ENTRY (OR RESUMPTION) ADDRESS FROM 
	DAC	R1	//ATL NODE, AND SAVE IN R1
			//
	LAC	A.PB,X	//SETUP 'CTBIAS' & 'CTSIZE' AND RELOCATION &
	PAX		//BOUNDARY REGISTERS.  THIS SETUP IS DONE UNCONDITIONALLY,
	LAC	P.BA,X	//BUT ONLY HAS MEANING FOR NORMAL MODE TASKS.
	DAC	CTBIAS	//
	MPLR		//
	LAC	P.TS,X	//
	DAC	CTSIZE	//
	AAC	-1	//
	MPLD		//
	XCT	FPHDWE	//SKIP IF FP HARDWARE EXISTS
	JMP	S4EX	//
	LAC	P.JE,X	//YES -- LOAD THE JEA REGISTER.
	DAC	R2	//
	LJE		//
	R2		//
S4EX	LAC	P.MM,X	//SET UP MM REGISTER
	LDMM		//
	RDCLK		//RESET XM CLOCK
	DBR		//ESTABLISH MODES (ADDRESSING & PROTECTION)
	JMP*	R1	//DROP FROM API-6 TO API-7, AND TRANSFER CONTROL
/
CTBIAS	0		/RELOCATION BIAS OF CURRENT TASK IF IN "NORMAL MODE"
			/UNDEFINED IF "EXECUTIVE MODE"
CTSIZE	0		/SIZE OF CORE AVAILABLE TO CURRENT TASK IN "NORMAL MODE"
			/UNDEFINED IF "EXECUTIVE MODE"
	.EJECT
/ STATUS FIVE -- RUNNING TASK HAS BEEN INTERRUPTED (BY .SET6)
/
/ ENTRY AT API-7, ATL NODE ADR IN XR, AND REGISTERS
/ SAVED IN PARTITION BLOCK.
/
S5	JMS	DTC	/ DECLARE TASK CURRENT
			//AC CONTAINS THE "CONNECT" LOCATION OF THE
			//PARTITION BLOCK.
			// RUNNING AT API-6 (LEFT BY 'DTC') -- EFFECTIVELY
			// EXIT API-6 INTERRUPT ROUTINE.
	JMP	RSR	//RESTORE REGISTERS & RETURN TO INTERRUPTED PROGRAM
			//TASK EXECUTION.
/
 .TITLE *** REGISTER SAVE AND RESTORE ROUTINES
/
/ IF AN INTERRUPT SERVICE ROUTINE IS TO USE THE SYSTEM'S REGISTER
/ SAVE AND RESTORE ROUTINES, IT MUST PROVIDE THE FOLLOWING LINKAGE
/ AND BUFFER.  WHEN THE EXECUTIVE USES SAVE & RESTORE (TASK SWITCH-
/ ING), THE LINKAGE AND BUFFER IS CONTAINED IN THE PARTITION BLOCK
/ OF THE INTERRUPTED TASK'S PARTITION.
/
/  INT	0	/INTERRUPT CONNECT LOCATION
/  	DBA
/  	JMS* (SAV)
/
/  	---	/AC BUFFER
/  	---	/XR BUFFER
/  	---	/LR BUFFER
/  	---	/MQ BUFFER
/  	---	/SC BUFFER
/ 	---	/R1 BUFFER
/ 	---	/R2 BUFFER
/ 	---	/R3 BUFFER
/ 	---	/R4 BUFFER
/ 	---	/R5 BUFFER
/ 	---	/R6 BUFFER
/ 	---	/X10 BUFFER
/ 	---	/X11 BUFFER
/ 	---	/X12 BUFFER
/ 	---	/X13 BUFFER
/ 	---	/X14 BUFFER
/ 	---	/X15 BUFFER
/ 	---	/X16 BUFFER
/ 	---	/X17 BUFFER
/ 	---	/L20 BUFFER
/
/ 	NOP:SKP	/TASK:EXECUTIVE INDICATOR
/		/  NOP -- INTERRUPT SERVICE ROUTINE
/		/  SKP -- PARTITION BLOCK
/	IF AN INTERRUPT SERVICE ROUTINE, CONTROL IS
/	TRANSFERRED TO THE WORD FOLLOWING THE 'NOP' 
/	AFTER THE REGISTERS HAVE BEEN SAVED.  
/
/	IF A PARTITION BLOCK, ADDITIONAL BUFFER AREA FOLLOWS
/	THE 'SKP' INSTRUCTION.
/
/	---	/MM REGISTER BUFFER
/	---	/XM CLOCK OVERFLOWS
/	---	/XM CLOCK TICKS
/	---	/TASK USE COUNT
/	---	/TASK USE COUNT POINTER
/
/	AND IF FLOATING POINT HARDWARE EXISTS, THE FOLLOWING
/	BUFFER AREA IS ALSO PRESENT.
/
/	---	/EPA BUFFER
/ 	---	/FMA1 BUFFER
/ 	---	/FMA2 BUFFER
/	---	/FMQ1 BUFFER
/	---	/FMQ2 BUFFER
/	---	/JEA BUFFER
/
/ --------
/
/ TO EXIT AN INTERRUPT SERVICE ROUTINE WHERE REGISTERS HAVE
/ BEEN SAVED BY 'SAV',
/	LAC	(INT)
/	JMP*	(RES)
/
	.EJECT
  
  
/ REGISTER SAVE ROUTINE
/
/ LINKAGE VIA 'JMS* (SAV)' WITH ALL REGISTERS CONTENTS OF AN
/ INTERRUPTED PROGRAM.  INTERRUPTS ARE INHIBITED THRU THE
/ INSTRUCTION FOLLOWING THE JMS.
/
/ ENTRY IS IN SCOM WHERE INTERRUPTS ARE INHIBITED AND CONTROL
/ IS TRANSFERRED TO 'SAVV'
/
SAVV	DAC*	SAVE	///SAVE AC
	PXA		///SAVE XR
	ISZ	SAVE	///
	DAC*	SAVE	///
	.ENB		///SETUP XR TO SAVE REMAINDER OF REGISTERS
	LAC	SAVE	///
	AND	(077777)
	AAC	P.FP-P.XR
	PAX
	XCT	P.SW,X	/SKIP IF  EXEC
	JMP	SAVV1	/INTERRUPT SERVICE ROUTINE -- IGNORE MM DATA
	CLA		/CLEAR AC BECAUSE CLOCK REGISTER IS OR'D INTO IT
	RDCLK		/READ THE XM CLOCK
	AAC	-2	/SUBTRACT 2 UNITS BECAUSE THESE WERE USED GETTING HERE
	CLL		/CLEAR LINK SO OVERFLOWS CAN BE DETECTED
	TAD	P.C2,X	/ADD CLOCK VALUES
	DAC	P.C2,X	/SAVE RESULT
	SZL		/WERE THERE ANY OVERFLOWS?
	ISZ	P.C1,X	/YES -- RECORD IT
	NOP		/NO
	RDMM		/READ THE MM REGISTER AND 
	DAC	P.MM,X	/SAVE IN THE PBDL NODE
SAVV1	PLA		/SAVE LR
	DAC	P.LR,X
/
	LACQ		/SAVE MQ
	DAC	P.MQ,X
	LACS		/SAVE SC (THE 2'S COMPLEMENT OF THE
	TCA		/SC IN THE LOW ORDER SIX BITS OF A
	AND	(000077)/NORMALIZE INSTRUCTION)
	XOR	(640400)
	DAC	P.SC,X
/
	LAC	P.IC,X	/GET RESTART ADDR FROM PBDL (#204)
	RTL		/SEE IF TASK IS NRM. (#204)
	SPA		/IS IT NRM? (#204)
	JMP	SAVV2	/YES -- DON"T SAVE ALL REGISTERS (#204)
			/NO -- ITS EXEC MODE, SAVE ALL (#204)
/
	LAC	R1	/SAVE R1
	DAC	P.R1,X
	LAC	R2	/SAVE R2
	DAC	P.R2,X
	LAC	R3	/SAVE R3
	DAC	P.R3,X
	LAC	R4	/SAVE R4
	DAC	P.R4,X
	LAC	R5	/SAVE R5
	DAC	P.R5,X
	LAC	R6	/SAVE R6
	DAC	P.R6,X
/
	LAC	X10	/SAVE X10
	DAC	P.10,X
	LAC	X11	/SAVE X11
	DAC	P.11,X
	LAC	X12	/SAVE X12
	DAC	P.12,X
	LAC	X13	/SAVE X13
	DAC	P.13,X
	LAC	X14	/SAVE X14
	DAC	P.14,X
	LAC	X15	/SAVE X15
	DAC	P.15,X
	LAC	X16	/SAVE X16
	DAC	P.16,X
	LAC	X17	/SAVE X17
	DAC	P.17,X
/
SAVV2	LAC	L20	/SAVE L20 (#204)
	DAC	P.20,X
/
/ IF REGISTERS HAVE BEEN SAVED BY AN INTERRUPT SERVICE ROUTINE
/ (SAVE AREA TERMINATED WITH A 'NOP'), CONTROL IS TRANSFERRED TO THE 
/ SERVICE ROUTINE AT THE WORD FOLLOWING THE 'NOP'.
/
/ IF REGISTERS HAVE BEEN SAVED FOR THE EXECUTIVE IN A TASK'S
/ PARTITION'S PARTITION BLOCK (SAVE AREA TERMINATED BY A 'SKP'),
/ ADDITIONAL REGISTERS ARE TO BE SAVED.
/
	XCT	P.SW,X	/EXEC OR TASK?
	JMP	P.IS,X	/TASK -- TRANSFER CONTROL TO INTERRUPT
			/SERVICE ROUTINE AT WORD FOLLOWING SAVE 
			/AREA (FOLLOWING 'NOP').
	XCT	FPHDWE	/EXEC -- FLOATING POINT HARDWARE?
	JMP	M1	/NO -- TRANSFER CONTROL TO EXECUTIVE
			/YES -- SAVE REGISTERS & TRANSFER TO EXEC
	PXA		/SETUP R1 AS TRANSFER VECTOR FOR
	AAC	P.JE	/SAVING FP15'S REGISTERS		/(213)
	DAC	R1
	SJE;	I+R1	/ SAVE JEA FIRST TO PRESERVE GUARD BIT	/(213)
	AAC	P.FB-P.JE					/(213)
	DAC	R1						/(213)
	UNDST		/STORE EPA, FMA1 AND FMA2.
	R1+400000
	AAC	+P.FM-P.FB
	DAC	R1
	UNSWQ		/SWAP FMA AND FMQ.
	0
	EST		/STORE FMQ1 AND FMQ2.
	R1+400000
	JMP	M1
/
	.EJECT
/ RESTORE (REGISTERS) AND RETURN (CONTROL) ROUTINE
/
/ LINKAGE VIA 'JMP* (RSR)' WITH AC CONTAINING THE "CONNECT" ADDRESS
/
/ ENTRY EITHER VIA SCOM ('RES') OR DIRECTLY TO 'RSR'.
/
RSR	AAC P.FP-P.IC /SETUP XR TO FETCH SAVED REGISTER CONTENTS
	PAX
/
	XCT	P.SW,X	/INTERRUPT SERVICE OR TASK?
	JMP	RSR2	/INT SERVICE -- DON'T SETUP 'CTBIAS' & 'CTSIZE', RELOCATION
			/AND BOUNDARY REGISTERS, OR FP15'S REGISTERS.
	LAC	P.BA,X	/TASK (TASK SWITCHING) -- SETUP 'CTBIAS' & 'CTSIZE'
	DAC	CTBIAS	/AND RELOCATION & BOUNDARY REGISTERS.
	MPLR
	LAC	P.TS,X
	DAC	CTSIZE
	AAC	-1
	MPLD
	LAC	P.MM,X	/RESTORE THE MM REGISTER
	LDMM
	XCT	FPHDWE	/FLOATING POINT HARDWARE?
	JMP	RSR2	/NO -- DO NOT RESTORE FP15'S REGISTERS
	PXA		/YES -- USE R1 TO RESTORE FP15 REGISTERS
	AAC	+P.FM
	DAC	R1
	ELQ
	R1+400000
	AAC	P.FB-P.FM					/(213)
	DAC	R1
	UNDLD
	R1+400000
	AAC	P.JE-P.FB					/(213)
	DAC	R1						/(213)
	LJE;	I+R1	/ RESTORE JEA LAST TO PRESERVE GUARD BIT /(213)
/
RSR2	LAC	P.LR,X	/RESTORE LR
	PAL
	LAC	P.MQ,X	/RESTORE MQ
	LMQ
	LAC	(400000)/RESTORE SC (AC-MQ IS NORMALIZED, THEREFORE
	XCT	P.SC,X	/THE NORM INSTRUCTION FORMED DURING
			/REGISTER SAVE, WILL JUST SET THE SC
			/TO THE 2'S COMPLEMENT OF THE LOW
			/ORDER SIX BITS OF THE INSTRUCTION.
/
	LAC	P.IC,X	/GET RESTART ADDR FROM PBDL (#204)
	RTL		/SEE IF TASK IS NRM. (#204)
	SPA		/IS IT NRM? (#204)
	JMP	RSR3	/YES -- DON"T RESTORE ALL REGISTERS (#204)
			/NO -- EXEC MODE, RESTORE THE WORLD (#204)
/
	LAC	P.R1,X	/RESTORE R1
	DAC	R1
	LAC	P.R2,X	/RESTORE R2
	DAC	R2
	LAC	P.R3,X	/RESTORE R3
	DAC	R3
	LAC	P.R4,X	/RESTORE R4
	DAC	R4
	LAC	P.R5,X	/RESTORE R5
	DAC	R5
	LAC	P.R6,X	/RESTORE R6
	DAC	R6
/
	LAC	P.10,X	/RESTORE X10
	DAC	X10
	LAC	P.11,X	/RESTORE X11
	DAC	X11
	LAC	P.12,X	/RESTORE X12
	DAC	X12
	LAC	P.13,X	/RESTORE X13
	DAC	X13
	LAC	P.14,X	/RESTORE X14
	DAC	X14
	LAC	P.15,X	/RESTORE X15
	DAC	X15
	LAC	P.16,X	/RESTORE X16
	DAC	X16
	LAC	P.17,X	/RESTORE X17
	DAC	X17
/
RSR3	LAC	P.20,X	/RESTORE L20 (#204)
	DAC	L20
/
	.INH		/(IMPURE CODE NECESSARY FOR AC, XR, & PC RESTORATION.)
	LAC	P.AC,X	///FETCH AC AND PC (RETURN PARAMETERS)
	DAC	RARACB	///WHILE XR STILL POINTS TO SAVE AREA.
	LAC	P.IC,X	///
	DAC	RARPCB	///
	XCT	P.SW,X	///SKIP IF EXEC
	SKP		///INTERRUPT SERVICE -- DON'T CLEAR XM CLOCK
	RDCLK		///CLEAR XM CLOCK BY READING IT
	LAC	P.XR,X	///RESTORE XR
	PAX		///
	LAC	RARACB	///RESTORE AC
	.ENB		///
	DBR		///DEBREAK, RESTORE, & RETURN TO INTERRUPTED
	JMP*	RARPCB	///PROGRAM
/
RARACB	0		/AC BUFFER
RARPCB	0		/RESTART ADDRESS BUFFER
/
	.LST
	.IFUND	L.RER
	.NOLST
	.ENDC
 .TITLE *** RE-ENTRANT SYSTEM ROUTINES
/
/ *************************************************************
/
/ IN GENERAL, ALL THE RE-ENTRANT SYSTEM ROUTINES ASSUME THAT
/ THEY ARE CALLED IN PAGE MODE.
/
/ *************************************************************
/
/ NADD -- ADD NODE TO DEQUE
/
/ LINKAGE:
/   R1 -- ADDRESS OF LIST HEAD (OR PRECEDING NODE)
/   R2 -- ADDRESS OF NODE TO BE ADDED
/   JMS  NADD
/
/ EXIT CONDITIONS:
/   RETURN AT JMS+1 UNCONDITIONALLY
/
/ REGISTERS ALTERED:
/   XR & AC							/EAG:167
/
/ ENTRY FROM SCOM OR SPRI WITH INTERRUPTS INHIBITED.		/EAG:167
/
								/EAG:167
								/EAG:167
	.IFDEF %QDBG						/(176)
NADDE	JMS QDBG		///				/(176)
	LAC R2			///NODE ADDRESS TO BE ADDED.	/(176)
	LAC* R1			///				/(176)
	.ENDC							/(176)
	.IFUND %QDBG						/(176)
NADDE	LAC* R1			///				/(176)
	.ENDC							/(176)
	DAC* R2			///				/EAG:167
	PAX			///				/EAG:167
	LAC R2			///				/EAG:167
	DAC 1,X			///				/EAG:167
	DAC* R1			///				/EAG:167
	PAX			///				/EAG:167
	LAC R1			///				/EAG:167
	DAC 1,X			///				/EAG:167
	.ENB			///				/EAG:167
	JMP* NADD		///				/EAG:167
								/EAG:167
	.EJECT							/EAG:167
/ NDEL, NDELXR -- DELETE NODE FROM THREAD			/EAG:167
/
/ NDEL CALLING SEQUENCE:					/EAG:167
/   R1 -- ADDRESS OF NODE TO BE DELETED
/   JMS  NDEL
/								/EAG:167
/ NDELXR CALLING SEQUENCE:					/EAG:167
/   XR -- ADDRESS OF NODE TO BE DELETED				/EAG:167
/   JMS NDELXR							/EAG:167
/
/ EXIT CONDITIONS:
/   RETURN AT JMS+1 UNCONDITIONALLY
/
/ REGISTERS ALTERED:
/   XR & AC							/EAG:167
/
/ ENTRY FROM SCOM WITH WITH INTERRUPTS INHIBITED		/EAG:167
/
								/EAG:167
								/EAG:167
NDELE	LAC NDEL		///				/EAG:167
	DAC NDELXR		///				/EAG:167
	LAC R1			///				/EAG:167
	PAX			///				/EAG:167
NDLXRE	LAC 1,X			///				/EAG:167
	DAC NDEL.0		///				/EAG:167
	LAC 0,X			///				/EAG:167
	DAC* NDEL.0		///				/EAG:167
	PAX			///				/EAG:167
	LAC NDEL.0		///				/EAG:167
	DAC 1,X			///				/EAG:167
	.ENB			///				/EAG:167
	JMP* NDELXR		///				/EAG:167
				///				/EAG:167
				///				/EAG:167
NDEL.0				///				/EAG:167
								/EAG:167
	.EJECT							/EAG:167
/ PENP -- PICK AN EMPTY NODE FROM POOL
/
/ CALLING SEQUENCE:
/   JMS  PENP
/
/ EXIT CONDITIONS:
/   RETURN AT JMS+1 IF POOL IS EMPTY
/   RETURN AT JMS+2 WITH PICKED NODE ADDRESS IN THE AC, R1 AND	/(173)
/   R2 IF THE POOL IS NOT EMPTY.				/(173)
/
/ REGISTERS ALTERED:
/   R1, R2, XR, & AC						/EAG:202
/
/ ENTRY FROM SCOM WITH INTERRUPTS INHIBITED			/EAG:167
/
PENPE	LAC	POOL	/// EMPTY POOL?
	SAD	(POOL)	///
	JMP	PENP1	/// YES -- RETURN AT JMS+1
	DAC	R1	/// NO -- SAVE NODE ADR IN R1
	LAC*	POOL	/// PICK FIRST NODE FROM POOL
	PAX		///
	DAC	POOL	///					/EAG:167
	LAC	(POOL)	///
	DAC	1,X	///
	LAC	R1	///RETURN AT JMS+2 WITH PICKED NODE ADR IN AC
	DAC R2		///AND R2.				/(173)
	ISZ	PENP	///					/EAG:167
PENP1	.ENB		///
	JMP*	PENP	///					/EAG:167
/
	.EJECT
/
/ PICK -- PICK A NODE FROM A DEQUE
/
/ LINKAGE:
/   R1 -- ADDRESS OF LIST HEAD (OR PRECEDING NODE)
/   JMS  PICK
/
/ EXIT CONDITIONS:
/   RETURN AT JMS+1 IF DEQUE IS EMPTY
/   RETURN AT JMS+2 WITH PICKED NODE ADDRESS IN AC & R2		/EAG:167
/
/ REGISTERS ALTERED:
/   R2, XR, & AC						/EAG:167
/
/ ENTRY FROM SCOM WITH INTERRUPTS INHIBITED			/EAG:167
/
PICKE	LAC*	R1	///EMPTY DEQUE?
	SAD	R1	///
	JMP	PICK1	///YES -- RETURN AT JMS+1
	DAC	R2	///NO -- PICK NODE
	LAC*	R2	///					/EAG:167
	DAC*	R1	///					/EAG:167
	PAX		///
	LAC	R1	///
	DAC	1,X	///
	LAC	R2	///RETURN AT JMS+1 WITH PICKED NODE ADR IN AC
	ISZ	PICK	///					/EAG:167
PICK1	.ENB		///
	JMP*	PICK	///					/EAG:167
/
	.EJECT
/ SNAM -- SEARCH DEQUE FOR NAME
/
/ CALLING SEQUENCE:
/   R1 -- DEQUE LIST HEAD
/   R2 -- POINTER TO NAME DOUBLEWORD
/   JMS  SNAM
/
/ EXIT CONDITIONS:
/   RETURN AT JMS+1 IF NAME NOT FOUND
/   RETURN AT JMS+2 WITH NODE ADR IN AC & R2 IF NAME FOUND	/EAG:167
/
/ REGISTERS ALTERED:
/   R1, R2, R6, X17, XR, & AC
/
/ ENTRY FROM SCOM WITH RETURN ADDRESS IN AC
/
SNAME	DAC	R6	/SAVE RETURN ADR IN R6
	LAC	R2	/SETUP XR TO EXAMINE NAME DOUBLEWORD
	PAX
/
	LAC*	R1	/START SCAN AT LISTHEAD
/
SNAM1	SAD	R1	/FORWARD LINKAGE TO LISTHEAD?
	JMP*	R6	/YES -- END OF SCAN, NAME NOT FOUND, RETURN AT JMS+1
	DAC	R2	/SAVE FORWARD LINKAGE IN R2 AND
	IAC		/SETUP X17 TO EXAMINE NAME WORDS IN NODE
	DAC	X17	/IN NODE.
	LAC*	X17	/EXAMINE FIRST NAME HALF
	SAD	0,X	/NAME MATCH?
	SKP
	JMP	SNAM2	/NO -- NEXT NODE (IF ANY)
	LAC*	X17	/MAYBE -- CHECK SECOND HALF
	SAD	1,X	/NAME MATCH?
	JMP	SNAM3	/YES -- RETURN AT JMS+2 WITH NODE ADDRESS IN AC
SNAM2	LAC*	R2	/NO -- NEXT NODE (IF ANY)
	JMP	SNAM1
/
SNAM3	LAC	R2	/MATCH FOUND -- SET NODE ADDRESS IN AC
	ISZ	R6	/AT RETURN AT JMS+2
	JMP*	R6
/
	.EJECT
/ SPRI -- SEARCH DEQUE FOR PRIORITY AND INSERT NODE
/
/ CALLING SEQUENCE:
/   R1 -- DEQUE LIST HEAD
/   R2 -- ADDRESS OF NODE TO BE INSERTED
/   JMS  SPRI
/
/ EXIT CONDITIONS:
/   RETURN AT JMS+1 UNCONDITIONALLY
/
/ REGISTERS ALTERED:
/   R1, R3, R6, XR, & AC					/EAG:167
/
/ ENTRY FROM SCOM WITH RETURN ADDRESS IN AC
/
SPRIE	DAC	R6	/SAVE RETURN ADR IN R6
	LAC	R2	/SET NODE PRIORITY IN R3
	PAX
	LAC	4,X
	DAC	R3
	LAC	R1	/SET XR TO ACCESS LIST HEAD
	PAX
PR3	.INH
	LAC	0,X	/// END OF DEQUE?
	PAX		///					/EAG:167
	SAD	R1	///
	JMP	PR2	/// YES -- ADD NODE AT END OF DEQUE
			/// NO -- EXAMINE PRIORITY OF DEQUE NODE
	LAC	4,X	/// IS PRIORITY OF NODE TO BE ADDED HIGHER
	TCA		/// (LOWER NUMBER) THAN NODE UNDER EXAMINATION?
	TAD	R3	///
	SMA		///
	JMP	PR4	/// NO -- EXAMINE NEXT NODE
PR2	LAC	1,X	/// YES -- SETUP R1 FOR 'NADD' AND ADD NODE 
	DAC	R1	///
	LAC	R6	/// COPY RETURN ADDRESS FOR NADD	/EAG:167
	DAC	NADD	///					/EAG:167
	JMP	NADDE	/// AND USE NADD TO INSERT NODE		/EAG:167
/
PR4	.ENB		///
	JMP	PR3	///
 .TITLE *** RE-ENTRANT ROUTINES FOR I/O HANDLER TASKS
/
/ *************************************************************
/
/ IN GENERAL, ALL THE RE-ENTRANT SYSTEM ROUTINES ASSUME THAT
/ THEY ARE CALLED IN PAGE MODE.
/
/ *************************************************************
/
/ THE FOLLOWING TWO RE-ENTRANT SUBROUTINES ALLOW I/O HANDLER
/ TASKS TO PERFORM ATTACH & DETACH FUNCTIONS SUCH THAT I/O REQUESTS
/ ARE DE-QUEUED PER TASK OR PER PRIORITY, AND THAT THE REASSIGN MCR
/ FUNCTION TASK CAN ACT APPROPRIATELY WHEN AN ATTEMPT IS MADE TO 
/ REASSIGN A LUN WHEN IT HAS BEEN ATTACHED TO A TASK.
/
/ REDUNDANT ATTACH AND DETACH REQUESTS ARE IGNORED.
/
/ AN ATTACH-DETACH PAIR IS CONSIDERED A PENDING TRANSFER FOR I/O
/ RUNDOWN PURPOSES, AND FOR NORMAL MODE REQUESTORS, THEIR TRANSFERS
/ PENDING COUNT IS INCREMENTED WHEN AN ATTACH (NON-REDUNDANT) IS MADE
/ AND DECREMENTED WHEN A DETACH (NON-REDUNDANT) IS MADE.
/
/ ALAD -- ATTACH INDICATED LUN [AND DEVICE] TO INDICATED TASK
/
/ DLAD -- DETACH INDICATED LUN [AND DEVICE] FROM INDICATED TASK
/
/ A LUN IS ATTACHED TO A TASK BY SETTING ITS STL NODE ADDRESS
/ IN THE ATTACH-FLAG-TABLE SLOT CORRESPONDING TO THE LUN, AND SETTING
/ THE ADDRESS OF THE ATTACH-FLAG-TABLE SLOT IN THE 'ATTACH FLAG' WORD
/ THE PHYSICAL DEVICE NODE.
/
/ A LUN IS DETACHED FROM A TASK BY ZEROING THE ATTACH-FLAG-TABLE
/ SLOT, AND THE PDVL 'ATTACH FLAG' WORD.
/
/ CALLING SEQUENCE:
/   R1 -- ADDRESS OF PHYSICAL DEVICE NODE
/   R2 -- ADDRESS OF PICKED I/O REQUEST NODE
/   JMS* (ALAD)     OR     JMS* (DLAD)
/
/ EXIT CONDITIONS:
/   RETURN AT JMS+1 WITH -24 IN AC IF ASSIGNMENT HAS CHANGED
/   WHILE REQUEST WAS QUEUED OR WITH -203 IF THE REQUEST WAS MADE OTHER
/   THAN AT TASK LEVEL.
/   RETURN AT JMS+2 IF ATTACH OR DETACH IS PERFORMED.
/
/ REGISTERS ALTERED:
/   R3, R6, X10, X11, XR, & AC					/EAG:167
/
/ COMMON CODE -- ENTRY FROM SCOM WITH RETURN ADDRESS IN AC AND	/EAG:167
/ THE LINK INDICATING WHETHER THIS IS AN ATTACH OR DETACH.	/EAG:167
/								/EAG:167
/	LINK = 0 ==> ATTACH					/EAG:167
/								/EAG:167
/	LINK = 1 ==> DETACH					/EAG:167
/								/EAG:167
/
ATDT	DAC R6		/ SAVE THE RETURN ADDRESS.		/(207)
	LAC R2		/ FETCH THE I/O REQUEST NODE ADDRESS.	/(207)
	PAX		/ AND SET UP ACCESS TO IT.		/(207)
 
	LAC 2,X		/ FETCH THE STL NODE ADDRESS OF THE TASK	/(207)
			/ ISSUING THE ATTACH.			/(207)
	SNA		/ WAS THE ATTACH TASK ISSUED?		/(207)
	JMP ATDTNT	/ NO, ATTEMPT TO ATTACH FROM AN INT.	/(207)
			/ HANDLER IS ILLEGAL.			/(207)
	DAC X10		/ SAVE THE STL NODE ADDRESS FOR THE	/(207)
			/ AFT.					/(207)
 
	LAC 3,X		/ FETCH THE PBDL ADDRESS.		/(207)
	AAC P.TP	/ CALCULATE THE ADDRESS OF THE XFR	/(207)
			/ PENDING COUNT.			/(207)
	DAC R3		/ AND SAVE IT FOR LATER.		/(207)
 
	LAW 17000	/ FETCH THE LUN TO BE ATTACHED.		/(207)
	AND 5,X		/ LUN IS IN THE HIGH ORDER BITS.	/(207)
	SWHA		/ LUN IS NOW IN THE LOW ORDER BITS.	/(207)
	PAX		/ SET UP THE XR TO ACCESS THE LUT.	/(207)
	TAD (AFT-2)	/ CALCULATE THE ADDRESS - 1 OF THE RIGHT/(207)
			/ AFT ENTRY.				/(207)
	DAC X11		/ AND SET UP TO ACCESS IT VIA X11.	/(207)
 
	LAC R1		/ FETCH THE PDVL NODE ADDRESS OF THE	/(207)
			/ DEVICE TO BE ATTACHED/DETACHED.	/(207)
	.INH							/(207)
	SADIX (LUT-1)	/// IS THE DEVICE STILL ASSIGNED TO THE	/(207)
			/// SAME LUN?				/(207)
	JMP ATDT.1	/// YES, CONTINUE WITH PDVL NODE ADDRESS/(207)
			/// IN THE AC.				/(207)
	.ENB							/(207)
 
	LAW -24		/ ERROR - DEVICE ASSIGNMENT HAS CHANGED	/(207)
	JMP* R6		/ TAKE ERROR EXIT FROM ATDT.		/(207)
 
ATDTNT	LAW -203	/ ERROR - ATTACH/DETACH NOT TASK ISSUED	/(207)
	JMP* R6							/(207)
 
ATDT.1	PAX		/// SET UP TO ACCESS THE PDVL NODE.	/(207)
	LAC D.AF,X	/// FETCH THE DEVICE ATTACH FLAG	/(207)
	SZL		/// ATTACH OR DETACH?			/(207)
	JMP DLAD1	/// DETACH.				/(207)
	SZA		/// IS THE DEVICE ALREADY ATTACHED?	/(207)
	JMP ALAD2	/// YES. ALLOW ONLY ONE LUN/TASK TO 	/(207)
			/// ATTACH TO A DEVICE.			/(207)
 
	LAC X10		/// FETCH STL NODE ADDRESS.		/(207)
	DAC* X11	/// AND STORE IT IN THE AFT.		/(207)
 
	LAC X11		/// FETCH THE AFT ENTRY ADDRESS		/(207)
	DAC D.AF,X	/// AND FLAG THE DEVICE AS ATTACHED.	/(207)
 
	ISZ* R3		/// INCREMENT THE XFR PENDING COUNT.	/(207)
 
ALAD2	.ENB							/(207)
	ISZ R6		/// SET UP NON-ERROR RETURN FROM ATDT	/(207)
	JMP* R6		/ RETURN.				/(207)
 
DLAD1	SNA		/// IS THE DEVICE ALREADY ATTACHED?	/(207)
	JMP ALAD2	/// NO, TAKE NORMAL RETURN FROM ATDT.	/(207)
	DZM D.AF,X	/// CLEAR ATTACH FLAG.			/(207)
	PAX		/// SET UP TO ACCESS THE AFT.		/(207)
	DZM 0,X		/// CLEAR THE AFT ENTRY.			/(207)
	CLA!CMA!CLL	/// DECREMENT THE XFR PENDING COUNT.	/(207)
	TAD* R3							/(207)
	SZL		/// DID WE ADD IN 0 FROM THE XFR PENDING	/(207)
			/// COUNT.				/(207)
	DAC* R3		/// NO, UPDATE THE NEW XFR PENDING COUNT/(207)
	JMP ALAD2	/// TAKE THE NORMAL RETURN FROM ATDT.	/(207)
	.EJECT							/EAG:167
/
/ DQRQ -- DE-QUEUE AN I/O REQUEST. IF AN "ABORT" REQUEST IS AT THE HEAD
/ OF THE QUEUE, RETURN IT EVEN IF THE DEVICE-UNIT IS ATTACHED TO
/ ANOTHER TASK.  OTHERWISE, IF THE DEVICE-UNIT IS ATTACHED
/ TO A TASK, ONLY REQUESTS FROM THE ATTACHED TASK ARE DE-QUEUED (THE
/ PRIORITY ORDERED QUEUE IS SCANNED FOR STL NODE ADR).  IF THE DEVICE-
/ UNIT IS NOT ATTACHED TO A TASK, REQUESTS ARE DE-QUEUED FROM THE TOP
/ OF THE QUEUE (DE-QUEUED BY REQUESTOR PRIORITY).
/								/EAG:167
/ NOTE THAT ABORT REQUESTS ARE DISTINGUISHED NOT BY EXAMINING	/EAG:167
/ THE I/O FUNCTION CODE, BUT RATHER BY THE I/O REQUEST		/EAG:167
/ PRIORITY, WHICH IS ZERO.					/EAG:167
/
/ CALLING SEQUENCE:
/   R1 -- PHYSICAL DEVICE NODE ADDRESS
/   JMS*  (DQRQ)
/
/ EXIT CONDITIONS:
/   RETURN AT JMS+1 WITH ATTACH FLAG IN AC IF NO REQUEST TO SERVICE
/   RETURN AT JMS+2 WITH REQUEST NODE IN AC & R2		/EAG:167
/
/ REGISTERS ALTERED:
/   R2, R5, R6, XR, & AC					/EAG:167
/
/ ENTRY FROM SCOM WITH RETURN ADDRESS IN AC
/
								/EAG:167
								/EAG:167
DQRQ1	DAC R6			/ SAVE RETURN ADDRESS IN R6	/EAG:167
/								/EAG:167
	LAC R1			/ POINT XR TO PDVL NODE.	/EAG:167
	PAX			/				/EAG:167
/								/EAG:167
	AAC +D.QF		/(171) POINT R5 TO I/O REQUEST	/EAG:167
	DAC R5			/ QUEUE LISTHEAD.		/EAG:167
/								/EAG:167
	LAC D.AF,X		/ PUT DEVICE ATTACH FLAG (AFT	/EAG:167
	DAC R2			/ TABLE ENTRY POINTER) IN R2.	/EAG:167
/								/EAG:167
	CLL!TCA			/ CLEAR LINK IF DEVICE IS	/EAG:167
				/ ATTACHED; SET LINK OTHERWISE.	/EAG:167
/								/EAG:167
	AXR +D.QF		/(171) POINT XR TO I/O REQUEST	/EAG:167
				/ QUEUE LISTHEAD.		/EAG:167
/								/EAG:167
DQRQ.2	LAC 0,X			/ POINT XR TO NEXT NODE IN	/EAG:167
	PAX			/ REQUEST QUEUE, OR TO REQUEST	/EAG:167
				/ QUEUE LISTHEAD IF SCAN DONE.	/EAG:167
	SAD R5			/ SCANNED ENTIRE REQUEST QUEUE?	/EAG:167
	JMP DQRQ.4		/ JMP IF YES -- RETURN ATTACH	/EAG:167
				/ FLAG (CURRENTLY IN R2).	/EAG:167
	LAC* R2			/ PICK UP STL OF ATTACHED TASK	/EAG:167
	SAD 2,X			/ MATCH STL OF REQUEST?		/EAG:167
	JMP DQRQ.3		/ STL'S MATCH -- DEQUEUE RQST.	/EAG:167
	LAC 4,X			/ CHECK REQUEST PRIORITY.	/EAG:167
	SZA!SNL			/ SKIP IF REQUEST PRIORITY IS	/EAG:167
				/ ZERO (I.E. AN ABORT REQUEST)	/EAG:167
				/ OR IF DEVICE IS NOT ATTACHED.	/EAG:167
	JMP DQRQ.2		/ CAN'T DEQUEUE THIS REQUEST --	/EAG:167
				/ GO CONTINUE SCAN.		/EAG:167
/								/EAG:167
DQRQ.3	PXA			/ XR POINTS TO NODE TO DEQUEUE	/EAG:167
	DAC R2			/ SAVE IT IN R2, AND DELETE	/EAG:167
	JMS NDELXR		/ NODE FROM THE REQUEST QUEUE.	/EAG:167
	ISZ R6			/ RETURN TO JMS+2		/EAG:167
/								/EAG:167
DQRQ.4	LAC R2			/ PICK UP RETURN VALUE,		/EAG:167
	JMP* R6			/ AND RETURN.			/EAG:167
								/EAG:167
	.EJECT							/EAG:167
/
/ VAJX -- TO VERIFY & ADJUST (TO 17-BITS) I/O TRANSFER PARAMETERS.
/
/ CALLING SEQUENCE:
/   R2 -- I/O REQUEST NODE ADDRESS
/   R3 -- STARTING ADR OF TRANSFER
/   R4 -- LENGTH OF TRANSFER IN WORDS.
/   JMS* (VAJX)
/
/ EXIT CONDITIONS:
/   RETURN AT JMS+1 IF INVALID TRANSFER
/   RETURN AT JMS+2, WITH R3 ADJUSTED TO 17-BITS, IF VALID TRANSFER
/
/ REGISTERS ALTERED:
/   R3, R5, XR, & AC
/
VAJX1	DAC	R5	/SAVE RETURN ADDRESS IN R5
/
	LAC	R2	/FETCH PARTITION BLOCK ADDRESS FROM REQUEST NODE
	PAX
	LAC 2,X		/ FETCH STL NODE ADDRESS.		/(173)
	PAX		/ SET UP XR IN CASE I/O WAS TASK ISSUED	/(210)
	SZA!CLA		/ WAS THE I/O REQUEST TASK ISSUED?	/(210)
			/ CLEAR THE NORMAL/EXEC MODE INDICATOR	/(210)
			/ IN CASE THE I/O WASN'T TASK ISSUED.	/(210)
	LAC S.EP,X	/ YES, FETCH THE NORMAL/EXEC MODE 	/(210)
			/ INDICATOR FROM THE STL NODE.		/(210)
	RTL		/ IS IT EXEC MODE?			/(173)
	SMA		/ AC SIGN BIT = 1 IF NO.		/(173)
	JMP VAJX2	/ EXEC MODE, LEAVE WITHOUT CHECKING.	/(173)
	LAC S.PB,X	/ FETCH THE PBDL NODE ADDRESS.		/(210)
	PAX		/ SET UP TO ACCESS THE PBDL.		/(210)
/
	LAC	R4	/WILL I/O OVERFLOW OR UNDERFLOW PARTITION?
	SPA
	JMP*	R5	/YES -- (UNDERFLOW) RETURN AT JMS+1
	TAD	R3	/(R3 IS RELATIVE TO PARTITION BASE)
	TCA
	TAD	P.TS,X
	SPA
	JMP*	R5	/YES -- (OVERFLOW) RETURN AT JMS+1
	LAC	R3	/NO -- VALID REQUEST, ADJUST R3 TO 17-BITS
	TAD	P.BA,X
	DAC	R3
/
VAJX2	ISZ	R5	/RETURN AT JMS+2
	JMP*	R5
								/EAG:167
	.EJECT							/EAG:167
/
/ IOCD -- TO DECLARE I/O REQUEST COMPLETED (DECREMENT TRANSFERS PENDING COUNT)
/
/ CALLING SEQUENCE:
/   R2 -- I/O REQUEST NODE ADDRESS
/   JMS* (IOCD)
/
/ EXIT AT JMS+1 UNCONDITIONALLY
/
/ REGISTERS ALTERED:
/   XR & AC							/EAG:167
/
IOCD1	LAC	R2	///SETUP XR TO ACCESS I/O REQUEST NODE
	PAX		///
	LAC 3,X		///FETCH PBDL NODE ADDRESS.		/(173)
	PAX		///SETUP XR TO ACCESS PARTITION BLOCK	/(173)
	LAC	P.TP,X	///AND DECREMENT TRANSFERS PENDING COUNT.
	SZA		///
	AAC	-1	///
	DAC	P.TP,X	///
	.ENB		///					/(173)
	JMP*	IOCD	///					/EAG:167
								/EAG:167
	.EJECT							/EAG:167
/
/ PABF -- PREALLOCATE I/O BUFFER
/
/ DECREASE THE VIRTUAL PARTITION SIZE BY THE SIZE OF AN I/O BUFFER,
/ UNLESS THIS WOULD CAUSE THE TASK SIZE TO BE GREATER.
/
/ LINKAGE:
/   R2 -- I/O REQUEST NODE ADDRESS
/   R4 -- I/O BUFFER SIZE
/   JMS* (PABF)
/
/ EXIT CONDITIONS:
/   RETURN AT JMS+1 ON ERROR
/   RETURN AT JMS+2 IF SUCCESSFUL
/
/ REGISTERS ALTERED:
/   R4, R5, XR & AC
/
/ ENTRY FROM SCOM WITH RETURN ADDRESS IN THE AC
/
PABF1	DAC	R5	/SAVE RETURN ADDRESS IN R5
/
	LAC	R2	/I/O REQUEST NODE ADDRESS
	PAX
	LAC	2,X	/STL NODE ADDRESS
	PAX
	LAC	S.PB,X	/PARTITION BLOCK NODE ADDRESS
	PAX
	LAC	R4	/I/O BUFFER SIZE
	SPA!SNA
	JMP*	R5	/SIZE ERROR
	AAC	+2	/ADD 2 FOR HEADER
	SPA!TCA
	JMP*	R5	/SIZE ERROR
	.INH		/INHIBIT INTERRUPTS
	TAD	P.VS,X	///DECREASE VIRTUAL PARTITION SIZE
	DAC	R4	///TEMP. SAVE
	TCA		///
	TAD	P.TS,X	///COMPARE WITH TASK SIZE
	SMA!SZA		///
	JMP	PABF2	///WOULD MAKE TASK TOO LARGE
	LAC	R4	///
	DAC	P.VS,X	///
	IDX	R5	///
/
PABF2	.ENB		///ENABLE INTERRUPTS
	JMP*	R5	///
								/EAG:167
	.EJECT							/EAG:167
/
/ ALBF -- ALLOCATE I/O BUFFER
/
/ PARTITION IS EXAMINED FOR AN EXISTING CHAIN OF I/O BUFFERS. IF ONE IS
/ FOUND THAT IS FREE AND EXACTLY THE REQUESTED SIZE, IT IS USED. IF ONE
/ IS NOT FOUND OF THE EXACT SIZE AND IF SUFFICIENT ROOM TO CREATE ONE IN
/ THE PARTITION EXISTS, A NEW BUFFER IS CREATED AND ADDED TO THE CHAIN.
/ IF THAT FAILS, AN EXISTING FREE BUFFER WHOSE SIZE IS LARGER THAN AND
/ MOST CLOSELY MATCHES THE DESIRED SIZE IS USED.
/ THE CALLER ASKS FOR AN "N" WORD BUFFER AND AN "N+2" WORD BUFFER
/ IS USED. WORD 0 BIT 0 IS A FREE(0)/BUSY(1) BIT. THE REST OF WORD 0 IS A
/ POINTER TO THE NEXT BUFFER IN THE CHAIN OR 0 IF NONE. WORD 1 CONTAINS
/ THE BUFFER SIZE "N+2". THE CALLER IS GIVEN THE ADDRESS OF WORD 2 OF THE
/ BUFFER.
/
/ A NEW BUFFER IS NOT CREATED IF IT WOULD OVERFLOW INTO THE TASK AREA. THE
/ LOWEST BUFFER (OR PREALLOCATED BUFFER -- SEE PABF) DETERMINES THE VIRTUAL
/ PARTITION SIZE WHICH LIMITS HOW FAR THE TASK MAY INCREASE ITS SIZE BY
/ THE 'RAISE BOUND' DIRECTIVE.
/
/ LINKAGE:
/   R2 -- I/O REQUEST NODE ADDRESS
/   R4 -- DESIRED BUFFER SIZE
/   JMS* (ALBF)
/
/ EXIT CONDITIONS:
/   RETURN AT JMS+1 IF ERROR
/   RETURN AT JMS+2 IF SUCCESSFUL WITH BUFFER ADDRESS IN AC
/
/ REGISTERS ALTERED:
/   R1, R3, R4, R5, R6, X10, X11, X12, XR & AC
/
/ ENTRY FROM SCOM WITH RETURN ADDRESS IN THE AC
/
ALBF1	DAC	R5	/SAVE RETURN ADDRESS IN R5
/
	LAC	R4	/BUFFER SIZE
	SPA!SNA
	JMP*	R5	/SIZE ERROR
	AAC	+2	/ADD 2 TO THE DESIRED BUFFER SIZE (TO ACCOUNT
	SPA!TCA		/FOR LINKAGE WORDS) AND VALIDATE.
	JMP*	R5	/ERROR RETURN
	DAC	R4	/STORE ADJUSTED BUFFER SIZE IN 2'S COMPLEMENT
/
ALBF2	LAC	R2	/SET XR TO POINT TO I/O REQUEST NODE
	PAX
	LAC	2,X	/SET XR TO POINT TO STL NODE
	PAX
	LAC	S.PB,X	/SET XR TO POINT TO PARTITION BLOCK NODE
	PAX
	DAC	R1	/SAVE NODE'S ADDRESS
	LAC	P.BA,X	/COMPUTE FOR LATER USE THE 2'S COMPLEMENT OF
	TAD	P.TS,X	/ADDRESS JUST ABOVE THE HIGHEST TASK ADDRESS
	TCA
	DAC	R3
	DZM	X10	/INIT. ADDRESS OF "BUFFER CLOSEST IN SIZE".
	LAC	(377777) /INIT. CLOSEST SIZE = VERY LARGE.
	DAC	X11
/
	.INH		/INHIBIT INTERRUPTS.
	LAC	P.BP,X	///IS THIS THE 1ST BUFFER TO BE ALLOCATED?
	SNA		///
	JMP	ALBF5	///YES.
	.ENB		///ENABLE INTERRUPTS.
/
ALBF3	PAX		/NO -- SET XR TO ADDRESS OF NEXT BUFFER
	LAC	0,X	/IS THE BUFFER IN USE?
	SPA
	JMP	ALBF4	/YES.
	LAC	1,X	/IS THE BUFFER SIZE EXACTLY WHAT IS WANTED?
	TCA
	SAD	R4	/(R4 CONTAINS NEGATIVE OF DESIRED SIZE)
	JMP	ALBF7	/YES.
	TAD	X11	/IS THIS SIZE CLOSER THAN ALL THE PREVIOUS ONES?
	SPA!SNA
	JMP	ALBF4	/NO.
	LAC	1,X	/YES -- IS IT LARGER THAN THE DESIRED SIZE?
	TAD	R4
	SPA
	JMP	ALBF4	/NO -- IGNORE IT.
	LAC	0,X	/YES -- SAVE THE BUFFER'S ADDRESS IN X10 AND ITS
	AND	(377777) /SIZE IN X11 FOR POSSIBLE FUTURE USE.
	DAC	X10
	LAC	1,X
	DAC	X11
/
ALBF4	.INH		/INHIBIT INTERRUPTS.
	LAC	0,X	///ARE THERE ANY MORE BUFFERS IN THE CHAIN?
	AND	(377777) ///
	SNA		///
	JMP	.+3	///
	.ENB		///YES -- ENABLE INTERRUPTS AND
	JMP	ALBF3	///CHECK THEM OUT.
	PXA		///SAVE THE LAST BUFFER'S ADDRESS.
	DAC	R6	///THIS IS ALSO THE ADDRESS IMMEDIATELY ABOVE THE
	JMP	ALBF6	///AREA WHERE A NEW BUFFER MAY BE ADDED.
ALBF5	PXA		///SAVE THE ADDRESS OF THE BUFFER POINTER WITHIN
	AAC	+P.BP	///THE PARTITION BLOCK NODE.
	DAC	R6	///
	LAC	P.BA,X	///COMPUTE THE ADDRESS OF THE TOP OF THE PARTITION
	TAD	P.SZ,X	///+1. THIS IS THE ADDRESS IMMEDIATELY ABOVE THE
			///AREA WHERE A NEW BUFFER MAY BE ADDED.
ALBF6	TAD	R4	///SUBTRACT THE ADJUSTED DESIRED SIZE.
	DAC	X12	///SAVE THE NEW BUFFER ADDRESS.
	TAD	R3	///COMPARE THIS WITH THE ADDRESS IMMEDIATELY
	SMA		///ABOVE THE TASK.
	JMP	ALBF8	///ROOM ENOUGH FOR BUFFER.
	LAC	X10	///WAS A FREE BUFFER FOUND ALBEIT THE SIZE WAS
	SNA		///LARGER?
	JMP	ALBF11	///NO -- ERROR RETURN.
	PAX		///SET BUFFER'S ADDRESS IN THE XR.
ALBF7	.INH		///INHIBIT INTERRUPTS.
	LAC	0,X	///IS THE BUFFER STILL FREE?
	SMA		///
	JMP	ALBF9	///YES.
	.ENB		///NO -- ENABLE INTERRUPTS AND START ALL OVER AGAIN.
	JMP	ALBF2	///
ALBF8	LAC	X12	///SET XR TO POINT TO NEW BUFFER.
	PAX		///
	LAC	(400000) ///SET BUFFER BUSY AND INDICATE NO OTHER
	DAC	0,X	///BUFFERS IN CHAIN.
	LAC	R4	///STORE BUFFER SIZE (+2 FOR HEADER).
	TCA		///
	DAC	1,X	///
	LAC	R6	///SET XR TO POINT TO WHAT WAS FORMERLY THE LAST
	PAX		///BUFFER IN THE CHAIN.
	LAC	0,X	///SAVE FREE/BUSY STATUS AND ADD POINTER TO THE
	AND	(400000) ///NEW BUFFER.
	TAD	X12	///
	.ENB		///ENABLE INTERRUPTS.
	DAC	0,X	///
/
	LAC	R1	/SET XR TO POINT TO THE PARTITION BLOCK NODE.
	PAX
	LAC	P.BA,X
/
	.INH		/INHIBIT INTERRUPTS.
	TAD	P.VS,X	///COMPARE MAX. TASK ADDRESS+1 (PARTITION BASE +
	TCA		///VIRTUAL SIZE) TO THE NEW BUFFER ADDRESS.
	TAD	X12	///
	SMA		///
	CLA		///BUFFER NOT LOWER.
	TAD	P.VS,X	///DECREASE THE VIRTUAL PARTITION SIZE.
	DAC	P.VS,X	///
	LAC	X12	///RETURN BUFFER ADDRESS (+2) IN THE AC.
	JMP	ALBF10	///
ALBF9	TAD	(400000) ///SET THE BUFFER BUSY.
	DAC	0,X	///
	PXA		///RETURN TO THE CALLER THE BUFFER ADDRESS+2 IN THE AC.
ALBF10	AAC	+2	///
	IDX	R5	///
ALBF11	.ENB		///ENABLE INTERRUPTS.
	JMP*	R5	///EXIT.
								/EAG:167
	.EJECT							/EAG:167
/
/ DABF -- DEALLOCATE I/O BUFFER
/
/ THE BUSY BIT FOR AN I/O BUFFER IN A PARTITION IS CLEARED. THE BUFFER,
/ HOWEVER, REMAINS DEFINED EVEN IF IT HAPPENS TO BE THE LOWEST ONE IN
/ THE PARTITION. THUS, ONCE BUFFERS ARE CREATED, THEY CANNOT BE REMOVED
/ UNTIL THE TASK EXITS.
/
/ LINKAGE:
/   R4 -- I/O BUFFER ADDRESS
/   JMS* (DABF)
/
/ EXIT CONDITIONS:
/   RETURN AT JMS+1 UNCONDITIONALLY
/
/ REGISTERS ALTERED:
/   R4, R5, XR & AC
/
/ ENTRY FROM SCOM WITH RETURN ADDRESS IN THE AC
/
DABF1	DAC	R5	/SAVE RETURN ADDRESS.
	LAC	R4	/SET BUFFER ADDRESS IN THE XR.
	AAC	-2	/(USER WAS ACTUALLY GIVEN BUFFER ADDRESS+2).
	PAX
	LAC	0,X	/CLEAR THE BUFFER'S BUSY BIT.
	AND	(377777)
	DAC	0,X
	JMP*	R5
								/EAG:167
	.EJECT							/EAG:167
/								/EAG:167
/ DQAB -- DEQUEUE AN I/O REQUEST IF AND ONLY IF IT IS AN	/EAG:167
/	  ABORT REQUEST.					/EAG:167
/								/EAG:167
/ CALLING SEQUENCE:						/EAG:167
/   R1 -- ADDRESS OF THE PHYSICAL DEVICE NODE			/EAG:167
/								/EAG:167
/ NOTE THAT THE DEVICE NODE SHOULD BE FOR UNIT ZERO (ON MULTI-	/EAG:167
/ UNIT DEVICES), AS ALL ABORT REQUESTS ARE QUEUED IN UNIT	/EAG:167
/ ZERO'S DEVICE NODE REGARDLESS OF FOR WHICH UNIT THEY ARE	/EAG:167
/ ACTUALLY INTENDED.						/EAG:167
/								/EAG:167
/ EXIT CONDITIONS:						/EAG:167
/	RETURN AT JMS+1 IF NO ABORT REQUEST TO SERVICE, WITH	/EAG:167
/		BITS 2 AND 3 (=140000) OF THE TRIGGER EVENT	/EAG:167
/		VARIABLE (ADDRESS IN THE PDVL NODE) CLEARED.	/EAG:167
/	RETURN AT JMS+2 WITH ADDRESS OF ABORT REQUEST NODE	/EAG:167
/		IN R2.						/EAG:167
/								/EAG:167
/ REGISTERS ALTERED:						/EAG:1&7
/	R2, XR, & AC						/EAG:167
/								/EAG:167
/ ENTRY FROM SCOM WITH INTERRUPTS INHIBITED.			/EAG:167
/								/EAG:167
								/EAG:167
								/EAG:167
DQAB1	LAC R1			/// POINT AC AND XR TO I/O	/EAG:167
	AAC +D.QF		/// REQUEST QUEUE LISTHEAD.	/EAG:167
	PAX			///				/EAG:167
	SAD 0,X			/// REQUEST QUEUE EMPTY?	/EAG:167
	JMP DQAB.2		/// JMP IF QUEUE EMPTY.		/EAG:167
	LAC 0,X			/// POINT R2 AND XR TO GIRSTEAG:167
	DQc!R:		/// SEQUEST IN THE REQUEST	/EAG:167
	PAX			/// QUEUE.			/EAG:167
	LAC 5,X			/// CHECK IF THE REQUEST IS	/EAG:167
	AND (777)		/// AN ABORT REQUEST.		/EAG:167
	SAD (17)		///				/EAG:167
	JMP DQAB.3		/// JMP IF IT'S AN ABORT.	/EAG:167
DQAB.2	LAC R1			/// POINT XR TO TRIGGER EVENT	/EAG:167
	PAX			/// VARIABLE, OBTAINING ITS	/EAG:167
	LAC D.TG,X		/// ADDRESS FROM THE PDVL NODE.	/EAG:167
	PAX			///				/EAG:167
	LAC 0,X			/// PICK UP EVENT VARIABLE,	/EAG:167
	AND (637777)		/// AND MASK OUT ABORT FLAG	/EAG:167
	DAC 0,X			/// BITS.			/EAG:167
	.ENB			/// AND RETURN TO JMS+1.	/EAG:167
	JMP* DQAB		///				/EAG:167
				///				/EAG:167
				///				/EAG:167
DQAB.3	LAC DQAB		/// ARRANGE FOR NDELXR TO	/EAG:167
	IAC			/// RETURN TO JMS+2,		/EAG:167
	DAC NDELXR		///				/EAG:167
	JMP NDLXRE		/// AND GO DELETE REQUEST NODE.	/EAG:167
								/EAG:167
	.EJECT							/EAG:167
/								/EAG:167
/ DMTQ -- PROCESS ABORT I/O REQUEST				/EAG:167
/								/EAG:167
/ THIS SUBROUTINE PROCESSES THE ABORT I/O FUNCTION FOR		/EAG:167
/ A DEVICE.  IT REQUIRES AS ARGUMENTS THE PDVL NODE		/EAG:167
/ ADDRESS ASSOCIATED WITH THE DEVICE'S UNIT ZERO AND		/EAG:167
/ THE I/O REQUEST NODE aEDSWSS (TO DETERMINE THE TASK FOR	/EAG:167
/ WHICH TO ABORT I/O AND WHETHER IT'S AN ABORT ALL UNITS OR	/EAG:167
/ ABORT SINGLE UNIT FUNCTION).					/EAG:167
/								/EAG:167
/ IF THE FUNCTION IS AN ABORT ALL UNITS (LUN = 0), ALL UNITS	/EAG:167
/ OF THE DEVICE WHICH ARE ATTACHED TO THE ABORTING TASK WILL	/EAG:167
/ BE DETACHED.  ALL I/O REQUESTS (IN EVERY UNIT REQUEST		/EAG:167
/ QUEUE) ISSUED BY THE TASK WILL BE REMOVED FROM THE REQUEST	/EAG:167
/ QUEUE(S) AND ABORTED, REGARDLESS OF THE LUN TO WHICH THEY	/EAG:167
/ WERE ISSUED.  THIS ROUTINE (DMTQ) NEED ONLY BE CALLED ONCE	/EAG:167
/ FOR A MULTI-UNIT DEVICE, PROVIDED THE UNIT ZERO PDVL NODE	/EAG:167
/ ADDRESS IS PROVIDED.  NOTE THAT ADDITIONAL CALLS (USING	/EAG:167
/ OTHER UNITS' PDVL NODE ADDRESSES) ARE PERMITTED, BUT WILL	/EAG:167
/ PERFORM NO FURTHER OPERATION.					/EAG:167
/								/EAG:167
/ IF THE FUNCTION IS AN ABORT SINGLE UNIT (LUN NON-ZERO), ALL	/EAG:167
/ I/O REQUESTS ISSUED BY THE TASK FOR THAT PARTICULAR LUN WILL	/EAG:167
/ BE REMOVED FROM THE APPROPRIATE REQUEST QUEUE AND ABORTED.	/EAG:167
/ THE DEVICE REMAINS ATTACHED AND REQUESTS TO THE SAME		/EAG:167
/ DEVICE-UNIT VIA OTHER LUNS REMAIN IN EFFECT.			/EAG:167
/								/EAG:167
/ DEFINITION:							/EAG:167
/								/EAG:167
/	"TO ABORT AN I/O REQUEST" MEANS:			/EAG:167
/								/EAG:167
/	    1.	THE I/O REQUEST NODE IS REMOVED FROM THE	/EAG:167
/		DEVICE UNIT'S I/O REQUEST QUEUE.		/EAG:167
/								/EAG:167
/	    2.	THE TRANSFERS PENDING COUNT IS DECREMENTED,	/EAG:167
/		IF THE REQUEST WAS ISSUED BY A NORMAL MODE	/EAG:167
/		TASK.						/EAG:167
/								/EAG:167
/	    3.	THE EVENT VARIABLE WHICH THE TASK SUPPLIED	/EAG:167
/		TO SIGNAL REQUEST COMPLETION IS SET TO -2,	/EAG:167
/		INDICATING THE REQUEST WAS ABORTED.  THIS	/EAG:167
/		REQUIREMENT IS OPTIONAL IN THE CASE OF ABORT	/EAG:167
/		ALL UNITS; IT IS ONLY NECESSARY FOR ABORT	/EAG:167
/		SINGLE UNIT.  NOTE THAT A SIGNIFICANT EVENT	/EAG:167
/		WILL NOT BE DECLARED, AS IT WOULD BE REDUNDANT.	/EAG:167
/								/EAG:167
/	    4.	THE I/O REQUEST NODE IS RETURNED TO THE FREE	/EAG:167
/		NODE POOL.					/EAG:167
/								/EAG:167
/ NOTE THAT THE DEVICE HANDLER IS RESPONSIBLE FOR ABORTING	/EAG:167
/ ALL REQUESTS WHICH IT IS CURRENTLY PROCESSING!		/EAG:167
/								/EAG:167
/ CALLING SEQUENCE:						/EAG:167
/   R1 -- ADDRESS OF THE PHYSICAL DEVICE NODE FOR UNIT ZERO	/EAG:167
/   R2 -- ADDRESS OF THE PICKED (ABORT) I/O REQUEST NODE	/EAG:167
/   JMS* (DMTQ)							/EAG:167
/								/EAG:167
/   RETURN AT JMS+1 UNCONDITIONALLY, WITH REGISTERS AS FOLLOWS:	/EAG:167
/	R1 -- ADDRESS OF FREE NODE POOL				/EAG:167
/	R2 -- ADDRESS OF THE ABORT I/O REQUEST NODE		/EAG:167
/	X10 -- STL ADDRESS OF ABORTING TASK			/EAG:167
/	X11 -- LUN # TO ABORT, SHIFTED LEFT 9 BITS, IF ABORT	/EAG:167
/	       SINGLE UNIT.  ZERO IF ABORT ALL UNITS.		/EAG:167
/	AC, XR -- ADDRESS OF THE EVENT VARIABLE ASSOCIATED	/EAG:167
/		  WITH THE ABORT I/O REQUEST.			/EAG:167
/								/EAG:167
/ EXAMPLE OF TYPICAL USAGE:					/EAG:167
/		LAC < PDVL UNIT ZERO >				/EAG:167
/		DAC* (R1)					/EAG:167
/		JMS DQAB					/EAG:167
/		  JMP < NO ABORT REQUESTS >			/EAG:167
/	 ABRT	JMS DMTQ					/EAG:167
/		SZA!CLA!IAC					/EAG:167
/		DAC 0,X						/EAG:167
/		JMS IOCD					/EAG:167
/		JMS NADD					/EAG:167
/		< SCAN ALL UNITS FOR ACTIVE REQUESTS >		/EAG:167
/		< WHICH MATCH STL IN X10 AND LUN IN  >		/EAG:167
/		< X11, AND ABORT SAME.  NOTE THAT R1 >		/EAG:167
/		< STILL POINTS TO THE FREE NODE POOL >		/EAG:167
/		< LISTHEAD, SUITABLE FOR USE BY NADD.>		/EAG:167
/ NOTE THAT ABORT REQUESTS DEQUEUED BY DQRQ TRANSFER TO THE	/EAG:167
/ LABEL "ABRT" IN THE ABOVE CODE SEQUENCE.			/EAG:167
/								/EAG:167
/ REGISTERS ALTERED:						/EAG:167
/   R1, R2, R3, R5, R6, X10, X11, X12, XR & AC			/EAG:167
/								/EAG:167
/ ENTRY FROM SCOM WITH RETURN ADDRESS IN THE AC.		/EAG:167
/								/EAG:167
								/EAG:167
								/EAG:167
DMTQ1	DAC R6			/ SAVE RETURN ADDRESS		/EAG:167
/								/EAG:167
	LAC R2			/ SAVE ADDRESS OF ABORT REQUEST	/EAG:167
	DAC R3			/ IN R3, AND POINT XR TO	/EAG:167
	PAX			/ REQUEST NODE.			/EAG:167
/								/EAG:167
	LAC 2,X			/ SAVE STL NODE ADDRESS IN X10.	/EAG:167
	DAC X10			/				/EAG:167
/								/EAG:167
	LAW 777000		/ MASK OUT LUN NUMBER,		/EAG:167
	AND 5,X			/ SAVE IT IN X11, AND		/EAG:167
	DAC X11			/ CHECK IF ABORT SINGLE UNIT	/EAG:167
	SNA!SWHA		/ OR ABORT ALL UNITS.		/EAG:167
	JMP DMTQ.0		/ JMP IF ABORT ALL UNITS.	/EAG:167
/								/EAG:167
	PAX			/ FETCH PDVL NODE ADDRESS OF	/EAG:167
	LACIX (LUT-1)		/ UNIT TO BE ABORTED INTO AC.	/EAG:167
	JMP DMTQ.3		/ GO SCAN REQUEST QUEUE.	/EAG:167
/								/EAG:167
								/EAG:167
								/EAG:167
DMTQ.0	LAC R1			/ POINT XR TO PDVL NODE.	/EAG:167
	PAX			/				/EAG:167
/								/EAG:167
DMTQ.1	.INH			/// INHIBIT INTERRUPTS WHILE	/EAG:167
	LAC D.AF,X		/// PLAYING WITH ATTACH FLAGS.	/EAG:167
	DAC R5			/// POINT R5 TO AFT TABLE ENTRY	/EAG:167
	SZA!CLL			/// IS DEVICE ATTACHED? SKIP	/EAG:167
				/// WITH LINK=0 IF NOT.		/EAG:167
	LAC* R5			/// PICK UP STL ADDRESS OF	/EAG:167
				/// ATTACHED TASK.		/EAG:167
	SAD X10			/// IS DEVICE ATTACHED TO US?	/EAG:167
	SKP!STL			/// SET LINK IF YES.		/EAG:167
	JMP DMTQ.2		/// JMP WITH LINK=0 IF NO	/EAG:167
	DZM* R5			/// DEVICE ATTACHED TO US -- SO	/EAG:167
	DZM D.AF,X		/// DETACH IT (CLEAR THE FLAGS)	/EAG:167
DMTQ.2	.ENB			/				/EAG:167
	SZL			/ WAS DEVICE DETACHED?		/EAG:167
	JMS IOCD		/ YES -- DECREMENT TRANSFERS	/EAG:167
				/ PENDING COUNT.		/EAG:167
	LAC R1			/ PICK UP PDVL ADDRESS FOR	/EAG:167
				/ WHAT FOLLOWS.			/EAG:167
/								/EAG:167
DMTQ.3	AAC +D.QF		/ ENTER WITH PDVL NODE ADDRESS	/EAG:167
	DAC R5			/ IN AC.  POINT XR AND R5	/EAG:167
	PAX			/ TO REQUEST QUEUE LISTHEAD.	/EAG:167
/								/EAG:167
	LAC (POOL)		/ INITIALIZE R1 TO RETURN NODES	/EAG:167
	DAC R1			/ TO FREE POOL USING NADD.	/EAG:167
/								/EAG:167
DMTQ.4	LAC 0,X			/ CHECK NEXT NODE IN REQUEST	/EAG:167
DMTQ.5	PAX			/ QUEUE.			/EAG:167
	SAD R5			/ REACHED END OF QUEUE?		/EAG:167
	JMP DMTQ.7		/ JMP IF YES.			/EAG:167
	DAC R2			/ SAVE REQUEST FOR IOCD.	/EAG:167
/								/EAG:167
	LAC 2,X			/ WAS REQUEST ISSUED BY THIS	/EAG:167
	SAD X10			/ TASK -- I.E., DOES STL ADDR.	/EAG:167
	SKP			/ MATCH?			/EAG:167
	JMP DMTQ.4		/ JMP IF DON'T MATCH.		/EAG:167
/								/EAG:167
	LAC X11			/ NOW CHECK LUNS.  X11=0 ==>	/EAG:167
	SZA			/ ABORT ALL UNITS, OTHERWISE	/EAG:167
	XOR 5,X			/ COMPARE LUNS FOR MATCH.	/EAG:167
	AND (777000)		/				/EAG:167
	SZA			/				/EAG:167
	JMP DMTQ.4		/ JMP IF DON'T MATCH		/EAG:167
/								/EAG:167
	LAC 6,X			/ EVERYTHING MATCHES -- ABORT	/EAG:167
	SNA			/ THIS REQUEST.  FIRST, CHECK	/EAG:167
	JMP DMTQ.6		/ IF REQUEST HAS EVENT VAR.	/EAG:167
	AAC -1			/ AND SET IT TO -2 IF IT DOES.	/EAG:167
	DAC X12			/				/EAG:167
	LAW -2			/				/EAG:167
	DAC* X12		/				/EAG:167
/								/EAG:167
DMTQ.6	LAC 0,X			/ SAVE ADDRESS OF NEXT NODE	/EAG:167
	DAC X12			/ IN REQUEST QUEUE.		/EAG:167
/								/EAG:167
	JMS NDELXR		/ DELETE NODE FROM RQST QUEUE	/EAG:167
/								/EAG:167
	JMS IOCD		/ ADJUST TRANSFERS PENDING CNT	/EAG:167
/								/EAG:167
	JMS NADD		/ AND RETURN NODE TO FREE POOL	/EAG:167
/								/EAG:167
	LAC X12			/ RESTART SCAN WITH NEXT NODE.	/EAG:167
	JMP DMTQ.5		/				/EAG:167
/								/EAG:167
								/EAG:167
								/EAG:167
/ COME HERE WHEN SCAN REACHES END OF REQUEST QUEUE.		/EAG:167
/ NOTE THAT XR POINTS TO REQUEST QUEUE LISTHEAD.		/EAG:167
								/EAG:167
DMTQ.7	LAC R3			/ RESTORE R2 TO ABORT REQUEST	/EAG:167
	DAC R2			/ NODE POINTER.			/EAG:167
/								/EAG:167
	LAC X11			/ IS THIS AN ABORT ALL UNITS?	/EAG:167
	SZA			/ SKIP IF YES.			/EAG:167
	JMP DMTQ.8		/ JMP IF ABORT SINGLE UNIT.	/EAG:167
/								/EAG:167
	AXR -D.QF		/ POINT XR TO PDVL NODE BASE	/EAG:167
/								/EAG:167
	LAC D.N1,X		/ SAVE DEVICE NAME IN X12.	/EAG:167
	DAC X12			/				/EAG:167
/								/EAG:167
	LAC D.FP,X		/ ADVANCE TO NEXT PDVL NODE.	/EAG:167
	DAC R1			/				/EAG:167
	PAX			/				/EAG:167
/								/EAG:167
	LAC X12			/ IS IT FOR THE SAME DEVICE?	/EAG:167
	SAD D.N1,X		/ SKIP IF DIFFERENT DEVICE.	/EAG:167
	JMP DMTQ.1		/ GO ABORT NEXT UNIT OF MULTI-	/EAG:167
				/ UNIT DEVICE.			/EAG:167
/								/EAG:167
	LAC (POOL)		/ RESTORE R1 TO FREE NODE POOL	/EAG:167
	DAC R1			/ LISTHEAD POINTER.		/EAG:167
/								/EAG:167
DMTQ.8	LAC R2			/ POINT XR TO ABRORT REQUEST,	/EAG:167
	PAX			/ THEN PICK UP ABORT REQUEST'S	/EAG:167
	LAC 6,X			/ EVENT VARIABLE ADDRESS, AND	/EAG:167
	PAX			/ LEAVE IT IN AC AND XR.	/EAG:167
/								/EAG:167
	JMP* R6			/ AND RETURN!			/EAG:167
								/EAG:167
								/EAG:167
	.LST
	.IFUND	L.MAC
	.NOLST
	.ENDC
 .TITLE *** MEMORY PROTECT INTERRUPT SERVICE
/
/ A MEMORY PROTECT VIOLATION HAS OCCURRED.  THE TASK IN VIOLATION HAS
/ BEEN INTERRUPTED AND 'CURTSK' POINTS TO ITS ATL NODE.
/
MPKINT	0
	DBA
	DAC	R3	/SAVE AC
	PXA		/SAVE XR
	DAC	R4
	LAC	MPKINT	/SAVE ENTRY POINT SO THAT THIS ROUTINE CAN BE
	PAL		/REENTERED.
	LAC	(2)	/SET CODE INDICATING REASON FOR VIOLATION.
	MPSNE
	AAC	-1
	DAC	R5
	MPCV
	MPCNE
	DBK
	JMS	PENP	/PICK AN EMPTY NODE FROM THE POOL
			/(R1, R6, XR, & AC ARE ALTERED)
			/IS POOL EMPTY?
	JMP	RETX	/YES -- CAN'T PRINT ERROR MESSAGE.
	IAC		/SETUP X13 TO FILL NODE WITH TERMINATION
	DAC	X13	/NOTICE INFORMATION.
	LAC	CURTSK	/SET TASK NAME
	PAX
	LAC	A.N1,X
	DAC*	X13
	LAC	A.N2,X
	DAC*	X13
	LAC	R5	/SET TERMINATION INDICATOR
			/   1 -- MEMORY BOUND VIOLATION
			/   2 -- NONEXISTENT MEMORY REFERENCE
	DAC*	X13
	PLA		/SET ADDRESS OF VIOLATION (ACTUALLY 
	DAC*	X13	/LINK, ADR MODE, PROTECT MODE, AND ADR
			/OF WORD FOLLOWING VIOLATION)
	LAC	R3	/SET CONTENTS OF AC AT VIOLATION
	DAC*	X13
	LAC	R4	/SET CONTENTS OF XR AT VIOLATION
	DAC*	X13
	.IFUND NOMAC						/(161)
	LAC MA.UN	/ IS THIS A MULTIACCESS TASK?		/(161)
	SNA		/ AC >< 0 IF YES.			/(161)
	JMP MPKIN1	/ NO.					/(161)
	LAC R2		/ FETCH NODE ADDRESS.			/(161)
	PAX		/ PREPARE TO SET EXIT CODE.		/(161)
	CLA!IAC		/ EXIT CODE IS 1.			/(161)
	DAC T.EC,X	/ SET EXIT CODE IN NODE.		/(161)
	LAC (TDV.EQ)	/ FETCH PROPER DEQUE HEAD.		/(161)
	JMP MPKIN2	/ GO REJOIN COMMON CODE.		/(161)
MPKIN1=.							/(161)
	.ENDC							/(161)
	LAC	(TNRL)	/ADD NODE TO TERMINATION NOTICE REQUEST LIST
MPKIN2	DAC R1		/ SET UP NADD FOR PROPER LIST.		/(161)
	JMS	NADD	/(R2, R6, XR, & AC ARE ALTERED)
	.IFUND NOMAC						/(161)
	LAC MA.UN	/ IS THIS A MULTIACCESS TASK?		/(161)
	SNA		/ AC >< 0 IF YES.			/(161)
	.ENDC							/(161)
	CAL	RQTTN	/REQUEST TASK TERMINATION NOTICE TASK
	JMP	RETX
RQTTN	1		/CAL PARAMETER BLOCK TO REQUEST TASK TO
	0		/OUTPUT TASK TERMINATION NOTICE.
	.SIXBT	"TNTERM"
	0
 .TITLE *** CLOCK INTERRUPT SERVICE
/
	INTENTRY CLKINT,L.MAC	/CLOCK INTERRUPT SERVICE ROUTINE ENTRY
/
	CLON		/CLEAR CLOCK OVERFLOW FLAG
/
TU	JMS*	(SLICE	/FIND OUT IF TIME SLICING IS ON AND IF SO
			/CHANGE THE ATL STATUS WORDS AS APPROPRIATE.
	ISZ	CISEC	/SKIP IF SIGNIFICANT EVENT COUNTER OVERFLOWS.
	JMP	TU1
	LAC	NTSCSE	/RESET THE SIGNIFICANT EVENT COUNTER FROM THE
	TCA		/"NUMBER OF TICKS SEPARATING CLOCK-GENERATED
	DAC	CISEC	/SIGNIFICANT EVENTS". GENERATE A GRATUITOUS
			/SIGNIFICANT EVENT (JUST TO KEEP THE SYSTEM
	.SET6		/GOING IN CASE ONE WAS MISSED).
TU1	LAC	(TT)	/SETUP TIME PARAMETER POINTER TO TICKS.
	DAC	TMUX
	LAC	TPS	/UPDATE TICKS COUNT -- OVERFLOW?
	JMS	TMU
	JMP	CQX	/NO -- CHECK CLOCK QUEUE
	ISZ	SSM	/YES -- UPDATE SECONDS-SINCE-MIDNITE COUNT
	LAC	(D60)	/AND UPDATE SECONDS COUNT -- OVERFLOW?
	JMS	TMU
	JMP	CQX	/NO -- CHECK CLOCK QUEUE
	LAC	(D60)	/YES -- UPDATE MINUTES COUNT -- OVERFLOW?
	JMS	TMU
	JMP	CQX	/NO -- CHECK CLOCK QUEUE
	LAC	(D24)	/YES -- UPDATE HOURS COUNT -- OVERFLOW?
	JMS	TMU
	JMP	CQX	/NO -- CHECK CLOCK QUEUE
	JMP	CU	/YES -- UPDATE CALENDAR AND CHECK HOURS,
			/SECONDS, MINUTES, & TICKS QUEUES
/
/ TMU -- TIME UPDATE SUBROUTINE.  ENTER WITH 'TMUX' POINTING TO
/ WORD (TT, SS, MM, OR HH) TO INCREMENT, AND AC CONTAINING THE
/ OVERFLOW VALUE.  IF OVERFLOW, THE WORD IS ZEROED AND THE
/ POINTER ('TMUX') IS INCREMENTED.
/
/ RETURN AT JMS+2 IF OVERFLOW
/ RETURN AT JMS+1 IF NO OVERFLOW
/
TMU	0
	ISZ*	TMUX	/INCREMENT WORD
	SAD*	TMUX	/OVERFLOW?
	SKP
	JMP*	TMU	/NO -- RETURN AT JMS+1
	DZM*	TMUX	/YES -- ZERO WORD, INCREMENT POINTER,
	ISZ	TMUX	/AND RETURN AT JMS+2
	ISZ	TMU
	JMP*	TMU
/
TMUX	0		/POINTER
/
/ CALENDAR UPDATE ROUTINE -- GOOD THRU DEC 31, 1999
/
CU	ISZ	DSR	/AUGMENT DAYS RUNNING COUNT
	NOP
	DZM	SSM	/RESET SECONDS SINCE MIDNITE
	ISZ	DA	/INCREMENT DAY-OF-MONTH
	LAC	MO	/DETERMINE NUMBER OF DAYS THIS MONTH
	SAD	(02)	/FEBRUARY?
	JMP	CU1	/YES -- SET AC=29 OR 30 (FOR LEAP YEAR)
	LAC	MO	/NO -- SET AC=31 OR 32 (PER MONTH MAP)
	XOR	(LRS 0)
	DAC	.+2
	LAC	(012652)/(MONTH MAP -- BIT SET FOR 31 DAY MONTHS)
	XX		/(LONG RIGHT SHIFT ONE BIT PER MONTH NUMBER)
	AND	(01)
	TAD	(D31)
	JMP	CU2
CU1	LAC	YR
	AND	(03)
	SNA!CLA
	IAC
	TAD	(D29)
CU2	SAD	DA	/AC CONTAINS ONE MORE THAN NUMBER OF DAYS
	SKP		/THIS MONTH.  HAS DAY COUNT OVERFLOWED MONTH?
	JMP	CQX	/NO -- CALENDAR UPDATE COMPLETE
	LAC	(+1)	/YES -- SET DAY TO ONE AND INCREMENT MONTH
	DAC	DA
	ISZ	MO
	LAC	MO	/MONTH OVERFLOW?
	SAD	(D13)
	SKP
	JMP	CQX	/NO -- CALENDAR UPDATE COMPLETE
	LAC	(+1)	/YES -- SET MONTH TO ONE AND INCREMENT YEAR
	DAC	MO
	ISZ	YR
/
/
/ CLOCK QUEUE EXAMINATION
/
CQX	LAC	(CKQ)	/SETUP XR TO ACCESS FIRST NODE
	PAX		/OF CLOCK QUEUE (DEQUE).
	LAC	C.FP,X
	SAD	(CKQ)	/EMPTY DEQUE?
	JMP	CIX	/YES -- EXIT CLOCK INTERRUPT SERVICE ROUTINE
	PAX		/NO -- SETUP XR TO ACCESS FIRST NODE
	ISZ	C.ST,X	/"DECREMENT" "SCHEDULE TICKS" -- ZERO?
	JMP	CIX	/NO -- EXIT CLOCK INTERRUPT SERVICE ROUTINE
	LAC	C.SS,X	/YES -- "SCHEDULE SECONDS" ZERO?
	SNA
	JMP	CINCD	/YES -- A NODE HAS COME DUE
	ISZ	C.SS,X	/NO -- "DECREMENT" "SCHEDULE SECONDS," RESET
	NOP		/"SCHEDULE TICKS" TO A WHOLE SECOND, AND
	LAC	CTPS	/EXIT CLOCK INTERRUPT SERVICE ROUTINE.
	DAC	C.ST,X
	JMP	CIX
/
CINCD	PXA		/SAVE ADDRESS OF CLOCK QUEUE NODE
	DAC	CICNA	/AND REMOVE NODE FROM DEQUE
	DAC	R1
	JMS	NDEL	/(R1, R2, R6, XR, & AC ARE ALTERED)
	LAC	CICNA	/RESTORE XR
	PAX
/
	LAC	C.TI,X	/EXAMINE TYPE INDICATOR
	SAD	(6)	/NUL NODE?
	JMP	CIRTP	/YES -- RETURN NODE TO POOL
	SAD	(5)	/NO -- MARK TIME NODE?
	JMP	CIMT	/YES -- SET EV & RETURN NODE TO POOL
			/NO -- REQUEST A TASK
/
	LAC	C.PE,X	/SAVE REQUEST PRIORITY
	DAC	CIPRI
	LAC	C.SP,X	/SAVE STL NODE ADDRESS
	DAC	CISNA
	PAX		/SET XR TO EXAMINE STL NODE
	.INH		///IS TASK ACTIVE, SET TO BE REMOVED ON EXIT,
	LAC	S.DP,X	///OR DISABLED?
	AND	(730000 ///OR DISABLED, OR IN PARTITION TROUBLE
	SZA		///
	JMP	CIRQ2	///YES -- SKIP REQUEST
	LAC	S.DP,X	///NO -- FLAG TASK ACTIVE
	XOR	(400000)///
	.ENB		///
	DAC	S.DP,X	///
/
	JMS	PENP	/PICK AN EMPTY NODE FROM POOL
			/(R1, R6, XR, & AC ARE ALTERED)
			/IS POOL EMPTY?
	JMP	CIRQ1	/YES -- SKIP REQUEST
	IAC		/SETUP AUTO-INCREMENT REGISTER X13
	DAC	X13	/TO FILL NODE PICKED FROM POOL
			/FOR ENTRY INTO ACTIVE TASK LIST
	LAC	CISNA	/SETUP XR TO ACCESS STL NODE
	PAX
	LAC	S.N1,X	/SET TASK NAME INTO NODE FOR ATL
	DAC*	X13
	LAC	S.N2,X
	DAC*	X13
	LAC	CIPRI	/SET RUN PRIORITY
	DAC*	X13
	LAC	S.PB,X	/SET PARTITION BLOCK ADDRESS
	DAC*	X13
	PXA		/SET STL NODE ADDRESS
	DAC*	X13
	LAC	S.DP,X	/SET TASK STATUS
	AND	(040000)/   1 -- IMAGE ON DISK
	SZA!CLA		/   4 -- FIXED IN CORE
	AAC	+3
	IAC
	DAC*	X13
	LAC	S.EP,X	/SET ENTRY POINT
	DAC*	X13
	DZM* X13	/ CLEAR THE MAPPING INFORMATION.	/(172)
/
	LAC	(ATKL)	/ADD NODE TO ACTIVE TASK LIST PER
	DAC	R1	/PRIORITY
	JMS	SPRI	/(R1, R2, R3, R6, XR, & AC ARE ALTERED)
/
	.SET6		/DECLARE A SIGNIFICANT EVENT
/
	JMP	CIRSX	/TASK HAS BEEN REQUESTED
/
CIRQ1	ISZ	SE.EP	/TASK NOT REQUESTED -- POOL EMPTY -- RECORD
	NOP		/"SYSTEM ERROR", CLEAR ACTIVE FLAG IN STL NODE,
	.INH		///AND RESCHEDULE IF APPROPRIATE.
	LAC	CISNA	///
	PAX		///
	LAC	S.DP,X	///
	AND	(377777)///
	.ENB		///
	DAC	S.DP,X	///
	JMP	CIRSX
/
CIRQ2	.ENB		/TASK NOT REQUESTED -- ACTIVE OR DISABLED --
			/ENABLE INTERRUPTS AND RESCHEDULE IF
			/APPROPRIATE.
/
CIRSX	LAC	CICNA	/SETUP XR TO ACCESS CLOCK QUEUE NODE
	PAX
	LAC	C.TI,X	/IS TASK TO BE RE-SCHEDULED?
	SNA
	JMP	CIRTP	/NO -- RETURN CLOCK NODE TO POOL
	LAC	C.RS,X	/YES -- RESET SCHEDULE INCREMENT
	DAC	CQIDS	/AND ENTER IN CLOCK QUEUE.
	LAC	C.RT,X
	DAC	CQIDT
	PXA
	DAC	R2
	JMS	CQI
	JMP	CIENN	/EXAMINE NEXT NODE
/
CIMT	LAC	C.PE,X	/A MARK TIME INTERVAL HAS ELAPSED -- SET
	AAC	-1	/EVENT VARIABLE TO +1, DECREMENT TRANSFERS
	DAC	X15	/PENDING COUNT (IF NORMAL MODE REQUESTOR), 
	CLA!IAC		/DECLARE A SIGNIFICANT EVENT, AND RETURN NODE
	DAC*	X15	/TO POOL.
/
	LAC	C.SP,X	/ SET XR TO PARTITION BLOCK NODE ADDRESS/(173)
	PAX
	.INH		///
	LAC P.TP,X	///FETCH TRANSFER PENDING COUNT.	/(173)
	SZA		///IF IT'S ALREADY 0 IGNORE THIS REQUEST/(173)
	AAC -1		///OTHERWISE DECREMENT THE COUNTE.	/(173)
	DAC	P.TP,X	///
	.ENB		///
/
	.SET6		///					/(173)
/
CIRTP	LAC	(POOL)	/A CLOCK QUEUE NODE IS NO LONGER NEEDED,
	DAC	R1	/RETURN IT TO THE POOL
	LAC	CICNA
	DAC	R2
	JMS	NADD	/(R2, R6, XR, AND AC ARE ALTERED)
/
CIENN	LAC	(CKQ)	/EXAMINE NEXT "NODE"
	PAX
	LAC	C.FP,X	/LIST HEAD (END OF DEQUE)?
	SAD	(CKQ)
	JMP	CIX	/YES -- EXIT CLOCK INT SERVICE ROUTINE
	PAX		/NO -- SETUP XR TO EXAMINE NODE
	LAC	C.ST,X	/IS NODE DUE AT SAME TIME AS
	SZA		/PREVIOUS NODE?
	JMP	CIX	/NO -- EXIT CLOCK INT SERVICE ROUTINE
	JMP	CINCD	/YES -- PROCESS
/
CIX	LAW	-1	/DECREMENT REAL TIME CLOCK
	.INH		///
	TAD	7	///
/ IF THE CLOCK INCREMENTS HERE, BETWEEN TAD & DAC, A TICK WILL
/ BE LOST.  SINCE CLOCK INTERRUPT SERVICE TIME NORMALLY IS 
/ LESS THAN THE CLOCK PERIOD, THIS IS HIGHLY IMPROBABLE,
/ AND INHIBITING INTERRUPTS MAKES IT MORE SO.  THIS IS
/ THE ONLY KNOWN FLAKEY SPOT IN RSX!  CAN IT BE DONE BETTER???
	DAC	7	///
	.ENB		///
	SMA		///IS CLOCK BEHIND?
	JMP	TU	/YES -- CATCH UP
	INTEXIT	CLKINT	/NO -- EXIT CLOCK INTERRUPT SERVICE ROUTINE
/
CICNA	0		/CLOCK NODE ADDRESS
CISNA	0		/STL NODE ADDRESS
CIPRI	0		/REQUEST PRIORITY
CISEC	-1		/COUNTER. WHEN ZERO, GENERATE A SIGNIFICANT EVENT.
	.TITLE *** 'IORD' I/O RUNDOWN TASK
/
/ THIS TASK IS TRIGGERED INTO EXECUTION WHENEVER THE 'EXIT' DIRECTIVE
/ DETECTS A NORMAL MODE TASK FOR WHICH THE COUNT OF PENDING TRANSFERS
/ TO/FROM ITS PARTITION IS NON-0.
/
/ THIS TASK IS ALWAYS CORE RESIDENT, AND RESIDES IN A "PARTITION" THAT
/ IS NOT AVAILABLE FOR OTHER TASKS. IT CONTAINS A "PARTITION BLOCK" THAT
/ IS ONLY USED AS A REGISTER SAVE AREA (WHEN THE TASK IS INTERRUPTED BY
/ THE EXECUTIVE). IT IS NOT A PART OF THE "PARTITION BLOCK DESCRIPTIONS
/ LIST.								/(161)
/
/ IT CONTAINS AN ACTIVE TASK LIST NODE WITH STATUS INITIALLY SET TO 4,
/ INDICATING IT IS READY TO BE RUN. WHEN THE TASK IS IDLE, IT WILL
/ "WAITFOR" ITS TRIGGER EVENT VARIABLE TO BE SET NON-0 BEFORE RESUMING
/ OPERATION.
/
/ THIS TASK IS NEVER REQUESTED, NOR DOES IT EVER EXIT; THEREFORE, THERE
/ IS NO SYSTEM TASK LIST ENTRY FOR IT.
/
/ WHENEVER AN ATL NODE IS INSERTED IN THE I/O RUNDOWN DEQUE ('IORDQ'),
/ 'IORD' IS TRIGGERED. NODES APPEAR IN ORDER OF TASK PRIORITY.
/
/ FOR EVERY TASK TO BE ABORTED, FIRST ALL MARK TIME REQUESTS BY THE TASK
/ ARE NULLIFIED. THEN, A SCAN OF THE PHYSICAL DEVICE LIST IS MADE TO
/ FIND ACTIVE I/O HANDLERS. EACH I/O HANDLER IS CALLED IN TURN TO ABORT
/ I/O FOR THAT TASK BY THE PLACEMENT IN THE HANDLER'S FIRST I/O REQUEST
/ QUEUE OF A PRIORITY ZERO "ABORT" DIRECTIVE.
/
IORDTW	CAL	IORDWT	/WAITFOR TASK TRIGGER.
	DZM	IORDTG	/CLEAR THE TRIGGER EVENT VARIABLE.
/
IORDNX	LAC	(IORDQ)	/PICK NODE FROM I/O RUNDOWN QUEUE.
	DAC	R1
	JMS	PICK	/(R2, R6, XR & AC ARE ALTERED).
			/QUEUE EMPTY?
	JMP	IORDTW	/YES.
	PAX		/NO -- SET XR WITH NODE'S ADDRESS.
	DAC IORDAT	/ SAVE ATL NODE FOR MULTIACCESS.	/(161)
	LAC	A.N1,X	/SAVE TASK NAME IN 'UNMARK' CPB.
	DAC	IORDUM+2
	LAC	A.N2,X
	DAC	IORDUM+3
	LAC	A.PB,X	/TASK'S PARTITION BLOCK ADDRESS.
	DAC	IORDPB
	LAC	A.SN,X	/TASK'S STL NODE ADDRESS.
	DAC	IORDSN
/
	CAL	IORDUM	/CANCEL TASK'S MARK TIME REQUESTS.
/
	LAC	IORDPB	/PARTITION BLOCK ADDRESS.
	PAX
	LAC	P.TP,X	/IS THE 'TRANSFERS PENDING' COUNT NOW 0?
	SNA
	JMP	IORDFR	/YES -- FREE UP THE PARTITION AND CHANGE THE STL
			/NODE TO INDICATE TASK INACTIVE.
/
/ SCAN THE PHYSICAL DEVICE LIST FOR ACTIVE I/O HANDLERS.
/
	DZM	IORDPN	/SET THE "PREVIOUS DEVICE NAME" TO ZERO.
	LAC	(PDVL)	/POINTER TO PDVL LISTHEAD.
	DAC	IORDPD
/
IORDLP	LAC	IORDPD	/SET XR TO PDVL NODE ADDRESS.
	PAX
	LAC	0,X	/GET ADDRESS OF NEXT NODE.
	SAD	(PDVL)	/END OF DEQUE?
	JMP	IORDTC	/YES.
	DAC	IORDPD	/NO -- SAVE PDVL NODE ADDRESS.
/
/ COMPARE THE DEVICE NAME OF THIS PDVL NODE WITH THE PRECEDING ONE TO
/ SEE IF THIS DEVICE HAS ALREADY BEEN PROCESSED ONCE. THE SYSTEM CON-
/ FIGURATION TASK HAS ORDERED PDVL NODES SO THAT NODES FOR THE SAME
/ DEVICE ARE ADJACENTLY LINKED.
/
	PAX
	LAC	2,X	/COMPARE WITH THE PRECEDING DEVICE NAME.
	SAD	IORDPN
	JMP	IORDLP	/SAME -- GO ON TO NEXT NODE.
	DAC	IORDPN	/SAVE NEW NAME.
	SKP
/
/ PICK AN EMPTY NODE FROM THE POOL AND CONSTRUCT AN "ABORT" REQUEST.
/
	CAL	(5)	/WAIT FOR NEXT SIGNIFICANT EVENT. MAYBE THEN
			/A NODE WILL BE FREE.
	JMS	PENP	/(R1, R6, XR & AC ARE ALTERED).
			/WAS A NODE FOUND?
	JMP	.-2	/NO.
	PAX		/YES -- SET NODE'S ADDRESS IN THE XR.
	LAC	IORDSN	/STORE STL NODE ADDRESS.
	DAC	2,X
	LAC	IORDPB	/STORE PARTITION BLOCK ADDRESS.
	DAC	3,X
	DZM	4,X	/SET PRIORITY CODE OF ZERO.
	LAC	(17)	/SET LUN=0 AND I/O FUNCTION CODE=17.
	DAC	5,X
	LAC	(IORDEV) /SET EVENT VARIABLE ADDRESS.
	DAC	6,X
	DZM	IORDEV
/
/ CHECK IF THE CURRENT PDVL NODE IS FOR THE PAPER TAPE PUNCH. IF SO,
/ PREPARE TO EXECUTE A RESUME DIRECTIVE BECAUSE THERE IS A SITUATION IN
/ WHICH THE PUNCH HANDLER WILL SUSPEND ITS EXECUTION.
/
	LAC	IORDPD	/SET THE XR WITH THE PDVL NODE ADDRESS.
	PAX
	AAC	+D.QF	/SET R1 WITH THE ADDRESS OF THE I/O REQUEST DEQUE
	DAC	R1	/FOR THE CALL BELOW TO "SPRI".
	LAC	D.N1,X	/IS THIS THE NODE FOR "PP"?
	SAD	IORDPP	/(.SIXBT "PP").
	JMP	.+3	/YES.
	LAC	(NOP)	/NO.
	SKP
	LAC	(CAL IORDRS)
	DAC	IORDXX
/
/ CHECK IF THE CURRENT PDVL NODE POINTS TO AN ACTIVE I/O HANDLER. MAKE
/ THIS CHECK AT API LEVEL 6 SO THAT THE MCR FUNCTION TASK 'REASSIGN'
/ CAN'T RUN.
/
	LAC	(400002)/RAISE TO API LEVEL 6.
	ISA
	LAC	D.TG,X	//IS THE HANDLER ACTIVE?
	SNA		//
	JMP	IORDNA	//NO -- TRY NEXT PDVL NODE.
	DAC	IORDHT	//YES -- SAVE HANDLER'S TRIGGER EVENT VARIABLE ADDRESS.
	.INH		//INHIBIT INTERRUPTS.
	LAC*	IORDHT	///SET BIT 2 IN THE HANDLER'S TRIGGER TO INDICATE
	AND	(677777)///A QUEUED ABORT REQUEST.
	TAD	(100000)///
	.ENB		///ENABLE INTERRUPTS.
	DAC*	IORDHT	///
	LAC	IORDPB	//SET XR WITH TASK'S PARTITION BLOCK NODE ADDRESS.
	PAX		//
	ISZ	P.TP,X	//ADD 1 TO THE 'TRANSFERS PENDING' COUNT SINCE AN
	NOP		//I/O REQUEST IS ABOUT TO BE QUEUED.
	JMS	SPRI	//INSERT NODE BY PRIORITY.
			//(R1, R2, R3, R6, XR & AC ARE ALTERED).
	.SET6		/DECLARE A SIGNIFICANT EVENT.
	DBK		//DEBREAK BACK TO LEVEL 7.
IORDXX	XX		//EITHER "NOP" OR "CAL IORDRS".
	CAL	IORDWF	/WAITFOR HANDLER TO RESPOND.
/
/ THE HANDLER HAS RESPONDED TO THE ABORT REQUEST. IS THE 'TRANSFERS
/ PENDING' COUNT NOW ZERO?
/
	LAC	IORDPB	/SET XR WITH PARTITION BLOCK ADDRESS.
	PAX
	LAC	P.TP,X
	SZA
	JMP	IORDLP	/COUNT NOT 0 -- CONTINUE SCAN.
/
/ I/O RUNDOWN FOR THIS TASK IS COMPLETE.
/
	.IFUND NOMAC						/(161)
IORDFR	LAC IORDPB	/ FETCH TASK'S PARTITION BLOCK ADDRESS.	/(161)
	PAX		/ SET UP TO ACCESS THE PARTITION BLOCK	/(161)
	LAC P.FW,X	/ FETCH MULTIACCESS INFO FROM PBDL.	/(161)
	AND (760)	/ EXTRACT USER NUMBER FROM FLAG WORDS.	/(161)
	SNA		/ AC >< 0 IF TASK IS MULTIACCESS.	/(161)
	JMP IORDF1	/ NORMAL EXIT.				/(161)
	LAC IORDAT	/ FETCH ATL NODE ADDRESS.		/(161)
	PAX		/ SET UP TO ACCESS ATL.			/(161)
	DZM T.EC,X	/ SET NORMAL EXIT FOR TDV.		/(161)
	LAC (TDV.EQ)	/ FETCH PROPER POOL HEAD.		/(161)
	JMP IORDF2	/ REJOIN COMMON CODE.			/(161)
IORDF1=.							/(161)
	.ENDC							/(161)
	.IFDEF NOMAC						/(161)
IORDFR=.							/(161)
	.ENDC							/(161)
	LAC (POOL)	/ FETCH NORMAL RETURN LIST.		/(161)
IORDF2	DAC R1		/ STORE LIST ADDRESS FOR NADD.		/(161)
	LAC IORDAT	/ FETCH NODE ADDRESS.			/(161)
	DAC R2		/ SET UP NODE ADDRESS FOR NADD.		/(161)
	JMS NADD	/ ADD NODE TO LIST.			/(161)
			/ (R2,R6,XR & AC ARE ALTERET).		/(161)
	LAC IORDSN	/ FETCH TASK'S STL NODE ADDRESS FOR	/(161)
	PAX		/ FREEUP.				/(161)
	JMS	FREEUP	/SUBROUTINE, USED ALSO BY "EXIT", TO FREE TASK'S
			/PARTITION IF TASK IS NOT FIXED IN CORE, AND TO
			/SET TASK INACTIVE IN ITS STL NODE.
			/(XR & AC ARE ALTERED).
	.SET6		/DECLARE A SIGNIFICANT EVENT.
	JMP	IORDNX	/ANY OTHER TASKS TO ABORT?
/
/ TEST THE "TRANSFERS PENDING" COUNT. IF IT IS STILL NON-0, MARK TIME
/ FOR 2 TICKS IN CASE A HANDLER OF PRIORITY LOWER THAN IOCD HAS SET THE
/ EVENT VARIABLE BEFORE DECREMENTING THE TRANSFERS PENDING COUNT. IF THE
/ COUNT IS STILL NON-0, ENTER A NODE IN THE TASK TERMINATION NOTICE
/ REQUEST LIST IN ORDER TO PRINT A MESSAGE TO THAT EFFECT. AN I/O HANDLER
/ HAS GOOFED SOMEWHERE.
/
IORDTC	LAC	IORDPB	/SET XR WITH PARTITION BLOCK ADDRESS.
	PAX
	LAC	P.TP,X
	SNA
	JMP	IORDFR	/COUNT IS ZERO.
	CAL	IORDMK	/MARK TIME FOR 2 TICKS.
	CAL	IORDWF
	LAC	IORDPB	/SET XR WITH PARTITION BLOCK ADDRESS.
	PAX
	LAC	P.TP,X
	SNA
	JMP	IORDFR	/COUNT IS NOW ZERO.
	JMS	PENP	/PICK AN EMPTY NODE FROM THE POOL.
			/(R1, R6, XR & AC ARE ALTERED).
			/IS THE POOL EMPTY?
	JMP	IORDNM	/YES -- CAN'T PRINT THE MESSAGE.
	IAC		/ SET UP X13 TO FILL THE NODE WITH TERMIN-
	DAC	X13	/ATION NOTICE INFORMATION.
	LAC	IORDSN	/SET XR WITH THE TASK'S STL NODE ADDRESS.
	PAX
	LAC	S.N1,X
	DAC*	X13	/STORE TASK NAME (FIRST HALF).
	LAC	S.N2,X
	DAC*	X13	/STORE TASK NAME (SECOND HALF).
	LAC	(4)	/SET TERMINATION INDICATOR FOR "NON-0 TRANSFERS
	DAC*	X13	/PENDING COUNT".
	LAC	IORDPB	/SET THE XR WITH THE TASK'S PARTITION BLOCK
	PAX		/NODE ADDRESS.
	LAC	P.TP,X
	DZM	P.TP,X
	DAC*	X13
	.IFUND NOMAC						/(161)
	LAC P.FW,X	/ FETCH FLAG WORDS.			/(161)
	AND (760)	/ EXTRACT USER NUMBER.			/(161)
	PAL		/ SAVE FOR LATER TEST.			/(161)
	SNA		/ IS THIS A MULTIACCESS TASK?		/(161)
	JMP IORTC1	/ NO.					/(161)
	LAC R2		/ FETCH TERMINATION NOTICE NODE ADDRESS	/(161)
	PAX		/ SET UP TO ACCESS NODE.		/(161)
	CLA!IAC		/ TERMINATION NOTICE EXIT CODE IS ONE	/(161)
	DAC T.EC,X	/ SET CODE IN NODE.			/(161)
	LAC (TDV.EQ)	/ FETCH CORRECT NODE LIST.		/(161)
	JMP IORTC2	/ REJOIN COMMON CODE.			/(161)
IORTC1=.							/(161)
	.ENDC							/(161)
	LAC	(TNRL)	/ADD NODE TO TERMINATION NOTICE REQUEST LIST.
IORTC2	DAC R1		/ ADD NODE TO CORRECT LIST.		/(161)
	JMS	NADD	/(R2, R6, XR & AC ARE ALTERED).
	.IFUND NOMAC						/(161)
	PLA		/ FETCH MULTIACCESS USER NUMBER FROM LR	/(161)
	SNA		/ AC >< 0 => MULTIACCESS.		/(161)
	.ENDC							/(161)
	CAL	RQTTN	/REQUEST THE TASK TERMINATION NOTICE TASK.
IORDNM	JMP	IORDFR	/FREE UP THE PARTITION AND FLAG THE TASK
			/INACTIVE IN ITS STL NODE.
/
/ THE CURRENT PDVL NODE DOESN'T POINT TO AN ACTIVE I/O HANDLER BECAUSE
/ THE TRIGGER EVENT VARIABLE POINTER CONTAINS ZERO.
/
IORDNA	DBK		//DEBREAK TO LEVEL 7.
	LAC	(POOL)	//EMPTY POOL LISTHEAD.
	DAC	R1
	JMS	NADD	/ADD UNUSED ABORT NODE TO THE EMPTY POOL.
			/(R2, R6, XR & AC ARE ALTERED).
	JMP	IORDLP	/TRY NEXT PDVL NODE.
/
/ VARIABLES.
/
IORDAT	0		/ IORD NODE ADDRESS.			/(161)
IORDTG	0		/IORD'S TRIGGER EVENT VARIABLE.
IORDEV	0		/IORD'S EVENT VARIABLE.
IORDPD	0		/PHYSICAL DEVICE NODE ADDRESS.
IORDPN	0		/NAME OF THE PREVIOUS DEVICE IN THE PDVL
			/NODE MOST RECENTLY SCANNED.
IORDSN	0		/TASK'S STL NODE ADDRESS.
IORDPB	0		/TASK'S PARTITION BLOCK ADDRESS.
IORDHT	0		/I/O HANDLER'S TRIGGER EVENT VARIABLE ADDRESS.
IORDPP	.SIXBT	"PP"	/PHYSICAL DEVICE NAME FOR THE PAPER TAPE PUNCH.
/
/ CAL PARAMETER BLOCKS.
/
IORDUM	23		/"UNMARK" CPB.
	0		/NO EVENT VARIABLE.
	XX		/TASK NAME (FIRST HALF).
	XX		/TASK NAME (SECOND HALF).
/
IORDMK	13		/"MARK TIME" CPB.
	IORDEV
	2		/FOR 2
	1		/TICKS.
/
IORDRS	07		/"RESUME" CPB.
	0		/NO EVENT VARIABLE.
	.SIXBT	"PP."	/TASK NAME (FIRST HALF).
	.SIXBT	"..."	/TASK NAME (SECOND HALF).
	0		/RESUME FOLLOWING THE SUSPEND.
/
IORDWT	20		/"WAITFOR" CPB.
	IORDTG		/THE TRIGGER EVENT VARIABLE.
/
IORDWF	20		/"WAITFOR" CPB.
	IORDEV		/THE EVENT VARIABLE.
/
/ ACTIVE TASK LIST NODE.
/
IORD	SFG		/FORWARD LINKAGE.
	TTY		/BACKWARD LINKAGE.
	.SIXBT	"IOR"	/TASK NAME (FIRST HALF).
	.SIXBT	"D@@"	/TASK NAME (SECOND HALF).
	10		/TASK PRIORITY (SEE NOTE BELOW).
	IORDIC-P.TP	/"PARTITION BLOCK" ADDRESS.		/(173)
	0		/STL NODE ADDRESS (NONE).
	4		/TASK STATUS (INITIALLY READY TO RUN).
	IORDTW		/RESUMPTION ADDRESS.
	0		/EVENT VARIABLE.
	.IFPNZ	NDSZMT
	.REPT	NDSZMT
	0
	.ENDC
/
/ THE PRIORITY OF "IORD" MUST BE LOWER THAN THAT OF ALL I/O HANDLER TASKS
/ IN ORDER TO AVOID AN ERRONEOUS ERROR MESSAGE INDICATING THAT THE TRANS-
/ FERS PENDING COUNT IS NON-0. THE PROBLEM ARISES WHEN THE LAST HANDLER
/ IN THE PHYSICAL DEVICE LIST IS OF LOWER PRIORITY THAN "IORD" AND
/ IT SETS IORD'S EVENT VARIABLE AND DECLARES A SIGNIFICANT EVENT BEFORE
/ CALLING "IOCD" TO DECREMENT THE TRANSFERS PENDING COUNT. SINCE "IORD"
/ IS OF HIGHER PRIORITY, IT GETS CONTROL BEFORE THE COUNT IS DECREMENTED,
/ HENCE THE ERRONEOUS MESSAGE. IF A HANDLER HAPPENS TO BE INSTALLED WITH
/ A LOWER PRIORITY, "IORD" GIVES IT A CHANCE BY MARKING TIME FOR TWO
/ CLOCK TICKS BEFORE CHECKING THE COUNT FOR A SECOND TIME. BY THE WAY,
/ THERE IS SPECIAL CODE IN THE "ABORT" MCR FUNCTION TO AVOID ABORTING
/ "IORD".
/
/ "PARTITION BLOCK" (REGISTER SAVE USE ONLY).
/
IORDIC	SHPB,L.MAC
/
	.IFUND L.ALL						/EAG:202
	.NOLST							/(176)
	.ENDC							/EAG:202
	.IFDEF %QDBG						/(176)
	.LST							/(176)
	.TITLE *** SCAN DEQUEUES FOR MULTIPLE NODES ***		/(176)
								/(176)
/ THIS SET OF SUBROUTINES IS AN ATTEMPT AT AN INTELLIGENT	/(176)
/ DEBUGGING AID FOR RSX. IT IS CALLED EACH TIME A NODE IS ADDED	/(176)
/ TO ANY LIST. IT'S FUNCTION IS TO  SCAN ALL SIGNIFICANT SMALL	/(176)
/ NODE DEQUES FOR THE NODE ADDRESS. THIS CODE IS INCLUDED BY	/(176)
/ STATING THE ASSEMBLY PARAMETER %QDBG				/(176)
/ CALL FORMAT:							/(176)
/								/(176)
/	JMS QDBG						/(176)
/	LAC NODEADDR						/(176)
/	...		/ RETURN POINT. NO REGISTERS ALTERED.	/(176)
								/(176)
QDBG	XX		/ ENTRY POINT.				/(176)
	.INH		/ THE Q SCANS WILL BE RUN INHIBITED.	/(176)
	DAC Q.ACS	/ SAVE THE AC.				/(176)
	PXA		/ SAVE THE XR.				/(176)
	DAC Q.XRS						/(176)
	XCT* QDBG	/ FETCH THE NODE ADDRESS.		/(176)
	DAC Q.NODE	/ NODE ADDRESS.				/(176)
	ISZ QDBG	/ SET UP RETURN ADDRESS.		/(176)
								/(176)
	.IFUND NOMAC						/(176)
	LAC (TDV.EQ)						/(176)
	JMS QSCAN						/(176)
	HLT							/(176)
	.ENDC							/(176)
								/(176)
	LAC (TNRL)						/(176)
	JMS QSCAN						/(176)
	HLT							/(176)
								/(176)
	LAC (IORDQ)						/(176)
	JMS QSCAN						/(176)
	HLT							/(176)
								/(176)
	LAC (POOL)	/ FETCH LIST HEAD.			/(176)
	JMS QSCAN	/ SCAN LIST.				/(176)
	HLT		/ ERROR.				/(176)
								/(176)
	LAC (STKL)	/ FETCH LIST HEAD.			/(176)
	JMS QSCAN	/ SCAN LIST.				/(176)
	HLT		/ ERROR.				/(176)
								/(176)
	LAC (ATKL)	/ FETCH LIST HEAD.			/(176)
	JMS QSCAN	/ SCAN LIST.				/(176)
	HLT		/ ERROR.				/(176)
								/(176)
	LAC (CKQ)	/ FETCH LIST HEAD.			/(176)
	JMS QSCAN	/ SCAN LIST.				/(176)
	HLT		/ ERROR.				/(176)
								/(176)
	LAC PDVL	/ FETCH PDVL NODE ADDRESS.		/(176)
Q.PLP	DAC Q.PDVL	/ SET UP ACCESS.			/(176)
	SAD (PDVL)	/ DONE WITH SCAN?.			/(176)
	JMP Q.DONE	/ YES.					/(176)
	AAC D.QF	/ CALC DEQUEUE ADDRESS.			/(176)
	JMS QSCAN	/ SCAN LIST.				/(176)
	HLT		/ ERROR.				/(176)
	LAC* Q.PDVL	/ FETCH NEXT NODE ADDRESS.		/(176)
	JMP Q.PLP	/ CONTINUE SCAN.			/(176)
								/(176)
Q.DONE	LAC Q.XRS	/ RESTOR XR.				/(176)
	PAX							/(176)
	LAC Q.ACS	/ RESTORE AC.				/(176)
	JMP* QDBG	/ RETURN TO CALLER.			/(176)
	.EJECT							/(176)
								/(176)
QSCAN	XX		/ SCAN AN ARBITRARY QUE.		/(176)
	DAC Q.LH	/SAVE LIST HEAD ADDRESS.		/(176)
Q.SL	PAX		/ ACCESS NEXT NODE.			/(176)
	LAC 0,X		/ FETCH FP.				/(176)
	SAD Q.LH	/ END OF LIST?				/(176)
	JMP QS.DON	/ YES.					/(176)
	SAD Q.NODE	/ SAME ADDRESS?				/(176)
	JMP* QSCAN	/ YES, TAKE ERROR EXIT.			/(176)
	JMP Q.SL	/ CHECK NEXT NODE.			/(176)
								/(176)
QS.DON	ISZ QSCAN	/ TAKE NORMAL EXIT.			/(176)
	JMP* QSCAN						/(176)
								/(176)
Q.LH	XX		/ LIST HEAD FOR QSCAN.			/(176)
Q.NODE	XX		/ NODE ADDRESS TO SCAN FOR.		/(176)
Q.ACS	XX		/ AC SAVE AREA.				/(176)
Q.XRS	XX		/ XR SAVE AREA.				/(176)
Q.PDVL	XX		/ CURRENT PDVL NODE FOR I/O DEQUES.	/(176)
	.ENDC							/(176)
	.LST							/(176)
