	.TITLE +++ XVM/RSX EXECUTIVE VERSION 1B (PART 2) +++

/
/ 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

/
/
/
P2EDTN=200206	/PART TWO [OF SOURCE FILE] EDIT NUMBER
/ 162	26-FEB-76 (RCHM)	BEGINNING OF MULTIACCESS	/(162)
/				CODING. FIRST EDIT SETS UP MA	/(162)

/				CONTROL WORDS IN SCOM, DEFINES	/(162)

/				THE NO MULTIACCESS CONDITIONAL	/(162)

/				AND CONDITIONALIZES TDV AND	/(162)

/				XFRCMD, MODIFY TTY FOR TESTING	/(162)

/				OF THE SINGLE UNIT ABORT FUNCTION/(162)
/				INSTALL MCR IN PAGE 1 OF THE	/(162)
/				EXEC. ALL EDITS TO MCR HAVE BEEN/(162)
/				ALTERED TO READ 162. PART 1 OF	/(162)
/				THE EXEC HAS THE LIST OF MCR	/(162)
/				EDITS.				/(162)
/ 163-5 12-MAR-76 (SCR)		NEW TTY HANDLER		/\COMMENTS
/								/EAG:166
/ 166	24-MAR-76 (EAG)		MOVE TDV AND ALL FOLLOWING	/EAG:166
/				CODE TO PART 2 FROM PART 1.	/EAG:166
/ 167 25-MAR-76	(SCR)		CHANGE TTY ABORT;FIX RUBOUT	/(167)
/ 170 26-MAR-76 (SCR)		MINOR BUG FIX FOR 167		/(170)
/ 171	30-MAR-76 (RCHM)	EDIT TO MATCH 173 OF RSXP1.	/(171)
/ 172	06-APR-76 (RCHM)	FIX SCF TO REQUEST SAV RATHER	/(172)
/				THAN MCR.			/(172)
/ 173	12-APR-76 (SCR)		TTY FIXES; SINGLE <CR>; TAB SIMUL /(173)
/ 174	16-APR-76 (SCR)		MORE TTY FIXES.			/(174)
/ 175	21-APR-76 (RCHM)	MAKE SURE THAT SCF PUTS IN A 	/(175)
/				PDVL NODE FOR "BD0".		/(175)
/ 176	22-APR-76 (SCR)		MORE OF THE ROOT MEMORIAL TTY	/(176)
/				BUG. THIS TIME, ^U DIDN'T WORK	/(176)
/				QUITE RIGHT.			/(176)
/ 177	27-APR-76 (RCHM)	CLEAN UP THE EXEC INTERFACE TO	/(177)
/				THE SYSTEM CONFIGURATOR.	/(177)
/ 200	29-APR-76 (RCHM)	BUILD IN DISPAT PARTITION IF	/(200)
/				THE EXEC IS GOING TO BE FOR MA.	/(200)
/ 201	6-MAY-76 (SCR)		FIX TTY FOR PARITY ASSEMBLY
/								/EAG:202
/ 202	13-MAY-76 (EAG)		EDIT TO MATCH 202 OF PART 1.	/EAG:202
/				ADD L.ALL SELECTIVE LISTING	/EAG:202
/				PARAMETER.			/EAG:202
/				ALSO ADD A FIX TO SYSTEM CON-	/EAG:202
/				FIGURATOR FOR STEVE ROOT.  IT	/EAG:202
/				IS FOR THE S-R-I GLITCH.	/EAG:202
/								/EAG:202
/ 203	14-MAY-76 (MJH)		CHANGE TIME SLICING ROUTINE.
/ 204	17-MAY-76 (RCHM)	MINOR BUG FIX TO SLICER		/(204)
/ 205	26-MAY-76 (SCR-EAG)	FIX LISTING CONDITIONALS	/(205)
/ 206	27-MAY-76 (SCR)		TTY: PARITY=0; CONFLICT ON BIT USE /(206)
/
/ DATE OF LAST EDIT:  MAY 27, 1976
/ 
	.IFUND L.ALL						/EAG:202
	.NOLST							/EAG:202
	.ENDC							/EAG:202
	.IFDEF NOMAC						/EAG:202
	.IFDEF L.MCR						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
 .TITLE *** TASK DEVELOPMENT (TDV) DISPATCH ROUTINE
/
/ THE TDV DISPATCH ROUTINE IS A CORE RESIDENT TASK CALLED "TDV...",
/ WHICH IS REQUESTED BY THE TTY HANDLER WHENEVER A ^T IS TYPED ON
/ THE TDV TTY.
/
/ THIS TASK OUTPUTS A "TDV>" PROMPTING SYMBOL TO LUN 12, READS A LINE 
/ FROM LUN 12, CONSTRUCTS A TDV FUNCTION TASK NAME BY APPENDING THREE
/ DOTS (DECIMAL POINTS) TO THE FIRST THREE CHARACTERS OF THE COMMAND
/ STRING, AND REQUESTS THAT TASK.
/
/ THE RESTRICTED 'TRANSFER COMMAND' DIRECTIVE IS SETUP TO RESPOND ONCE
/ TO THE REQUESTED TASK, AND TO RETURN A +2 OR +1 EVENT VARIABLE FOR
/ SUCCESSFUL COMPLETION.  TWO INDICATES CAR RTN TERMINATION, AND ONE 
/ INDICATES ALTMODE TERMINATION.
/
/ THE TDV FUNCTION TASK IS EXPECTED TO ISSUE A 'TRANSFER COMMAND' DIRECTIVE
/ TO GET THE 5/7 PACKED COMMAND STRING. "TDV..." WAITS FOR THE LINE TO BE
/ TRANSFERRED AND EXITS (REGARDLESS OF LINE TERMINATION).
/
/ ONCE A TDV FUNCTION TASK HAS RECEIVED ITS COMMAND STRING THE TDV
/ DISPATCH TASK MAY BE STARTED VIA ^T AND ANOTHER LINE OF COMMAND
/ INPUT MAY BE READ WHILE THE PREVIOUS COMMAND(S) ARE BEING PERFORMED.
/
/ WHEN A TDV FUNCTION TASK REQUEST IS REJECTED BECAUSE THE TASK IS
/ STILL ACTIVE, THE TDV DISPATCH TASK WAITS FOR THE PREVIOUS  REQUEST 
/ TO FINISH.  HENCE ONLY ONE LEVEL OF TDV INPUT BUFFERING EXISTS.
/
/ IF A COMMAND INPUT LINE IS CAR RTN TERMINATED, THE TDV FUNCTION TASK
/ WILL REQUEST THE TDV DISPATCH TASK "TDV..." UPON EXIT (WHICH WILL BE
/ IGNORED IF ^T HAS BEEN TYPED DURING SERVICE AND THE DISPATCH TASK
/ IS WAITING FOR THE FUNCTION TASK TO EXIT).
/
TDVENT	CAL	TDVA12	/ATTACH LUN 12
/
	CAL	TDVP12	/WRITE "TDV>" PROMPTING SYMBOL ON LUN 12
/
	CAL	TDVR12	/READ COMMAND INPUT LINE FROM LUN 12
	CAL	TDVWF1
/
	LAC	TDVEV1	/SAVE TERMINATION INDICATOR (1:ALTMODE::2:CAR RTN)
	DAC	TC.EV	/FOR 'TRANSFER COMMAND DIRECTIVE', AND RETURN
	SAD	(1)	/CARRIAGE IF ALTMODE TERMINATION.
	CAL	TDVC12
/
	CAL	TDVD12	/DETACH LUN 12
/
	LAC	TDVLB+2	/FORM FIRST HALF OF TDV FUNCTION TASK NAME FROM
	LMQ		/FIRST THREE CHARACTERS OF 5/7 PACKED LINE OF
	LLS	10	/COMMAND INPUT, AND SET NAME HALF IN REQUEST
	RAR		/CPB.  IF LINE CONSISTS OF ONLY AN ALTMODE, EXIT
	AND	(177)	/TDV DISPATCH.  IF FIRST THREE CHARACTERS ARE "LOG",
	SAD	(175)	/DO NOT DISPATCH.
	CAL	(10)
	SAD	(15)	/READ ANOTHER LINE IF CR ONLY.
	JMP	TDVENT
	LLS	7
	RAR
	LLS	3
	PAL
	LAC	TDVLB+3
	LMQ
	PLA
	LLS	3
	SAD	(141707)/.SIXBT "LOG".
	JMP	TDV999
	SAD	(240426)/.SIXBT "TDV".
	JMP	TDVERR
	DAC	TDVREQ+2
	AND	(77)	/ERROR IF 3RD CHARACTER IS A PERIOD, BECAUSE
	SAD	(56)	/IT WOULD LOOK LIKE AN I/O HANDLER, E.G., DT....
	JMP	TDVERR
/
	DZM	TDVEV2	/CLEAR "COMMAND TRANSFERRED" EVENT VARIABLE
/
TDV2	CAL	TDVREQ	/REQUEST TDV FUNCTION TASK
/
	LAC	TDVEV1	/REQUEST ACCEPTED?
	SMA
	JMP	TDV4	/YES -- WAIT FOR LINE TO BE REQUESTED
	SAD	(-202)	/NO -- WAS TASK ACTIVE?
	JMP	TDV3	/YES-- WAIT AND RE-REQUEST
			/NO -- WRITE ERR MESSAGE
TDVERR	CAL	TDVE13	/WRITE ERROR MESSAGE ON LUN 13, AND
	JMP	TDVENT	/ACCEPT ANOTHER LINE OF COMMAND INPUT.
/
TDV3	DAC	TDVTAC	/FLAG CURRENT TDV TASK ACTIVE
	CAL	(5)	/TDV FUNCTION TASK WAS ACTIVE -- WAIT FOR
	DZM	TDVTAC	/NEXT SIGNIFICANT EVENT AND TRY AGAIN.
	JMP	TDV2
/
TDV4	LAC	R4	/TDV FUNCTION HAS BEEN REQUESTED -- SET ATL NODE
	DAC	TDVCTF	/ADDRESS IN CURRENT-TDV-FUNCTION INDICATOR.
			/TO ALLOW THE RESTRICTED COMMAND TRANSFER DIR-
			/ECTIVE TO SERVICE THE JUST REQUESTED TDV FUNCTION
			/TASK ONCE.
/
	CAL	TDVWF2	/WAIT FOR COMMAND INPUT LINE TO BE TRANSFERRED
			/TO THE FUNCTION TASK.  I.E., WAIT FOR THE LINE
			/BUFFER TO BECOME AVAILABLE.
/
	CAL	(10)	/EXIT -- NOW TDV DISPATCH MAY OCCUR AS A RESULT
			/OF ^T TYPEIN OR REQUEST.
/
TDV999	LAC	TC.EV	/CHECK LINE TERMINATOR FOR LOG COMMAND.
	SAD	(1)
	CAL	(10)	/ALTMODE -- EXIT.
	JMP	TDVENT	/CAR. RET. -- READ NEXT LINE.
/
TDVEV1	0		/EVENT VARIABLE FOR I/O & TASK REQUEST
TDVEV2	0		/EVENT VARIABLE FOR TRANSFERRING OF COMMAND LINE
TDVCTF	0		/CURRENT TDV FUNCTION INDICATOR (ATL NODE ADDRESS)
			/CLEARED BY COMMAND TRANSFER DIRECTIVE WHEN COMMAND
			/LINE IS MOVED TO TDV FUNCTION TASK.
TDVTAC	0		/FLAG SET NON-0 (FOR EXIT DIRECTIVE) TO INDICATE CURRENT
			/TDV TASK IS ACTIVE.
/
/ CPB'S AND I/O BUFFERS
/
TDVA12	2400		/ATTACH LUN 12
	0
	LUN12
/
TDVD12	2500		/DETACH LUN 12
	0
	LUN12
/
TDVP12	2700		/WRITE PROMPTING SYMBOL ON LUN 12
	0
	LUN12
	2
	MES11
/
TDVR12	2600		/READ COMMAND LINE FROM LUN 12
	TDVEV1
	LUN12
	2
	TDVLB
	36
/
TDVC12	2700		/RETURN CARRIAGE ON LUN 12
	0
	LUN12
	2
	MES12
/
TDVE13	2700		/WRITE ERR MESSAGE ON LUN 13
	0
	LUN13
	2
	MES13
/
TDVREQ	1		/REQUEST TDV FUNCTION TASK
	TDVEV1
	.SIXBT	"---"
	.SIXBT	"..."
	0
/
TDVWF1	20		/WAITFOR 'EV1'
	TDVEV1
/
TDVWF2	20		/WAIT FOR 'EV2'
	TDVEV2
/
	TEXT 11,<TDV>>,<175>,L.MCR
	TEXT 12,,<15>,L.MCR
	TEXT 13,<TDV-BAD FUNCTION>,<15>,L.MCR
/
TDVLB	.BLOCK 36	/COMMAND LINE BUFFER
/
/ TDV ENTRY (NODE) IN SYSTEM TASK LIST. NOTE -- TASK IS INITIALLY
/ DISABLED BUT WILL BE ENABLED AT COMPLETION OF SYSTEM CONFIGURATION.
/
TDV	SCF		/FORWARD LINKAGE
	MCR		/BACKWARD LINKAGE
	.SIXBT	"TDV"	/TASK NAME (FIRST HALF)
	.SIXBT	"..."	/TASK NAME (SECOND HALF)
	140121		/FIXED IN CORE, DISABLED; DEFAULT PRIORITY OF 81
	TDVIC-P.TP	/"PARTITION BLOCK" ADDRESS		/(171)
	0		/DISK PARAMETERS (ZEROS
	0		/INDICATE A CORE RESIDENT
	0		/TASK)
	TDVENT		/ENTRY POINT ADDRESS
	.IFPNZ	NDSZMT
	.REPT	NDSZMT
	0
	.ENDC
/
/ TDV "PARTITION BLOCK" (REGISTER SAVE USE ONLY)
/
TDVNNN=P.TP-4		/ FILL PARTITION BLOCK EXCEPT FOR LINKS	/(171)
	.REPT	TDVNNN
	0
TDVIC	SHPB L.MCR						/EAG:202
	.IFUND L.ALL						/EAG:202
	.NOLST							/EAG:202
	.ENDC							/EAG:202
	.ENDC							/EAG:202
/
	.IFUND L.ALL						/EAG:202
	.NOLST							/EAG:202
	.ENDC							/EAG:202
								/EAG:202
	.LTORG
/
								/EAG:202
	.IFDEF L.LUN						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
	.TITLE *** INITIAL POOL OF EMPTY NODES ***
/
/ FILLS UP REMAINDER OF PAGE ZERO AND LINKS TO ADDITIONAL
/ EMPTY NODES THAT FILL UP THE REMAINDER OF PAGE ONE.
/
	.DEFIN	EN
	.IFPOZ	10000-NDSZ-NDSZ-.
	.+NDSZ
	.-1-NDSZ
	.REPT	NDSZM2
	0
	.ENDC
	.ENDM
/
/ NODES
/
PG0NB=.
/
BPL	.+NDSZ
	POOL
	.REPT	NDSZM2
	0
/
	.IFUND L.ALL						/EAG:202
	.NOLST							/EAG:202
	.ENDC							/EAG:202
								/EAG:202
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
	EN
/
	.IFDEF L.LUN						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
								/EAG:202
EPL	POOL		/ END OF EMPTY NODE POOL.		/(177)
			/ THIS CELL MAY BE UPDATED VIA .LOC	/(177)
			/ AT ASSEMBLY TIME LATER.		/(177)
	.-1-NDSZ
	.REPT	NDSZM2
	0
/
PG0NE=.-1
/
	.LST
	.IFUND	L.DSK
	.NOLST
	.ENDC
 .TITLE *** RP15/RF15/UC15 MULTI-DISK DRIVER TASK
/
/ 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" NOR IS THE "FLAGS" WORD
/ EVER CHECKED OR ALTERED.
/
/ 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.
/
/ THIS TASK PERFORMS THE PRIMITIVE DISK FUNCTIONS OF ALLOCATE,
/ DEALLOCATE, GET, PUT & HINF, AND IS CALLED AN I/O DRIVER.  THE
/ TERM I/O HANDLER TASK IS RESERVED FOR A FILE STRUCTURE SERVICE
/ ROUTINE WHICH WOULD USE THIS TASK FOR DISK I/O.
/
/ ACTUALLY, THE ALLOCATE AND DEALLOCATE FUNCTIONS (PROVIDED THAT THEY
/ ARE REQUESTED BY AN EXECUTIVE MODE TASK) ARE PASSED
/ ON TO ANOTHER TASK, "DSA", WHICH RUNS AT A LOWER PRIORITY
/ LEVEL THAN DOES THIS TASK. THIS IS DONE SO THAT ALLOCATE,
/ WHICH CAN TAKE A CONSIDERABLE AMOUNT OF REAL TIME TO
/ PERFORM, DOES NOT HOLD OFF OTHER DISK TRANSFERS.
/
/ THE CPB FORMATS ARE AS FOLLOWS, EXCEPT THAT HINF REQUIRES
/ ONLY THE FIRST 3 WORDS:
/
/	CPB	FUNCTION CODE
/		EVENT VARIABLE ADDRESS
/		LOGICAL UNIT NUMBER
/		CONTROL TABLE ADDRESS
/		DISK DEVICE TYPE
/
/ THEY DIFFER IN FUNCTION CODE AND CONTROL TABLE
/ WORD DESIGNATIONS.
/
/ ALLOCATE -- CODE 15 (MULTI-DISK CODE 115)
/ THE FIRST WORD OF A THREE WORD CONTROL TABLE CONTAINS
/ THE DESIRED STORAGE IN WORDS.  IF SUFFICIENT CONTIGUOUS
/ STORAGE IS AVAILABLE, THE FIRST WORD IS MODIFIED TO
/ REFLECT THE ACTUAL AMOUNT OF ALLOCATED STORAGE (WHICH
/ MIGHT EXCEED THE AMOUNT REQUESTED). ALSO, THE DISK
/ UNIT NUMBER AND DISK BLOCK # ARE SET IN THE SECOND AND
/ THIRD CONTROL TABLE WORDS.
/
/ DEALLOCATE -- CODE 16 (MULTI-DISK CODE 116)
/ THE UNALTERED CONTROL TABLE USED FOR ALLOCATION IS USED FOR
/ DEALLOCATION.
/
/ GET -- CODE 30 (MULTI-DISK CODE 130)
/ THE FIRST WORD OF A FOUR WORD CONTROL TABLE CONTAINS THE
/ UNIT NUMBER AND HI-ORDER BITS OF THE DISK BLOCK NUMBER. THE
/ SECOND WORD CONTAINS THE LO-ORDER BITS OF THE BLOCK NUMBER AND A
/ DISPLACEMENT FOR RF15 DISKS ONLY. THE THIRD WORD CONTAINS THE CORE
/ BUFFER ADDRESS, AND THE FOURTH WORD CONTAINS THE WORD COUNT.
/
/ FOR RP AND RK DISKS THE LO-ORDER 8 BITS OF WORD TWO MUST BE ZERO,
/ SINCE ONLY BLOCK ADDRESSING IS SUPPORTED. THIS DRIVER STILL
/ SUPPORTS WORD ADDRESSABILITY FOR THE RF15 DISK, WHICH USES THESE
/ LO-ORDER 8 BITS TO ADDRESS A WORD ON A PLATTER.
/
/ PUT -- CODE 31 (MULTI-DISK CODE 131)
/ THE CONTROL TABLE IS THE SAME AS FOR 'GET'.
/
/ HINF -- CODE 36
/ DOES NOT USE A CONTROL TABLE.
/
/ THE DISK DEVICE TYPE CODES ARE THE STANDARD RSX DEVICE CODES, WITH
/ THE ADDITION OF THE SPECIAL DEVICE CODE 0, WHICH IMPLIES USE THE
/ SYSTEM DISK, WHATEVER IT MAY BE.E.G., INSTALL USES DEVICE CODE 0
/ BECAUSE TASKS ARE ALWAYS INSTALLED ON THE SYSTEM DEVICE (UNIT 0
/ OF THE SYSTEM DEVICE TYPE). THIS FEATURE MAKES THE MCR FUNCTIONS
/ DEVICE INDEPENDENT. THE DEVICE CODES ARE:
/
/		0	SYSTEM DEVICE
/		2	RF FIXED-HEAD DISK
/		3	RP DISK PACK
/		24	RK DISK ON THE UC15 UNICHANNEL
/
/
/ THE DISK DEVICE TYPE CODE IS IGNORED AND THE SYSTEM DEVICE IS ASSUMED
/ WHEN THE NEW MULTI-DISK CODES INDICATED IN PARENTHESES ABOVE ARE NOT
/ USED. THIS ALLOWS COMPATIBILITY WITH EXISTING SOFTWARE USING DIRECT
/ GETS AND PUTS TO THE RF DISK, BUT ONLY IF THE RF DISK IS THE SYSTEM
/ DEVICE.
/
/ ***************************** NOTE *************************************
/ RF SOFTWARE USING DIRECT GETS AND PUTS TO DISK MAY NOT BE COMPATIBLE
/ WITH OTHER DISK SYSTEMS, SINCE DISK STRUCTURES VARY WIDELY AND UN-
/ AVOIDABLY AMONG THE DIFFERENT TYPES OF DISKS. THE CONCEPT OF "PLATTER"
/ DOES NOT APPLY TO THE OTHER DISKS AND THAT TERMINOLOGY HAS BEEN DROPPED
/ FROM DESCRIPTIONS OF THIS DRIVER. THE TWO WORD DISK ADDRESS IS NOW
/ CONSIDERED TO BE A BLOCK NUMBER THAT HAPPENS TO SPAN TWO CTB WORDS TO
/ MAINTAIN FORMAT COMPATIBILITY WITH RF-STYLE CTB'S. THE ALLOCATOR
/ GUARANTEES ALL BLOCKS ALLOCATED WILL FALL ON ONE BIT MAP, BUT THIS MAY
/ SPAN MORE THAN ONE "PLATTER" (BITS 3-17 OF THE HIGH-ORDER WORD).
/ CONSEQUENTLY, ARITHMETIC DONE ON CONTROL TABLE DISK ADDRESSES MUST CARRY
/ OVER ANY OVERFLOW FROM THE LOW-ORDER WORD INTO THE HIGH-ORDER WORD OR
/ SERIOUS ERRORS WILL OCCUR. REMEMBER THAT THE UNIT # (NOT THE PLATTER #)
/ OCCUPIES BITS 0-2 OF THE HIGH-ORDER DISK ADDRESS.
/ ***********************************************************************
/
/ THE REQUESTOR'S EVENT VARIABLE IS SET AS FOLLOWS:
/
/	+300003	VALUE SET BY HINF FUNCTION TO INDICATE
/		NON-DIRECTORY-ORIENTED INPUT & OUTPUT ON
/		DEVICE CODE 3 (RP15)
/
/	+1	REQUEST PERFORMED
/
/	-6	ILLEGAL I/O FUNCTION
/
/	-26	ILLEGAL FUNCTION FOR A NORMAL MODE TASK
/
/	-27	NONEXISTENT DISK UNIT NUMBER
/
/	-30	OUT-OF-PARTITION PARAMETER (NORMAL MODE)
/
/	-35	ILLEGAL DEVICE CODE OR NON-EXISTENT DISK TYPE
/
/	-36	NON-EXISTENT BLOCK NUMBER
/
/	-104	CONTROL TABLE ERROR (DISK STARTING ADDRESS IS NOT ON A
/					SECTOR BOUNDARY)
/
/	NNNNNN	THE CONTENTS OF THE DISK STATUS REGISTER IF
/		A DISK ERROR PERSISTS AFTER 'DSKMA' TRIES.
/		SINCE THE ERR FLAG IS BIT-0, NNN IS ALWAYS NEGATIVE.
/		THE FORMAT OF THIS WORD IS:
/		00  ERROR FLAG
/		01  WRITE PROTECT ERROR
/		02  NON-EXISTENT CYLINDER ADDRESS
/		03  NON-EXISTENT HEAD ADDRESS
/		04  NON-EXISTENT SECTOR ADDRESS
/		05  HEADER NOT FOUND
/		06  UNIT IS WRITE PROTECTED
/		07  SEEK INCOMPLETE
/		08  UNIT IS UNSAFE
/		09  PROGRAM ERROR
/		10  END OF PACK
/		11  TIMING ERROR
/		12  FORMAT ERROR
/		13  WRITE CHECK ERROR
/		14  WORD PARITY ERROR
/		15  LONGTITUDINAL PARITY ERROR
/		16  SEEK UNDERWAY
/		17  UNIT NOT READY
/
/	FOR OTHER VALUES, REFER TO THE TASK "DSA".
/
/
/RP15 IOTS:
/
DPLWC=706364	/LOAD TWO'S COMP. WORD COUNT
DPLCA=706344	/LOAD THE CURRENT ADDRESS
DPLDA=706304	/LOAD THE DISK ADDR (CYL=00:07, HEAD=08:12, SECT=14:17)
DPLF=706464	/LOAD DISK FUNCT (READ=015000, WRITE=025000, RECAL=035000)
DPRSA=706312	/READ STATUS A
DPRSB=706332	/READ STATUS B
DPSE=706361	/SKIP ON ERROR
DPSA=706321	/SKIP ON ATTENTION
DPCL=706404	/CLEAR CONTROL
/
/ RF15 IOT'S:
/ 
DSCF=707041	/CLEAR FUNCTION REGISTER
DSCC=707021	/CLEAR DISK CONTROL
DSFX=707042	/XOR AC BITS 15-17 INTO FNCN REG.
DLAH=707064	/LOAD HI ORDER DISK ADDR (PLATTER #)
DLAL=707024	/LOAD LO ORDER DISK ADDRESS
DSCN=707044	/EXECUTE FUNCTION REGISTER
DSCD=707242	/CLEAR STATUS REG & DISK FLAG
DSRS=707272	/READ STATUS REGISTER
/
/ LOCATIONS OF RF15 DMA CONTROL REGISTERS:
/
DSKFWC=36	/WORD COUNT REG ADDRESS
DSKFCA=37	/CORE ADDRESS REG ADDRESS
/
/ UC15 UNICHANNEL IOT'S:
/
SIOA=706001	/SKIP ON TCBP DONE FLAG
LIOR=706006	/LOAD TCBP REGISTER & CLEAR FLAG
CIOD=706002	/CLEAR TCBP DONE FLAG
RDRS=706112	/READ DR15 STATUS REGISTER (BIT 17)
LDRS=706122	/LOAD DR15 STATUS REGISTER FROM AC (BIT 17)
SAPI0=706101	/SKIP ON API0 FLAG=1
SAPI1=706121	/SKIP ON API1 FLAG=1
SAPI2=706141	/SKIP ON API3 FLAG=1
SAPI3=706161	/SKIP ON API3 FLAG=1
CAPI0=706104	/CLEAR API0 FLAG
CAPI1=706124	/CLEAR API1 FLAG
CAPI2=706144	/CLEAR API2 FLAG
CAPI3=706164	/CLEAR API3 FLAG
/
/
/ WAIT FOR TASK TO BE TRIGGERED (BY 'I/O CAL' CAL SERVICE ROUTINE, BY 'S2'
/ OR BY THE I/O RUNDOWN TASK) TO SIGNAL THAT A REQUEST HAS BEEN QUEUED.
/
	.LOC	10020		/BEGIN THIS TASK IN PAGE ONE
DSKTW	CAL	WFDTG		/WAIT FOR DISK TRIGGER
/
	DZM	DSKTG		/CLEAR TRIGGER
DSKPQ	LAC	(DSKRQ)		/PICK REQUEST NODE -- EMPTY DEQUE?
	DAC*	(R1
	JMS*	(PICK		/(R1, R2, R6, XR & AC ARE ALTERED)
	JMP	DSKTW		/YES -- WAIT FOR TRIGGER
	DAC	DSKRN		/NO -- SAVE ADDRESS OF REQUEST NODE
	DAC*	(R2		/AND SETUP R2 FOR 'VAJX'.
	JMS	DSKSX		/SETUP XR TO ACCESS REQUEST NODE
/
	LAC	6,X		/SAVE ADDRESS OF REQUESTOR'S EVENT
	SNA			/VARIABLE (ZERO IMPLIES NO EVENT
	LAC	(DSKRE)		/VARIABLE TO BE SET).
	DAC	DSKRE
	LAC	5,X		/TEST FOR SYSTEM DEVICE ONLY
	AND	(100)
	SNA
	JMP	DSKFC		/SWITCH NON ZERO SO ASSUME SYSTEM DEVICE
	LAC	10,X		/FETCH DISK DEVICE TYPE
	SNA			/CODE=0?
	SKP			/YES, USE SYSTEM DEVICE
	SAD	(2)
	SKP			/RF DISK
	SAD	(3)
	SKP			/RP DISK
	SAD	(24)
	SKP			/RK DISK
	JMP	DSKIDV		/NONE OF ABOVE, SO ILLEGAL DEVICE!
DSKFC	LAC	5,X		/FETCH THE FUNCTION CODE.
	AND	(777)
	SAD	(115)
	JMP	DSKA		/MULTI-DISK ALLOCATE
	SAD	(015)
	JMP	DSKA		/ALLOCATE.
	SAD	(116)
	JMP	DSKA		/MULTI-DISK DEALLOCATE
	SAD	(016)
	JMP	DSKA		/DEALLOCATE.
	SAD	(017)
	JMP	DSKAB		/ABORT.
	SAD	(036)
	JMP	DSKH		/HINF.
	SAD	(130)
	SKP			/MULTI-DISK GET.
	SAD	(030)
	SKP			/GET.
	SAD	(131)
	SKP			/MULTI-DISK PUT.
	SAD	(031)
	JMP	DSKCTC		/PUT.
/
DSKILF	LAW	-6		/ILLEGAL OR UNIMPLEMENTED FUNCTION.
	JMP	DSKSE
/
DSKCTC	LAC	7,X		/IS CONTROL TABLE WITHIN PARTITION (NORMAL MODE)?
	DAC*	(R3		/(R2 IS ALREADY SETUP)
	LAC	(4)
	DAC*	(R4
	JMS*	(VAJX		/(R3, R5, XR, & AC ARE ALTERED)
	JMP	DSKBP		/NO -- SET REQUESTOR'S EVENT VARIABLE TO -30
	LAW	-1		/YES -- SETUP X11 TO ACCESS CONTROL TABLE
	TAD*	(R3
	DAC*	(X11
	LAW	-DSKMA		/SET DSKEC WITH 2'S COMP OF NO. DISK TRYS
	DAC	DSKEC
/
	LAC	DSKRN		/SETUP XR TO ACCESS REQUEST NODE
	JMS	DSKSX
	LAC	5,X		/TEST FOR SYSTEM DEVICE ONLY
	AND	(100)
	SNA
	JMP	DSKSYS		/YES, SYSTEM DEVICE ONLY
	LAC	10,X		/NO,FETCH DISK TYPE FROM REQUEST NODE
	SNA
DSKSYS	LAC*	(SYSDSK		/LOAD DISK TYPE CODE
	DAC	DSKTYP		/SAVE IT.
	SAD	(2)
	JMP	DSKRF		/RF DISK TYPE
	SAD	(3)
	JMP	DSKRP		/RP DISK TYPE
	SAD	(24)
	JMP	DSKRK		/RK DISK TYPE
	JMP	DSKIDV		/ILLEGAL DEVICE CODE.
/
/ ABORT TASK I/O ROUTINE.
/
DSKAB	XOR	5,X		/ABORT IS LEGAL ONLY IF REQUESTED BY THE I/O
	SZA			/RUNDOWN TASK, WHO SETS LUN=0.
	JMP	DSKILF
/
	LAC	(DSK0)		/ADDRESS OF THE PHYSICAL DEVICE NODE.
	DAC*	(R1
	LAC	DSKRN		/ADDRESS OF THE REQUEST NODE.
	DAC*	(R2
	JMS*	(DMTQ		/EMPTY DSK'S I/O REQUEST QUEUE OF ALL I/O RE-
				/QUESTS MADE BY THE TASK BEING ABORTED.
				/(R1, R2, R3, R5, R6, X10, X11, X12, XR & AC
				/ARE ALTERED).
	JMP	DSKOC		/DONE.
/
/ HINF ROUTINE -- SET REQUESTER'S EVENT VARIABLE TO INDICATE DEVICE CODE
/ OF THE SYSTEM DISK DEVICE; NON-DIRECTORY ORIENTED; INPUT & OUTPUT.
/
DSKH	LAC*	(SYSDSK		/FETCH SYSTEM DISK DEVICE CODE.
	XOR	(300000)
	JMP	DSKSE
/
/ ALLOCATE AND DEALLOCATE ROUTINE.
/
DSKA	LAC 2,X		/ FETCH STL NODE ADDRESS.		/(171)
	SNA		/ WAS THIS REQUEST FROM A TASK?		/(171)
	JMP DSKA.1	/ NO, LET IT CONTINUE.			/(171)
	JMS DSKSX	/ SET UP TO ACCESS STL NODE.		/(171)
	LAC S.EP,X	/ FETCH ENTRY POINT INITIAL SETTINGS.	/(171)
	RTL		/ MOVE EXEC MODE INDICATOR INTO AC SIGN	/(171)
	SPA		/ IS THIS FUNCTION LEGAL (ONLY FOR EXEC)/(171)
	JMP	DSKIFN		/ERROR -- ILLEGAL FUNCTION FOR NORMAL MODE TASK
/
DSKA.1	LAC	(DSARQH)	/ADDRESS OF THE HEAD OF		/(171)
	DAC*	(R1		/"DSA'S" REQUEST QUEUE.
	LAC	DSKRN		/ADDRESS OF THE I/O REQUEST NODE.
	DAC*	(R2
	DAC*	(DSATEV)	/SET "DSA'S" TRIGGER EVENT
				/VARIABLE NON-0.
	JMS*	(SPRI		/INSERT THE ALLOCATE OR DEALLOCATE
				/REQUEST NODE INTO "DSA'S" DEQUE
				/IN ORDER OF PRIORITY.
				/(R1, R2, R3, R6, XR & AC ARE ALTERED).
	JMP	DSKPQ		/NO NEED TO DECLARE A SIGNIFICANT EVENT
				/SINCE THE TASK "DSA" IS OF LOWER PRIORITY.
/
/ GET OR PUT -- SET DISK FUNCTION REGISTER PER FUNCTION CODE
/ THERE ARE THREE ROUTINES FOR THE THREE DISK TYPES: DSKRF,DSKRP,DSKRK.
/
/
/ DSKRP -- ROUTINE TO HANDLE GETS & PUTS TO THE RP15 DISK PACK CONTROL.
/
DSKRP	LAC*	(RPDISK		/TEST FOR PRESENCE OF RP DISK.
	SPA
	JMP	DSKIDV		/ERROR - NO RP DISK.
	LAC	(100000		/ADD 1 TO THE CURRENT DISK UNIT AND ISSUE
	TAD	DSKUNT		/A NOP SO THE CURRENT UNIT IS DESELECTED.
	DPLF			/THIS ALLOWS THE CONTROLLER TO PROPERLY
				/INTERROGATE THE READ-WRITE/READ-ONLY SWITCH
	JMS	DSKG.P		/TEST FOR GET OR PUT.
	LAC	(014000)	/GET: READ & INTERRUPT.
	SKP
	LAC	(024000)	/PUT: WRITE & INTERRUPT.
	DAC	DSK.FN		/SAVE THE FUNCTION CODE.
	JMS	DSKGAD		/GET THE DISK BLOCK #
	JMS	DSKGBN		/FROM THE CONTROL TABLE.
	TAD	(-117230)	/BLOCK # IS NOW IN AC IF O.K.
	SMA			/SO TEST IT FOR SIZE.
	JMP	DSKBDB		/TOO BIG!
	LAC	DSKBLK		/PICK THE BLOCK NUMBER BACK UP
	IDIV			/DIVIDE BY 10 TO GET SECTOR
	12			/WHICH WILL BE IN AC.
	DAC	DSKBLK		/SAVE THIS
	LACQ			/GET REMAINDER AND
	IDIV			/DIVIDE BY 20 TO GET THE
	24			/HEAD ADDRESS IN AC.
	ALSS	5		/POSITION TO XOR INTO DISK
	XOR	DSKBLK		/PHYSICAL ADDRESS WORD.
	DAC	DSKBLK		/SAVE IT TEMP.
	LACQ			/GET REMAINDER WHICH IS THE
	ALSS	12		/CYLINDER ADDRESS AND POSITION IT
	XOR	DSKBLK		/XOR INTO THE DISK PHYSICAL ADDRESS.
	DAC	DSKBLK		/ALL DONE SO SAVE IT.
	LAC	DSKUNT		/CHECK UNIT # FOR SIZE.
	CLL!RTL
	RTL
	TCA
	TAD*	(RPDISK		/SUBTRACT FROM MAX. UNIT #
	SPA
	JMP	DSKIDV		/ERROR - NON-EXISTENT UNIT.
	JMS	DSKCKP		/CHECK TO SEE IF TRANSFER IS
				/WITHIN PARTITION. RETURN IF SO.
DSKRT	LAC	DSKCA		/YES, LOAD RP15 REGISTERS.
	DPLCA			/LOAD CORE BUFFER ADDRESS.
	LAC	DSKWC
	DPLWC			/LOAD 2'S COMPL. WORD COUNT
	LAC	DSKBLK
	DPLDA			/LOAD DISK PHYSICAL ADDRESS.
	DZM	DSKEV		/ZERO THE EV.
	DZM	DPERR		/CLEAR ERROR RECALIB. UNDERWAY FLAG.
	LAC	DSK.FN		/PICK UP THE FUNCTION CODE
	XOR	DSKUNT		/ADD IN THE DISK UNIT NUMBER.
	DPLF			/LOAD AND DON'T GO YET
	LAC	(1		/WASTE 4 MICRO SECONDS
	LAC	(1
	NOP
	DPRSB			/GET THE STATUS WORD
	AND	(1		/IS THIS UNIT OFF LINE?
	SZA
	JMP	DSKRPO		/YES -- GIVE A HARDWARE ERROR
	LAC	DSK.FN		/NO -- EXECUTE GET OR PUT
	XOR	(1000		/NOW SET THE GO BIT
	XOR	DSKUNT
	DPLF
	JMS	DSKWFD		/WAIT FOR EV AND TEST FOR ERROR.
	JMP	DSKRT		/ERROR, GO RETRY!
DSKRPO	DPRSA			/CONSTRUCT THE HARDWARE FAILURE EV
	SWHA
	STL
	RAR
	AND	(776000
	DAC	DPERR
	DPRSB
	AND	(1777
	XOR	DPERR
	JMP	DSKSE		/RETURN THE EV TO CALLER
/
/ DSKRF -- ROUTINE TO HANDLE GETS AND PUTS TO THE RF15 DISK CONTROL.
/
DSKRF	LAC*	(DSIZE		/TEST FOR PRESENCE OF RF DISK.
	SPA
	JMP	DSKIDV		/NO RF DISK PRESENT!
	JMS	DSKG.P		/TEST FOR GET OR PUT FUNCTION.
	LAC	(3)		/GET: READ & INTERRUPT
	SKP
	LAC	(5)		/PUT: WRITE & INTERRUPT
	DAC	DSK.FN		/SAVE THE FUNCTION CODE
	DSCF!DSFX		/LOAD THE FUNCTION CODE INTO CONTROLLER
	JMS	DSKGAD		/GO FETCH THE DISK ADDRESS
	LAC	DSKUNT		/UNIT # MUST BE ZERO.
	SZA
	JMP	DSKIDV		/ERROR - NONZERO UNIT #
	LAC	DSKHI		/GET THE PLATTER NUMBER
	TCA			/CHECK FOR SIZE
	TAD*	(DSIZE		/BY SUBTRACTING FROM # OF PLATTERS.
	SPA
	JMP	DSKIUN		/ERROR, SET EV TO -27.
	JMS	DSKCKP		/CHECK TO SEE IF TRANSFER IS
				/WITHIN THE PARTITION. RETURN IF SO.
DSKRTR	LAW	-1		/YES,SET UP REST OF CONTROL WORDS.
	TAD	DSKCA		/ADJUST CORE ADDRESS BY -1 AND
	DAC*	(DSKFCA		/PUT CORE ADDR. IN DMA CONTROL TABLE.
	LAC	DSKWC
	DAC*	(DSKFWC		/STORE WORD COUNT THERE.
	LAC	DSKHI		/STORE THE PLATTER NUMBER
	DLAH
	LAC	DSKLO		/STORE THE LOW ORDER DISK ADDRESS
	DLAL
	DZM	DSKEV		/ZERO THE EV.
	DSCN			/GO EXECUTE THE DISK FUNCTION
	JMS	DSKWFD		/WAIT FOR THE EV AND RETURN IF ERROR
	LAC	DSK.FN		/ERROR, SO RETRY THE TRANSFER!
	DSCF!DSFX		/RELOAD THE FUNCTION.
	JMP	DSKRTR		/GO RETRY!
/
/ DSKRK -- ROUTINE TO HANDLE GETS & PUTS TO THE UC15 UNICHANNEL DISK
/
DSKRK	LAC*	(RKDISK		/TEST FOR PRESENCE OF DISK.
	SPA
	JMP	DSKIDV		/ERROR - NO RK DISK.
	JMS	DSKG.P		/TEST FOR GET OR PUT
	LAC	(4)		/GET: READ & INTERRUPT
	SKP
	LAC	(2)		/PUT: WRITE & INTERRUPT
	DAC	DSK.FN		/SAVE AS FUNCTION CODE
	JMS	DSKGAD		/GET THE DISK BLOCK #
	JMS	DSKGBN		/FROM THE CONTROL TABLE.
	TAD	(-11410)	/BLOCK # STILL IN AC SO
	SMA			/TEST IT FOR SIZE.
	JMP	DSKBDB		/BAD BLOCK #.
	LAC	DSKBLK		/PICK UP BLOCK # AGAIN AND
	DAC	RK.BLK		/PUT IT IN THE CTB.
	LAC	DSKUNT		/CHECK UNIT NUMBER FOR SIZE.
	CLL!RTL
	RTL
	TCA
	TAD*	(RKDISK
	SPA
	JMP	DSKIDV		/ERROR - NON-EXISTENT UNIT #
	JMS	DSKCKP		/CHECK TO SEE IF TRANSFER IS
				/WITHIN PARTITION. RETURN IF SO.
	LAC	DSKCA		/FETCH CORE BUFFER ADDRESS
	LMQ			/SAVE IN MQ
	AND	(177777)	/EXTRACT LOW ORDER BITS
	DAC	RKSTAD+1	/AND PUT IN CTB.
	LLSS!ECLA  2		/SHIFT IN HIGH ORDER BITS AND
	DAC	RKSTAD		/PUT IN CTB.
	LAC	DSKWC		/FETCH WORD COUNT
	DAC	RK.WC		/AND PUT IN CTB.
	TAD	(200000		/SUBTRACT WORD COUNT FROM 64K
	SMA			/TRANSFER >64K?
	JMP	DSKRK1		/NO
	LAC	RKSTAD		/YES -- SET BIT TO TELL PIREX
	XOR	(4		/THIS TRANSFER IS OVER 64K
	DAC	RKSTAD
DSKRK1	LAC	DSKUNT		/FETCH DISK UNIT #,
	LRS	7		/POSITION IT AND
	XOR	DSK.FN		/XOR IN THE DISK FUNCTION.
	DAC	RKUNFC		/PUT IT IN THE CTB.
DSKRTY	DZM	RK.EV		/ZERO THE EV
	DZM	DSKEV
	LAC	(RK.TCB)	/LOAD AC WITH ADDRESS OF CTB.
	SIOA			/SKIP IF UC15 CAN ACCEPT REQUEST.
	JMP	.-1		/WAIT UNTIL IT CAN (INTERRUPTABLE).
	LIOR			/GO ISSUE REQUEST TO UC15!
	JMS	DSKWFD		/WAIT FOR EV AND RETURN IF ERROR.
	JMP	DSKRTY		/ERROR, GO RETRY.
/
/
DSKIFN	LAW	-26		/ILLEGAL FUNCTION FOR A NORMAL MODE TASK.
	JMP	DSKSE
/
DSKIUN	LAW	-27		/NON-EXISTENT UNIT NUMBER.
	JMP	DSKSE
/
DSKIDV	LAW	-35		/NON-EXISTENT DISK TYPE OR
	JMP	DSKSE		/ILLEGAL DEVICE CODE.
/
DSKBDB	LAW	-36		/BAD BLOCK NUMBER
	JMP	DSKSE		/TELL THE USER
/
/
DSKBP	LAW	-30		/BAD PARAMETER SPECIFIED, SET REQUESTOR'S
	JMP	DSKSE		/EVENT VARIABLE TO -30.
/
DSKBDC	LAW	-104		/BAD CONTROL TABLE
	JMP	DSKSE		/SHOW THE USER
/
/ DSKG.P -- SUBROUTINE TO FETCH THE FUNCTION CODE AND TEST FOR GET OR
/ PUT. RETURNS TO CALLER+1 ON GET AND TO CALLER+3 ON PUT. ASSUMES XR
/ POINTS TO REQUEST NODE.
/
DSKG.P	0
	LAC	5,X		/FETCH FUNCTION CODE.
	AND	(77)		/MASK OFF MULTI-DISK EXTENSION BIT.
	SAD	(30)
	JMP*	DSKG.P		/GET FUNCTION
	IDX	DSKG.P
	IDX	DSKG.P
	JMP*	DSKG.P		/PUT FUNCTION
/
/
/ DSKGBN -- SUBROUTINE TO FORM A ONE WORD BLOCK NUMBER AND CHECK
/ IT FOR ALIGNMENT WITH A SECTOR BOUNDARY. FOR USE BY BLOCK ORIENTED
/ DEVICES SUCH AS RP02 AND RK05. RETURNS TO DSKBDC IF THE DISK
/ ADDRESS DOES NOT FALL ON A SECTOR BOUNDARY, OTHERWISE RETURNS TO
/ CALLER. 
/
DSKGBN	0
	LAC	DSKLO		/LOAD LO BITS OF BLOCK #.
	AND	(377)		/TEST FOR SECTOR ALIGNMENT.
	SZA
	JMP	DSKBDC		/BAD BLOCK # IN CTB.
	LAC	DSKLO
	LMQ
	LAC	DSKHI		/LOAD HI BITS OF BLOCK 3.
	LLSS	12		/BLOCK # NOW IN AC.
	DAC	DSKBLK		/SAVE IT.
	JMP*	DSKGBN
/
/ DSKGAD -- SUBROUTINE TO FETCH THE TWO-WORD DISK BLOCK NUMBER
/ AND UNIT NUMBER FROM THE CONTROL TABLE AND STORE THEM IN DSKHI,
/ DSKLO, AND DSKUNT.
/
DSKGAD	0
	LAC*	X11		/GET FIRST WORD AND
	PAL			/SAVE TEMP.
	AND	(700000)
	DAC	DSKUNT		/EXTRACT UNIT NUMBER.
	PLA
	AND	(77777)		/EXTRACT HI PART OF
	DAC	DSKHI		/DISK BLOCK NUMBER.
	AND	(77400)
	SZA
	JMP	DSKBDC		/ERROR - BAD CONTROL TABLE.
	LAC*	X11
	DAC	DSKLO		/GET AND SAVE LO PART.
	JMP*	DSKGAD
/
/ DSKCKP -- SUBROUTINE TO CHECK THAT TRANSFER WILL TAKE PLACE WITHIN
/ THE USER'S PARTITION. ASSUMES THAT X11 HAS BEEN SET TO POINT TO
/ THE THIRD WORD OF THE CONTROL TABLE. THE SUBROUTINE RETURNS TO
/ THE CALLER IF THE TRANSFER IS WITHIN THE PARTITION AND TO AN
/ ERROR ROUTINE IF IT IS NOT.
/
DSKCKP	0
	LAC	DSKRN		/GET ADDR OF REQUEST NODE.
	DAC*	(R2
	LAC*	X11		/GET CORE ADDRESS FROM CTB
	DAC*	(R3
	SPA!SNA			/TEST FOR NEGATIVE ADDRESS
	JMP	DSKBDC		/ERROR - GO EXIT.
	LAC*	X11		/GET WORD COUNT FROM CTB.
	DAC*	(R4
	JMS*	(VAJX		/GO CHECK (R3,R5,XR & AC
				/ARE ALTERED).
	JMP	DSKBP		/NO - SET REQUESTOR'S EV TO -30
	LAC*	(R3		/YES - GET THE ADJUSTED CORE ADDR.
	DAC	DSKCA
	LAC*	(R4		/GET THE WORD COUNT.
	SNA			/IS THE WORD COUNT ZERO?
	JMP	DSKBDC		/YES -- THAT'S AN ERROR
	TCA
	DAC	DSKWC
	JMP*	DSKCKP
/
/ DSKWFD -- SUBROUTINE TO WAIT FOR DISK EVENT VARIABLE AND TO TEST
/ FOR A DISK ERROR. IF ERROR OCCURS, IT TESTS FOR MAXIMUM # OF 
/ RETRIES. RETURNS TO CALLER TO RETRY THE TRANSFER, RETURNS TO
/ DSKSE IF MAXIMUM # OF RETRIES REACHED, RETURNS TO DSKOC
/ IF TRANSFER WAS MADE O.K.
/
DSKWFD	0
	CAL	WFDEV		/WAIT FOR DISK EV
	LAC	DSKEV		/TEST FOR ERRORS
	SMA
	JMP	DSKOC		/NO ERROR, EXIT.
	ISZ	DSKEC		/ERROR, ENOUGH TRIES?
	JMP	DSKER		/NO -- SET UP TO DO A RETRY
	ISZ*	(SE.DF		/YES -- BUMP DISK FAILURE 
	NOP			/COUNTER AND EXIT TO
	JMP	DSKSE		/ERROR ROUTINE.
DSKER	ISZ*	(SE.DR		/NO, BUMP DISK RETRY
	NOP			/COUNTER AND TRY AGAIN!
	JMP*	DSKWFD
/
/ DSKSX -- SET UP XR FROM PAGE ONE.
/ ON ENTRY AC HAS ADDRESS OF NODE
/ ON RETURN AC AND XR ARE MODIFIED.
/
DSKSX	0
	TAD	(-010000
	PAX
	JMP*	DSKSX
/
/ FUNCTION COMPLETED -- SET REQUESTOR'S EVENT VARIABLE & PICK NEXT REQUEST
/
DSKOC	CLA!IAC
/
DSKSE	PAL			/SAVE EV VALUE TEMPORARILY.
	LAC	DSKRE		/SET XR TO POINT TO EV ADDRESS.
	JMS	DSKSX
	PLA
	DAC	0,X
/
	LAC	DSKRN	/DECREMENT TRANSFERS PENDING COUNT (NORMAL MODE)
	DAC*	(R2	/(R5, XR, & AC ARE ALTERED)
	JMS*	(IOCD
/
	LAC	(POOL)	/RETURN REQUEST NODE TO POOL
	DAC*	(R1
			/R2 CONTAINS REQUEST NODE ADDRESS)
	JMS*	(NADD	/(R2, R6, XR, & AC ARE ALTERED)
/
/
/ NOTE -- SINCE DSK IS THE FIRST TASK IN THE ACTIVE TASK LIST, THERE IS
/ NO POINT IN DECLARING A SIGNIFICANT EVENT. IT WOULD ONLY SERVE TO CAUSE
/ A SCAN OF THE ATL WHICH WOULD RETURN RIGHT BACK TO THIS POINT.
/
	JMP	DSKPQ	/PICK NEXT REQUEST IF ANY
/
/ CONSTANTS & VARIABLES
/
DSKRE	0		/REQUESTOR'S EVENT VARIABLE ADDRESS
DSKRN	0		/REQUEST NODE ADDRESS
DSKTG	0		/TRIGGER EVENT VARIABLE
DSKEV	0		/INTERRUPT EVENT VARIABLE
DSKAC	0		/AC BUFFER (INT SAVE & RESTORE)
DSKEC	0		/ERROR COUNT
DSKBLK	0		/BLOCK NUMBER DISK ADDRESS READY FOR IOT LOADING
DSKWC	0		/TWO'S COMP WC - READY FOR IOT LOAD
DSKCA	0		/CORE ADDRESS -    "    "   "   "
DSK.FN	0		/DISK FUNCTION
DPERR	0		/ERROR FLAG - NON ZERO WHEN RECAL IS UNDERWAY
DSKHI	0		/HI PART OF DISK BLOCK NUMBER.
DSKLO	0		/LO PART OF DISK BLOCK NUMBER.
DSKUNT	0		/DISK UNIT NUMBER IN BITS 0-2.
DSKTYP	0		/DISK TYPE (STANDARD RSX DEVICE CODE)
/
/ UC15 UNICHANNEL DISK TASK CONTROL BLOCK (TCB)
/
RK.TCB	23401		/API TRAP LOC 47, PRIORITY 1 INT.
	202		/TASK CODE 2; 200 NOT SPOOLED.
RK.EV	0		/EV FOR RK DISK
RK.BLK	0		/DISK BLOCK NUMBER.
RKSTAD	0		/STARTING ADDRESS IN COMMON MEMORY (BITS 17 & 16)
	0		/LOW ORDER BITS OF ADDRESS (BITS 15-0, RIGHT JUSTIFIED)
RK.WC	0		/WORD COUNT
RKUNFC	0		/UNIT # AND DISK FUNCTION.
RK.CST	0		/CONTROL STATUS WORD.
RK.EST	0		/ERROR STATUS WORD.
RK.DST	0		/DRIVER STATUS WORD.
/
/
/ CAL PARAMETER BLOCKS
/
WFDTG	20		/WAIT FOR DISK TRIGGER
	DSKTG
/
WFDEV	20		/WAIT FOR DISK EVENT VARIABLE
	DSKEV
/
/ ACTIVE TASK LIST NODE -- THIS MUST BE THE FIRST NODE IN THE ATL
/ BECAUSE DSK DOESN'T DECLARE SIGNIFICANT EVENTS (AND VICE VERSA).
/
DSK	DSA		/FORWARD LINKAGE
	ATKL		/BACKWARD LINKAGE
	.SIXBT	"DSK"	/TASK NAME (FIRST HALF)
	.SIXBT	"@@@"	/TASK NAME (SECOND HALF)
	1		/PRIORITY
	DSKIC-P.TP	/"PARTITION BLOCK" ADDRESS		/(171)
	0		/STL NODE ADR (NONE)
	4		/TASK STATUS (INITIALLY WAITING)
	DSKTW		/RESUMPTION ADDRESS
	0		/EVENT VARIABLE
	.IFPNZ	NDSZMT
	.REPT	NDSZMT
	0
	.ENDC
/
/ "PARTITION BLOCK" (REGISTER SAVE USE ONLY)
/
DSKIC	SHPB L.DSK						/EAG:202
/
/ PHYSICAL DEVICE LIST NODE
/
DSK0	TT00		/FORWARD LINKAGE
	PDVL		/BACKWARD LINKAGE
	.SIXBT	"DK@"	/DEVICE NAME (FIRST HALF)
	0		/DEVICE NAME (SECOND HALF)
	0		/DEVICE ATTACH FLAG (ALWAYS 0 FOR DISK)
	0		/UNIT NUMBER
DSKRQ	.		/REQUEST QUEUE (FORWARD LINKAGE)
	.-1		/REQUEST QUEUE (BACKWARD LINKAGE)
	DSKTG		/TRIGGER EVENT VARIABLE ADDRESS
	0		/(UNUSED)
/
/ RP15 DISK PACK INTERRUPT SERVICE ROUTINE
/
DSKRPI	0
	DBA		/SET INDEX MODE
	DAC	DSKAC	/SAVE AC
	LAC	DPERR	/IS AN ERROR CLEAR UNDERWAY?
	SZA		/SKIP IF NOT
	JMP	DPALLD	/YES, AND IT IS FINISHED - SET THE EV
	DPSE		/SKIP IF ERROR
	JMP	DPALLD-1 /NO ERRORS, LEAVE
	DPRSA		/ASSEMBLE THE ERROR STATUS WORD
	SWHA
	STL
	RAR
	AND	(776000) /CLEAR EXTRA BITS
	DAC	DPERR	/TEMP SAVE
	DPRSB
	AND	(001777) /ONLY WHAT IS NEEDED
	XOR	DPERR	/FINISH UP
	DAC	DPERR	/SAVE
	AND	(0200)	/IS THIS THE END OF PACK?
	SZA!CLC		/SKIP IF NOT
	DAC	DSKEC	/YES - NO MORE RETRIES - IT WON'T HELP
	LAC	(037000)
	XOR	DSKUNT 	/XOR IN THE UNIT # TO BE RECALIBRATED.
	DPLF		/RECAL
	JMP	DPINTE	/EXIT
	CLA!IAC		/TRANSFER IS OK - SET THE EV TO +1
DPALLD	DAC	DSKEV	/SET THE EV
	DPCL		/CLEAR THE CONTROL
	.SET6		/DECLARE A SIGNIFICANT EVENT
DPINTE	LAC	DSKAC	/RESTORE ENVIRONMENT & RETURN
	DBR		/CONTROL TO INTERRUPTED PROGRAM
	JMP*	DSKRPI
/
/RF15 DISK INTERRUPT SERVICE ROUTINE
/
DSKRFI	0
	DBA		/SET INDEX MODE
	DAC	DSKAC	/SAVE AC
	DSRS		/SET EV TO DISK STATUS
	DAC	DSKEV
	SPA		/THAW FROZEN DISK IF ERROR
	DSCC
	DSCD		/CLEAR DISK FLAG & STATUS
	.SET6		/DECLARE A SIGNIFICANT EVENT
	LAC	DSKAC	/RESTORE ENVIRONMENT AND RETURN
	DBR		/CONTROL TO INTERRUPTED PROGRAM.
	JMP*	DSKRFI
/
/ UC15 UNICHANNEL DISK INTERRUPT SERVICE ROUTINE
/
DSKRKI	0
	DBA		/SET INDEX MODE
	DAC	DSKAC	/SAVE AC.
	LAC	RK.CST	/FETCH CONTROL STATUS WORD.
	AND	(100000)
	SNA!IAC		/TEST FOR ERROR.
	JMP	DSKNOE	/O.K. - SET EV TO +1
	LAC	RK.EST	/ERROR - GET ERROR STATUS WORD,
	AND	(177777
	XOR	(400000	/MAKE MINUS AND
DSKNOE	DAC	DSKEV	/STORE AS EV.
	CAPI1		/CLEAR API1 FLAG
	.SET6		/DECLARE A SIGNIFICANT EVENT,
	LAC	DSKAC	/RESTORE ENVIRONMENT & EXIT.
	DBR
	JMP*	DSKRKI
/
 .TITLE *** RP15/RF15/UC15 MULTI-DISK ALLOCATE/DEALLOCATE TASK
/
/ THIS TASK IS CALLED "DSA" AND IT IS DIRECTLY ASSOCIATED WITH THE
/ MULTI-DISK DRIVER TASK "DSK".
/
/ SINCE AN RP02 DISK CONTAINS 41 BIT MAPS, AN ALLOCATE REQUEST
/ MAY TAKE A CONSIDERABLE AMOUNT OF TIME TO BE PROCESSED (POSSIBLY
/ 41 DISK TRANSFERS). THEREFORE, IN ORDER TO NOT HOLD OFF OTHER DISK
/ I/O REQUESTS, "DSK" PASSES ON "ALLOCATE" AND "DEALLOCATE" RE-
/ QUESTS TO "DSA" ("DSA" RUNS AT A PRIORITY LEVEL LOWER THAN "DSK").
/
/ WHEN "DSK" RECEIVES AN "ALLOCATE" OR "DEALLOCATE" REQUEST, PROVIDED
/ THAT THE REQUEST WAS MADE BY AN EXECUTIVE MODE TASK, IT PUTS
/ THE I/O REQUEST NODE INTO A DEQUE BELONGING TO "DSA", SETS "DSA'S"
/ TRIGGER EVENT VARIABLE, AND DECLARES A SIGNIFICANT EVENT.
/
/ "DSA" DOES NOT HAVE A PHYSICAL DEVICE NODE IN WHICH I/O REQUESTS ARE
/ QUEUED, HENCE IT DOES NOT RECEIVE "ABORT" REQUESTS BY I/O RUNDOWN.
/ THIS IS ALRIGHT SINCE ONLY EXEC MODE REQUESTS ARE PROCESSED HERE.
/
/ "DSA" ACCESSES THE DISK INDIRECTLY BY MAKING "GET" AND "PUT" RE-
/ QUESTS TO LOGICAL UNIT 1 -- KNOWN TO BE ASSIGNED TO "DSK".
/
/ SPACE ON THE RP02 DISK IS DOLED OUT IN 400 WORD BLOCKS (256 DECIMAL).
/ THERE ARE 5 CYLINDERS COVERED BY EACH BIT MAP. THERE ARE 5*20*10=1000
/ BLOCKS COVERED (DECIMAL) WHICH MEANS 1000/18 WORDS NEEDED FOR
/ EACH BIT MAP, PLUS A THREE WORD HEADER (SEE DOS DESCRIPTION).
/
/ EACH PLATTER OF THE RS09 DISK HAS ONE BIT MAP COVERING THE 1024 (DECIMAL)
/ BLOCKS ON THE PLATTER. THIS BIT MAP OCCUPIES THE LAST BLOCK ON EACH
/ PLATTER (1777 FOR PLATTER 0, 3777 FOR PLATTER 1, ETC.).THE MAP MUST
/ CONTAIN 1024/18 WORDS TO COVER 1024 DISK BLOCKS, PLUS THREE WORDS
/ FOR THE HEADER (STANDARD DOS FORMAT, Q.V.).
/
/THE RK05 DISK WHICH IS USED ON THE UC15 UNICHANNEL SYSTEM CONTAINS
/ TWO BIT MAPS PER CARTRIDGE (UNIT) WHICH ARE LOCATED IN DISK BLOCKS
/ 1775 AND 1776.
/
/
/ A ZERO BIT INDICATES THAT THE ASSOCIATED BLOCK IS FREE AND MAY BE
/ ALLOCATED. SINCE THE BIT MAP MUST ALWAYS EXIST, ITS SPACE MUST BE
/ MARKED AS OCCUPIED
/
/ FOR "ALLOCATE" THE REQUESTOR SPECIFIES A NUMBER OF STORAGE WORDS
/ DESIRED. IF THIS IS NOT A MULTIPLE OF 400 WORDS (OCTAL), IT IS
/ ROUNDED UP. ALLOCATED BLOCK SEGMENTS ARE CONTIGUOUS AND RESIDE
/ ENTIRELY ON ONE PLATTER.
/
/ THIS TASK IS ALWAYS CORE RESIDENT AND IT RESIDES IN A "PARTITION"
/ THAT IS NOT AVAILABLE FOR OTHER TASKS.  IT CONTAINS A "PARTITION
/ BLOCK" THAT IS USED ONLY AS A REGISTER SAVE AREA (WHEN THE TASK IS
/ INTERRUPTED BY THE EXECUTIVE). IT IS NOT A PART OF THE "PARTITION
/ BLOCK DESCRIPTIONS LIST" NOR IS THE "FLAGS" WORD EVER CHECKED OR ALTERED.
/
/ IT CONTAINS AN ACTIVE TASK LIST NODE WITH STATUS INITIALLY SET TO
/ 4 (INDICATING IT IS READY TO BE RUN). WHENEVER THE TASK HAS NO
/ FURTHER PROCESSING TO DO, IT WAITS FOR ITS "TRIGGER EVENT VARIABLE"
/ TO BE SET BEFORE RESUMING OPERATION.
/
/ THIS TASK IS NEVER "REQUEST'ED" NOR DOES IT EVER "EXIT"; HENCE, IT
/ HAS NO ENTRY IN THE SYSTEM TASK LIST.
/
/ LABELLING CONVENTION:
/
/ ALL ADDRESS TAGS DEFINED IN THIS TASK BEGIN WITH "DSA".
/
/ EVENT VARIABLES RETURNED:
/
/	+1	ALLOCATE OR DEALLOCATE REQUEST PERFORMED
/		SUCCESSFULLY.
/
/	-15	INSUFFICIENT CONTIGUOUS FREE STORAGE
/		AVAILABLE FOR ALLOCATE. MEDIUM FULL.
/
/	-26	ILLEGAL FUNCTION FOR A NORMAL MODE TASK.
/		(CHECK IS MADE IN "DSK" TASK).
/
/	-104	CONTROL TABLE ARGUMENT ERROR:
/
/		(1) AMOUNT OF STORAGE TO ALLOCATE OR
/		    DEALLOCATE IS NEGATIVE OR ZERO.
/
/		(2) AMOUNT OF STORAGE TO ALLOCATE IS
/		    LARGER THAN 377400 OCTAL.
/
/		(3) AMOUNT OF STORAGE TO BE DEALLOCATED
/		    IS NOT A MULTIPLE OF 400 OCTAL, INDI-
/		    CATING THAT THE INTEGRITY OF THE CON-
/		    TROL TABLE IS IN QUESTION.
/
/		(4) ILLEGAL BLOCK NUMBER -- NUMBER IS
/		    NEGATIVE OR INDICATES A NON-EXISTENT PLATTER.
/
/		(5) DISK BOUNDARY VIOLATION -- DISK
/		    ADDRESS PLUS THE AMOUNT OF STORAGE
/		    TO BE DEALLOCATED MINUS 1 EXCEEDS
/		    THE RANGE OF THE BIT MAP.
/
/		(6) DISK ADDRESS IS NOT A MULTIPLE OF
/		    400 OCTAL, INDICATING THAT THE IN-
/		    TEGRITY OF THE CONTROL TABLE IS IN QUESTION.
/
/	-N	CONTENTS OF THE DISK STATUS REGISTER WHEN A
/		PERSISTENT DISK ERROR CANNOT BE CIRCUMVENTED.
/
IDX=ISZ				/USED WHEN THE SKIP IS NOT INTENDED.
/
	.EJECT
/ TASK STARTS AT THIS LOCATION WHICH IS IN PAGE 1. THE BIT MAP BUFFER
/ DSAMAP IS LOCATED IN THIS PAGE AND OCCUPIES 400 LOCATIONS.
/
DSATW	CAL	DSAW4T		/"WAITFOR" TRIGGER EVENT
				/VARIABLE FOR THE TASK "DSA".
/
DSANXT	DZM	DSATEV		/CLEAR THE "TRIGGER".
	DZM	DSADER		/CLEAR THE DISK ERROR FLAG.
	LAC	(DSARQH)	/SAVE THE REQUEST QUEUE ADDRESS
	DAC*	(R1)		/FOR USE BY "PICK".
	JMS*	(PICK)		/PICK THE 1ST NODE IN THE QUEUE.
				/(R1, R2, R6, XR & AC ARE ALTERED).
				/WAS THE DEQUE EMPTY?
	JMP	DSATW		/YES -- WAIT FOR TRIGGER.
	DAC	DSARQN		/NO -- SAVE THE NODE ADDRESS.
DSAINT	NOP			/SET TO SKIP INITIALIZATION CODE.
	LAC	DSAW4T+1	/GET AN ADDRESS FROM THIS PAGE,
	AND	(370000)	/EXTRACT THE PAGE AND BANK BITS,
	TCA			/NEGATE THEM AND SAVE.
	DAC	DSAXAD
	LAC	(JMP	DSASKP)
	DAC	DSAINT		/SKIP THIS CODE NEXT TIME THRU.
	LAC	DSARQN
DSASKP	TAD	DSAXAD		/ADJUST ADDRESS BEFORE USING IN XR.
	PAX
/
/ ***********************************************************************
/
/ NOTE -- SINCE THE DIRECTIVE WAS ISSUED FROM AN EXEC MODE TASK, IT IS
/ GUARANTEED THAT IT LIES IN THE LOWER 32K OF CORE. HENCE, INDIRECT
/ REFERENCES WORK PERFECTLY WELL.
/
/ ***********************************************************************
/
	LAC	7,X		/GET THE ADDRESS OF THE CONTROL TABLE.
	DAC	DSACTB
	IAC
	DAC	DSACTU		/SAVE ADDRESS OF UNIT # IN CTB.
	LAC*	DSACTB		/EXAMINE THE AMOUNT OF STORAGE TO
	SPA!SNA			/BE ALLOCATED OR DEALLOCATED.
	JMP	DSACTE		/ERROR -- SIZE IS NEGATIVE OR ZERO.
/
/ TEST THAT THE STORAGE SIZE IS LESS THAN OR EQUAL TO 377,400 OCTAL.
/ ANYTHING LARGER (FOR ALLOCATE) WOULD REQUIRE 400,000 (WHICH IS
/ NEGATIVE) SINCE DISK SPACE IS DOLED OUT IN 400 WORD CHUNKS.
/
	TAD	(-377400)
	SMA!SZA!CLL
	JMP	DSACTE		/ERROR -- SIZE TOO LARGE.
	PXA			/SAVE THE XR TEMPORARILY
	DAC	DSAT2
/
/ COMPUTE THE NUMBER OF 256 WORD STORAGE BLOCKS (400 OCTAL).
/
	LAC*	DSACTB
	CLQ
	LRS	10		/DIVIDE BY 400.
	PAX			/SAVE TEMPORARILY.
	LACQ			/CHECK FOR OVERFLOW INTO THE MQ.
	SZA			/IF SO, ANOTHER STORAGE BLOCK
	AXR	1		/IS NEEDED.
	PXA
	DAC	DSASBR		/+# OF STORAGE BLOCKS REQUESTED.
	TCA
	DAC	DSABKS		/-# OF STORAGE BLOCKS REQUESTED.
	LAC	DSAT2		/RESTORE THE XR
	PAX
	LAC	5,X		/IS THE SYSTEM DISK SPECIFIED?
	AND	(100
	SZA
	LAC	10,X
	SZA			/SKIP IF SO, DISREGARD UNIT IN CTA
	LAC*	DSACTU		/EXTRACT UNIT # FROM CTB
	AND	(700000)
	DAC	DSAUNT		/SAVE IT IN REQUESTED UNIT LOC.
/
/ DISPATCH TO ALLOCATE OR TO DEALLOCATE ROUTINE.
/
	LAC	DSARQN		/ADDRESS OF THE REQUEST NODE.
	TAD	DSAXAD		/ADJUST THE PAGE BITS.
	PAX
	LAC	5,X		/FETCH THE FUNCTION CODE AND
	AND	(100)		/CHECK THE MULTI-DISK BIT.
	SNA
	JMP	DSASDK		/BIT IS 0 SO ASSUME SYSTEM DISK.
	LAC	10,X		/BIT IS NON-0 SO GET DEVICE TYPE.
	SNA			/IS IT 0, INDICATING SYSTEM DEVICE?
DSASDK	LAC*	(SYSDSK)	/YES, GET SYSTEM DEVICE CODE AND
	DAC	DSATYP		/SAVE DISK DEVICE TYPE.
DSALC3	SAD	(2		/MODIFIED INSTRUCTION -- CHANGES TO
				/JMP DSADSP WHEN THE BIT MAP TABLE
				/IS PROPERLY FILLED OUT, FOR BOTH THE
				/RF AND RK. (RK TABLE IS FIXED)
				/HOWEVER, NOW, IS THIS THE RF?
	SKP
DSALC2	JMP	DSADSP		/NO -- DISPATCH
	LAC	(DSARFT		/YES -- INIT. X12 TO POINT TO RF TABLE
	DAC*	(X12
	AAC	+5		/INIT. X13 TO POINT TO 2ND HALF OF TABLE
	DAC*	(X13
	LAC	(1776		/PREPARE TO GET THE 1ST RF BIT MAP
	JMS	DSATAB		/FILL OUT TABLE FOR RF
	LAC	DSADBM		/TEMP COUNTER OF RF BIT MAPS
	TCA
	DAC	DSADBM		/SAVE THIS
	LAC	DSALC2		/MODIFY INST. IN DSALC3
	DAC	DSALC3
DSADSP	LAC	5,X		/FETCH FUNCTION CODE TO DISPATCH
	AND	(77)		/BUT LEAVE THE MULTI-DISK BIT.
	SAD	(016)
	JMP	DSADAL		/DEALLOCATE.
/
/ ASSUME ALLOCATE.
/
	JMS	DSACMP		/IS A BIT MAP IN CORE?
	JMP	DSANBM		/NO,START AT FIRST BIT MAP ON DISK.
	LAC	DSACBK		/YES, GET CURRENT MAP BLOCK #
DSARBM	DAC	DSAPLT		/SET TO REQUESTED MAP BLOCK #
	JMS	DSASEL		/LOAD ON DISK TYPE:
DSADBM	.-.			/RF - # OF BIT MAPS
	-51			/RP -       "
	-2			/RK -       "
	DAC	DSAPCT		/PUT INTO MAP COUNTER.
	JMP	DSALP1
/
/ NO BIT MAP IN CORE, GO FETCH ONE
/
DSANBM	JMS	DSASEL		/LOAD ON DISK TYPE:
	1776			/RF - FIRST BIT MAP
	764			/RP - FIRST BIT MAP
	1776			/RK - FIRST BIT MAP
	JMP	DSARBM
/
/ LOOP -- SCAN EACH BIT MAP  FOR THE SPACE REQUESTED.
/
DSALP1	JMS	DSAGBM		/"GET" A BIT MAP (IF NOT ALREADY IN CORE)
				/AND "WAITFOR" COMPLETION. CHECK FOR
				/DISK ERROR & SET FLAG IF SO,
				/CLEAR THE EVENT VARIABLE, AND
				/SET THE AC + ON RETURN IF THE TRANSFER
				/WAS SUCCESSFUL; RETURN THE DISK STATUS,
				/IF NOT.
				/(ASSUME ALL ACTIVE REGISTERS ARE
				/MODIFIED DUE TO THE CAL).
	SPA			/ERROR?
	JMP	DSAGME		/YES. RETURN WITH MINUS EV.
/
/ SCAN THE BIT MAP FOR A CONTIGUOUS SET OF FREE (0) BITS (EACH BIT
/ REPRESENTS 400 OCTAL WORDS OF DISK SPACE). FIND A SET LARGE
/ ENOUGH TO SATISFY THE ALLOCATE REQUEST.
/
	LAC	DSAMAP+1	/NUMBER OF BLOCKS ON THIS MAP
	TCA			/NEGATE
	TAD	DSAMAP+2	/ADD NUMBER OF BLOCKS TAKEN UP ON THIS MAP
	TAD	DSASBR		/PLUS THE NUMBER OF BLOCKS REQUESTED
	SMA!SZA			/SKIP IF THERE ARE POSSIBLY ENOUGH
	JMP	DSANRM		/NO, NOT ENOUGH ROOM ON THIS MAP, GET ANOTHER
	LAC	DSAMAP+1	/PICK UP THE NUMBER OF BLOCKS IN THE MAP
	IDIV!660000		/DIVIDE BY
	22			/18 TO FIND THE NUMBER OF WORDS
	TCA			/REMAINDER
	DAC	DSAREM		/SAVE THIS FOR THE LAST WORD
	DZM	DSARTS		/CLEAR FLAG INDICATING ALLOC. ON THE LAST WORD
	LACQ			/NUMBER OF FULL WORDS
	TCA!SNA			/ON THE BIT MAP
	JMP	DSANRM		/NO WORDS AVAILABLE ON THIS ONE - FORGET IT
	DAC	DSAWCT		/SET THIS IN AS LOOP CONTROL
	DZM	DSABNM		/INITIALIZE THE BIT NUMBER TO 0.
	CLX
	LAC	(SPA!CLA)	/SET THE SWITCHABLE INSTRUCTION
	DAC	DSASCH		/FOR A 0-BIT SEARCH.
/
DSALP2	LAW	-22		/18 DECIMAL BITS PER WORD
	DAC	DSACNT
DSAMNX	777777
	AND	DSAMAP+3,X	/GET WORD FROM BIT MAP.
	SAD	DSAMNX		/SAD (777777)
	JMP	DSA1S		/SAVE TIME (MAYBE).
/
DSALP3	DAC	DSATMP
/
/ SWITCHABLE INSTRUCTION -- SPA!CLA MEANS SEARCH FOR A 0-BIT;
/ SMA!CLA MEANS SEARCH FOR A 1-BIT.
/
DSASCH	XX			/SPA!CLA OR SMA!CLA.
	JMP	DSANOT		/NOT THE DESIRED BIT TYPE.
/
/ NOTE -- AC IS 0 (+).
/
	XCT	DSASCH
	JMP	DSA1BT
/
/ SAVE THE LOCATION OF THE 1ST 0-BIT.
/
	PXA			/SAVE INDEX OF WORD'S ADDRESS.
	DAC	DSAIDX
	LAC	DSARTS		/IS THIS THE PARTIAL WORD OF A BIT MAP?
	SNA
	JMP	.+3
	TAD	DSACNT		/YES -- GET BIT POSITION FOR PARTIAL WORD BY ADDING  THE
				/COMPLEMENT OF FORMAER VALUE OF DSAREM
	JMP	.+3
	LAC	DSACNT		/SAVE BIT POSITION WITHIN THE WORD.
	AAC	22
	DAC	DSABTP
	LAC	DSABNM		/SAVE THE ABSOLUTE BIT NUMBER.
	DAC	DSABTN
/
/ CHANGE THE LOOP INSTRUCTION TO SEARCH FOR A 1-BIT.
/
	LAC	DSALIT		/LAC (SMA!CLA).
	DAC	DSASCH
	JMP	DSASSW
/
/ IN ORDER TO SPEED UP PROCESSING TIME, BYPASS WORD CONTAINING ALL
/ 1-BITS WHEN SEARCHING FOR A 0-BIT.
/
DSA1S	XCT	DSASCH		/SKIP IF SEARCHING FOR 1-BIT.
	JMP	.+3
	LAW	-1		/RESTORE THE AC TO -1.
	JMP	DSALP3
	LAC	DSABNM		/ADD 18 DECIMAL TO THE CURRENT BIT NUMBER.
	AAC	22
	DAC	DSABNM
	JMP	DSAAXR
/
/ FOUND A 1-BIT.
/
DSA1BT	JMS	DSANUF		/WERE ENOUGH FREE BLOCKS FOUND?
				/IF SO, DON'T RETURN HERE -- GO TO
				/DSAFND. IF NOT, RETURN HERE WITH
				/AC=0.
/
	LAC	(SPA!CLA)	/SWITCH BACK TO 0-BIT SEARCH.
DSASSW	DAC	DSASCH
/
/ BIT JUST EXAMINED IS THE WRONG TYPE.
/
DSANOT	IDX	DSABNM		/AUGMENT THE ABSOLUTE BIT #.
	LAC	DSATMP
	RAL
	ISZ	DSACNT		/IS THE CURRENT WORD DEPLETED?
	JMP	DSALP3		/NO.
/
	CLA
	XCT	DSASCH		/SKIP IF SEARCHING FOR 0-BIT.
	JMS	DSANUF		/HAVE ENOUGH FREE BLOCKS BEEN FOUND?
				/IF SO, DON'T RETURN HERE -- GO TO
				/DSAFND. IF NOT, RETURN HERE WITH
				/AC=0.
DSAAXR	AXR	1		/INDEX TO NEXT WORD.
	ISZ	DSAWCT		/END OF FULL BIT MAP WORDS??
	JMP	DSALP2		/NO.
	LAC	DSAREM		/YES, IS THERE A REMAINDER?
	SNA			/SKIP IF SO
	JMP	DSAEOM		/NO, END OF BIT MAP
	DAC	DSACNT		/YES, SET UP FOR A PARTIAL SEARCH
	TCA			/SAVE THE 2'S COMP. OF DSAREM SO CORRECT BIT POSITION
	DAC	DSARTS		/CAN BE CALC. FOR THE PARTIAL WORD
	LAW	-1		/OF THE LAST WORD
	DAC	DSAWCT		/SET UP SO ONLY ONE MORE WORD TO LOOK AT
	DZM	DSAREM		/AND NO MORE REMAINDER
	JMP	DSAMNX		/CONTINUE
/
/ END OF BIT MAP REACHED. THIS IS CONSIDERED TO BE EQUIVALENT TO
/ HAVING FOUND A 1-BIT.
/
DSAEOM	CLA
	XCT	DSASCH		/SPA!CLA OR SMA!CLA.
	JMS	DSANUF		/WERE ENOUGH FREE BLOCKS FOUND?
				/IF SO, DON'T RETURN HERE -- GO TO
				/DSAFND. IF NOT, RETURN HERE WITH
				/AC=0.
/
/ ALLOCATE REQUEST CANNOT BE HONORED ON THIS DISK BIT MAP:
/ SUFFICIENT CONTIGUOUS FREE SPACE DOES NOT EXIST OR DISK
/ FAILURE PERSISTS.
/
DSANRM	LAC	DSAMAP+377	/PICK UP THE LINK TO THE NEXT ONE
	SAD	(-1)		/IS THIS THE END?
	SKP			/YES
	JMP	DSAENM		/NO, USE AS POINTER TO NEXT MAP.
	JMS	DSASEL		/LOAD ON DISK TYPE:
	1776			/RF - FIRST BIT MAP
	764			/RP - FIRST BIT MAP
	1776			/RK - FIRST BIT MAP
DSAENM	DAC	DSAPLT		/SET THIS AS THE NEXT BIT MAP TO USE
	ISZ	DSAPCT		/O.K. TO TRY NEXT BIT MAP?
	JMP	DSALP1		/YES.
/
/ IF A DISK ERROR OCCURRED, RETURN THE DISK STATUS IN THE REQUESTOR'S
/ EVENT VARIABLE. OTHERWISE, RETURN CODE FOR "MEDIUM FULL".
/
DSAGME	LAC	DSADER		/DISK ERROR IF NON-0.
	SNA
	LAW	-15		/CANNOT ALLOCATE SPACE REQUESTED.
				/MEDIUM FULL.
	JMP	DSAREV
/
/ THE BIT MAP CONTAINS ENOUGH FREE SPACE TO HONOR THE ALLOCATE.
/
DSAFND	LAC	DSAIDX		/SET THE XR AS INDEX TO THE WORD
	PAX			/CONTAINING THE INITIAL 0 IN
				/THIS SEQUENCE.
	JMS	DSASET		/SET THE NUMBER OF REQUESTED BITS...
	STL			/(THIS IS AN ARGUMENT TO DSASET)
				/...IN THE BIT MAP TO 1'S.
				/(LINK, AC, MQ, XR, DSACNT & DSABKS ALTERED).
	LAC	DSACTB		/SET THE XR WITH THE
	TAD	DSAXAD		/PAGE-BIT ADJUSTED
	PAX			/CONTROL TABLE ADDRESS.
	CLL			/CONVERT THE NUMBER OF STORAGE
	LAC	DSASBR		/BLOCKS TO THE NUMBER OF WORDS
	ALS	10		/ALLOCATED, AND STORE IN THE
	DAC	0,X		/REQUESTOR'S CONTROL TABLE.
/
/ NOTE: HERE WE NEED TO COMPUTE THE BLOCK # OF THE FIRST BLOCK COVERED BY
/ THE BIT MAP. SINCE BIT MAP POSITION RELATIVE TO THE DISK BLOCKS IT
/ COVERS VARIES WITH THE DISK TYPE, THE FOLLOWING CODE IS FORCED TO BE
/ DEVICE SPECIFIC. WHAT IS BEING PUT INTO THE AC IS MINUS THE # OF BLOCKS
/ IN FRONT OF THE BLOCK CONTAINING THE BIT MAP.
/
	JMS	DSASEL		/LOAD AC WITH START OF SECOND HALF OF TABLE
	DSARFT+5
	0
	DSARKT+3
	SZA			/DOES THE AC (=0) INDICATE THE RP?
	JMP	DSANRP		/NO
	LAC	DSAMAP+377	/YES -- IS THIS THE LAST RP BITMAP?
	SAD	(-1
	CLA!SKP			/YES -- IT'S UNIQUE
	LAW	-764		/NO -- DON'T USE THE TABLE TO FIND THE BIT MAP
	TAD	DSAPLT
	JMP	DSABTA
DSANRP	DAC*	(X12		/INIT. X12 AS A POINTER
	LAC*	X12		/LOOK FOR A BIT MAPBLOCK=DSAPLT
	SPA!SNA			/END OF TABLE?
	JMP	DSACTE		/YES -- ERROR
	SAD	DSAPLT		/MATCH?
	SKP			/YES
	JMP	.-5		/NO -- CHECK NEXT TABLE ENTRY
	JMS	DSASEL		/GET LAST BLOCK ON THE PREVIOUS BIT MAP
	-6
	-54
	-4
	TAD*	(X12
	DAC	DSATMP
	LAC*	DSATMP		/GET THAT BLK NO. INTO AC
	IAC			/AC NOW HAS 1ST BLOCK COVERED ON CORRECT MAP
DSABTA	TAD	DSABTN		/ADD ON RELATIVE BLOCK NUMBER
				/TO GET THE BLOCK NO. OF 1ST
				/BLOCK ALLOCATED
	LMQ			/CONVERT THIS TO A DOUBLE-WORD ADDRESS
	LLSS!ECLA 10		/AND PUT IN IN THE USER'S CTB.
	XOR	DSACUN		/XOR IN THE UNIT NUMBER FIRST.
	DAC	1,X
	LACQ
	DAC	2,X		/STORE THE SECOND WORD.
	CAL	DSAPUT		/WRITE OUT THE BIT MAP
	JMS	DSADEC		/WAIT FOR IT AND
	SPA			/SKIP IF NO ERROR.
	JMP	DSAREV		/ERROR!
	JMP	DSAEV1		/ALLOCATE WAS SUCCESSFUL. SET
				/THE REQUESTOR'S EVENT VARIABLE TO +1.
/
	.EJECT
/ DEALLOCATE ROUTINE.
/
DSADAL	LAC*	DSACTB		/AMOUNT OF STORAGE TO BE DEALLOCATED
	AND	(377)		/MUST BE AN EVEN MULTIPLE OF 400
	SZA			/OCTAL.
	JMP	DSACTE		/NO. SOMETHING IS WRONG.
	LAC	DSACTB		/PUT THE ADDRESS OF THE CONTROL
	TAD	DSAXAD		/TABLE (ADJUSTED FOR PAGE BITS)
	PAX			/ IN THE XR.
	LAC	X,2		/CREATE A BLOCK NUMBER
	LMQ			/FROM THE INFO IN THE CONTROL TABLE
	AND	(377		/IS THE DISK ADDR. VALID (MUST BE A
	SZA			/MULTIPLE OF 400 OCTAL)?
	JMP	DSACTE		/NO -- ERROR
	LAC	X,1
	AND	(377)		/MASK OFF UNIT #.
	LLSS	12		/CONVERT TO BLOCK #.
	DAC	DSAREM		/SAVE TEMP. IN SCRATCH.
	LACQ
	SZA			/TEST LO BITS LEFT IN MQ.
	JMP	DSACTE		/ERROR - NOT ON BLOCK BOUNDARY.
	LAC	DSATYP		/IS THIS THE RP?
	SAD	(3
	SKP
	JMP	DSADA1		/NO -- USE THE TABLE
	LAC	DSAREM		/YES -- CALCULATE THE VALUES FOR THE RP
	IDIV			/DIVIDE BY 1000(10)
	1750
	DAC	DSABTP		/SAVE THE RELATIVE BLK NO.
	TAD	DSASBR		/ADD THE NUMBER OF BLKS TO DEALLOCATE
	TAD	(-1750		/DOES THIS FIT ON THE MAP?
	SMA!SZA
	JMP	DSACTE		/NO -- ERROR
	LACQ			/YES -- GET QUOTIENT
	MUL!660000		/MULTIPLY BY 1000(10)
	1750
	LACQ			/GET RESULT
	SAD	(116100		/LAST RP MAP?
	SKP			/YES
	TAD	(764		/ADD 500(10)
	DAC	DSAPLT		/SAVE THE BIT MAP BLOCK NUMBER
	JMP	DSADA2
DSADA1	LAC	DSAREM		/NEGATE BLK NO. OF 1ST BLK TO DEALL.
	TCA
	DAC	DSATMP		/SAVE THIS TEMP.
	JMS	DSASEL		/FIND OUT WHAT MAP THIS IS ON.
	DSARFT
	0
	DSARKT
	DAC*	(X12
	LAC*	X12
	SPA!SNA			/END OF TABLE?
	JMP	DSACTE		/YES -- ERROR
	TAD	DSATMP		/SUBTRACT BLK NO. FROM HIGHEST
				/BLOCK ON THE MAP
	SPA			/IS THE BLOCK ON THIS MAP?
	JMP	.-5		/NO -- EXAMINE NEXT MAP
	TAD	DSABKS		/YES -- ALL BLKS TO DEAL ON THE MAP?
	IAC			/ADD 1 SO IF DEALLOCATING LAST BLOCKS ON MAP
				/A CONTROL ERROR IS NOT DECLARED.
	SPA
	JMP	DSACTE		/NO -- ERROR
	JMS	DSASEL		/YES -- WHAT BLOCK CONTAINS THE MAP?
	5
	53
	3
	TAD*	(X12
	DAC	DSATMP		/DSATMP POINTS TO THE BLOCK NO OF MAP
	LAC*	DSATMP
	DAC	DSAPLT		/SAVE THE MAP NUMBER
	LAC*	(X12
	AAC	-2
	DAC*	(X12
	LAC*	X12		/GET LAST BLK OF PREVIOUS MAP
	TCA
	TAD	DSAREM		/GET THE RELATIVE BLK NO.
	AAC	-1
	DAC	DSABTP		/SAVE RELATIVE BLK NO.
/
/ O.K. TO DEALLOCATE.
/
DSADA2	JMS	DSAGBM		/"GET" THE BIT MAP (IF NOT ALREADY IN CORE)
				/AND "WAITFOR" COMPLETION. CHECK FOR
				/DISK ERROR & SET FLAG IF SO,
				/CLEAR THE EVENT VARIABLE, AND
				/SET THE AC + ON RETURN IF THE TRANSFER
				/WAS SUCCESSFUL; RETURN THE DISK STATUS,
				/IF NOT.
				/(ASSUME ALL ACTIVE REGISTERS ARE
				/ALTERED DUE TO THE CAL).
	SPA			/ERROR?
	JMP	DSAREV		/YES. DEALLOCATE WAS UNSUCCESSFUL.
				/SET THE REQUESTOR'S EVENT VARIABLE
				/WITH THE DISK STATUS.
/
/
/FIND OUT WHICH BIT IN WHICH WORD THE DEALLOCATION FIRST BLOCK BELONGS TO
/
	LAC	DSABTP		/PICK UP THE RELATIVE BLOCK NUMBER
	IDIV!660000		/DIVIDE THIS BY
	22			/18 DECIMAL
	DAC	DSABTP		/SAVE THE REMAINDER AS THE OFFSET INTO THE WORD
	LACQ			/AND THE QUOTIENT IS
	PAX			/THE OFFSET INTO THE WORDS OF THE MAP
/
	JMS	DSASET		/SET THE NUMBER OF REQUESTED BITS...
	CLL			/(ARGUMENT TO DSASET)
				/...IN THE BIT MAP TO 0'S.
				/(LINK, AC, MQ, XR, DSACNT & DSABKS ALTERED).
	CAL	DSAPUT		/WRITE OUT THE BIT MAP
	JMS	DSADEC		/WAIT FOR EV AND
	SMA			/SKIP IF ERROR.
/
/
/ COME HERE ON SUCCESSFUL COMPLETION OF ALLOCATE OR DEALLOCATE.
/
DSAEV1	CLA!IAC
/
/ SET THE REQUESTOR'S EVENT VARIABLE IF ONE IS SPECIFIED.
/
DSAREV	PAL			/SAVE VALUE TEMPORARILY.
	LAC	DSARQN		/ADDRESS OF THE REQUEST NODE.
	DAC*	(R2)		/SAVE FOR CALL TO "IOCD" BELOW.
	TAD	DSAXAD		/ADJUST PAGE BITS BEFORE PUTTING IN XR.
	PAX
	LAC	6,X		/WAS AN EVENT VARIABLE SPECIFIED?
	SNA
	JMP	DSANOV		/NO.
	TAD	DSAXAD		/ADJUST PAGE BITS.
	PAX			/ADDRESS OF THE EVENT VARIABLE.
	PLA
	DAC	0,X
/
DSANOV	JMS*	(IOCD)		/DECREMENT THE I/O PENDING COUNT (FOR
				/NORMAL MODE TASKS ONLY).
				/(R5, XR & AC ARE ALTERED).
/
/ DECLARE A SIGNIFICANT EVENT.
/
	.SET6
/
/ RETURN THE I/O REQUEST NODE TO THE "EMPTY" POOL.
/
	LAC	(POOL)		/ADDRESS OF THE "EMPTY" POOL.
	DAC*	(R1)
	LAC	DSARQN		/ADDRESS OF THE NODE.
	DAC*	(R2)
	JMS*	(NADD)		/ADD THE NODE TO "POOL".
				/(R2, R6, XR & AC ARE ALTERED).
/
	JMP	DSANXT		/CHECK IF THERE ARE ANY OTHER
				/ALLOCATE OR DEALLOCATE REQUESTS.
/
/ ERRORS.
/
DSACTE	LAW	-104		/ERROR IN ARGUMENT IN CONTROL TABLE.
	JMP	DSAREV
/
	.EJECT
/
/ DSACMP -- SUBROUTINE TO COMPARE BIT MAPS TO SEE IF ONE THAT MATCHES
/ CURRENT REQUEST IS IN CORE. IT COMPARES DISK DEVICE TYPE AND UNIT #
/ TO DETERMINE IF A MAP ON THE REQUESTED UNIT OF THE REQUESTED DISK
/ TYPE IS IN CORE. RETURNS TO CALLER+1 IF NO MATCH IS FOUND, TO CALLER+2
/ IF A MATCH IS FOUND.
/
/	CALLING SEQUENCE:
/
/		(DSATYP -- CONTAINS REQUESTED DISK TYPE)
/		(DSAUNT -- CONTAINS REQUESTED UNIT #)
/		JMS	DSACMP
/		XX		/RETURN HERE IF NO MATCH
/		XX		/RETURN HERE ON MATCH
/
/	MODIFIED REGISTERS:
/
/		AC
/
DSACMP	0
	LAC	DSACPL		/IS THERE A BIT MAP IN CORE?
	SPA
	JMP*	DSACMP		/NO - EXIT.
	LAC	DSAGTY		/YES - IS CURRENT DISK TYPE
	SAD	DSATYP		/EQUAL TO REQUESTED TYPE?
	SKP
	JMP*	DSACMP		/NO - EXIT.
	LAC	DSACUN		/YES - IS CURRENT UNIT #
	SAD	DSAUNT		/EQUAL TO REQUESTED UNIT #?
	SKP
	JMP*	DSACMP		/NO - EXIT.
	IDX	DSACMP		/YES - RETURN TO CALLER+2
	JMP*	DSACMP
/
	.EJECT
/
/ DSASEL -- SUBROUTINE TO LOAD AC WITH ONE OF THREE CONSTANTS FOLLOWING
/ THE CALL, DEPENDING ON DISK DEVICE TYPE (DSATYP). RETURNS TO CALLER+4.
/
/	CALLING SEQUENCE:
/
/		(DSATYP CONTAINS REQUESTED DISK TYPE CODE)
/		JMS	DSASEL
/		CONSTANT 1	/LOADED IF DISK TYPE IS RF.
/		CONSTANT 2	/LOADED IF DISK TYPE IS RP
/		CONSTANT 3	/LOADED IF DISK TYPE IS RK.
/		(RETURN HERE)
/
/	MODIFIED REGISTERS:
/
/		AC
/
DSASEL	0
	LAC	DSASEL		/SETUP RETURN ADDRESS.
	AAC	3
	DAC	DSARTN
	LAC	DSATYP
	SAD	(2)		/RF DISK?
	JMP	DSARF
	SAD	(3)		/RP DISK?
	JMP	DSARP
	ISZ	DSASEL		/ASSUME RK.
DSARP	ISZ	DSASEL		/BUMP POINTER ONCE MORE.
DSARF	LAC*	DSASEL		/LOAD THE AC
	JMP*	DSARTN
DSARTN	XX			/RETURN ADDRESS
/
	.EJECT
/ SUBROUTINE DSASET -- CALLED BY ALLOCATE AND DEALLOCATE TO SET
/ AND CLEAR, RESPECTIVELY, A CONTIGUOUS SET OF BITS IN THE CORE BIT MAP.
/
/ CALLING SEQUENCE:
/
/	(DSABTP -- CONTAINING STARTING BIT # (0 TO 21 OCTAL))
/	(XR -- CONTAINING ADDRESS OF THE STARTING WORD - BASE ADDRESS)
/	(DSABKS -- CONTAINING -# OF BITS TO BE SET)
/	JMS	DSASET
/	ARG			/ARG = STL TO SET BIT = 1.
/	(UNCONDITIONAL RETURN)	/ARG = CLL TO SET BIT = 0.
/
/ MODIFIED REGISTERS:
/
/	LINK, AC, MQ,  XR, DSACNT, AND DSABKS
/
DSASET	0
	LAC*	DSASET		/STL OR CLL.
	DAC	DSASOC
	DAC	DSASTE		/SAVE INST. FOR RETURN
	DZM	DSATMP		/ZERO COUNT OF BLOCKS CHANGED
	LAW	-22		/SET COUNT FOR 18 DECIMAL BITS.
	DAC	DSACNT
	CLL
	LAC	DSAMAP+3,X	/GET 1ST WORD TO BE MODIFIED.
	DAC	DSAT1		/SAVE OLD CONTENTS OF WORD
/ 
DSAST1	RAL
	LMQ
	LAW	-22		/DOES THE COUNT INDICATE THAT THE 1ST
	TAD	DSABTP		/BIT TO BE MODIFIED IS NOW IN THE LINK?
	SAD	DSACNT
	JMP	DSAMQA		/YES.
	LACQ			/NO.
	IDX	DSACNT
	JMP	DSAST1
DSAMQA	LACQ
/
/ THE FOLLOWING REGISTER IS INITIALLY SET TO STL OR CLL TO
/ SET =1 OR =0 A SET OF BITS. WHEN THE NUMBER OF BITS TO BE SET IS
/ EXHAUSTED, THIS INSTRUCTION IS CHANGED TO NOP SO
/ THAT THE REMAINDER OF THE WORD WILL BE UNCHANGED.
/
DSASOC	XX			/STL OR CLL OR NOP.
	RAL
	ISZ	DSABKS		/HAVE ALL THE DESIRED BITS BEEN SET?
	JMP	DSAST2		/NO.
/
/ ALL DESIRED BITS HAVE BEEN SET (OR CLEARED). SINCE THE CURRENT WORD
/ MAY NOT YET BE ROTATED INTO POSITION, MODIFY THE LOOP INSTRUCTION
/ SO THAT IT NO LONGER SETS OR CLEARS BITS.
/
	LMQ			/TEMPORARY SAVE.
	LAC	(NOP)
	DAC	DSASOC
	LACQ
/
DSAST2	ISZ	DSACNT		/NO. IS THIS WORD FINISHED?
	JMP	DSASOC		/NO.
/
/ WORD HAS BEEN ROTATED LEFT 19 DECIMAL PLACES.
/
	DAC	DSAMAP+3,X	/STORE WORD.
	LAW	-22		/SET COUNTER TO COUNT SHIFTS DURING
	DAC	DSAT2		/COUNTING OF CHANGED BITS.
	LAC	DSAT1		/GET OLD VALUE OF WORD
	XOR	DSAMAP+3,X	/PREPARE TO COUNT CHANGED BITS
	SPA
	IDX	DSATMP		/BIT WAS CHANGED SO BUMP COUNTER
	ISZ	DSAT2		/END OF WORD?
	SKP
	JMP	.+3		/YES -- CONTINUE
	ALS	1		/NO -- SHIFT TO TEST NEXT BIT
	JMP	.-6
/
/ END TEST -- HAS THE SWITCHABLE INSTRUCTION BEEN CHANGED TO NOP?
/ IF SO, DONE.
/
	LAC	DSASOC		/IS IT NOP?
	SAD	(NOP)
	JMP	DSASTE		/YES. RETURN.
/
	LAW	-22		/NO. RESET THE COUNT OF
	DAC	DSACNT		/BITS PER WORD.
	AXR	1		/INDEX TO NEXT WORD.
	CLL
	LAC	DSAMAP+3,X	/PICK UP AND CONTINUE
	DAC	DSAT1		/(SAVE IT)
	RAL			/WITH THE NEXT WORD.
	JMP	DSASOC
/
DSASTE	XX			/STL OR CLL
	LAC	DSATMP		/GET NO. OF BITS CHANGED
	SNL
	TCA
	TAD	DSAMAP+2
	DAC	DSAMAP+2	/FIX BLOCKS COUNTER IN MAP
	JMP*	DSASET		/RETURN
	.EJECT
/ SUBROUTINE DSANUF -- COMPUTE THE NUMBER OF CONTIGUOUS 0-BITS FOUND
/ SO FAR, AND DETERMINE IF THIS IS ENOUGH TO SATISFY THE ALLOCATE
/ REQUEST.
/
/ CALLING SEQUENCE:
/
/	JMS	DSANUF
/	(RETURN HERE IF NOT ENOUGH)	/VALUE OF AC=0.
/	(IF ENOUGH, DON'T RETURN HERE)
/	(INSTEAD, GO TO DSAFND)
/
/ ALTERED REGISTERS:
/
/	AC
/
DSANUF	0			/NOTE -- LINK STORED HERE BY JMS.
	LAC	DSABTN		/BIT NUMBER OF THE 1ST 0-BIT.
	TCA
	TAD	DSABNM		/CURRENT BIT NUMBER.
/
/ AC NOW CONTAINS THE NUMBER OF CONTIGUOUS 0-BITS.
/
	TAD	DSABKS		/-# OF BLOCKS REQUESTED.
DSALIT	SMA!CLA			/ENOUGH? (THIS INSTRUCTION IS USED
				/AS A LITERAL).
	JMP	DSAFND		/YES.
	RES			/PRIME THE CPU TO RESTORE THE LINK
				/FROM THE SUBROUTINE ENTRY POINT.
	JMP*	DSANUF
/
	.EJECT
/ SUBROUTINE DSADEC -- (1) PERFORMS A "WAITFOR" THE EVENT VARIABLE
/ ASSOCIATED WITH THE "GET" OR "PUT" OPERATION, (2) SETS A DISK ERROR
/ FLAG IF A DISK ERROR OCCURRED, AND (3) CLEARS THE EVENT VARIABLE.
/
/ CALLING SEQUENCE:
/
/	JMS	DSADEC
/	(UNCONDITIONAL RETURN)	/EVENT VARIABLE VALUE IS IN THE AC.
/
/ ALTERED REGISTERS:
/
/	ALL ACTIVE REGISTERS (DUE TO CAL)
/
DSADEC	0
	CAL	DSAWT4		/"WAITFOR" "GET" OR "PUT" COMPLETION.
	LAC	DSAEV		/PICK UP, THEN CLEAR, THE EVENT
	DZM	DSAEV		/VARIABLE.
	SPA			/DISK ERROR?
	DAC	DSADER		/YES. SAVE THE DISK STATUS.
	JMP*	DSADEC
/
/ 
/ SUBROUTINE DSATAB -- CONSTRUCTS THE BIT MAP TABLES
/
/ CALLING SEQUENCE:
/ 
/	INIT. X12 (POINTS TO PART 1 OF TABLE)
/	INIT. X13 (POINTS TO PART 2 OF TABLE)
/	AC=1ST BIT MAP BLOCK NO.
/	JMS	DSATAB
/	(IF NO ERROR, RETURN AT JMS+1)
/	(IF ERROR, JMP TO DSAREV)
/
/ ALTERED REGISTERS: ALL
/ 
DSATAB	0
	DZM	DSATMP
	DAC	DSAPLT		/SAVE THE BIT MAP NO.
	LAC*	(X12		/SAVE X12 AROUND CAL
	DAC	DSAT1
	LAC*	(X13		/SAVE X13
	DAC	DSAT2
	JMS	DSAGBM		/GET THE BIT MAP
	SPA			/ERROR?
	JMP	DSAREV		/YES
	LAC	DSAT1		/NO -- RESTORE X12 AND X13
	DAC*	(X12
	LAC	DSAT2
	DAC*	(X13
	LAC	DSAMAP+1	/NO -- GET THE BLKS ON THIS MAP
	TAD	DSATMP		/ADD ALL BLKS COVERED SO FAR
	DAC	DSATMP		/SAVE RESULT
	AAC	-1
	DAC*	X12		/SAVE LAST BLK COVERED BY THIS MAP
	LAC	DSAPLT
	DAC*	X13		/SAVE THE MAP NO.
	IDX	DSADBM		/FOR RF COUNT MAPS
	LAC	DSAMAP+377	/LAST MAP?
	SAD	(-1
	JMP*	DSATAB		/YES -- RETURN
	JMP	DSATAB+2	/NO -- GET NEXT MAP
	.EJECT
/ SUBROUTINE DSAGBM -- TESTS IF THE REQUESTED BIT MAP IS IN CORE AND,
/ IF NOT, BRINGS IT IN.
/
/ CALLING SEQUENCE:
/
/	JMS	DSAGBM
/	(UNCONDITIONAL RETURN)	/AC + IF NO ERROR.
/				/AC - (DISK STATUS) IF ERROR.
/
/ ALTERED REGISTERS:
/
/	ALL ACTIVE REGISTERS (DUE TO CAL)
/
DSAGBM	0
	LAC*	(WARMFL)	/SAVE BIT 0 OF THE "WARM START" FLAG
	RAL			/IN THE LINK.
	.INH			///INHIBIT INTERRUPTS.
	LAC*	(WARMFL)	///CLEAR BIT 0 IN THE FLAG.
	AND	(377777)	///
	.ENB			///ENABLE INTERRUPTS.
	DAC*	(WARMFL)	///
	SZL			/IF THE RF15 WARM START BIT WAS ON, NO
	JMP	DSAWRM		/BIT MAP HAS BEEN READ IN SINCE THE LATEST
				/WARM START OR SAVE, WHICHEVER CAME LAST.
	JMS	DSACMP		/DOES DISK TYPE AND UNIT # MATCH
	JMP	DSAWRM		/NO, TREAT AS WARM START.
	LAC	DSAPLT		/YES, BUT IS REQUESTED MAP
	SAD	DSACBK		/EQUAL TO CURRENT MAP?
	JMP*	DSAGBM		/YES, SO RETURN.
DSAWRM	LAW	-1		/SET THE MAP FLAG TO INDICATE
	DAC	DSACPL		/THAT NO BIT MAP IS IN CORE (IN CASE OF
				/AN ERROR).
	CLL
	LAC	DSAPLT		/ CHANGE THE BLOCK # OF THE BIT MAP TO A
	LMQ			/DOUBLE WORD DISK ADDRESS
	LLSS!ECLA  10		/MULTIPLY BY 400(8)
	XOR	DSAUNT		/XOR DISK UNIT # INTO BITS 0-2.
	DAC	DSADKC		/LOAD HI ORDER ADDRESS INTO CTB.
	LACQ
	DAC	DSADKC+1	/THEN LOAD LO ORDER PART INTO CTB.
	LAC	DSATYP		/SET UP DISK TYPE CODE
	DAC	DSAGTY		/IN GET/PUT CPB'S.
	DAC	DSAPTY
	CAL	DSAGET		/"GET" THE BIT MAP.
	JMS	DSADEC		/"WAITFOR" COMPLETION, CHECK FOR DISK
				/ERROR & SET FLAG IF SO, CLEAR THE EVENT
				/VARIABLE, AND RETURN THE EVENT VARIABLE
				/SETTING IN THE AC. (ASSUME ALL ACTIVE
				/REGISTERS ARE ALTERED DUE TO THE CAL).
	SPA			/ERROR?
	JMP*	DSAGBM		/YES (DISK STATUS IN THE AC).
	LAC	DSAUNT
	DAC	DSACUN		/UPDATE CURRENT UNIT #.
	LAC	DSAPLT		/NO -- SET THE CURRENT MAP BLOCK # TO
	DAC	DSACBK		/INDICATE WHICH BIT MAP IS IN CORE.
	LAC	(1		/SET DSACPL POSITIVE TO INDICATE THAT
	DAC	DSACPL		/A BIT MAP IS IN CORE.
	JMP*	DSAGBM		/NOTE -- AC +.
/
	.EJECT
/ "GET" CPB.
/
DSAGET	13000			/"GET" I/O REQUEST CODE.
	DSAEV			/EVENT VARIABLE.
	1			/LOGICAL UNIT 1 (TO WHICH IT IS
				/KNOWN THAT "DSK" IS ASSIGNED).
	DSADKC			/CONTROL TABLE ADDRESS.
DSAGTY	0			/DISK DEVICE TYPE
/
/ "PUT" CPB.
/
DSAPUT	13100			/"PUT" I/O REQUEST CODE.
	DSAEV			/EVENT VARIABLE.
	1			/LOGICAL UNIT 1 (TO WHICH IT IS
				/KNOWN THAT "DSK" IS ASSIGNED).
	DSADKC			/CONTROL TABLE ADDRESS.
DSAPTY	0			/DISK DEVICE TYPE.
/
DSADKC	.-.			/CONTROL TABLE FOR GET AND PUT
	.-.			/DOUBLE WORD DISK ADDRESS GOES HERE
	DSAMAP			/CORE BUFFER ADDRESS.
	400			/NUMBER OF WORDS TO "GET" OR "PUT".
/
/ "WAITFOR" CPB.
/
DSAWT4	20			/"WAITFOR" CODE.
	DSAEV
/
DSAEV	0			/EVENT VARIABLE ASSOCIATED WITH
				/"GET" AND "PUT".
/
/ "WAITFOR" CPB.
/
DSAW4T	20			/"WAITFOR" CODE.
	DSATEV
/
DSATEV	0			/EVENT VARIABLE USED TO "TRIGGER"
				/EXECUTION OF THIS TASK. VARIABLE IS
				/SET BY THE TASK "DSK" WHEN IT HAS
				/QUEUED AN ALLOCATE OR DEALLOCATE
				/REQUEST.
DSADER	0			/IF A PERSISTENT DISK ERROR OCCURS,
				/THE CONTENTS OF THE DISK STATUS
				/REGISTER ARE STORED HERE.
DSABTP	0			/BIT POSITION WITHIN THE WORD.
DSASBR	0			/+# OF STORAGE BLOCKS REQUESTED.
DSABKS	0			/-# OF STORAGE BLOCKS REQUESTED.
DSACNT	0			/COUNTER.
DSATMP	0			/TEMPORARY STORAGE.
DSABNM	0			/BIT NUMBER (0 TO 1777).
DSABTN	0			/BIT NUMBER (0 TO 1777).
DSAWCT	0			/-# OF WORDS REMAINING TO BE
				/SCANNED IN THE BIT MAP.
DSAIDX	0			/INDEX.
DSATYP	0			/REQUESTED DISK DEVICE TYPE.
DSAUNT	0			/REQUESTED DISK UNIT NUMBER (BITS 0-2).
DSACUN	0			/CURRENT UNIT NUMBER (BITS 0-2).
DSACBK	0			/CURRENT BIT MAP BLOCK NUMBER.
DSACTU	0			/ADDRESS OF UNIT # IN CTB.
DSAXAD	0			/PAGE BIT ADJUSTMENT FACTOR.
DSACTB	0			/ADDRESS OF THE CONTROL TABLE
				/ASSOCIATED WITH THE ALLOCATE
				/OR DEALLOCATE REQUEST.
DSARQN	0			/ADDRESS OF THE I/O REQUEST NODE.
DSARQH	.			/HEAD OF THE I/O REQUEST QUEUE
	.-1			/FOR THIS TASK. ENTRIES ARE
				/MADE BY THE TASK "DSK".
DSACPL	-1			/SET POSITIVE TO INDICATE WHEN A
				/BIT MAP IS IN CORE. SET NEGATIVE WHEN
				/NO BIT MAP IS IN CORE.
DSAPLT	.-.			/REQUESTED DISK BIT MAP ADDRESS
DSAREM	.-.			/SCRATCH STORAGE
DSAPCT	0			/BIT MAP COUNTER USED BY ALLOCATE.
DSAT1	0			/TEMP STOREAGE
DSAT2	0			/TEMP STOREAGE
DSARTS	0			/BIT COUNTER FOR LAST PARTIAL WORD OF MAP
/
/ DSA "SHORT PARTITION BLOCK" (FOR REGISTER SAVE USE ONLY)
/
				/DSAIC = PARTITION BLOCK
DSAIC	SHPB L.DSK		/ADDRESS PLUS AN OFFSET.	/EAG:202
/
/ ACTIVE TASK LIST NODE.
/
DSA	TTY			/FORWARD LINKAGE
	DSK			/BACKWARD LINKAGE
	.SIXBT	"DSA"		/TASK NAME (FIRST HALF)
	0			/TASK NAME (SECOND HALF)
	1			/TASK PRIORITY (MUST BE LOWER
				/THAN THAT OF THE TASK "DSK").
	DSAIC-P.TP	/"PARTITION BLOCK" ADDRESS		/(171)
	0			/STL NODE ADDRESS (NONE).
	4			/TASK STATUS (INITIALLY
				/READY FOR RESUMPTION).
	DSATW			/RESUMPTION ADDRESS.
	0			/EVENT VARIABLE ADDRESS
	.IFPNZ	NDSZMT
	.REPT	NDSZMT
	0
	.ENDC
/
/
/ DISK BIT MAP BUFFER FOR DSA ROUTINE
/
DSAMAP	.BLOCK	400
	.EJECT
/
/ BIT MAP TABLES
/
/ THE FORMAT OF THESE THREE TABLES IS AS FOLLOWS:
/
/	DSARXT	-1
/		####	/LAST BLOCK COVERED BY 1ST BIT MAP
/		####	/LAST BLOCK COVERED BY 2ND BIT MAP
/		.
/		.
/		.
/		####	/LAST BLOCK COVERED BY LAST BIT MAP
/		-1
/		####	/BLOCK NUMBER OF 1ST BIT MAP
/		####	/BLOCK NUMBER OF 2ND BIT MAP
/		.
/		.
/		.
/		####	/BLOCK NUMBER OF LAST BIT MAP
/
DSARFT=.
	.REPT	12
	-1
DSARKT=.
	-1
	10645
	11407
	-1
	1776
	1775
	-1
								/EAG:166
								/EAG:166
	.LST							/EAG:166
	.IFUND L.SCF						/EAG:202
	.NOLST							/EAG:166
	.ENDC							/EAG:166
	.TITLE *** ATL NODE FOR SYSTEM CONFIGURATOR
 
 
 
 
/

/ ATL NODE FOR THE SYSTEM CONFIGURATION ROUTINE.  THIS ROUTINE 

/ IS ASSEMBLED INTO THE SYSTEM AS AN ACTIVE TASK WHICH WILL RUN ONCE,

/ REMOVE ITSELF FROM THE SYSTEM , AND EXIT.  THIS NODE IS RETURNED

/ TO THE POOL UPON EXIT.
/

SFG	ATKL		/FORWARD LINKAGE

	IORD		/BACKWARD LINKAGE

	.SIXBT	"SFG"	/TASK NAME (FIRST HALF)

	.SIXBT	"@@@"	/TASK NAME (SECOND HALF)

	1000		/TASK PRIORITY

	SFGIC-P.IC	/PARTITION BLOCK ADDRESS

	SCF		/STL NODE ADDRESS
	4		/TASK STATUS (READY TO RESUME)
	SCONF		/RESUMPTION ADDRESS

	0		/EVENT VARIABLE ADDRESS

	.IFPNZ	NDSZMT

	.REPT	NDSZMT

	0
	.ENDC
								/EAG:202
								/EAG:202
	.IFUND L.ALL						/EAG:202
	.NOLST							/EAG:202
	.ENDC							/EAG:202
	.IFDEF L.LUN						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
	.TITLE *** DISK - UFD TABLE ***

/

/ THIS TABLE RELATES THE DEFAULT UFD NAME FOR ALL DISKS TO

/ THE DISK UNIT. THE TABLE IS SETUP FOR THE SYSTEM DISK BY

/ SCF. THE MNT MCR FUNCTION SETS THE TABLE FOR USER DISKS

/ WHILE THE DSM MCR FUNCTION CLEARS THE TABLE FOR THE

/ SPECIFIED DISK. THE FIRST EIGHT ENTRIES ARE FOR RP0-RP7.

/ THE NEXT EIGHT ENTRIES ARE FOR RK0-RK7. THE LAST ENTRY

/ IS FOR THE RF. NOTE THAT THE NAME OF THE UFD IS STORED IN

/ THIS TABLE AND NOT THE UFD STARTING BLOCK.

/

/
UFDDSK=.

	.REPT	21

	0

/

	.LST

	.IFUND	L.MAC

	.NOLST
	.ENDC
	.TITLE *** TIME SLICING SUBROUTINE
/ 
/ ***   NOTES ON TIME SLICING   ***
/  
/ THE TIME SLICING ROUTINE FOUND BELOW WAS ENTERRED IN
/ EDIT #202. IT WORKS THIS WAY: WHEN THE TIME SLICING TICK
/ COUNTER IS ISZ'D TO ZERO THE ATL IS SCANNED (BEGINNING WITH
/ CURTSK). THE FIRST TASK WHICH IS IN THE TIME SLICING BAND
/ AND IS IN STATUS 5 IS REMOVED FROM THE ATL, HAS ITS PRIORITY
/ CHANGED TO THE HIGHEST PRIORITY IN THE BAND, AND IS THEN
/ SPRI'D (INSERT BY PRIORITY) INTO THE ATL AGAIN. IN THIS WAY
/ I/O BOUND TIME SLICED TASKS MIGRATE TOWARD THE TOP OF
/ THE ATL WHILE COMPUTE BOUND TASKS MIGRATE TOWARD THE REAR.
/ TASKS BELOW THE BAND RUN AS IF TIME SLICING WAS NOT ON!
/ 
/ 
SLICE	0
	LAC*	(SLITIM		/IS TIME SLICING ON?
	SNA
	JMP*	SLICE		/NO -- RETURN
/
	ISZ*	(SLICNT		/YES -- HAS THE COUNTER RUN OUT?
	JMP*	SLICE		/NO -- RETURN
	LAC*	(SLITIM		/YES -- RESET ISZ COUNTER
	TCA
	DAC*	(SLICNT
/
	LAC*	(CURTSK		/PREPARE TO SCAN ATL. START WITH
	JMP SLI.B	/ ENTER SLICING LOOP AT THE CORRECT	/(204)
			/ ENTRY POINT.				/(204)
/
SLI.N	LAC	A.FP,X		/END OF ATL?
	SAD	(ATKL
	JMP	SLI.E		/YES -- PREPARE TO EXIT
SLI.B	DAC* (R2)	/ NO -- SAVE NODE ADDRESS FOR SPRI.	/(204)
	JMS	SLI.SR		/CHECK CHARACTERISTICS OF THIS NODE
	JMP	SLI.N		/RETURN HERE IF PRIO TOO LOW
	JMP	SLI.E		/RETURN HERE IF PRIO TOO HIGH
	JMP	SLI.N		/RETURN HERE IF NOT IN STATE 5
	LAW 16000	/ FETCH AND MASK TO REMOVE TASK PRI.	/(204)
	.INH			/SET PRIO TO HIGHEST IN BAND
	AND A.TP,X	/ FETCH AND REMOVE OLD PRIORITY.	/(204)
	XOR*	(SLIHR
	.ENB
	DAC	A.TP,X
	LAC* (R2)	/ FETCH NODE ADDRESS FOR NDELXR.	/(204)
	PAX		/ SET UP XR FOR NDELXR.			/(204)
	JMS* (NDELXR)	/ REMOVE THE NODE FROM THE ATL.		/(204)
	LAC	(ATKL	/ FETCH LIST HEAD.
	DAC*	(R1
	JMS*	(SPRI		/ENTER NODE INTO ATL
	.SET6			/DECLARE A SIGNIFICANT EVENT
SLI.E	JMP*	SLICE		/RETURN
	.EJECT
/ 
/ SUBROUTINE SLI.SR -- SEE IF TASK IS IN PRIO RANGE AND AT STATUS 5
/ 
/	IF PRIO IS TOO LOW RETURN AT JMS+1
/	IF PRIO IS TOO HIGH RETURN AT JMS+2
/	IF NOT IN STATUS 5 RETURN AT JMS+3
/	IF IN PRIO RANGE AND IN STATUS 5 RETURN AT JMS+4
/ 
/	ON ENTRY THE AC POINTS TO THE NODE
/ 
/	THE FOLLOWING REGISTERS ARE ALTERED: AC, XR, LINK
/ 
/ 
SLI.SR	0
	JMS	SLI.ST		/SET XR TO ACCESS NODE
	LAC	A.TP,X		/IS TASK PRIO IN RANGE?
	TAD*	(SLILR
	SPA
	JMP*	SLI.SR		/NO -- RETURN AT JMS+1 (TOO LOW A PRIO. NO.)
	IDX	SLI.SR		/OK SO FAR -- INCREMENT RETURN ADDR
	LAC	A.TP,X
	TCA
	TAD*	(SLIHR
	SPA
	JMP*	SLI.SR		/NO -- RETURN AT JMS+2 (TOO HIGH A PRIO. NO.)
	LAC	A.TS,X		/YES -- IS STATUS 5?
	SAD	(5
	IDX	SLI.SR		/YES -- RETURN AT JMS+4
	IDX	SLI.SR		/NO -- RETURN AT JMS+3
	JMP*	SLI.SR
/
/ SUBROUTINE SLI.ST -- ADJUST THE XR TO ACCESS ATL FROM PAGE 1
/ 
SLI.ST	0
	TAD	(-010000
	PAX
	JMP*	SLI.ST
/ 
	.LST
	.IFUND	L.TTY
	.NOLST
	.ENDC
 .TITLE *** TTY MULTI-TERMINAL TASK

/

/ ******************************

/

/ INTERNAL CONVENTIONS

/

/ ******************************

/

/ TERMINOLOGY:

/

/ INITIALLY, THIS TASK IS MEANT TO CONTROL I/O ONLY TO

/ TELETYPES. IT MAY BE DESIRABLE IN THE FUTURE TO

/ ALLOW FOR TELETYPE-LIKE TERMINALS, E.G., SERIAL ASCII

/ CARD READER OR VT05 DISPLAY. THEREFORE, THE FOLLOW-

/ ING TERMINOLOGY HAS BEEN USED HEREIN:

/

/	TTY			AN I/O TERMINAL CONNECTED TO

/				THE LT15 OR LT19 CONTROLS, OR

/				THE CONSOLE TERMINAL. ALSO,

/				"TTY" IS THE NAME OF THIS TASK.

/

/	"KEYBOARD"		THE INPUT HARDWARE OF A TTY

/

/	"PRINTER"		THE OUTPUT HARDWARE OF A TTY

/

/	MCR TTY			THE "KEYBOARD" OR INPUT SIDE

/				OF THE TTY FROM WHICH THE

/				MONITOR CONSOLE ROUTINE (MCR)

/				MAY BE INVOKED (BY "TYPING"

/				CTRL C).

/

/	CTRL			THE "CONTROL" KEY ON A TELETYPE.

/

/	.LE.			"IS LESS THAN OR EQUAL TO"

/

/ LABELLING CONVENTION:

/

/	ALL ADDRESS TAGS DEFINED IN THIS TASK BEGIN WITH "TT".

/

IDX=ISZ				/USED HEREIN TO ADD 1 TO A REGISTER

				/WHEN THERE IS NO INTENTION TO SKIP.

/

/ 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" NOR IS THE "FLAGS" WORD EVER CHECKED OR ALTERED.

/

/ IT CONTAINS AN ACTIVE TASK LIST NODE WITH STATUS INITIALLY SET

/ TO FOUR, WHICH MEANS THAT THE TASK IS READY TO BE STARTED OR RESUMED.

/

/ THE TASK WILL PERFORM A 'WAITFOR' ON THE DEVICE'S TRIGGER EVENT

/ VARIABLE SO THAT THE TASK IS RUN ONLY WHEN APPROPRIATE I/O

/ REQUESTS ARE QUEUED AND READY TO BE PROCESSED OR WHEN INTERRUPTS HAVE

/ OCCURRED AND ARE READY TO BE PROCESSED.

/

/ TTY IS NEVER REQUESTED, NOR DOES IT EVER EXIT.  THEREFORE THERE IS

/ NO SYSTEM TASK LIST ENTRY FOR IT.

/

/ RECOGNIZED I/O FUNCTIONS:

/

/	24	ATTACH

/	25	DETACH

/	26	INPUT (READ)

/	27	OUTPUT (WRITE)

/	36	HINF

/

/ LEGAL DATA MODES:

/

/	2	IOPS ASCII

/	3	IMAGE ASCII

/

	.EJECT

/ EVENT VARIABLES RETURNED:

/

/	+Y0XX01	VALUE SET BY THE HINF FUNCTION TO INDICATE DEVICE

/		CODE (1), UNIT NUMBER (XX), NON-DIRECTORY-ORIENTED INPUT

/		AND/OR OUTPUT (Y).

/

/	+2	(1) IOPS ASCII OUTPUT ABORTED BY "TYPE-IN" OF

/		    CTRL U.

/

/		(2) IOPS ASCII INPUT LINE ENDS WITH CARRIAGE

/		    RETURN RATHER THAN ALTMODE.

/

/	+1	OPERATION SUCCESSFULLY COMPLETED OTHER THAN

/		AS INDICATED ABOVE.

/

/	-6	UNIMPLEMENTED FUNCTION OR FUNCTION IS ILLEGAL

/		FOR THIS TTY.

/

/	-7	ILLEGAL DATA MODE.

/

/	-16	ILLEGAL WORD-PAIR-COUNT OR BUFFER SIZE.

/

/		(1) IOPS ASCII INPUT -- BUFFER SIZE IS NEGATIVE

/		    OR LESS THAN +4.

/

/		(2) IMAGE ASCII INPUT -- BUFFER SIZE IS NEGATIVE

/		    OR LESS THAN +3.

/

/		(3) IMAGE ASCII OUTPUT -- WORD PAIR COUNT IN

/		    LINE BUFFER HEADER IS LESS THAN +2.

/

/	-24	I/O REQUEST REJECTED BECAUSE THE LUN VIA

/		WHICH THE REQUEST WAS MADE HAS BEEN

/		REASSIGNED AWAY FROM THIS PHYSICAL DEVICE.

/

/	-30	I/O TRANSFER PARAMETER (ADDRESS OR BUFFER)

/		EXCEEDS THE TASK'S PARTITION BOUNDS.

/

/	-203	ATTACH/DETACH NOT ISSUED AT TASK LEVEL.

/

	.EJECT

/

	.TITLE TTY TERMINAL DATA REGISTERS

/

/

/  WORD 0  [TTWD00]

/

/  FLAGS REGISTER

/

/  EQUATES FOR THE BITS THEREIN

/
TTB.OU=400000		/(163)TERMINAL ENGAGED IN OUTPUT
TTB.IN=200000		/(163)TERMINAL ENGAGED IN INPUT
TTB.KB=40000		/(163)TERMINAL HAS A KEYBOARD
TTB.PR=20000		/(163)TERMINAL HAS A PRINTER
TTB.TY=14000		/(163)TERMINAL TYPE 2 BIT CODE

TTB.T1=10000

TTB.T2=4000
TTB.SP=3000		/(163)TERMINAL SPEED 2 BIT CODE

TTB.S1=2000

TTB.S2=1000
TTB.AL=400		/(163)TERMINAL NEEDS ALT'S PRINTED
TTB.CR=200		/(163)LAST ASCII REQ ENDED WITH CARRIAGE RETURN 
TTB.AS=100		/(163)DATA MODE IOPS ASCII IF BIT SET
TTB.CA=40		/(163)VT05 DIRECT CURSOR ADDRESSING IF SET
TTB.HT=20		/(163)TERMINAL HAS HORIZONTAL TAB <<NOT USED>>
TTB.IO=1		/(163) I/O AVAILABLE, ZEROED WHEN ECHOING CHAR'S

/

	.REPT	TTYS

TTWD00	TTB.PR+TTB.KB+TTB.IO+TTB.CR

/

/  WORD 1  [TTWD01]  REQUESTOR'S EVENT VARIABLE ADDRESS

/

/  CONTAINS ZERO IF NOT PROVIDED

/

	.REPT	TTYS

TTWD01	0

/

/  WORD 2  [TTWD02]  POINTER TO LINE BUFFER HEADER (XR ADJUSTED)

/

	.REPT	TTYS

TTWD02	0

/

/  WORD 3  [TTWD03]  CURRENT DATA POINTER (XR ADJUSTED)

/

/  ALWAYS POINTS TO CHARACTER POSITION FOR NEXT ACTION

/

	.REPT	TTYS

TTWD03	0

/

/  WORD 4  [TTWD04]  CHARACTER COUNT FOR INPUT OR OUTPUT (MINUS)

/

	.REPT	TTYS

TTWD04	0

/

/  WORD 5  [TTWD05]  SAVE CHAR COUNT CONTL U; HORIZONTAL POSITION

/

/  THE RIGHT HALF IS HORIZONTAL POSITION COUNT FOR TABBING

/  THE LEFT HALF STORES THE 9 BITS OF CHARACTER

/  COUNT IN CASE CONTROL U ON ASCII INPUT

/

	.REPT	TTYS
TTWD05	1		/(163)POSITION 1

/

/  WORD 6  [TTWD06]  CHARACTER REPEAT REGISTER, THREE FIELDS

/

/  BITS 0-4 IS A POSITIVE REPEAT COUNT FOR ..

/  BITS 10-17  CONTAIN THE CHARACTER TO BE REPEATED

/

/  BIT 9 IS THE NULL BIT, IF OFF, REPEAT NULLS AFTER THE FIRST

/	PRINTING OF THE REPEAT CHAR

/

	.REPT	TTYS
TTWD06	0

/

/  WORD 7  [TTWD07]  REQUEST QUEUE POINTER FOR EACH 

/

/  TERMINAL'S I/O REQUEST LIST

/
TTWD07	TT0DQ		/(163)TT0 ALREADY SET UP TO QUEUE
TTYS1=TTYS-1
	.REPT	TTYS1
	.
/
/  POINT IS SO LISTS LOOK EMPTY TO CONFIGURATOR I/O REQ.
/

/

/  WORD 8  [TTK.EV]  EVENT VARIABLE CONTAINING KEYBOARD

/

/  AND PRINTER INTERRUPTS THAT COULD NOT BE HANDLED

/  AT INTERRUPT LEVEL.

/

/  BIT 0  SET TO FLAG INPUT OF A SPECIAL CHARACTER  NOT 40-174

/  BIT 1  SET TO FLAG CHARACTER INPUT

/  BITS 2-8  SEVEN BIT INPUT CHARACTER

/

/  BIT 9  SET TO FLAG OUTPUT CHARACTER
/  BITS 10-17  EIGHT BIT OUTPUT CHARACTER (TO BE OUTPUT!!)

/
IMASK=777		/(163)TO CLEAR INPUT CHAR
OMASK=777000		/(163)TO CLEAR OUTPUT CHAR

/
	.REPT	TTYS

TTK.EV	0

/

/  FLAG TO TERMINATE SCAN LOOP

/

TTMARK=177177

	TTMARK

/

/

/  WORD 9  [TTWD09]  I/O REQUEST NODE ADDRESS

/

	.REPT	TTYS

TTWD09	0

/

/  WORD 10[TTWD10]  DISPATCH TO PACKING ROUTINES

/

/  NORMALLY THIS WORD CONTAINS AN INSTRUCTION

/  OF THE FORM JMP XX, WHERE XX IS THE ADDRESS OF A ROUTINE

/  TO PACK OR UNPACK A CHAR FROM THE USER BUFFER.

/

	.REPT	TTYS

TTWD10 HLT

/

/  WORD 11  [TTWD11]  STACKED ECHO REQUEST WORD

/

/  BITS 10-17 CHARACTER TO ECHO

/  BITS 0-5 REPEAT COUNT

/  BIT 9 IS NUL ECHO BIT, AS IN WORD TTWD06

/

	.REPT	TTYS

TTWD11	0

/

	.TITLE	TTY SCAN AND SPECIAL INPUT PROCESSING

/

/ CAL PARAMETER BLOCK FOR "WAITFOR" DIRECTIVE.

/
TTWT4	20			/"WAITFOR" TTY TRIGGER EVENT
	TTTGEV			/VARIABLE.
/
TTTOP	.INH			/(167)HAS ANOTHER EVENT COME UP?
	LAC	TTTGEV		/(167)CHECK RELEVANT 4 BITS
	AND	(740000		/(167)
	.ENB			/(170) SYSTEM BACK IN
	DAC	TTTGEV		/(170) CLEARING IRRELEVANT BITS
	SNA			/(167)SKIP IF STILL WORK TO DO
/ THIS TASK IS INITIALLY ENTERED HERE AT TASK LEVEL (API-7).
/
TTYTW	CAL	TTWT4		/'WAITFOR' TTY TRIGGER EVENT VARIABLE
/
/
	CLA!IAC			/(167)CLEAR LEAVING EXTRANEOUS BIT
	DAC	TTTGEV		/(170)TO HOLD DOWN SIGN. EVENTS
/
/ NOTE -- CONTROL DOES NOT RETURN TO THIS LOCATION UNTIL

/ TTTGEV IS SET (NON-0), INDICATING A QUEUED TTY I/O REQUEST

/ OR INDICATING THAT THE TTY INTERRUPT SERVICE ROUTINE

/ RECEIVED AN INTERRUPT.  PROCESSING WILL BE DONE IN ORDER

/ OF IMPORTANCE:

/

/	1.  "KEYBOARDS" AND "PRINTERS"

/	2.  "ABORT" I/O REQUEST

/	3.  NORMAL I/O REQUESTS

/

/ NOTE -- EVERYTIME A "KEYBOARD", "PRINTER" OR I/O REQUEST HAS

/ BEEN SERVICED, BELOW, CONTROL RETURNS TO THIS POINT TO

/ SCAN FOR MORE INTERRUPTS OR REQUESTS.  

/ WHEN A COMPLETE SCAN IS MADE AND NOTHING

/ SERVICEABLE IS FOUND, CONTROL GOES TO "TTYTW",

/ ABOVE, TO "WAITFOR" THE TASK'S "TRIGGER".

/

/ CHECK FOR SERVICEABLE "KEYBOARD" OR "PRINTER"

/ INTERRUPTS AT API LEVEL 3 TO PREVENT GETTING IN-
/ TERRUPTED IN THE MIDDLE OF A TEST.
/
/
TTSCAN	.RTL3			/RAISE TO API-3.
TTSCN3	CLX			/(163)SCAN FOR KEYBRD OR PRNTR INTERRUPT
/				/(163)ENTER HERE IF ALREADY AT LEVEL 3
	CLA!SKP			/(163)JOIN LOOP AC=0 FOR SAD'S
TTSCNL	AXR	1		/(163)BUMP XR TO NEXT
TTREEN	SAD	TTK.EV,X	/(163)NON0 IF ANYTHING HAPPENED
	JMP	TTSCNL		/(163)KEEP SCANNING
	LAC	TTK.EV,X	/(163)CHECK FOR ENDING FIRST

	SAD	(TTMARK
	JMP	TTABO		/(163)NEXT, CHECK FOR ABORT REQ
	SPA!SWHA		/(163)CHECK FOR SPECIAL CHAR IN
	JMP	TTINSP		/(163)YES
	SMA			/(163)SKIP ON PRINTER INTERRUPT
	JMP	TTKSVC		/(163)KEYBOARD
	JMP	TTPSVC		/(163)PRINTER OR BOTH

/
TTINSP	AND	(177		/(163)STRIP TO 7 BIT CHAR
	DAC	TTCHAR		/(163)NON-INTERRUPT TEMPORARY
	PXA			/ SAVE THE TTY NUMBER.		/(176)
	DAC TTUNIT						/(176)

	LAC	(IMASK
	AND	TTK.EV,X	/(163)CLEAR INPUT SIDE OF EVENT WORD

	DAC	TTK.EV,X

	LAC	TTCHAR
	SAD	(24		/(163)CONTROL T

	JMP	TTC.T
	.IFUND	NOMAC		/(163)CHECK MULTI-ACCESS CHAR'S
	SAD	(31		/(163)CONTROL Y, FLUSH TASK

	JMP	TTC.Y
	SAD	(20		/(163)CONTROL P RESUME

	JMP	TTC.P

	.ENDC

	SAD	(003)

	JMP	TTC.C		/CTRL C.

	SAD	(025)

	JMP	TTC.U		/CTRL U.

	SAD	(030)

	JMP	TTC.X		/CTRL X.
	LAC	TTWD00,X	/(163)IMPUT ACTIVE AT ALL

	RAL
	SMA			/(163)SKIP IF YES
	JMP	TTSCN3		/(163)RESTART SCAN
	JMP	TTKSV2		/(163)INPUT SERVICING

/

/
TTABO	DBK			/DEBREAK FROM API-3 TO API-7.
	LAC	(TTYS		/(170) LOOP CONTROL FOR ABORT  IN
	DAC	TTTEMP		/(170) IT IS TO BE NEEDED
/
/ DE-QUEUE THE "ABORT" REQUEST.
/
	LAW	-D.QF		/COMPUTE THE ADDRESS OF TTY0'S
	TAD	TTWD07		/PHYSICAL DEVICE NODE.
	DAC*	(R1)
	JMS*	(DQAB		/(167) NEW ABORT SEQUENCE
	JMP	TTRQSC		/(167) WASN'T ONE
	JMS*	(DMTQ		/(167) EAG
	SZA!CLA!IAC		/(167) EAG
	DAC*	TTLIT0,X	/(167) WANT  DAC* (0),X TO SET EV
/				/(167) IS RETURNED ADDR IN XR.
	JMS*	(IOCD		/(167) EAG
	JMS*	(NADD		/(167) EAG
	DZM	TTUNIT		/(167) SCAN THRU UNIT NUMBERS
TTABLP	JMS	TTUINX		/(167) SET UNIT # TO XR
	LAC	TTWD00,X	/(167) TELETYPE ACTIVE
	AND (TTB.IN+TTB.OU)	/ INPUT AND OUTPUT BITS.	/(174)
	SNA			/(167) SKIP IF YES
	JMP	TTABNX		/(167) NO, GO TO NEXT UNIT
	LAC	TTWD09,X	/(167) REQ NODE
	DAC*	(R2
	TAD	TTXADJ
	PAX			/(167) SET UP XR TO CHECK STL ENTRY
	LAC	2,X		/(167) STL MATCH
	SAD*	(X10		/(167) EAG
	SKP
	JMP	TTABNX		/(167)NO MATCH, NO ACTION
	LAC*	(X11		/(167) EAG
	SZA			/(167) EAG
	XOR	5,X		/(167) EAG
	AND	(777000		/(167) EAG
	SZA			/(167) EAG
	JMP	TTABNX		/(167) LUN MISMATCH, NO ACTION
/
/
	JMS	TTUINX		/RESTORE THE XR WITH THE TTY UNIT NUMBER.
	LAC	(TTABRT		/(163)USE TTFORC AS MULTI-ENTRY ROUTINE

	DAC	TTFORC

	.RTL3
	LAC	TTWD00,X	/(163)INPUT OR OUTPUT FORCE <CR>
	SPA			/(163)SKIP ON INPUT
	JMP	TTFOR1		/(163)JOIN TTFORC ENTRY 1
	AND	(-1\TTB.IN\TTB.CR /(163)INPUT OFF
	XOR	(TTB.CR		/(163)CARRIAGE RETURN FLAG ON

	DAC	TTWD00,X
	RAR			/(163)CHECK ECHOING
	SNL!RAL			/(163)SKIP IF NOT
	JMP	TTFOR2		/(163)ECHOING, ENTER FORCE ROUTINE

	DBK
	LAC	(15		/(163)REGULAR CR
	JMS	TTPRNT
	DBK

/
TTABRT	DZM	TTK.EV,X	/(163)SHUT DOWN; RETURN HERE AT MAINSTRM
	LAC	TTWD01,X	/(167) EAG
	TAD	TTXADJ		/(167) EAG
	PAX			/(167) EAG
	LAW	-2		/(167) EAG
	DAC	0,X		/(167) EAG
	JMS*	(IOCD		/(170) EAG
	JMS*	(NADD		/(170) EAG
/

/ PREPARE FOR NEXT TTY UNIT.

/

/

/

TTABNX	IDX	TTUNIT
	LAC	TTTEMP		/(163)LOOP CONTROL WORD

	SAD	TTUNIT		/ANY MORE TO PROCESS?
	JMP	TTSCAN		/(167) SAFETY FOR NOW
	JMP	TTABLP		/YES.
/
/

/ SCAN I/O REQUEST QUEUE FOR EACH TTY.

/
TTRQSC	LAC	(TTYS		/(163)# OF TTY'S ON THIS MACHINE.

	PAL

	CLX

TTRQLP	LAC	TTWD07,X	/GET POINTER TO TTY'S REQUEST QUEUE.

	DAC	TTTEMP
	SAD*	TTTEMP		/(163)IF HEAD POINTS TO ITSELF, THE

	JMP	TTRQNX		/QUEUE IS EMPTY -- NO PENDING I/O.
	LAC	TTWD00,X	/(163)INPUT OR OUTPUT ACTIVE
	RAL			/(163)SPEED SENSITIVE, USE FAST
	SMA!SNL			/(163)FORM; SKIP IF EITHER ACTIVE

	JMP	TTRSVC		/YES. SERVICE TTY I/O REQUEST.

/

TTRQNX	AXS	1		/TRY NEXT TTY.

	JMP	TTRQLP

/

/ A COMPLETE SCAN OF "KEYBOARD" AND "PRINTER" INTERRUPTS AND

/ OF TTY I/O REQUESTS HAS BEEN MADE; NOTHING

/ SERVICEABLE WAS FOUND.  RETURN TO WAIT FOR "TTTGEV"

/ TO TRIGGER TASK EXECUTION.

/
	JMP	TTTOP		/(170) CHECK BEFORE WAITING

/

/ RETURN HERE IF THE TTY IS ATTACHED AND IF

/ NONE OF THE I/O REQUESTS WERE MADE BY THE

/ ATTACHED TASK.

/

TTNXRQ	JMS	TTUINX		/RESTORE THE XR WITH THE TTY UNIT NUMBER.

	JMP	TTRQNX

/

/ CTRL C INPUT FROM "KEYBOARD."

/

TTC.C	DBK			/DEBREAK FROM API-3 TO API-7.

/

/ WHEN CTRL C IS "TYPED" AT THE CURRENT MCR

/ TTY, THE MCR TASK IS REQUESTED.

/

	PXA			/IS THIS UNIT THE

	SAD*	(TTMCTT)	/MCR TTY?

	SKP!CLA

	JMP	TTSCAN		/NO. IGNORE CTRL C AND

				/SCAN FOR MORE TTY I/O.

/

	SAD*	(MCRRI)		/YES. IS THE "MCR REQUEST

				/INHIBIT" FLAG SET (NON-0)?

	JMP	TTRMCR		/NO.

/

/ SET THE INHIBIT FLAG TO -1 (INSTEAD OF +1) TO INDICATE

/ THAT CTRL C WAS INPUT WHEN THE INHIBIT FLAG WAS AL-

/ READY SET; AND THEN IGNORE THE CTRL C.

/

	LAW	-1

	DAC*	(MCRRI)

	JMP	TTSCAN

/

/ THE INHIBIT FLAG IS NOT SET.  SET IT TO +1 AND THEN "REQUEST"

/ THAT THE TASK "...MCR" BE RUN.

/

TTRMCR	IDX*	(MCRRI)

/

	CAL	TT.MCR		/"REQUEST" THE TASK "...MCR".

/

	JMP	TTSCAN

/

/ CTRL T INPUT FROM "KEYBOARD".

/
	.IFDEF	NOMAC		/(163)OLD ^T PROCESSOR

/

TTC.T	DBK			/DEBREAK FROM API-3 TO API-7.

/

	PXA			/REQUEST "TDV..." (TASK DEVELOPMENT DISPATCH

	SAD*	(TTTDTT)	/ROUTINE) IF CTRL T WAS TYPED ON TDV INPUT TTY.

	CAL	TT.TDV

/

	JMP	TTSCAN		/CTRL T HAS BEEN PROCESSED.

	.ENDC

/

/

/  CONTROL T FOR MULTI-ACCESS

/

	.IFUND	NOMAC

/

TTC.T	DBK
	PXA			/(163)MAKE UNIT # INTO BIT

	TAD	(LRS!CLQ!1
	DAC	TTC.TX		/(163)SHIFTER TO POSITION BIT
	CLA!IAC			/(163)THE BIT TO SHIFT

TTC.TX	XX
	LAC*	(MA.CT		/(163)CONTROL T FLAGS WORD

	OMQ

	DAC*	(MA.CT
	LAC*	(MA.UCA		/(163)IS TDV ALREADY ACTIVE
	SNA			/(163)SKIP IF YES
	CAL	TT.TDV		/(163)REQUEST IF NOT ACTIVE

	JMP	TTSCAN

/

/  CONTROL Y FOR MULTI-ACCESS

/

TTC.Y	DBK

	PXA

	TAD	(LRS!CLQ!1

	DAC	TTC.YX

	CLA!IAC

TTC.YX	XX

	LAC*	(MA.CY

	OMQ

	DAC*	(MA.CY

	JMP	TTSCAN

/

TTC.P	DBK
	PXA			/(163)TASK NAME FROM TTY UNIT #

	LRSS	3

	ALS	3

	LLS	3

	TAD	(566060

	DAC	TT.CTP+3

	CAL	TT.CTP

	JMP	TTSCAN

/

/

	.ENDC

/

/ CTRL X INPUT FROM "KEYBOARD".

/

TTC.X	DBK			/DEBREAK FROM API-3 TO API-7.

/

	PXA			/FORM THE TASK NAME FROM THE TTY NUMBER

	LRSS	3		/("TTY.NN" FOR TTY #NN).

	ALS	3

	LLS	3

	XOR	(566060)

	DAC	TT.CTX+3

/

	CAL	TT.CTX		/REQUEST THE TASK.

/

	JMP	TTSCAN		/CTRL X HAS BEEN PROCESSED.

/

/ CAL PARAMETER BLOCKS FOR "REQUEST" DIRECTIVES.

/

TT.MCR	1			/"REQUEST" CODE

	0			/NO EVENT VARIABLE

	.SIXBT	"..."		/TASK NAME (FIRST HALF)

	.SIXBT	"MCR"		/TASK NAME (SECOND HALF)

	0			/DEFAULT PRIORITY

/

TT.TDV	1			/"REQUEST" CODE

	0			/NO EVENT VARIABLE

	.SIXBT	"TDV"		/TASK NAME (FIRST HALF)

	.SIXBT	"..."		/TASK NAME (SECOND HALF)

	0			/DEFAULT PRIORITY

/

TT.CTX	1			/"REQUEST" CODE

	0			/NO EVENT VARIABLE

	.SIXBT	"TTY"		/TASK NAME (FIRST HALF)

	.SIXBT	".NN"		/TASK NAME (SECOND HALF)

	0			/DEFAULT PRIORITY

/

	.IFUND	NOMAC

/
TT.CTP	7			/(163)RESUME CODE

	0
	.SIXBT	"USR"		/(163)ALIAS TASKS AS "USR.NN"

	.SIXBT	".NN"
	0			/(163)DEFAULT RESUME ADDR

/

	.ENDC

/

/

/ CTRL U INPUT FROM "KEYBOARD."

/

/ PROCESS THIS CHARACTER NOW ONLY IF THE TTY IS SELECTED

/ FOR OUTPUT (WRITE) IN IOPS ASCII MODE.

/
TTC.U	LAC	TTWD00,X	/(163)FLAGS WORD
	AND	(TTB.AS		/(163)IF IMAGE, DO NOTHING
	SNA			/(163)SKIP IF ASCII
	JMP	TTSCN3		/(163)JUST SCAN AGAIN

	LAC	TTWD00,X
	SPA!RAL			/(163)SKIP IF NOT OUTPUT
	JMP	TTC.UO		/(163)OUTPUT CONTROL U
	SMA			/(163)SKIP ON INPUT CONTROL U
	JMP	TTSCN3		/(163)NEITHER, THROW AWAY

/
TTC.UI	777000			/(163)GET REPLACEMENT COUNT

	AND	TTWD05,X

	SWHA
	TAD	(777000		/(163)AND 1'S FILL IT

	DAC	TTWD04,X
	LAC	TTWD02,X	/(163)REPLACE DATA POINTER

	AAC	2

	DAC	TTWD03,X
	LAC	TTPKJ1		/(163)SET UP PACKER TO DO FIRST

	DAC	TTWD10,X
	DBK			/(163)TO PACKGROUND
	LAC	(100		/(163)ECHO A @
	JMS	TTPRNT
	DBK
	JMP	TTSCAN
TTC.UO	JMS	TTFORC		/(163)FORCE OUTPUT CR
	LAC	(2		/(163)RETURN EV 2
	JMP	TTSREV		/(163)REQUEST DONE EV 2

/

/  ROUTINE TTFORC

/

/  FORCE ECHO OF CR IN REPEAT REG. TTWD06

/  ENTER AT LEVEL 3; EXIT MAINSTRM

/

TTFORC	0
	RAR			/(163)TOP ENTRY, ADJUST TTWD00
TTFOR1	AND	(-1\TTB.OU\TTB.CR\TTB.IO /(163)OFF OUTPT, ON ECHO
	XOR	(TTB.CR		/(163)ON CARRIAGE RETURN

	DAC	TTWD00,X
	LAC	TTK.EV,X	/(163)IF OUTPUT PENDING HERE
	AND	(777		/(163)NO INTERRUPT TO WAKE US UP!
	SZA			/(163)SKIP IF OK
	JMP	TTC.UD		/(163)TREAT DIFFERENTLY
	LAC	TTWD00,X	/(163)IF 300 BAUD LA30

TTFOR2	AND	(TTB.TY+TTB.SP
	SAD	(TTB.T1+TTB.S2	/(163)EXTRA FILLERS ON ECHO
	SKP!CLA			/(163)WAS , GO PICK UP ECHO
	LAC	(620000		/(163)NOPE, SUBTRACT OFF EXTRAS
	TAD	(200015		/(163)CR AND 7 NULL PAD

	DAC	TTWD06,X
	DZM	TTWD11,X	/(163)KILL ANY PENDING ECHO

	DBK
	JMP*	TTFORC		/(163)EXIT AT MAINSTREAM

/
TTC.UD	IDX	TTWD00,X	/(163)CLEAR ECHOING
	777000			/(163)CLEAR THE OUTPUT REQ CHAR.

	AND	TTK.EV,X

	DAC	TTK.EV,X

	DBK

	LAC	(15
	JMS	TTPRNT		/(163)NORMAL CHAR
	DBK

	JMP*	TTFORC

 .TITLE *** TTY I/O REQUEST SERVICE

/

/ CONTROL COMES HERE WHEN AN I/O DIRECTIVE REQUEST HAS BEEN

/ QUEUED FOR A TTY THAT IS CURRENTLY IDLE

/ (NOT SERVICING ANOTHER REQUEST).  THE TTY UNIT NUMBER

/ IS IN THE XR.

/

/ NOTE -- INITIALLY NONE OF THE TERMINALS ARE "ATTACHED"

/ TO SPECIFIC TASKS.  WHEN A DEVICE IS NOT

/ ATTACHED TO A TASK, I/O REQUESTS TO THAT DEVICE ARE

/ PROCESSED IN ORDER OF PRIORITY.  WHEN A DEVICE IS

/ ATTACHED TO A TASK, ONLY THE I/O REQUESTS MADE BY

/ THAT TASK ARE PROCESSED.  REQUESTS MADE BY OTHER

/ TASKS REMAIN QUEUED (DORMANT) UNTIL THE TASK

/ RELINQUISHES THE DEVICE VIA A "DETACH" REQUEST.

/

TTRSVC	PXA			/SAVE LOGICAL UNIT #

	DAC	TTUNIT		/OF CURRENT TTY.

/

/ USE A COMMON MONITOR SUBROUTINE TO PICK AN I/O REQUEST FROM

/ THIS TTY'S QUEUE.

/

	LAW	-D.QF		/COMPUTE THE PHYSICAL DEVICE NODE

	TAD	TTWD07,X	/ADDRESS & STORE IT IN R1.

	DAC*	(R1)

	JMS*	(DQRQ)		/DE-QUEUE AN I/O REQUEST.

				/(R1, R2, R4, R5, R6, XR

				/& AC ARE ALTERED).

				/WAS A REQUEST FOUND?

	JMP	TTNXRQ		/NO -- TRY NEXT TTY.

	PAL			/YES -- SAVE REQUEST NODE ADDRESS TEMPORARILY.

/

/ GET AND SAVE ALL THE USEFUL INFORMATION FROM THE REQUEST NODE.

/

	JMS	TTUINX		/RESTORE THE INDEX REGISTER

				/WITH THE LOGICAL TTY UNIT #.

	PLA			/SET UP AUTO INDEX REGISTER 10

	DAC	TTWD09,X	/TO START WITH THE 6TH

	AAC	4		/WORD IN THE REQUEST NODE.

	DAC*	(X10)

/

/ THE SIXTH WORD IN THE REQUEST NODE CONTAINS THE LOGICAL

/ UNIT # (LUN) IN THE LEFT HALF AND THE CAL FUNCTION CODE

/ IN THE RIGHT HALF.

/

	LAC*	X10		/GET LUN & CAL CODE.

	AND	(777)		/SAVE THE CAL CODE
	DAC	TTABNA		/(163)TEMPORARY FOR CAL LEVEL

/

	LAC*	X10		/GET ADDRESS OF REQUESTOR'S

	DAC	TTWD01,X	/EVENT VARIABLE (0 IF NONE).

/

	LAC*	X10		/GET DATA MODE AND SAVE

	AND	(7)
	AAC	-3		/(163)STORE MODE-3
	DAC	TTABSN		/(163)IN LOW THREE BITS OF TTABSN

/

	LAC*	X10		/GET AND SAVE ADDRESS OF
	DAC	TTHDR0		/(163)UNADJUSTED BY XR
	TAD	TTXADJ		/(163)AND ADJUSTED BY XR

	DAC	TTWD02,X

	AAC	2
	DAC	TTWD03,X	/(163)AND STARTING DATA ADDRESS

/

	LAC*	X10		/GET AND SAVE THE

	DAC	TTWD04,X	/LINE BUFFER SIZE.

/

/

/ EXAMINE CAL FUNCTION CODE AND DISPATCH TO APPROPRIATE

/ ROUTINE.

/

	LAC	TTABNA

	SAD	(36)

	JMP	TTHINF		/"HINF" REQUEST.
	CLL!RAR			/(163)COMPARE FOR REQ'S IN PAIRS
	SAD	(12		/(163)ATTACH OR DETACH (24 OR 25)
	JMP	TTATDT		/(163)DO IN COMMON
	SAD	(13		/(163)READ OR WRITE (26 OR 27)
	JMP	TTRDWR		/(163)START OFF IN COMMON

/

/ UNIMPLEMENTED OR ILLEGAL FUNCTION -- SET REQUESTOR'S

/ EVENT VARIABLE TO -6 AND IGNORE THE REQUEST.

/

TTIFNC	LAW	-6

	JMP	TTSREV		/SET REQUESTOR'S EVENT VARIABLE.

/

/

/  ATTACH AND DETACH PROCESSING

/
TTATDT	LAC	(ALAD		/(163)SUBROUTINE ENTRY FOR ATTACH
	SZL			/(163)SKIP IF ATTACH (24)
	AAC	DLAD-ALAD	/(163)MAKE ENTRY FOR DETACH
	DAC	TTTEMP		/(163)STORE FOR LATER JMS*

	LAW	-D.QF		/COMPUTE THE PHYSICAL DEVICE NODE

	TAD	TTWD07,X	/ADDRESS & STORE IT IN R1.

	DAC*	(R1)

	LAC	TTWD09,X	/STORE THE I/O REQUEST NODE'S

	DAC*	(R2)		/ADDRESS IN R2.

/

/  FOR MULTI ACCESS, NORM. MODE,  IGNORE ATTACH OR DETACH TO TELETYPE

/  WHOSE LUN IS IN THE MAPPED RANGE. HOWEVER, SEND BACK

/  AN EV OF +1 TO KEEP CALLER HAPPY.

/

	.IFUND	NOMAC

/
	TAD	TTXADJ		/(163)ADJUSTED ADDRESS
	PAX			/(163)TO FETCH EXEC MODE,  LUN #
	LAC 2,X		/ SHOULD WE LET THIS ATT/DET THROUGH?	/(171)
	SNA		/ AC = STL NODE ADDRESS IF TASK ISSUED.	/(171)
	JMP TTATD1	/ NOT TASK ISSUED, LET IT THROUGH.	/(171)
	PXL		/ SAVE XR IN LR.			/(171)
	TAD TTXADJ	/ SET UP TO ACCESS STL NODE.		/(171)
	PAX							/(171)
	LAC S.EP,X	/ FETCH INITIAL SETTING OF EXEC/NORM	/(171)
	PLX		/ RESTORE XR.				/(171)
	RTL		/ PUT EXEC INDICATOR IN AC SIGN BIT.	/(171)
	SMA		/ IS IT NORMAL MODE?			/(171)
	JMP	TTATD1		/(163)EXEC MODE, DO THE ATT, DET
	777000			/(163)MASK, LUN IN LEFT HALF

	AND	5,X

	SWHA
	CMA!IAC			/(163)-LUN FOR LIMIT COMPARES
	DAC	TTABNA		/(163)USE ABORT TEMPORARY
	TAD*	(MA.BLU		/(163)ADD IN BOTTOM INCLUSIVE LIMIT
	SNA!SPA!CLL!CLA		/(163)SKIP IF MISSED,MAKE LINK STAY 0!
	LAC	TTABNA		/(163)CHECK UPPER INCLUSIVE LIMIT
	TAD*	(MA.ELU		/(163)SET LINK IF PASSED BOTH TESTS
	SNL!CLA!IAC		/(163)IF PASSED BOTH, RETURN EV=+1

/

	.ENDC

/
TTATD1	JMS*	TTTEMP		/(163)CALL ALAD OR DLAD
	JMP	TTSREV		/(163)RETURN EV, ERROR IF DID JMS*
	JMP	TTDONE		/(163)CALLED AND OK, RETURN +1

/

/

/  READ ONLY START UP

/
TTRD00	AND	(TTB.KB		/(163)BETTER HAVE A KEYBOARD
	SNA			/(163)SKIP IF OK

	JMP	TTIFNC
	LAC	(SKP		/(163)DEFAULT IF NO PRINTER TO ECHO

	DAC	TT.PRT,X
	LAC	TTWD00,X	/(163)NOW FIND OUT

	AND	(TTB.PR
	SNA			/(163)SKIP IF HAVE ONE
	JMP	TTRDW0		/(163)JOIN
	LAC	TT.PCL,X	/(163)PRINTER CLEAR TABLE

	AAC	4
	DAC	TT.PRT,X	/(163)IOT SET UP
	LAC	(TTB.IN		/(163)SET UP INPUT BIT
	JMP	TTRDW0		/(163)JOIN

/

/  READ AND WRITE COMMON START UP

/
TTRDWR	777377			/(163)KILL ANY HORIZONTAL POSITION
	AND	TTWD05,X	/(163)ABOVE 256 DECIMAL

	DAC	TTWD05,X
	LAC	TTWD00,X	/(163)CHECK IF HARDWARE OK
	SNL			/(163)SKIP ON WRITE
	JMP	TTRD00		/(163)GO TO READ
	AND	(TTB.PR		/(163)WRITE BETTER HAVE A PRINTER
	SNA			/(163)SKIP IF DOES
	JMP	TTIFNC		/(163)NO, CALL ILLEGAL FUNCTION

	LAC	(TTB.OU

/
TTRDW0	DAC	TTBITS		/(163)STORE BITS
	LAC	TTABSN		/(163)DATA MODE(IMAGE=0,ASCII=-1)
	SNA!CMA			/(163)SKIIP ON NON-IMAGE
	JMP	TTRDWI		/(163)IMAGE
	SNA			/(163)SKIP ON NON-ASCII

	JMP	TTRDWA
TTIMDE	LAW	-7		/(163)ILLEGAL DATA MODE

	JMP	TTSREV

/

/
TTRDWI	SNL
	JMP	TTRDIM		/(163)READ IMAGE
	JMP	TTWRIT		/(163)WRITE
/
TTRDWA	LAC	(TTB.AS		/(163)STORE KNOWLEDGE OF ASCII

	XOR	TTBITS

	DAC	TTBITS
	SZL			/(163)LINK STILL THERE

	JMP	TTWRIT
TTRDAS	LAC	TTPKJ1		/(163)SET TO PACK FIRST ASCII CHAR

	DAC	TTWD10,X
	777776			/(163)TRUNCATE WORD COUNT TO EVEN

	AND	TTWD04,X
	JMS	TTRAJX		/(163)VERIFY AND ADJUST FOR READ

/
	LAC	TTWD04,X	/(163)MAKE UP COUNT LIMIT
	CLL!RTL			/(163)*5/2

	TAD	TTWD04,X

	RAR

	CMA!IAC

	DAC	TTWD04,X
TTRDJ	LAC	TTWD00,X	/(163)CHECK IF LINE FFEED NEEDED
	AND	(TTB.CR		/(163)LAST LINE ASCII CR ?
	SNA!CLL!CML		/(163)SKIP IF YES
	JMP	TTEORW		/(163)LINE FEED NOT NEEDED
TTRD06	LAC	(12		/(163)LINE FEED
	JMS	TTPRNT		/(163)PRINT OUT LF, PLUS ANY FILLS
	JMP	TTERW1
TTEORW	.RTL3			/(163)FINAL PROCESSING REED-RIGHT
TTERW1	LAC	TTWD00,X	/(163)ENTER HERE IF AT 3

	AND	(-1\TTB.AS\TTB.CR\TTB.IN\TTB.OU
/				/(163)TURN OFF ASCII, CR, INPUT, OUTPUT
	XOR	TTBITS		/(163)SET WHICHEVER BITS STORED

	DAC	TTWD00,X
	LAC	(777		/(163)SAVE CHAR COUNT

	AND	TTWD04,X
	SWHA			/(163)IN LEFT HALF OF TTWD05,X

	XOR	TTWD05,X
	AND	(777000		/(163)05 GETS BACK ITS OWN LOW HALF

	XOR	TTWD05,X

	DAC	TTWD05,X

	JMP	TTSCN3

/
TTRDIM	LAC	(JMP TTPKI	/(163)IMAGE DISPATCHER

	DAC	TTWD10,X
	LAC	TTWD04,X	/(163)BUFFER WORD SIZE
	JMS	TTRAJX		/(163)VERIFY IN BOUNDS
	LAC	TTWD04,X	/(163)MAKE MINUS WORD COUNT

	CMA!IAC

	DAC	TTWD04,X
	JMP	TTRDJ		/(163)FINISH UP WITH ASCII READ

/

/  SURBROUTINE TTRAJX DOES VERIFY AND ADJUST FOR READ

/  CALL WITH WORD LENGTH IN AC

/

/

TTRAJX	0

/

	DAC	TTWD04,X	/BUFFER SIZE MUST

	SPA			/BE POSITIVE.

	JMP	TTILWC		/NO. ERROR.

	AAC	-3		/SIZE MUST BE AT

	SPA			/LEAST 3.

	JMP	TTILWC		/NO. ERROR.

	TAD	(-773)		/DOES SIZE EXCEED 776?

	SPA!SNA

	JMP	.+3		/NO.

	LAC	(776)		/YES. LIMIT THE SIZE

	DAC	TTWD04,X	/TO 776 SINCE THE

				/LARGEST RECORDABLE

				/WORD PAIR COUNT

				/IS 377.

	LAC	TTWD04,X

	DAC*	(R4)		/SAVE FOR CALL BELOW TO "VAJX".

/

/ VERIFY THAT THE LINE BUFFER RESIDES ENTIRELY WITHIN THE REQUESTER'S

/ PARTITION (THE CHECK IS MADE ONLY FOR NORMAL MODE TASKS) AND ADJUST

/ THE HEADER ADDRESS TO 17 BITS.

/

	LAC	TTWD09,X	/ADDRESS OF THE I/O REQUEST NODE.

	DAC*	(R2)

	LAC	TTHDR0		/ADDRESS OF THE LINE BUFFER HEADER WORD 0.

	DAC*	(R3)

	JMS*	(VAJX)		/(R3, R5, XR & AC ARE ALTERED).

				/ERROR?

	JMP	TTXPER		/YES -- BUFFER EXCEEDS PARTITION BOUNDS.

	JMS	TTUINX		/NO -- RESTORE THE XR WITH THE LOGICAL TTY UNIT #.

	LAC*	(R3)		/SAVE THE ADJUSTED HEADER ADDRESS.

	DAC	TTHDR0
	TAD	TTXADJ		/(163)STORE ADJUSTED ADDR

	DAC	TTWD02,X

	AAC	+2

	DAC	TTWD03,X

/

	JMP*	TTRAJX

/

/

/

/ VERIFY THAT THE ADDRESS OF THE LINE BUFFER HEADER IS WITHIN THE TASK'S

/ PARTITION (FOR NORMAL MODE TASKS ONLY) AND ADJUST THE HEADER ADDRESS

/ TO 17 BITS.

/
TTWRIT	LAC	TTWD09,X	/ADDRESS OF THE I/O REQUEST NODE.

	DAC*	(R2)

	LAC	TTHDR0		/ADDRESS OF LINE BUFFER HEADER WORD 0.

	DAC*	(R3)

	CLA!IAC			/PRETEND THE BUFFER SIZE IS 1.

	DAC*	(R4)
	JMS*	(VAJX)		/(R3, R5, XR & AC ARE ALTERED).
				/ERROR?
	JMP	TTXPER		/YES -- HEADER OUTSIDE OF PARTITION.
	JMS	TTUINX		/(163)REFILL INDEX REGISTER
	PXL			/(163)AND LIMIT WITH UNIT #
	LAC*	(R3)		/NO -- DON'T SAVE THE ADJUSTED HEADER
				/ADDRESS IN TTHDR0 BECAUSE VAJX MUST
				/BE CALLED AGAIN.
	TAD	TTXADJ		/(163)BUT SAVE IN TTY DATA AREA
	DAC	TTWD02,X	/(163)BUFFER HEADER
	AAC	2
	DAC	TTWD03,X	/(163)DATA POINTER
/
/ CHECK THE I/O REQUEST NODE TO SEE IF THE TASK IS RUNNING IN EXECUTIVE

/ MODE. IF SO, AND IF THE MODE IS IOPS ASCII, THERE MIGHT BE NO HEADER

/ WORD PAIR (THIS IS TRADITIONAL AS WELL AS A CONVENIENCE). SET THE

/ NEGATIVE WORD COUNT [TTWD04] TO ZERO SO THAT IT IS EFFECTIVELY VERY LARGE.

/
	LAC	TTABSN		/(163)DATA MODE

	SNA
	JMP	TTVWPC		/(163)IMAGE GOES TO TTVWPC

	LAC	TTWD09,X	/I/O REQUEST NODE ADDRESS.

	AAC	+3

	DAC	TTTEMP

	LAC*	TTTEMP

/

/ !!!!! THE FOLLOWING TWO COMMENT LINES (SZA; JMP TTVWPC) SHOULD BE

/ !!!!! CHANGED INTO REAL CODE WHENEVER IT IS DECIDED THAT MACRO,

/ !!!!! FORTRAN, ET AL, WHICH NORMALLY RUN AS NORMAL MODE TASKS WITH

/ !!!!! MEMORY PROTECT ENABLED, HAVE BEEN PROPERLY CONVERTED SO THAT

/ !!!!! THEY USE LINE BUFFER HEADERS WITH CORRECT WORD-PAIR-COUNTS

/ !!!!! FOR ALL TELETYPE MESSAGES. UNTIL THEN, THIS HANDLER WILL NOT

/ !!!!! PROTECT AGAINST NON-EX-MEM IF THE BUFFER HAPPENS NOT TO HAVE
/ !!!!! A LINE TERMINATOR IN IOPS ASCII MODE.
/
////	SZA			/SKIP IF EXEC MODE TASK.
////	JMP	TTVWPC		/NO.
/
	770000			/(163)LARGE WORD COUNT
	DAC	TTWD04,X
	JMP	TTWR02		/WRITE IN IOPS ASCII.

/

/ GET AND VALIDATE THE LINE BUFFER'S WORD-PAIR-COUNT.

/
TTVWPC	LAC	TTWD02,X	/(163)ADJUSTED HEADER ADDRESS FOR XR

	PAX
	LAC	0,X		/(163)WRITE HEADER
	PLX			/(163)RESTORE XR
	SWHA			/(163)PULL COUNT TO RIGHT HALF

	AND	(377)		/DECREASE THE COUNT BY 2 TO BYPASS THE

	RCL			/HEADER WORD PAIR, AND VALIDATE THE WORD ...
	DAC*	(R4)		/SAVE FOR THE CALL BELOW TO "VAJX".

	TCA			/... COUNT (WHICH MUST STILL BE NEGATIVE).

	AAC	2

	DAC	TTWD04,X

	SMA

	JMP	TTILWC		/ILLEGAL WORD COUNT.

/

/ VERIFY THAT THE LINE BUFFER LIES WITHIN THE TASK'S PARTITION. THE REQUEST

/ NODE ADDRESS SHOULD STILL BE IN R2.

/

	LAC	TTHDR0		/UNADJUSTED ADDRESS OF LINE BUFFER HEADER

	DAC*	(R3)		/WORD 0.
	JMS*	(VAJX)		/(R3, R5, XR & AC ARE ALTERED).
				/ERROR?
	JMP	TTXPER		/YES -- LINE BUFFER EXCEEDS PARTITION BOUNDS.
	JMS	TTUINX		/NO -- RESTORE THE XR.
	PXL			/AND LR
/
TTTCOD	LAC	TTABSN		/(163)DATA MODE
	SZA			/(163)ASCII TO TTWR02

	JMP	TTWR02

/

/ IMAGE ASCII WRITE.

/

TTWR03=.

/

/
	LAC	TTWD00,X	/(163)NEED TO FORCE A LF?

	AND	(TTB.CR
	SNA			/(163)SKIP IF YES
	JMP	TTWNLF		/(163)NO
	LAC	(12		/(163)LINE FEED TO PRINT ROUTINE
TTW55	JMS	TTPRNT		/(163)IMAGE CASES JOIN HERE
/				/(163)TTPRNT EXITS AT LEVEL3
	LAC	(JMP TTUPI	/(163)IMAGE UNPACK
	JMP	TTWRLF		/(163)JOIN ASCII WRITE

/
TTWNLF	LAC	TTWD03,X	/(163)FETCH FIRST CHAR

	IDX	TTWD03,X
	IDX	TTWD04,X	/(163)AND COUNT IT

	PAX

	LAC	(177

	AND	0,X
	PLX			/(163)RESTORE XR
	JMP	TTW55		/(163)JOIN OTHER IMAGE CASE

/

/ IN IOPS ASCII (MODE 2) WRITE'S, THE HEADER WORD-PAIR-COUNT IS USED ONLY

/ AS AN UPPER LIMIT ON THE MESSAGE SIZE. OUTPUT NORMALLY TERMINATES WHEN

/ A CARRIAGE RETURN OR ALTMODE CHARACTER IS ENCOUNTERED.

/
TTWR02	LAC	TTWD04,X	/(163)MAKE ASCII WORD OUNT
	CLL!RTL			/(163)ALREADY MINUS
	CLL			/(163)MAKE UPCOMING SIGN BIT - ON CARRY

	TAD	TTWD04,X
	RAR			/(163)HAVE DONE *5, NOW /2

	DAC	TTWD04,X
	LAC	TTWD03,X	/(163)FETCH 1ST CHAR

	PAX
	774000			/(163)MASK FOR FIRST

	AND	0,X

	SWHA!CLL
	RTR			/(163)FIRST CHAR RIGHT JUSTTIFIED
	PLX			/(163)COME BACK WITH UNIT #
	DAC	TTCHAR		/(163)SAVE FOR LATER
	LAC	TTWD00,X	/(163)CHECK HISTORY OF LAST LINE

	AND	(TTB.CR
	SNA			/(163)SKIP IF MIGHT NEED A LF
	JMP	TTWRN1		/(163)WRITE OUT 1ST CHAR
	LAC	TTCHAR		/(163)CHECK FOR LF
	SAD	(12		/(163)YES, PRINT FIRST

	JMP	TTWRNA
	SAD	(20		/(163)OVERPRINT
	JMP	TTWRNA		/(163)YES PRINT FIRST

/
	LAC	(12		/(163)NEED TO DO A LF
TTSHUN	JMS	TTPRNT		/(173)SINGLE CHAR MESG. COMES HERE
	LAC	(JMP TTUP1	/(163)UNPACK FIRST ASCII
TTWRLF	DAC	TTWD10,X	/(163)OTHER ASCII JOINS HERE
	JMP	TTERW1		/(163)END OF READ WRITE

/
TTWRN1	LAC	TTCHAR
	SAD	(175		/(173)COULD BE ALREADY DONE <ALT>
	SKP!CLA			/(173)YES, PRINT A NULL; CONVENIENCE ONLY.
	SAD	(15		/(173)<CR> ALSO ALREADY DONE
	JMP	TTSHUN		/(173)PRINT SOMETHING TO WAKE UP NEXT TIME
TTWRNA	JMS	TTPRNT		/(163)SEND OUT CHAR
	LAC	(JMP TTUP2	/(163)FETCH SECOND CHAR
	IDX	TTWD04,X	/(163)BUMP COUNTER
	JMP	TTWRLF		/(163)JOIN UP

/

/

TTILWC	LAW	-16		/ILLEGAL WORD-PAIR-COUNT OR ILLEGAL

	JMP	TTSREV		/BUFFER SIZE.

TTXPER	LAW	-30		/I/O TRANSFER ADDRESS OR BUFFER EXCEEDS

	JMP	TTSREV		/THE PARTITION BOUNDS.

/

/ (CODE 36) SET REQUESTOR'S EVENT VARIABLE WITH HANDLER INFORMATION

/ CODE TO SIGNIFY: DEVICE CODE 1; TTY UNIT NUMBER; NON-DIRECTORY-ORIENTED

/ INPUT AND/OR OUTPUT.

/
TTHINF	LAC	(TTB.KB\TTB.PR	/(163)HINF NEEDS PRINTR, KEYBRD BITS

	AND	TTWD00,X
	CLQ!LRSS!4		/(163)MOVE OVER TO FETCH UNIT #

	XOR	TTUNIT
	LLS	6		/(163)MOVE TO FINAL POSITION
	IAC			/(163)TTY UNIT CODE
	JMP	TTSREV		/(163)SEND BACK AS EV

 .TITLE *** TTY "KEYBOARD" INPUT SERVICE

/

/ CONTROL COMES HERE FROM THE TTSCAN ROUTINE WHEN THE 

/ "KEYBOARD" EVENT VARIABLE FOR THIS TTY IS NON-0

/ ON ITS INPUT SIDE.

/

/ THE CHARACTER "CTRL C" (7-BIT CODE 03) IS PROCESSED

/ OUTSIDE OF THIS ROUTINE.

/

/ THE CHARACTER "CTRL U" (7-BIT CODE 25),

/ IS PROCESSED OUTSIDE THIS ROUTINE

/

/ ALL OTHER CHARACTERS WHICH ARE INPUT WHILE THE TTY

/ IS SELECTED FOR OUTPUT HAVE BEEN DISCARDED.

/
TTKSVC	AND	(177		/(163)CHAR ALREADY IN AC

	DAC	TTCHAR
	LAC	TTK.EV,X	/(163)CLEAR OUR SIDE OF WORD

	AND	(IMASK

	DAC	TTK.EV,X

TTKSV2	PXL
	DBK			/(163)THRU INTERFACING, LEVEL DOWN

/

	LAC	TTCHAR

/

/////////////////////////////

/

/ CTRL D SHOULD BE DETECTED

/ HERE IF IT IS TO BE USED AS

/ A MEANS OF CREATING AN

/ END OF FILE CONDITION.

/

/////////////////////////////

/

	SAD	(176)		/CONVERT CODES 176 AND

	LAC	(175)		/33, WHICH ARE POSSIBLE

	SAD	(33)		/OTHER FORMS OF ALTMODE

	LAC	(175)		/(PREFIX OR ESCAPE) TO

	DAC	TTCHAR		/THE PDP-15 STANDARD IN-

				/TERNAL 175 REPRESENTATION.

/

/ DISPATCH ON DATA MODE.

/

	LAC	TTWD00,X
	AND	(TTB.AS		/(163)ASCII BIT
	SZA!IAC!CLA		/(163)SKIP ON IMAGE

	JMP	TTRIOP		/READ IN IOPS ASCII.

/

/ ASSUME IMAGE ASCII (MODE 3).

/
	DAC	TTRDEV		/(163)DEFAULT RETURNED EV IS 1
	AAC	2		/(163)REMEMBER HEADER MODE

	DAC	TTTEMP

	LAC	TTWD03,X	/GET DATA STORAGE POINTER AND ...

	PAX

	LAC	TTCHAR		/ ... STORE THE INPUT CHARACTER IN THE
	DAC	0,X		/(163)REQUESTOR'S LINE BUFFER

	IDX	TTWD03,X	/INCREMENT THE STORAGE POINTER.

/
	PLX			/(163)RESTORE XR
	JMS	TTPRNT		/IF NECESSARY, OUTPUT THE

				/CHARACTER TO THE "PRINTER".

				/(AC ALTERED).

/
	LAC	TTWD04,X	/(163)DONE, ALREADY COUNTED AT INTRRUP
	SPA!CLA!CMA		/(163)LEVEL, SKIP IF DONE
	JMP	TTSCN3		/(163)THAT'S IT
	DZM	TTBITS		/(163)CLEAR OPTIONAL TTWD00 BITS

/

/  COMPUTE WORD PAIR COUNT TO RETURN

/
TTKSJ	TAD	TTWD02,X	/(163)IOPS JOINS HERE
	CMA!IAC			/(163)COMPUTE WORD COUNT FOR BUFFER
	TAD	TTWD03,X	/(163)
	CLL!RAR			/(163)WORDS TO PAIRS
	SWHA			/(163)LEFT HALF IN HEADER
	TAD	TTTEMP		/(163)MODE CODE
	DAC	TTTEMP		/(163)SAVE
	LAC	TTWD02,X	/(163)NOW GET BACK HEADER POINTER

	PAX

	LAC	TTTEMP
	DAC	0,X		/(163)TO USER

	PLX
	JMP	TTREQD		/(163)SET TTWD00, RETURN EV ETC.

/

/ IOPS ASCII (MODE 2) INPUT.

/
TTRIOP	DAC	TTRDEV		/(163)DEFAULT RETURNED EV
	IAC!CLL			/(163)IO@S ASCII FOR HEADER

	DAC	TTTEMP

	LAC	TTCHAR		/TEST FOR ERASE CHARACTER.

	SAD	(177)
	JMP	TTR.O		/RUBOUT.

/

/ DON'T TEST FOR BUFFER OVERFLOW IF THE CHARACTER

/ IS CARRIAGE RETURN OR ALTMODE.

/

	SAD	(15)		/CARRIAGE RETURN?

	SKP

	SAD	(175)		/ALTMODE?

	JMP	TTIAST		/YES.

/

/ TEST FOR BUFFER OVERFLOW.

/

	LAC	TTWD04,X
	SPA!CLA			/(163)SKIP IF YES
	JMP	TTIAST		/(163)NOPE
	AAC	62		/(163)ASCII, TRUNCATED

	DAC	TTTEMP
	LAC	(15		/(163)FORCE CR

	DAC	TTCHAR

/

/ STORE THE CHARACTER IN IOPS (5/7) ASCII FORMAT.

/
TTIAST	.RTL3			/(163)USE INPUT INTERRUPT PACKER
	LAC	TTCHAR		/(163)IT EXPECTS CHAR IN TTITMP

	DAC	TTITMP

	JMS	TTPKEX
	LAC	(TTKIGN		/(163)RESTORE EXIT FOR INTERRUPT LEVEL

	DAC	TTPKEX

	DBK
	PLX			/(163)PACKER ZAPPED XR

	LAC	TTCHAR
	JMS	TTPRNT
	DZM	TTBITS		/(163)DEFAULT CLEAR BITS FROM TTWD00

	LAC	TTCHAR

	SAD	(175)		/ALT MODE?

	JMP	TTIASU

	SAD	(15)		/CARRIAGE RETURN?
	SKP			/(163)YES, END OF LINE
	JMP	TTSCN3		/I/O REQUEST NOT YET COMPLETED.
	IDX	TTRDEV		/(163)CR ON INPUT MAKE EV=2
	LAC	(TTB.CR		/(163)SET UP TO PUT CR BIT IN TTWD00

	DAC	TTBITS
TTIASU	LAC	TTWD10,X	/(163)MAKE BUFFER HEADER
	SAD	TTPKJ1		/(163)ROUND DIFFERENT ON 1ST OF 5

	SKP!CLA

	LAW	-2
	JMP	TTKSJ		/(163)JOIN UP

/

/
TTR.O	.RTL3			/(163)ASCII RUB-OUT SERVICE
	LAW	-1		/(163)BACK UP COUNTER
	TAD	TTWD04,X
	DAC	TTWD04,X
	LAC	TTPKJ1		/(163)CONVERT DISPATCH TO 0-4 INDEX
	CMA!IAC
	TAD	TTWD10,X
	LRSS	3
	SZA!CLL			/(163)HAVE BACKUP UP TOO FAR
	JMP	TTR.O1		/(163)NOT ON CHARS 2-5
TTLM2	-2			/(163)MAYBE, CHECK POINTERS
	TAD	TTWD03,X
	SAD	TTWD02,X
	JMP	TTR.O9		/(163)TOO FAR, GET OUT
	CLA!CLL			/(163)REESTABLISH INDEX
TTR.O1	TAD	TTLM2		/(163)MAKE INDEX-2.LINK0 FOR WORD BACKUP
	PAX			/(163)TO FETCH DISPATCHER AND MASK
	LAC	TTMTAB+2,X	/(163)MASK TO REMOVE LAST CHAR
	DAC	TTABNA		/(163)USE IT LATER WHEN XR DIFFERENT
	LAC	TTJTAB+2,X	/(163)AND NEW DISPATCHER
	PLX			/(163)INDEX BY TT UNIT #
	DAC	TTWD10,X	/(163)DISPATCHER SET
	LAC	TTWD03,X	/(163)MODIFY STORED DATA
	SZL			/(163)SKIP IF HAVE TO BACK UP A WORD
	JMP	TTR.O2		/(163) NO
	AAC	-1		/(167) BACK UP POINTER
	DAC	TTWD03,X	/(167) AND SAVE NEW VALUE
	PAX			/(167) SET UP TO ZAP PREVIOUSLY STORED WORD
	DZM	1,X		/(167)
TTR.O2	PAX			/(163)SET UP TO MASK PRESENT WORD
	LAC	0,X
	AND	TTABNA
	DAC	0,X
	DBK			/(163)THAT'S IT
	PLX			/(167) RESTORE XR
	LAC	(134		/(163)NOW, ECHO A \
	JMS	TTPRNT
	JMP	TTSCN3
/
TTR.O9	IDX	TTWD04,X	/(163)EXIT CASE, MOVE COUNT BACK
	JMP	TTSCN3
	JMP	TTSCN3
/
/  TABLES FOR RUBOUT PROCESSING
/
TTJTAB=.
TTPKJ5	JMP	TTPKA5
TTPKJ3	JMP	TTPKA3
TTPKJ1	JMP	TTPKA1
TTPKJ4	JMP	TTPKA4
TTPKJ2	JMP	TTPKA2
TTMTAB	777400		/(163)MASKS
	777760
TTLIT0	0
	700000
	774000
 .TITLE *** TTY "PRINTER" OUTPUT SERVICE

/

/ CONTROL COMES HERE FROM THE TTSCAN ROUTINE WHEN

/ THE OUTPUT REGISTER FOR THIS TTY INDICATES THAT

/ A "PRINTER" INTERRUPT WAS EXPECTED AND HAS

/ OCCURRED. THE LATTER (BIT 1) IS CLEARED BY TTSCAN.

/

/
TTPSVC	SWHA			/(163)BRING CHAR TO RIGHT
	AND	(177

	DAC	TTCHAR
	LAC	TTK.EV,X	/(163)CLEAR OUR SIDE

	AND	(OMASK

	DAC	TTK.EV,X

	LAW	-1
	TAD	TTWD05,X	/(163)INTERRUPT SIDE OVERCOUNTED
	DAC	TTWD05,X	/(163)LINE POSITION
	DBK			/(163)DOWN FOR PRINTING

/

/
	LAC	TTCHAR		/(163)PRINT THE CHAR
	SZA			/(163)FINAL CHAR, IF NULL, RUB
	SAD	(177		/(163)DON'T PRINT
	JMP	TTPRTL		/(163)GO RAISE TO 3 TO JOIN
	JMS	TTPRNT
TTPRET	CLA!IAC			/(163)DEFAULT EV

	DAC	TTRDEV
	DZM	TTBITS		/(163)DEFAULT SETTING OF RETURN BITS
	LAC	TTWD00,X	/(163)ASCII IMAGE SPLIT

	AND	(TTB.AS
	SNA			/(163)SKIP ON ASCII

	JMP	TTPIM
	LAC	TTCHAR		/(163)CHECK FOR ENDING CHAR

	SAD	(15
	JMP	TTPCR		/(163)<CR> SET CARRIAGE RETURN BIT

	SAD	(175
	JMP	TTREQD		/(163)ALT, WE'RE DONE
	LAW	-30		/(163)IF ASCII TO END NOW
	DAC	TTRDEV		/(163)HERE IS EV
TTPIM	LAC	TTWD04,X	/(163)THRU?
	SPA
	JMP	TTSCN3
/
/  TTREQD ENTER WITH EV IN TTRDEV, BITS IN TTBITS
/
TTREQD	LAC	TTWD00,X
	AND	(-1\TTB.OU\TTB.IN\TTB.CR	/(163)CLEAR BITS
	XOR	TTBITS		/(163)SET ANY THAT NEED IT

	DAC	TTWD00,X

	DBK

	JMP	TTSR2

/
TTPCR	LAC	(TTB.CR		/(163)SET CR TO TTWD00
	DAC	TTBITS
	JMP	TTREQD
/
TTPRTL	.RTL3			/(163)TO LEVEL 3 SINCE TTPRNT DONES ALSO
	JMP	TTPRET
/
/
/  REQUEST DONE CODE, VARIOUS ENTRY POINTS

/
TTDONE	CLA!IAC			/(163)OK + 1

TTSREV	DAC	TTRDEV		/SAVE VALUE TEMPORARILY.

TTSR1	JMS	TTUINX		/RESTORE THE XR WITH THE TTY UNIT #.

TTSR2	LAC	TTWD09,X	/ADDRESS OF THE I/O REQUEST NODE.

	DAC*	(R2)
	LAC	TTWD01,X	/(163)RETURN EV
	SNA			/(163)SKIP IF YES

	JMP	TTNOEV

	TAD	TTXADJ

	PAX
	LAC	TTRDEV		/(163)EV VALUE

	DAC	0,X

TTNOEV	JMS*	(IOCD

TTEVNT	LAC*	(POOL
	DAC*	(R1		/(163)RETURN NODE

	JMS*	(NADD
	.SET6			/(163)SIGNIFICANT EVENT
	JMP	TTSCAN		/(163)CHECK FOR MOREACTION

 .TITLE *** TTY MISCELLANEOUS SUBROUTINES

/
/  ROUTINE ENTERED AT MAINSTREAM WITH CHAR IN AC
/  ROUTINE EXITS AT LEVEL 3 !! AC IS MODIFIED, TTCHAR MAY BE MODIFIED
/
/ CALLING SEQUENCE:

/

/	(7-BIT CHARACTER IN THE AC)
/	JMS	TTPRNT

/	(UNCONDITIONAL RETURN)

/

/ ALTERED REGISTERS:

/

/	AC & TTCHAR

/
TTPRNT	0

	AND	(177)
TTPRN0	DAC	TTCHAR		/(163)CHARACTER

/
	SAD	(175		/(163)ALT SPECIAL CASE

	JMP	TTPALT

/

	.EJECT

/ INPUT FROM A "KEYBOARD" BACK TO THE "PRINTER"

/ AND CALLED TO "PRINT" CHARACTERS ON OUTPUT

/ IF THE UNIT IS CAPABLE OF RECEIVING DATA FROM THE CPU.

/

/ NOTE -- THE 8TH BIT IS COMPUTED ON OUTPUT

/ TO FORM AN EVEN PARITY CHARACTER, WHICH IS

/ TYPICALLY REQUIRED FOR ASYNCHRONOUS DATA

/ CHANNELS AND FOR PAPER TAPE. TAPES PUNCHED ON

/ MODEL ASR TELETYPES, OR THE LIKE, PROVIDED

/ THAT THEY ARE NOT OIL BASE TAPES, CAN BE READ

/ VIA THE PC15 HIGH SPEED PAPER TAPE READER.

/ UNLIKE THE PC15 PUNCH HANDLER, HOWEVER, TTY

/ DOES NOT RECOGNIZE THE CLOSE FUNCTION AND

/ THEREFORE DOES NOT OUTPUT AN EOT (END-OF-

/ TRANSMISSION) CHARACTER, WHICH THE PC15

/ READER HANDLER INTERPRETS AS END-OF-FILE.

/

/

/ ALTERED REGISTERS:

/

/	AC

/

/ THE FOLLOWING COULD BE DONE BUT ISN'T:

/

/ DON'T KEEP TRACK OF THE POSITION WITHIN A LINE IN ORDER

/	TO SIMULATE HORIZONTAL TAB ON A TTY WHICH

/	DOES NOT HAVE THE TABBING MECHANISM.

/

/ DON'T SIMULATE VERTICAL TABS AND FORM FEEDS.  A

/	TTY WHICH CAN RECEIVE OUTPUT IS ASSUMED

/	TO HAVE THE HARDWARE MECHANISM WHICH

/	CAN DO VERTICAL TABS AND FORM FEEDS.

/

/ DON'T TEST FOR A DEVICE THAT IS FULL DUPLEX WITH

/	LOCAL COPY.  FOR NOW, ALL TTY'S THAT CAN BOTH

/	SEND AND RECEIVE ARE ASSUMED TO BE

/	FULL DUPLEX WITHOUT LOCAL COPY, WHICH IM-

/	PLIES THAT "KEYBOARD" INPUT MUST BE SENT

/	BACK TO THE "PRINTER".

/

	.EJECT
TTPRN1	LAC	TTWD00,X	/(163)DO WE HAVE A PRINTER?

	AND	(TTB.PR

	SNA
	JMP	TTPRN3		/(163)TO LEVEL 3 AND EXIT
/
/  WHAT KIND OF DEVICE

/00=KSR35; 01=KSR33; 10=LA30; 11=VT05.

/
	LAC	TTWD00,X	/(163)DEVICE TYPE HERE
	AND	(TTB.TY		/(163)STRIP OTHER 16 BITS
	SAD	(TTB.TY		/(163)VT05
	JMP	TTVTST		/(163)YES
	SAD	(TTB.T1		/(163)LA30

	JMP	TTLA30
	SZA			/(163)SKIP ON KSR35
	JMP	TTY33		/(163)IS A 33

	LAC	TTCHAR		/CHECK FOR CERTAIN CHARACTERS.

	SAD	(11)

	JMP	TTHTAB		/HORIZONTAL TAB.

TTY35	SAD	(13)

	JMP	TTVTAB		/VERTICAL TAB.

	SAD	(07)

	JMP	TTBELL		/BELL.

	SAD	(14)

	JMP	TTFORM		/FORM FEED.

	SAD	(21)

	JMP	TTDBSP		/DOUBLE SPACE.

/

/ THE PRECEDING CHARACTERS MAY NEED MORE THAN A

/ SINGLE CHARACTER TO BE OUTPUT.  GENERALLY, THEY

/ REQUIRE FILLER CHARACTERS (USUALLY NULLS) TO

/ FOLLOW THEM IN ORDER TO PROVIDE THE TIMING DELAY

/ NOT EXISTING IN THE HARDWARE.  FOR EXAMPLE, A

/ HORIZONTAL TAB CANNOT ALWAYS COMPLETE WITHIN A

/ SINGLE CHARACTER TIME. THE NUMBER OF FILLERS

/ NEEDED IS A FUNCTION OF THE OUTPUT BAUD RATE

/ OF THE TERMINAL.

/

/ THE PRIMARY CHARACTER IS "PRINTED" DIRECTLY BY THIS SUB-

/ ROUTINE.  THE FILLER CHARACTER AND REPEAT COUNT ARE

/ ENTERED IN THE TTY'S OUTPUT REGISTER.

/
TT1INT	CLA			/(163)NO REPEAT NEEDED
TTSETO	DAC	TTTMPR		/(163)SAVE REPEAT COUNT
	LAC	TT.PCL,X	/(163)MAKE PRINTING IOT

	AAC	2

	DAC	TTP.IO
	.RTL3			/(163)AVOID RACES
	LAC	TTWD00,X	/(163)ECHOING
	RAR			/(163)ECHOING BIT TO LINK
	SNL!CLL!RAL		/(163)SKIP IF NOT, CLEAR BIT
	JMP	TTESTK		/(163)GO STACK ECHO
	DAC	TTWD00,X	/(163)REPLACE WORD
	LAC	TTCHAR		/(163)CHARACTER TO PRINT

	.IFDEF PARITY

	CLL!RAL

	XOR	TTCHAR

	AND	(252

	AAC	146

	AND	(210

	AAC	170

	AND	(200

	XOR	TTCHAR

	.ENDC
TTP.IO	XX			/(163)IOT TO ECHO
	SWHA			/(163)CHECK KEEP CHARACTER BIT
	SMA!SWHA		/(163)SKIP ON BIT ON
	CLA			/(163)SUBSEQUENT ECHOES ARE NULLS!!
	TAD	TTTMPR		/(163)REPEAT COUNT
	DAC	TTWD06,X
	JMP*	TTPRNT
/
TTESTK	LAC	TTCHAR

	.IFDEF PARITY

	CLL!RAL

	XOR	TTCHAR

	AND	(252

	AAC	146

	AND	(210

	AAC	170

	AND	(200

	XOR	TTCHAR

	.ENDC
	TAD	TTTMPR		/(163)REPEAT COUNT
	TAD	(20000		/(163)ADD A COUNT FOR FIRST CHAR!!
	DAC	TTWD11,X	/(163)BACK UP ECHO STACKER
	JMP*	TTPRNT
/
/ SPECIAL CASE -- VERTICAL TAB, HORIZONTAL TAB & BELL.

/
TTHTAB=.
TTBELL=.
TTVTAB	LAC	(40000		/(163)2 NULLS
	JMP	TTSETO		/(163)GO WITH COUNT IN AC
/
/ SPECIAL CASE -- FORM FEED.
/
TTFORM	LAC	(300000		/(163)12 DECIMAL NULLS

	JMP	TTSETO

/
TTPALT	LAC	TTWD00,X	/(163)PRINTING ALT'S TODAY?
	AND	(TTB.AL
	SZA			/(163)SKIP IF NOT
	JMP	TTPRN1		/(163)YES, DO REGULAR
	LAC	TTWD00,X
	AND	(TTB.AS+TTB.OU	/(163)CHECK IMAGE OUTPUT
	SAD	(TTB.OU
	SKP!CLA			/(163)IS IMAGE OUTPUT, PRINT NULL
	JMP	TTPRN3		/(163)TO LEVEL 3 AND OUT
	JMP	TTPRN0		/(163)FORCE NULL TO TTCHAR
/
TTPRN3	.RTL3			/(163)TO LEVEL 3 AND EXIT
	JMP*	TTPRNT
/
/
/ SPECIAL CASE -- DOUBLE SPACE. ONE OF THE ROUTINES IN THE FORTRAN

/ OBJECT TIME SYSTEM PUTS A CODE 21 AT THE BEGINNING OF AN IOPS

/ ASCII LINE FOR OUTPUT TO MEAN DOUBLE SPACE. (THIS IS NOT THE

/ MEANING OF CODE 21 AS DEFINED IN USASCII).

/

/ CONVERT THE 21 TO A CODE 12 (LINE FEED). IF THIS IS THE FIRST

/ CHARACTER FROM THE OUTPUT LINE BUFFER, A SECOND LINE FEED WILL

/ ALREADY HAVE BEEN PRINTED PROVIDED THAT THE PRECEDING LINE WAS

/ TERMINATED BY A CARRIAGE RETURN IN IOPS ASCII. IF CODE 21 APPEARS

/ IN THE MIDDLE OF A LINE, ONLY A SINGLE LINE FEED WILL BE PRINTED.

/

TTDBSP	LAC	(12)

	DAC	TTCHAR

	JMP	TT1INT

/

/TEST HERE FOR SPECIAL VT05 CHARACTERS.

/

TTVTST	LAC	TTCHAR		/GET CHARACTER.

	SAD	(12

	JMP	TTVT05		/LINE FEED.

	SAD	(13

	JMP	TTVT05		/MOVE CURSOR DOWN.

	SAD	(16

	JMP	TTCAD		/CURSOR DIRECT ADDRESS.

	SAD	(32

	JMP	TTVT05		/MOVE CURSOR UP.

	SAD	(35

	JMP	TTVT05		/MOVE CURSOR TO ORIGIN.

	SAD	(37

	JMP	TTVT05		/ERASE TO END OF SCREEN.

/

/NOT SPECIAL CHARACTER BUT TEST FOR CURSOR DIRECT

/ADDRESSING BY TESTING CAD UNDERWAY FLAG IN TTWD00.

/

	LAC	TTWD00,X
	AND	(TTB.CA		/(163)CURSOR ADDRESSING

	SNA			/CAD UNDERWAY?
	JMP	TT1INT		/(163)REGULAR

	.RTL3

	LAC	TTWD00,X

	AND	(-1\TTB.CA

	DAC	TTWD00,X

	DBK

/SPECIAL CASE -- VT05 CHARACTERS USED FOR VERTICAL CURSOR

/MOVEMENTS REQUIRE FILL CHARACTERS. THE NUMBER OF

/CHARACTERS IS A FUNCTION OF BAUD RATE:

/	 600 BAUD = 1 FILLER

/	1200 BAUD = 2 FILLERS

/	2400 BAUD = 4 FILLERS.

/

TTVT05	LAC	TTWD00,X

	AND	(TTB.SP
	SAD	(TTB.SP		/(163)SKIP NOT 2400
	TAD	(TTB.S2		/(163)MAKE '3'  '4'

	CLL!RTL

	RTL
	JMP	TTSETO		/(163) 0,1,2,4 FILLER COUNT IN AC

/

	.EJECT

/

/SPECIAL CASE -- CURSOR DIRECT ADDRESSING ON VT05.

/THIS FEATURE PERMITS ABSOLUTE POSITIONING OF THE CURSOR.

/THE CAD CHARACTER ITSELF (ASCII 16) REQUIRES NO DELAY.

/HOWEVER, IT IS FOLLOWED BY TWO "PRINTABLE" CHARACTERS WHICH

/HAVE A SPECIAL MEANING TO THE VT05 AS ABSOLUTE CURSOR Y AND X

/POSITIONS. THE Y POSITION CHARACTER MUST BE FOLLOWED BY FILL

/CHARACTERS SINCE IT INITIATES VERTICAL CURSOR MOVEMENT. A

/CAD UNDERWAY FLAG IS SET IN TTWD05 WHEN A CAD IS DETECTED

/AND IS RESET AFTER THE NEXT CHARACTER IS RECEIVED.

/

TTCAD	.RTL3

	LAC	TTWD00,X

	AND	(-1\TTB.CA

	TAD	(TTB.CA

	DAC	TTWD00,X

	DBK

	JMP	TT1INT

/

/

/TEST HERE FOR A CARRIAGE RETURN TO A KSR33. MUST RESET THE

/PRINT POSITION COUNTER BEFORE PRINTING THE CR. OTHER

/CHARACTERS ARE PROCESSED THRU THE LA30 AND KSR35 ROUTINES.

/

TTY33	LAC	TTCHAR

	SAD	(15		/CARRIAGE RETURN?

	SKP!CLA

	JMP	TTAB33		/NO,GO TO LA30 ROUTINE.

				/YES, MUST RESET COUNT
	JMS	TTRSET		/(163)RESET HORIZONTAL POSITION
	JMP	TT1INT		/(163)NO NULLS

/

	.EJECT

/

/THIS SECTION TESTS FOR CR AND TAB GOING TO LA30'S.

/KEEPS TRACK OF PRINT POSITION FOR TAB SIMULATION AND

/CARRIAGE RETURN DELAY COMPUTATION. KSR33'S USE THE

/TAB SIMULATION SECTION AND ENTER AT TTAB33.

/

TTLA30	LAC	TTCHAR		/GET THE CHARACTER.

	SAD	(15

	JMP	TTLACR		/CARRIAGE RETURN.

TTAB33	SAD	(11

	JMP	TTABLA		/HORIZONTAL TAB.

	AAC	-40		/CHARACTER CODES
	SMA			/(163)<40 NON-SPACING

TTSPC1	IDX	TTWD05,X

TTGO35	LAC	TTCHAR		/RETURN TO KSR35 ROUTINE

	JMP	TTY35		/TO PROCESS OTHER CHAR.

/

/

/

/

TTRSET	0

	777000

	AND	TTWD05,X	/CLEAR PRINT

	IAC

	DAC	TTWD05,X	/AND RESTORE.

	JMP*	TTRSET

/

	.EJECT

/

/THE TIMING CHARACTERISTICS FOR THE CARRIAGE RETURN FUNCTION

/ON THE LA30 DECWRITER OPERATING AT 300 BAUD ARE PECULIAR.

/THE WORST CASE DELAY OCCURS AT CHARACTER POSITION 12 (DECIMAL),

/DROPS OFF TO CHARACTER 20 AND THEN INCREASES MORE SLOWLY TO

/POSITION 79.

/

/NINE FILL CHARACTERS ARE REQUIRED IN THE WORST CASE;

/HOWEVER,BECAUSE TIMING CHARACTERISTICS VARY FROM UNIT TO UNIT,

/AN ALGORITHM TO FIT NUMBER OF FILLERS TO PRINT POSITION IS NOT

/PRACTICAL. THEREFORE,THIS PROGRAM USES A VALUE OF SEVEN FILLERS

/WHICH WILL WORK IN MOST CASES. IF THE TIMING OF A PARTICULAR

/DEVICE APPROACHES WORST CASE, SO THAT ERRORS CONTINUE TO APPEAR,
/THE USER SHOULD MODIFY THE LITERAL LOADED AT TT300 TO INCREASE
/THE NUMBER OF FILLERS.

/

/

/LINE POSITION = 1 TO 80.
/IF POSITION 1 THRU 16, FILLERS = POSITION/2.

/IF POSITION 17 THRU 20, FILLERS = 5.
/IF POSITION 21 THRU 80, FILLERS = (POSITION + 40.)/16.

/

/
TTLACR	JMS	TTRSET		/(163)RESET HORIZONTAL POSITION

	LAC	TTWD00,X	/CHECK BAUD RATE.

	AND	(TTB.SP
	SZA			/(163)SKIP ON 110, NO FILLS
TT300	LAC	(160000		/(163)300  7 FILLS

	JMP	TTSETO

/

/

/SPECIAL CASE -- HORIZONTAL TAB ON LA 30 AND KSR33 MUST BE

/SIMULATED. THIS ROUTINE CONVERTS TAB CHARACTERS TO SPACES,

/DEPENDING ON THE CARRIAGE POSITION. A TAB IS CONSIDERED TO

/BE 8 SPACES FROM THE PREVIOUS TAB. TAB STOPS ARE LOCATED
/AT POSITIONS 1,9,17,25,33,41,49,57,65,73, ETC. 
/
TTABLA	LAC	(640		/(173)CHANGE TAB, 400 BIT ALL SPACES
	DAC	TTCHAR		/(173)NO 400 BIT, REPEATS NULLS
	LAC	TTWD05,X	/(173)PRINT POSITION IN LOW HALF
	DAC	TTTMPR		/(173)SAVE OLD VALUE
	AAC	7		/(173)CARRY MOD 8, UNLESS 0 MOD 8
	AND	(777770		/(173)STRIP GARBAGE BITS
	IAC			/(173)FORCE TO 1 MODE 8
	DAC	TTWD05,X	/(173)THAT'S NEW POSITION
	CMA!IAC			/(173)TAKE AWAY OLD TO GET  # TO DO
	TAD	TTTMPR		/(173) OLD VALUE FROM HERE
	CMA			/(173)CMA GIVES #-1 FOR REPEAT COUNT
/				/(173)SINCE 1 GOES OUT IMMEDIATELY!
	ALSS	15		/(173)TO REPEAT POSITION
	JMP	TTSETO		/GO TO PRINT, CHAR IN TTCHAR, COUNT IN AC
/
	.EJECT
/
/ SUBROUTINE TTUINX -- SET THE TTY LOGICAL UNIT NUMBER IN THE XR.
/
/ CALLING SEQUENCE:
/
/	JMS	TTUINX
/	(UNCONDITIONAL RETURN)
/
/ ALTERED REGISTERS:
/
/	XR & AC
/
TTUINX	0
	LAC	TTUNIT
	PAX
	JMP*	TTUINX

/

/

	.TITLE	TTY SYSTEM BLOCK AND MISC STORAGE

/

/ TTY "SHORT PARTITION BLOCK" (FOR REGISTER SAVE USE ONLY)

/
TTYIC	0			/TTYIC = PARTITION BLOCK
	DBA			/ADDRESS PLUS AN OFFSET.
	JMS*	(SAVE)
	.IFUND L.ALL						/EAG:202
	.NOLST							/EAG:202
	.ENDC							/EAG:202
	.REPT	PBIB
	0
	SKP
	.REPT	PBMM
	0
	.REPT	PBFP
	0
	.IFDEF L.TTY						/(205)
	.LST							/(205)
	.ENDC							/(205)
/
/ ACTIVE TASK LIST NODE
/
TTY	IORD			/FORWARD LINKAGE
	DSA			/BACKWARD LINKAGE
	.SIXBT	"TTY"		/TASK NAME (FIRST HALF)
	0			/TASK NAME (SECOND HALF)
	1			/TASK PRIORITY
	TTYIC-P.IC		/PARTITION BLOCK ADDRESS
	0			/STL NODE ADRESS (NONE)
	4			/TASK STATUS (INITIALLY READY FOR RESUMPTION)
	TTYTW			/RESUMPTION ADDRESS
	0			/EVENT VARIABLE ADDRESS
	.IFPNZ	NDSZMT
	.REPT	NDSZMT
	0
	.ENDC
/

/ PHYSICAL DEVICE LIST NODE FOR TT-0

/

TT00	PDVL			/FORWARD LINKAGE

	DSK0			/BACKWARD LINKAGE

	.SIXBT	"TT@"		/DEVICE NAME (FIRST HALF)

	0			/DEVICE NAME (SECOND HALF)

	0			/DEVICE ATTACH FLAG

	0			/UNIT NUMBER

TT0DQ	.			/REQUEST QUEUE (FORWARD LINKAGE)

	.-1			/REQUEST QUEUE (BACKWARD LINKAGE)

	TTTGEV			/TRIGGER EVENT VARIABLE ADDRESS

	0			/(UNUSED)

/

TTUNIT	0			/LOGICAL TTY UNIT NUMBER.

TTTGEV	0			/TTY TRIGGER EVENT VARIABLE.

				/BIT 0 IS SET BY THE "QUEUE I/O" DIRECTIVE.

				/BIT 1 IS SET BY TTY'S INTERRUPT SERVICE.

				/BIT 2 IS SET BY I/O RUNDOWN TASK WHEN

				/IT HAS QUEUED AN "ABORT" REQUEST.

TTCHAR	0			/7-BIT INPUT OR OUTPUT CHARACTER.

				/BITS 0-10 MUST ALWAYS BE 0.

TTHDR0	0			/ADDRESS OF HEADER WORD 0 IN THE

				/REQUESTOR'S LINE BUFFER.

TTTEMP	0			/TEMPORARY STORAGE.
/				/(163)NOT TO BE USED BY TTPRNT!!
TTTMPR	0			/(163)TTPRNT TEMPORARY
TTBITS	0			/(163)SAVE BITS TO PUT IN TTWD00

TTABNA	0			/ADDRESS OF THE "ABORT" I/O REQUEST NODE.

TTABSN	0			/STL NODE ADDRESS OF THE ABORTING TASK.

TTRDEV	0			/ADDRESS OF THE I/O RUNDOWN TASK'S EVENT

				/VARIABLE.

TTXADJ	.&70000\777777+1	/INDEX REGISTER ADJUSTMENT FACTOR -- TWOS

				/COMPLEMENT OF THE PAGE BITS OF THE PAGE

				/IN WHICH THIS CODE RESIDES -- CANCELS

				/OUT THE PAGE BITS ADDED BY THE HARDWARE

				/ON INDEXED MEMORY REFERENCE INSTRUCTIONS.
TTIAC	0			/(163)INTERRUPT LEVEL ONLY SAVE AC
TTIXR	0			/(163)INTERRUPT LEVEL ONLY SAVE XR
TTITMP	0			/(163)INTERUUPT LEVEL ONLY TEMPORARY
TTINUM	0			/(163)INTERRUPT LEVEL ONLY UNIT #

/

	.TITLE *** TTY INTERRUPT SERVICE

/

/

/ FOR THE LT15 AND LT19 DEVICES, CHARACTERS RECEIVED BY

/ THE CPU TRAP VIA API CHANNEL 35 (REGISTER 75),

/ WHICH CONTAINS THE INSTRUCTION "JMS* (TTYKI)".

/

/ FOR THE LT15 AND LT19 DEVICES, COMPLETION OF TRANS-

/ MISSION OF A CHARACTER FROM THE CPU TO THE DEVICE,

/ WHICH INDICATES THAT THE DEVICE IS READY TO RE-

/ CEIVE MORE DATA, CAUSES A TRAP VIA API CHANNEL 34

/ (REGISTER 74), WHICH CONTAINS THE INSTRUCTION

/ "JMS* (TTYPI)".

/

/ THE CONSOLE TTY, WHICH IS NOT CONNECTED TO

/ THE API HARDWARE, INTERRUPTS VIA LOCATION 0

/ AS DO ALL PIC DEVICES.  THE EXECUTIVE WILL,

/ HOWEVER, SIMULATE AN API INTERRUPT SO THAT

/ THE CONSOLE TTY WILL CAUSE ENTRY TO THE

/ INTERRUPT SERVICE ROUTINES IN THE SAME MANNER

/ AS DO THE LT15 AND THE LT19.

/

/ "TTYKI" AND "TTYPI" ARE ENTERED AT API LEVEL 3.

/

/ A CONNECT DIRECTIVE IS NOT ISSUED BECAUSE THE

/ EXECUTIVE STARTS UP WITH THE TTY INTERRUPT LINES
/ ALREADY CONNECTED TO THE INTERRUPT SERVICE ROUTINES.

/

/  KEYBOARD INTERRUPT SECTION

/

/

/  ENTRY FOR CONSOLE TTY

/

TTYKCT	DAC	TTIAC
	LAC*	(0		/(163)GET PC

	DAC	TTYKI
	PXA			/(163)SAVE XR

	DAC	TTIXR
	CLX			/(163)UNIT #0
	JMP	TTKALL		/(163)JOIN UP

/

TTYKI	0

	DBA
	DAC	TTIAC		/(163)SAVE AC

	PXA
	DAC	TTIXR		/(163)SAVE XR; LR NO LONGER NEEDED
TTYKSK	704101+10		/(163)KEEP UNIT-1 IN AC

	SKP!IAC

	JMP	TTKTT

	704121

	SKP!IAC

	JMP	TTKTT

	704141

	SKP!IAC

	JMP	TTKTT

	704161

	SKP!IAC

	JMP	TTKTT

	704301

	SKP!IAC

	JMP	TTKTT

	704321

	SKP!IAC

	JMP	TTKTT

	704341

	SKP!IAC

	JMP	TTKTT

	704361

	SKP!IAC

	JMP	TTKTT

	704501

	SKP!IAC

	JMP	TTKTT

	704521

	SKP!IAC

	JMP	TTKTT

	704541

	SKP!IAC

	JMP	TTKTT

	704561

	SKP!IAC

	JMP	TTKTT

	704701

	SKP!IAC

	JMP	TTKTT

	704721

	SKP!IAC

	JMP	TTKTT

	704741

	SKP!IAC

	JMP	TTKTT
	704761
/
/  BACK UP ASSEMBLY OVER UNWANTED PART OF CHAIN
/
	.IFZER TTYS-1
	.LOC TTYKSK
	.ENDC
	.IFPNZ TTYS-1
	.LOC TTYS-1*3+TTYKSK-2
	.ENDC
/
	JMP	TT.KRS+TTYS	/(163)CLEAR ILLEGAL INTERRUPT, EXIT

/

/
TTKTT	IAC			/(163)MAKE UNIT NUMBER
	PAX			/(163)UNIT # TO XR
TTKALL	LAC	TTWD00,X	/(163)CHECK OUT STATUS
	CLL!RAL			/(163)LINK=0 FOR LATER, CHECK INPUT ACTIVE
	SMA!RTR			/(163)SKIP IF INPUT ACTIVE, SET UP NEXT
	JMP	TTKNOI		/(163)INPUT IN ACTIVE, ALLOW ONLY SPECIALS
	SNL!CLL!RAL		/(163)SKIP IF NOT ECHOING, SAY ECHOING
	JMP	TTKECH		/(163)ALREADY ECHOING, MUST STACK ECHO!
	DAC	TTWD00,X	/(163)REPLACE WORD, SAYING, ECHOING

	.IFUND	PARITY
	LAW	-200		/(163)OR IN CHAR, RANGE -200 TO -1(L=0)
	XCT	TT.KRS,X	/(163)READ AND CLEAR IOT INDEXED BY TT#
	AAC	3		/(163)SPEC'S 175-177 LEAVE LINK CLEAR
	TAD	(135		/(163)REG. CHAR.'S 40-174 CARRY LINK TO 1
	AAC	40		/(163)SPEC'S 0-37 LEAVE LINK CLEAR
	DAC	TTITMP		/(163)CHAR NOW STRIPPED 7 BITS; SAVE IT
	ISZ	TTWD04,X	/(163)SKIP IF IT IS LAST CHAR
	SNL!CML			/(163)SKIP IF NOT A SPECIAL CHAR
	JMP	TTKSPC		/(163)FAILED SOME TEST, NOT QUICK MODE

	.ENDC

/

	.IFDEF	PARITY

/
	CLA!CLL!CML		/(163)OR CHAR INTO 0 AC, LINK=1

	XCT	TT.KRS,X
	DAC	TTINUM		/(163)SAVE 8 BIT CHAR

	AND	(177
	DAC	TTITMP		/(163)SAVE 7 BIT CHAR

	AAC	-175
	TAD	(135		/(163)LINK 0 IF REGULAR
	ISZ	TTWD04,X	/(163)LAST CHAR SKIPS
	SZL			/(163)SKIP ON REGULAR CHAR
	JMP	TTKSPC		/(163)FAILED SOME TEST, NOT QUICK
	LAC	TTINUM		/(163)ECHO 8 BIT CHAR

	.ENDC
	IDX	TTWD05,X	/(163)BUMP HORIZONTAL LINE POSITION
	XCT	TT.PRT,X	/(163)QUICK MODE, ECHO CHAR
/				/(163)SKIPS IF NO PRINTER!!!!
	XCT	TTWD10,X	/(163)DISPATCH TO PACK CHAR IN TTITMP
	IDX	TTWD00,X	/(163)SAY NOT ECHOING, NO PRINTER
	XCT	TTWD10,X	/(163)STILL PACK CHAR

/

	.IFUND	PARITY
TTKECH	LAW	-200		/(163)ALREADY ECHOING
	XCT	TT.KRS,X	/(163)READ CHAR
	AAC	3		/(163)SAME AS ABOVE BUILD SPECIAL
	TAD	(135		/(163)BIT IN LINK

	AAC	40
	DAC	TTITMP		/(163)SAVE CHAR
	ISZ	TTWD04,X	/(163)COUNT, DONE?
	SNL!CML			/(163)SKIP IF REGULAR CHAR
	JMP	TTKSPE		/(163)SPECIAL CHAR

	.ENDC

/

	.IFDEF	PARITY
TTKECH	CLA!CLL!CML
	XCT	TT.KRS,X
	DAC	TTINUM

	AND	(177

	DAC	TTITMP

	AAC	-175

	TAD	(135

	ISZ	TTWD04,X

	SZL

	JMP	TTKSPE

	LAC	TTINUM

	.ENDC
	IDX	TTWD05,X	/(163)MOVE POSITION COUNTER
	TAD	(20000		/(163)SAVE ECHO REQ

	DAC	TTWD11,X
	XCT	TTWD10,X	/(163)DISPATCH TO PACK
/
/
TTKNOI	777000		/(201) ROOM IN TTK.EV
	AND	TTK.EV,X /(201) CHECK OUR SIDE
	SZA!CLL!CML	/(201) SKIP IF CAN FIT, LINK ON FOR NEXT
	JMP	TTKIGN	/(201) ALL STACKED UP, THROW AWAY INTR.
	LAW	-200
	XCT	TT.KRS,X	/(163)BRING IN CHAR

	AAC	3
	TAD	(135		/(163)SPECIALS LEAVES LINK 1

	SNL
	JMP	TTKIGN		/(163)NOT A SPECIAL, NO INPUT, IGNORE!
	AAC	40		/(163)RE CONSTITUTE CHAR
	JMP	TTKJOI	/(201) JOIN UP TO FILL TTK.EV
/
TTKSPC	IDX	TTWD00,X /(201) WE'RE NOT REALLY ECHOING
TTKSPE	777000		/(201) CHECK TTK.EV FOR ROOM
	AND	TTK.EV,X /(201) LEFT SIDE SHOULD BE EMPTY
	SZA!CLA!CMA	/(201) SKIP IF OK
	JMP	TTKBAK	/(201) COULDN'T FIT, BACK UP COUNTER
	LAC	TTITMP	/(201) CHARACTER
TTKJOI	AAC	200	/(201) INPUT FLAG
	SWHA!SZL	/(201) MOVE TO LEFT SIDE; SKIP IF NOT SPECIAL
	XOR	(400000	/(201) SPECIAL CHAR FLAG
	TAD	TTK.EV,X	/(163)ADD IN OTHER SIDE
	DAC	TTK.EV,X
	LAC	TTTGEV		/(163)SET EVENT VARIABLE
	SZA!CLL!RTL		/(167)SHIFT TO SET BIT
	AAC	2		/(167) EVENTUAL LINK, SET TO AVOID SET6
	CLL!CML
	RTR
	DAC	TTTGEV
	LAC	(401000		/(167) AC FOR SIGN. EVENT SET
	SNL			/(167) IF TTTGEV ALREADY  NON0 DON'T SET
	ISA
TTKIGN	LAC	TTIXR		/(163)RESTORE XR

	PAX
	LAC	TTIAC		/(163)RESTORE AC

	DBR
	JMP*	TTYKI		/(163)OUT

/
/
TTKBAK	TAD	TTWD04,X	/(163)ALREADY COUNTED, BACK UP

	DAC	TTWD04,X

	JMP	TTKIGN

/

/  PACKING FUNCTIONS

/

/  THESE ROUTINES SERIALLY REUSABLE. CALL AT LEVEL 3

/  TO PREVENT REENTRANT PROBLEMS

/  CALL WITH TT UNIT # IN XR
/  CALL WITH 7 BIT CHAR IN TTITMP

/  TTWD03,X  HAS 0,X POINTER TO DATA ADJUSTED TO PAGE

/  TTPKEX HAS ADDR TO JMP* EXIT TO

/  CALL WITH LINK CLEARED

/  THESE ROUTINES DESTROY THE XR!!!!

/
TTPKEX	TTKIGN			/(163)EXIT VECTOR FROM PACKERS
	XCT	TTWD10,X	/(163)DISPATCH IF CALLED FROM BELOW

/
/  FOR OBSCURE REASONS OF THE TTR.O ROUTINE, 
/  THE TTPKAX ROUTINES MUST APPEAR IN THE PRESENT ORDER,
/  AND THE DISTANCE BETWEEN TTPKA3 AND TTPKA1 MUST NOT
/  EXCEED THE PRESENT 47 OCTAL LOCATIONS!!!!
/
/
/
TTPKA1	LAC	TTPKJ2		/(163)SET UP DISPATCH TO SECOND
	DAC	TTWD10,X	/(163)STORE FOR NEXT TIME
	LAC	TTWD03,X	/(163)GET DATA POINTER
	PAX			/(163)XR TO PLACE DATA
	LAC	TTITMP		/(163)CHARACTER TO AC
	SWHA			/(163)LEFT JUSTIFY IN WORD

	RTL
	DAC	0,X		/(163)INTO BUFFER
	JMP*	TTPKEX
/
TTPKA4	LAC	TTPKJ5		/(163)GET DISPATCH TO #5
	DAC	TTWD10,X
	LAC	TTWD03,X
	PAX
	LAC	TTITMP		/(163)CHAR
	SWHA
	RAR
	TAD	0,X
	DAC	0,X
	JMP*	TTPKEX
/
TTPKA2	LAC	TTPKJ3		/(163)NEXT

	DAC	TTWD10,X

	LAC	TTWD03,X

	PAX

	LAC	TTITMP
	RTL			/(163)LEAVE ROOM FOR FIRST 7 BITS

	RTL

	TAD	0,X
	DAC	0,X		/(163)UPDATE BUFFER
	JMP*	TTPKEX
/
TTPKA5	LAC	TTPKJ1
	DAC	TTWD10,X
	LAC	TTWD03,X
	IDX	TTWD03,X
	PAX
	LAC	TTITMP
	RAL
	TAD	0,X
	DAC	0,X
	JMP*	TTPKEX
/
/
TTPKA3	LAC	TTPKJ4
	DAC	TTWD10,X

	LAC	TTWD03,X
	IDX	TTWD03,X	/(163)NEXT CHAR FROM NEXT WORD!

	PAX

	LAC	TTITMP
	CLL!RAR			/(163)TOP 4 CHAR BITS INTO 1ST WORD

	CLL!RAR

	CLL!RAR

	TAD	0,X

	DAC	0,X
	LAC	TTITMP		/(163)BOTTOM 3 LEAD OFF 2ND WORD

	RTR

	RTR

	AND	(700000

	DAC	1,X
	JMP*	TTPKEX
/
/
/
/  IMAGE PACK

/
TTPKI	LAC	TTWD03,X	/(163)NO CHANGE IN VECTOR
	IDX	TTWD03,X	/(163)BUT MOVE POINTER FOR EACH CHAR

	PAX

	LAC	TTITMP

	DAC	0,X

	JMP*	TTPKEX

/

/  THREE TABLES OF IOT'S

/

/  KEYBOARD; CLEAR FLAG, OR CHARACTER TO AC

/

/

TT.KRS	700322

	704102

	704122

	704142

	704162

	704302

	704322

	704342

	704362

	704502

	704522

	704542

	704562

	704702

	704722

	704742

	704762
	JMP	TTKIGN		/(163)JUMP TO CHAIN TO CLEAR ILLEGAL
/				/(163)INTERRUPT, EXIT FROM INTERRUPT

/

/  TABLE OF CLEAR IOT ONLY FOR TELEPRINTER SIDE

/

TT.PCL	700402

	704002

	704022

	704042

	704062

	704202

	704222

	704242

	704262

	704402

	704422

	704442

	704462

	704602

	704622

	704642

	704662
	JMP	TTPIGN		/(163)EXIT FROM ILLEGAL INTERRUPT CLEAR

/

/  TABLE OF PRINT AND CLEAR IOT FOR TELEPRINTER SIDE

/

/  THIS TABLE NEED EXTEND ONLY THRU ASSEMBLED UNITS

/

TT.PRT	700406

	704006

	704026

	704046

	704066

	704206

	704226

	704246

	704266

	704406

	704426

	704446

	704466

	704606

	704626

	704646

	704666

/

/

/  BACK UP ASSEMBLY OVER UNWANTED PART OF TABLE

/

	.LOC	TT.PRT+TTYS

/

/

/
TTYPCT	DAC	TTIAC		/(163)CONSOLE TELETYPE ENTRY
	LAC*	(0		/(163)GET PC

	DAC	TTYPI
	PXA			/(163)SAVE XR

	DAC	TTIXR
	CLX			/(163)UNIT #0
	DZM	TTINUM		/(163)SAVE UNIT THRU XR USE
	JMP	TTPALL		/(163)JOIN WITH LT-19

/

TTYPI	0

	DBA

	DAC	TTIAC

	PXA

	DAC	TTIXR
TTYPSK	704001+10		/(163)AC HAS UNIT -1

	SKP!IAC

	JMP	TTPTT

	704021

	SKP!IAC

	JMP	TTPTT

	704041

	SKP!IAC

	JMP	TTPTT

	704061

	SKP!IAC

	JMP	TTPTT

	704201

	SKP!IAC

	JMP	TTPTT

	704221

	SKP!IAC

	JMP	TTPTT

	704241

	SKP!IAC

	JMP	TTPTT

	704261

	SKP!IAC

	JMP	TTPTT

	704401

	SKP!IAC

	JMP	TTPTT

	704421

	SKP!IAC

	JMP	TTPTT

	704441

	SKP!IAC

	JMP	TTPTT

	704461

	SKP!IAC

	JMP	TTPTT

	704601

	SKP!IAC

	JMP	TTPTT

	704621

	SKP!IAC

	JMP	TTPTT

	704641

	SKP!IAC

	JMP	TTPTT
	704661
/
/  BACK UP ASSEMBLY OVER UNWANTED PART OF SKIP CHAIN
/
	.IFZER TTYS-1
	.LOC TTYPSK
	.ENDC
	.IFPNZ TTYS-1
	.LOC TTYS-1*3+TTYPSK-2
	.ENDC
/
	JMP	TT.PCL+TTYS	/(163)NONE FOUND. CLEAR OTHER ILLEGALS

/

/

/
TTPTT	IAC			/(163)BRING UP TO UNI T #
	PAX			/(163)TTY # TO XR TO ACCESS TABLES
	DAC	TTINUM		/(163)SAVE (UNPACKERS DESTROY XR)
TTPALL	LAC	TTWD00,X	/(163)FIND OUT STATUS
	SMA!CLL!RAR		/(163)SKIP IF OUTPUT ACTIVE
	JMP	TTPNOU		/(163)NOPE
	SNL!RAL			/(163)SKIP IF NOT ECHOING
	JMP	TTPECH		/(163)ECHOING
TTPJOI	LAC	TT.PRT,X	/(163)SET UP PRINTING IOT

	DAC	TTPIOT
TTPJO2	IDX	TTWD05,X	/(163)INCREMENT POSITION
	ISZ	TTWD04,X	/(163)COUNT RUN OUT
	XCT	TTWD10,X	/(163)NO, FETCH CHAR TO AC
/				/(163)AND RETURN TO TTPART
	LAC	(JMP TTPSP2	/(163)LAST CHAR, GO BACK DOWN

	DAC	TTPIOT
	XCT	TTWD10,X	/(163)AND FETCH CHAR

/
TTPNOU	SZL			/(163)SKIP IF ECHOING
	JMP	TTPCLR		/(163)NO ECHO, NO OUTPUT ?? CLEAR FLAG
TTPECH	760000			/(163)ENTER LINK 0!
	TAD	TTWD06,X	/(163)CHECK REPEAT COUNT
	SNL			/(163)LINK 1 IF MORE TO DO
	JMP	TTPSWT		/(163)THIS REPEAT DONE, CHECK OTHER WORK
TTPECJ	XCT	TT.PRT,X	/(163)PUT OUT CHAR
	SWHA			/(163)CHAR TO (DEFAULT) BE CONVERTED TO NULL
	SMA!SWHA		/(163)SKIP IF NOT
	AND	(777000		/(163)ZAP THE CHAR
	DAC	TTWD06,X	/(163)REPLACE CONTROL WORD
	JMP	TTPIGN		/(163)ALL DONE

/
TTPSWT	760000			/(163)LINK STILL 0
	TAD	TTWD11,X	/(163)CHECK BACK UP ECHOER
	DZM	TTWD11,X	/(163)CLEAR IN ANY CASE
	SZL			/(163)SKIP IF NOTHING THERE
	JMP	TTPECJ		/(163)JOIN UP, REPLACE IN TTWD06!
	LAC	TTWD00,X	/(163)ECHOING DONE, NEED TO START OUTPUT?
	SMA!IAC			/(163)SKIP IF OUTPUT, SAY ECHO DONE
	JMP	TTPCOO		/(163)NOTHING, JUST COOL IT
	DAC	TTWD00,X	/(163)RESTART OUTPUT
	JMP	TTPJOI		/(163)LINK 0!

/

TTPCOO	DAC	TTWD00,X
	JMP	TTPCLR		/(163)CLEAR FLAG

/

/

/
TTPSPC	SZA			/(163)SKIP IF NULL
	SAD	(177		/(163)IS IT A RUBOUT
	JMP	TTPRBO		/(163)PRINT AND CONTINUE
/
TTPSP2	DAC	TTITMP		/(163)SAVE 7(8) BIT CHAR
	LAC	TTINUM		/(163)REESTABLISH XR FOR INDEX

	PAX

	LAC	TTK.EV,X
	AND	(777		/(163)IS OUR SIDE FREE?
	SZA			/(163)SKIP IF OK
	JMP	TTPCLR		/(163)NO, JUST IGNORE ?!?!
	777000			/(163)SEND CHAR BACK DOWN

	AND	TTK.EV,X
	TAD	(400		/(206) INTERRUPT OUTPUT BIT
	TAD	TTITMP		/(163)DATA PART OF CHAR
	DAC	TTK.EV,X	/(163)TELL DOWNSTAIRS HE HAS WORK TO DO
TTPSET	LAC	TTTGEV		/(163)SET EVENT VARIABLE
	SZA!CLL!RTL		/(167)ROTATE TO SET BIT
	AAC	2		/(167)SET EVENTUAL LINK; DON'T .SET6
	CLL!CML
	RTR
	DAC	TTTGEV
	LAC	(401000		/(167) AC FOR SET 6
	SNL			/(167) SKIP IF EVENT VARIABLE ALREADY ACTIVE
	ISA
TTPCLR	XCT	TT.PCL,X	/(163)CLEAR FLAG
	JMP	TTPIGN		/(163)CLEAR OUT OF HERE

/

/ THIRD CHAR FETCH ACTION TO FALL INTO TTPART

/
TTUP3	LAC	(JMP TTUP4	/(163)SET UP TO DISPATCH TO 4 NEXT

	DAC	TTWD10,X
	LAC	TTWD03,X	/(163)WORD FETCH POINTER
	IDX	TTWD03,X	/(163)BUMP ONE FOR NEXT TIME
	PAX			/(163)FETCH INDEXED FROM PAIR
	LAC	(700000		/(163)MASK FOR LOW THREE BITS OF CHAR

	AND	1,X
	RAL			/(163)SO THEY SNUG UP TO TOP FOUR
	XOR	0,X		/(163)DOUBLE XOR MERGE
	AND	(777760		/(163)MASK CONTROLS WHICH PART OF WHICH WORD
	XOR	0,X		/(163)NOTE THAT 2 XOR'S CANCEL

	RTL			/SPIN CHARACTER INTO PLACE

	RAL
TTPART	AAC	-175		/(163)RETURN CHAR IN AC, LINK 0
	TAD	(135		/(163)CARRY INTO LINK ONLY IF CHAR 40-174
	AAC	40		/(163)CHAR RECONSTITUTED
	SNL!CML			/(163)SKIP ON REGULAR CHAR
	JMP	TTPSPC		/(163)SPECIAL CHAR, GO SEND BACK DOWN

	.IFDEF	PARITY
	DAC	TTITMP		/(163)MAKE EVEN PARITY

	RAL

	XOR	TTITMP

	AND	(252

	AAC	146

	AND	(210

	AAC	170

	AND	(200

	TAD	TTITMP

	.ENDC

	.IFUND	PARITY

TTPRBO=.

	.ENDC
TTPIOT	XX			/(163)PRINT CHAR. CLEAR FLAG

/
TTPIGN	LAC	TTIXR		/(163)RESTORE FOR EXIT

	PAX

	LAC	TTIAC

	DBR

	JMP*	TTYPI

/
	.IFDEF	PARITY
TTPRBO	SZA
	AAC	200		/(163)EVEN PARITY RUBOUT

	JMP	TTPIOT

	.ENDC

/

/

/ ACTION TO FETCH CHAR'S , ASCII

/  CALL WITH THE LINK 0

/
TTUP1	LAC	(JMP TTUP2	/(163)SET FOR NEXT TIME
	DAC	TTWD10,X	/(163)JUMP SERVES AS SPECIAL FLAG
	LAC	TTWD03,X	/(163)POINTER TO DATA

	PAX
	774000			/(163)MASK FOR 1ST CHAR OF 5

	AND	0,X

	SWHA

	RTR		/CHAR IN PLACE

	JMP	TTPART

/

TTUP2	LAC	(JMP TTUP3

	DAC	TTWD10,X

	LAC	TTWD03,X

	PAX

	LAC	(3760

	AND	0,X

	RTR

	RTR

	JMP	TTPART

/

TTUP4	LAC	(JMP TTUP5

	DAC	TTWD10,X

	LAC	TTWD03,X

	PAX

	LAC	(77400

	AND	0,X

	RAL

	SWHA

	JMP	TTPART

/

TTUP5	LAC	(JMP TTUP1

	DAC	TTWD10,X

	LAC	TTWD03,X
	IDX	TTWD03,X
	PAX
	LAC	(376
	AND	0,X

	RAR

	JMP	TTPART

/

/  IMAGE ONLY ONE ACTION

/
TTUPI	LAC	TTWD03,X
	IDX	TTWD03,X
	PAX
	LAC	(177
	AND	0,X
	JMP	TTPART
/
/
/
	.IFUND L.ALL						/EAG:202
	.NOLST							/EAG:202
	.ENDC							/EAG:202
	.IFDEF L.MCR						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
 .TITLE *** MONITOR CONSOLE (MCR) DISPATCH ROUTINE

/

/ THE MCR DISPATCH ROUTINE IS A CORE RESIDENT TASK CALLED "...MCR",

/ WHICH IS REQUESTED BY THE TTY HANDLER WHENEVER A ^C IS TYPED ON

/ THE MCR INPUT TTY (AND THE ^C REQUEST INHIBIT FLAG IS NOT SET).

/ THE RESIDENT MCR ACCEPTS A LINE OF COMMAND INPUT ON THE MCR TTY

/ AND REQUESTS AN "MCR TASK" TO PERFORM THE INDICATED FUNCTION. 

/ AN "MCR TASK" IS A NORMAL RSX TASK, EXCEPT THAT IT USUALLY

/ RUNS IN A CORE PARTITION THAT IS DEDICATED TO MCR FUNCTIONS,

/ AND HAS A NAME CONSISTING OF THREE DOTS (PERIODS) FOLLOWED

/ BY THE FIRST THREE CHARACTERS OF THE FUNCTION NAME.

/

/ NOTE -- ANY TASK WHOSE NAME CONSISTS OF SIX CHARACTERS OF WHICH

/ THE FIRST THREE ARE DOTS (PERIODS) MAY BE REQUESTED BY TYPING

/ THE LAST THREE CHARACTERS OF THE TASK NAME TO THE RESIDENT MCR.

/ HOWEVER, THE RESIDENT MCR SETS THE ^C REQUEST INHIBIT FLAG AND

/ EXPECTS THE REQUESTED ROUTINE TO CLEAR THIS FLAG AT AN APPROPRIATE

/ TIME.

/

/ AS A CONVENTION, IF THE FIRST LINE OF COMMAND INPUT IS TERMINATED

/ BY A CAR RTN, THE MCR FUNCTION TASKS REQUEST THE RESIDENT MCR

/ "...MCR" UPON COMPLETION.  IF THE FIRST LINE OF COMMAND INPUT IS

/ ALTMODE TERMINATED, ^C MUST BE TYPED IN TO CUE THE RESIDENT MCR.

/

/ THE 'IFAC' & 'FAC' SUBROUTINE ENTRIES, AND THE ^C REQUEST INHIBIT

/ FLAG 'MCRRI' ARE IN SCOM (SO THAT THEY MAY BE ACCESSED FROM MCR

/ FUNCTION TASKS.

/

/ THE RESIDENT MCR USES THE FIRST THREE CHARACTERS OF COMMAND INPUT

/ TO FORM A TASK (MCR FUNCTION OVERLAY) NAME AND FLUSHES REMAINING

/ CHARACTERS THRU THE FIRST BREAK CHAR (BLANK OR COMMA).  FOR

/ EXAMPLE, THE DIRECTIVE "SCHEDULE JOE 22:30:00 90M" WILL RESULT

/ IN A REQUEST FOR THE TASK "...SCH" AND THE NEXT CHARACTER RETURNED

/ BY THE "FAC" SUBROUTINE WILL BE THE "J" OF "JOE".

/

/ SPECIAL CASE -- IF AN INPUT LINE STARTS WITH "LOG", IT IS CONSIDERED

/ TO BE A COMMENT ON THE MCR LOG.  (THEREFORE AN MCR FUNCTION TASK CALLED

/ "...LOG" IS INVALID.)

/

/ SINCE 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 BLOCKS DESCRIPTIONS LIST", NOR IS THE "FLAGS

/ WORD" EVER CHECKED OR ALTERED. HOWEVER, SINCE THIS TASK EXITS AND IS

/ REQUESTED, THE TASK SIZE, VIRTUAL PARTITION SIZE AND BUFFERS POINTER

/ WORDS ARE ALTERED.

/

MCRENT	CAL	MCRA2	/ATTACH LUN 2

/

	CAL	MCRP2	/WRITE  "MCR>" PROMPTING SYMBOL ON LUN 2

/

/

	.IFPNZ MCRTMO						/(162)

	JMS IFACTO	/ ISSUE A TIMED READ.			/(162)

	.ENDC							/(162)

	.IFZER MCRTMO						/(162)

	JMS* (IFAC)	/ READ A LINE AND WAIT FOR COMPLETION.	/(162)

	.ENDC							/(162)

/

	CAL	MCRD2	/DETACH LUN 2

/

	JMS* (FAC)	/ FETCH FIRST CHARACTER			/(162)

	SAD	(175)	/EXIT MCR IF ALTMODE ONLY

	JMP	MCROUT

	SAD	(15)	/READ ANOTHER LINE IF CR ONLY.

	JMP	MCRENT

	DAC	MCRCB1	/PACK FIRST THREE CHARACTERS (.SIXBT) INTO MQ

	JMS* (FAC)	/ FETCH SECOND CHARACTER		/(162)

	DAC	MCRCB2

	JMS* (FAC)	/ FETCH THIRD CHARACTER.		/(162)

	LRS	6

	LAC	MCRCB2

	LRS	6

	LAC	MCRCB1

	LRS	6

	LACQ		/ARE FIRST THREE CHARACTERS "LOG" ?

	SAD	(141707)

	JMP	MCRLOG	/YES -- IGNORE LINE CONTENTS, CHECK TERMINATOR

	DAC	MCRFNM	/NO -- FORM NAME OF MCR FUNCTION TASK

MCRFBC	JMS* (FAC)	/ FLUSH REMAINDER OF MCR FUNCTION NAME	/(162)

	SAD	(040)	/(BREAK CHAR: BLANK, COMMA, CAR RTN, ALTMODE)

	JMP	MCRTRQ

	SAD	(054)

	JMP	MCRTRQ

	SAD	(015)

	JMP	MCRTRQ

	SAD	(175)

	JMP	MCRTRQ

	JMP	MCRFBC

/

MCRTRQ	CLA!IAC		/SET ^C INHIBIT FLAG TO +1 (IN CASE A ^C HAD

	DAC* (MCRRI)	/ BEEN TYPED DURINT THE PRIVIOUS 	/(162)

			/ FUNCTION TASK.			/(162)

			/AND THAT TASK REQUESTED THE RESIDENT MCR. THIS

			/IS NECESSARY FOR MCR FUNCTION TASKS THAT INTERPRET

			/A NEGATIVE ^C INHIBIT FLAG AS A PREMATURE TERMINATION

			/INDICATOR)

	CAL	MCRRPB	/REQUEST INDICATED MCR FUNCTION TASK

	LAC	MCREV	/WAS REQUEST ACCEPTED?

	SMA

	CAL	(10)	/YES -- EXIT RESIDENT MCR TASK

	CAL	MCRE3	/NO -- WRITE ERR MESSAGE ON LUN 3 & TRY AGAIN

	JMP	MCRENT

/

MCRLOG	LAC	IFACTI	/WAS LINE CAR RTN TERMINATED?

	SAD	(+2)

	JMP	MCRENT	/YES -- CONTINUE MCR DIALOGUE

			/NO -- TERMINATE MCR DIALOGUE

MCROUT	DZM* (MCRRI)	/ CLEAR MCR REQUEST INHIBIT		/(162)

	CAL	(10)	/FLAG AND EXIT

/

MCREV	0		/EVENT VARIABLE

MCRCB1	0

MCRCB2	0

/
/ CPB'S AND OUTPUT TEXT
/
MCRA2	2400		/ATTACH LUN 2

	0

	2

/

MCRD2	2500		/DETACH LUN 2

	0

	2

/

MCRP2	2700		/WRITE PROMPTING SYMBOL ON LUN 2

	0

	2

	2

	MES1

/

MCRE3	2700		/WRITE ERR MESSAGE ON LUN 3

	0

	3

	2

	MES3

/

MCRRPB	1		/REQUEST MCR FUNCTION TASK

	MCREV

	.SIXBT	"..."

MCRFNM	.SIXBT	"---"

	0

/

MCRWPB	20		/WAIT FOR EVENT VARIABLE

	MCREV

/
	TEXT 1,<MCR>>,<175>,L.MCR
	TEXT 2,,<15>,L.MCR
	TEXT 3,<MCR-BAD FUNCTION>,<15>,L.MCR
/

/ MCR ENTRY (NODE) IN SYSTEM TASK LIST

/

	.IFUND NOMAC						/(162)
MCR	SCF			/ FORWARD LINKAGE		/(162)

	.ENDC							/(162)

	.IFDEF NOMAC						/(162)

MCR	TDV			/ FORWARD LINKAGE		/(162)

	.ENDC							/(162)

	STKL		/BACKWARD LINKAGE

	.SIXBT	"..."	/TASK NAME (FIRST HALF)

	.SIXBT	"MCR"	/TASK NAME (SECOND HALF)

	040002		/FIXED IN CORE, DEFAULT PRIORITY OF TWO
	MCRIC-P.TP	/"PARTITION BLOCK" ADDRESS		/(171)

	0		/DISK PARAMETERS (ZEROS

	0		/INDICATE A CORE RESIDENT

	0		/TASK)

	MCRENT		/ENTRY POINT ADDRESS

	.IFPNZ	NDSZMT

	.REPT	NDSZMT

	0

	.ENDC

/

/ MCR "PARTITION BLOCK" (REGISTER SAVE USE ONLY)

/
MCRNNN=P.TP-4		/ FILL PARTITION BLOCK EXCEPT FOR LINKS	/(171)

	.REPT	MCRNNN

	0
MCRIC	SHPB L.MCR						/EAG:202

/

/ IFAC -- SUBROUTINE TO READ A LINE OF COMMAND INPUT AND INITIALIZE

/ THE FETCH-A-CHARACTER SUBROUTINE.  'IFACTI' IS LEFT INDICATING TYPE

/ OF LINE TERMINATION (1, ALTMODE; 2 CAR RTN).

/

/ SUBROUTINE ENTRY IS IN SCOM

/

	.IFPNZ MCRTMO						/(162)
IFACTO	XX		/ TIMED READ ENTRY.			/(162)
	LAC IFACTO	/ SET UP RETURN.			/(162)

	DAC* (IFAC)	/ IN SCOM.				/(162)

	JMS IFCCC	/ CALCULATE INITIAL BUFFER CHECKSUM	/(162)

	CAL IFACRL	/ READ A LINE.				/(162)

IFCT.0	LAC (-MCRTMO)	/ FETCH TIMEOUT INCREMENT.		/(162)

	DAC IFCTOI	/ SET UP TIMOUT LOOP.			/(162)

IFCT.1	CAL IFCMKT	/ SET UP A MARK TIME.			/(162)

	CAL IFCMKW	/ WAIT FOR MARK TIME TO EXPIRE.		/(162)

	LAC IFACEV	/ CHECK FOR COMPLETION OF READ.		/(162)

	SZA		/ DONE YET?				/(162)

	JMP IFCT.2	/ YES, GO PROCESS LINE.			/(162)

	ISZ IFCTOI	/ CONE WITH TIMEOUT INTERVAL YET?	/(162)

	JMP IFCT.1	/ NO, CONTINUE LOOP.			/(162)

	JMS IFCCC	/ CALCULATE CHECKSUM. IS READ IN PROG	/(162)

	SZL		/ RESS. LINK = 0 IF BUFFER IS THE SAME.	/(162)

	JMP IFCT.0	/ REINITIALIZE TIMEOUT.			/(162)

	CAL IFCCRQ	/ CANCEL READ REQUESTS FOR MCR.		/(162)

	CAL IFCMKW	/ WAIT FOR READ CANCEL TO COMPLETE.	/(162)
/			/(170) ABORT HAS RETURNED CARRIAGE
	CAL MCRD2	/  DETACH DEVICE (LUN 2)		/(162)

	JMP MCROUT	/ EXIT MCR.				/(162)

								/(162)

/ SUBROUTINE TO CALCULATE THE CHECKSUM FOR AN INPUT BUFFER AND	/(162)

/ SET THE LINK 0 OR 1 IF THE CHECKSUM IS THE SAME OR DIFFERENT	/(162)

								/(162)

IFCCC	XX		/ ENTRY POINT.				/(162)

.X=.&70000\777777+1	/ INDEXING CONSTANT.			/(162)

	LAC (FACLB+2+.X)/ FETCH INDEXING CONSTANT.		/(162)

	PAX		/ PUT IN XR.				/(162)

	AAC 34		/ CALCULATE LIMIT.			/(162)

	PAL		/ SET UP LIMIT.				/(162)

	CLA		/ CLEAR AC FOR CHECKSUM.		/(162)

IFCCC1	TAD 0,X		/ CALCULATE CHECKSUM.			/(162)

	AXS 1		/ DONE WITH LOOP?			/(162)

	JMP IFCCC1	/ NOT YET.				/(162)

	STL		/ SET THE LINK FOR DIFFERENCE.		/(162)

	SAD IFCBCS	/ IS IT THE SAME?			/(162)

	CML		/ YES, CLEAR LINK			/(162)

	DAC IFCBCS	/ SAVE NEW CHECKSUM FOR NEXT TIME.	/(162)

	JMP* IFCCC	/ RETURN TO CALLER.			/(162)

								/(162)

/ VARIABLES AND DIRECTIVES FOR TIMED READ HEADER TO FAC ROUTINE./(162)

								/(162)

IFCBCS	0		/ CHECKSUM STORAGE AREA.		/(162)

IFCTOI	0		/ TIME OUT INTERVAL.			/(162)

IFCEV	0		/ EVENT VARIABLE FOR MKT AND CRG.	/(162)

								/(162)

IFCMKT	13		/ MARK TIME.				/(162)

	IFCEV		/ EVENT VARIABLE.			/(162)

	17		/ 15 (10) TICKS.			/(162)

	1		/ TICKS.				/(162)

								/(162)

IFCMKW	20		/ WAIT					/(162)

	IFCEV		/ EVENT VARIABLE.			/(162)

								/(162)

IFCUNM	23		/ UNMARK				/(162)

	0		/ EVENT VARIABLE.			/(162)

	.SIXBT "...MCR"	/ TASK NAME.				/(162)

								/(162)
IFCCRQ	1700		/(170) SINGLE UNIT ABORT.
	IFCEV		/ EVENT VARIABLE.			/(162)

	2		/ LUN 2.				/(162)

	.ENDC							/(162)

IFACE	CAL	IFACRL	/READ LINE

	CAL	IFACWF

/

	.IFPNZ MCRTMO						/(162)

IFCT.2	CAL IFCUNM	/ KILL OUTSTANDING TIMER REQUEST.	/(162)

	.ENDC							/(162)

	LAC	IFACEV	/SET LINE TERMINATION INDICATOR

	DAC	IFACTI	/(EV IS RETURNED +1 FOR ALTMODE, OR +2 FOR CAR RTN)

	SAD	(2)	/RETURN CARRIAGE IF ALTMODE TERMINATED

	JMP	.+3

	CAL	IFACRC

	CAL	IFACWF	/(IN CASE OF ...SAV WHICH REQUIRES A QUIESCENT SYSTEM)

/

	LAC	(FACCB+5)

	DAC	FACCBX

	LAC	(FACLB+2)

	DAC	FACLBX

/

	LAC* (IFAC)	/ FETCH RETURN ADDRESS.			/(162)

	DAC .+2		/ SET UP FOR FOR JMP *.			/(162)

	JMP* .+1	/ RETURN TO CALLER.			/(162)

	XX		/ ADDRESS OF RETURN.			/(162)

/

IFACRL	2600		/READ LINE FROM LUN 2 CPB

	IFACEV

	2

	2

	FACLB

	36

/

IFACWF	20		/WAIT FOR 'IFACEV'

	IFACEV

/

IFACRC	2700		/RETURN CARRIAGE ON LUN 2

	IFACEV

	2

	2

	MES2

/

IFACEV	0		/EVENT VARIABLE

IFACTI	0		/LINE TERMINATION INDICATOR

/

/ FAC -- SUBROUTINE TO FETCH A CHARACTER FROM 5/7 ASCII LINE BUFFER 'FACLB'.

/ INDICIES 'FACLBX' AND 'FACCBX' MUST BE SET WHEN A NEW LINE IS READ.

/ CHARACTERS ARE NOT FETCHED BEYOND TERMINAL CHARACTERS

/

/ SUBROUTINE ENTRY IS IN SCOM AREA.

/

FACE	LAC*	FACCBX	/FETCH NEXT UNPACKED CHARACTER FROM 'FACCB'

	SMA		/WAS CHAR BUFFER (FACCB) EMPTY?

	JMP	FAC2	/NO -- TEST FOR TERMINAL CHAR

	LAC	(FACCB-1) /YES -- REFILL 'FACCB'

	DAC	FACCBX	

	LAC*	FACLBX	/(FIRST HALF OF WORD PAIR)

	ISZ	FACLBX

	LMQ

	CLA!CLL

	JMS	FACUPS	/(FIRST CHAR)

	JMS	FACUPS	/(SECOND CHAR)

	JMS	FACUPS	/(FIRST FOUR BITS OF THIRD CHAR)

	LAC*	FACLBX	/(SECOND HALF OF WORD PAIR)

	ISZ	FACLBX

	LRS	17	/(LAST THREE BITS OF THIRD CHAR)

	XOR*	FACCBX

	DAC*	FACCBX

	CLA

	JMS	FACUPS	/(FOURTH CHAR)

	JMS	FACUPS	/(FIFTH CHAR)

	LAC	(FACCB)	/RESET CHAR BUF INDEX

	DAC	FACCBX

	LAC*	FACCBX	/FETCH FIRST CHAR FROM CHAR BUF

/

FAC2	SAD	(015)	/IF TERMINAL CHARACTER, (CAR RTN OR ALTMODE)

	JMP FACEO	/ RETURN WITH CHAR IN AC BUT DO NOT	/(162)

	SAD	(175)	/AUGMENT CHAR BUF INDEX (REPEATED CALLS

	JMP FACEO	/ OF FAC WILL RETURN THE TERMINAL CHAR)	/(162)

/

	ISZ	FACCBX	/NON-TERMINAL CHARACTER -- AUGMENT CHARACTER

			/ BUFFER INDEX AND RETURN WITH CHAR IN	/(162)

			/ AC					/(162)

FACEO	DAC FACET	/ SAVE CHARACTER IN TEMPORARY LOCATION	/(162)

	LAC* (FAC)	/ FETCH RETURN ADDRESS FROM SCOM.	/(162)

	DAC .+3		/ SET UP FOR JMP*.			/(162)

	LAC FACET	/ FETCH CHARACTER.			/(162)

	JMP* .+1	/ RETURN TO CALLER.			/(162)

	XX		/ ADDRESS FOR RETURN.			/(162)

FACET	XX		/ CHARACTER TEMPORARY FOR RETURN TO CALL/(162)

/

FACUPS	0		/UNPACKING SUBROUTINE -- AC & LINK MUST BE

	LLS	7	/CLEARED, NEXT CHAR MUST BE IN HIGH ORDER

	ISZ	FACCBX	/MQ, 'FACCBX' MUST POINT TO WORD PRECEDING

	DAC*	FACCBX	/CHAR TO BE STORED.

	CLA		/CHAR IS SHIFTED INTO AC (LOW ORDER BITS

	JMP*	FACUPS	/OF THIRD CHAR ARE ZERO BECAUSE LINK IS

			/ZERO), STORED, 'FACCBX' IS LEFT POINTING

			/TO CHAR, AND AC IS CLEARED (LINK IS

			/ALSO LEFT CLEARED).
FACLBX	FACLB+2		/LINE BUFFER INDEX

FACCBX	FACCB+0		/CHARACTER BUFFER INDEX

FACCB	.BLOCK	5	/CHARACTER BUFFER (5 IMAGE ALPHA CHARS)

	-1		/END OF 'FACCB' INDICATOR

/

/ FACLB -- LINE BUFFER FOR THE 'FAC' SUBROUTINE ALSO CONTAINS

/ COLD START INITIALIZATION CODE.  WHEN A MASTER IMAGE IS LOADED

/ INTO CORE, R1 CONTAINS THIS ADDRESS.  THE RSX BOOTSTRAP TRANSFERS CONTROL

/ PER R1 AFTER LOADING AN IMAGE.

/
FACLB	DBA		/SET "INDEX MODE"

	CAF		/CLEAR ALL FLAGS

	LAC* (R2)	/ SETUP PI INTERRUPT TRANSFER WORD	/(162)

	DAC* (L1)						/(162)

	LAC* (R3)	/ SETUP CAL INTERRUPT TRANSFER WORD	/(162)

	DAC* (L21)						/(162)

	LAC* (R4)	/ SETUP CAL INDIRECT TRAP.		/(162)

	DAC* (L20)						/(162)

	ION		/ENABLE PI
	LAC	(400000)/ENABLE API

	ISA

	KRS		/SELECT FULL DUPLEX CONSOLE KEYBOARD

	JMP* (M6)	/ START ACTIVE TASK LIST SCAN FROM TOP	/(162)

/
	.BLOCK	36+FACLB-. /REMAINDER OF 36 (OCT) WORD BUFFER

/
	.ASCII	<015>	/TERMINATOR IN CASE OF TRUNCATED LONG LINE
								/EAG:202
								/EAG:202
	.IFUND L.ALL						/EAG:202
	.NOLST							/EAG:202
	.ENDC							/EAG:202
	.IFDEF L.ALL						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
/
	.LTORG
								/EAG:202
								/EAG:202
	.IFDEF L.LUN						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
 .TITLE *** LOGICAL UNIT TABLE

/

/ LOGICAL I/O UNITS ARE EQUIVALENCED TO PHYSICAL UNITS VIA THIS TABLE.

/ EACH LOGICAL UNIT IS REPRESENTED BY A ONE-WORD ENTRY IN THIS TABLE,

/ WITH THE FIRST WORD REPRESENTING LOGICAL UNIT NUMBER (LUN) ONE.

/ EACH PHYSICAL UNIT IS REPRESENTED BY A NODE IN THE PHYSICAL DEVICE

/ LIST (PDVL).

/

/ WHENEVER A LOGICAL UNIT NUMBER IS ASSIGNED TO A PHYSICAL UNIT, THE

/ CORESPONDING TABLE ENTRY IS SET TO THE ADDRESS OF THE PDVL NODE.

/

/ WHENEVER A LOGICAL UNIT NUMBER IS NOT ASSIGNED TO A PHYSICAL UNIT

/ (ASSIGNED TO 'NONE"), THE CORESPONDING TABLE ENTRY IS SET TO ZERO.

/

	.DEC

NLUM21=NLU-21		/INITIAL DEVICE ASSIGNMENTS:

	.OCT		/
LUT	DSK0		/LUN 1 -- DISK DRIVER

	TT00		/LUN 2 -- TTY 0

	TT00		/LUN 3 -- TTY 0

	TT00		/LUN 4 -- TTY 0

	0		/LUN 5 -- NONE

	0		/LUN 6 -- NONE

	0		/LUN 7 -- NONE

	0		/LUN 8 -- NONE

	0		/LUN 9 -- NONE

	0		/LUN 10 -- NONE

	0		/LUN 11 -- NONE

	TT00		/LUN 12 -- TTY 0
	TT00		/LUN 13 -- TTY 0

	TT00		/LUN 14 -- TTY 0

	0		/LUN 15 -- NONE

	TT00		/LUN 16 -- TTY 0

	0		/LUN 17 -- NONE

	0		/LUN 18 -- NONE

	0		/LUN 19 -- NONE
	TT00		/LUN 20 -- TTY 0
	TT00		/LUN 21 -- TTY 0
								/EAG:202
	.IFUND L.ALL						/EAG:202
	.NOLST							/EAG:202
	.ENDC							/EAG:202
								/EAG:202

	.REPT NLUM21	/ALL OTHERS -- NONE
	0
								/EAG:202
	.IFDEF L.LUN						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
								/EAG:202

/
	.TITLE *** LUN - UFD TABLE ***

/

/ THIS TABLE RELATES A UFD NAME WITH A DISK-LUN PAIR.

/ THE TABLE IS ACCESSED BY MNT, DSM, REA, AND THE DISK

/ FILES HANDLERS. IF A LUN IS NOT ASSOCIATED WITH A DISK

/ THIS TABLE HAS NO INFORMATION. HOWEVER, WHENEVER A LUN

/ IS ASSIGNED TO A DISK AND THE DISK IS MOUNTED, THEN THE
/ LUN UFD TABLE ENTRY GIVES THE FILES HANDLER THE UFD TO

/ BE USED FOR THAT LUN-DISK PAIR.
/
								/EAG:202
LUNUFD	0			/ NUMBER OF LUNS = NLU		/EAG:202
								/EAG:202
	.IFUND L.ALL						/EAG:202
	.NOLST							/EAG:202
	.ENDC							/EAG:202
								/EAG:202
NLUM1=NLU-1							/EAG:202
								/EAG:202
	.REPT NLUM1						/EAG:202
	0							/EAG:202
								/EAG:202
	.IFDEF L.LUN						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
/
 .TITLE *** ATTACH FLAG TABLE

/
/ THIS TABLE CONSISTS OF A ONE-WORD ENTRY FOR EACH LOGICAL UNIT,

/ AND IS USED TO INDICATE WHETHER A LUN IS ATTACHED OR UNATTACHED

/ TO A TASK.

/

/ WHENEVER A LUN IS ATTACHED TO A TASK, ITS ENTRY IS SET TO THE

/ TASK'S STL NODE ADDRESS.
/

/ WHENEVER A LUN IS NOT ATTACHED TO A TASK, ITS ENTRY IS SET

/ TO ZERO.
/
								/EAG:202
								/EAG:202
AFT	0							/EAG:202
								/EAG:202
	.IFUND L.ALL						/EAG:202
	.NOLST							/EAG:202
	.ENDC							/EAG:202
								/EAG:202
NLUM1=NLU-1							/EAG:202
								/EAG:202
	.REPT NLUM1						/EAG:202
	0							/EAG:202
								/EAG:202
	.IFDEF L.SCF						/EAG:202
	.LST							/EAG:202
	.ENDC							/EAG:202
								/EAG:202
TEXECU=.		/ TOP OF THE EXECUTIVE			/(177)
 .TITLE *** SYSTEM CONFIGURATION TASK
/

/

/

	.LOC 50020

/

SCFBEG=.		/BEGINNING OF SCF

/

/ THE SYSTEM CONFIGURATION ROUTINE IS AN ACTIVE TASK THAT IS

/ LOADED INTO CORE ONLY UPON A COLD START BOOTSTRAP. IT RUNS 

/ WITHOUT REGARD TO CORE PARTITIONS (THEY ARE NOT DEFINED

/ AT SYSTEM CONFIGURATION INITIATION) AND REMOVES ITSELF FROM

/ THE SYSTEM UPON COMPLETION OF SYSTEM CONFIGURATION.

/

/ XVM/RSX HAS DYNAMIC REPARTITIONING. THE SYSTEM CONFIGURATOR

/ MUST MERELY SET UP SOME DEFAULT SYSTEM TO GET RUNNING.  THE USER

/ CAN LATER CHANGE TO A SPECIFIC CORE LAYOUT OF HIS CHOICE.

/ THE DEFAULT SYSTEM LIST IS AT 'PARPNT'.  THE SAME HOLD TRUE

/ FOR DEVICES; THEIR DEFAULT LIST IS AT 'DEVPNT'.  IN ORDER TO ALLOW

/ DYNAMIC RECONFIGURATION, NODES MUST NOW BE OF TWO TYPES, SMALL

/ (SAME AL ALWAYS) AND LARGE (FOR PBDL).  THE POOL OF LARGE NODES

/ IS CALLED 'LPOOL'.  FUTHERMORE, NODES MUST BE CONSTRUCTED IN

/ PARTITIONS RATHER THAN IN ALL THE NOOKS AND CRANNIES TO ALLOW

/ FOR CHANGING THE CORE LAYOUT ON THE FLY.  WE WILL ASK THE SCF

/ TERMINAL OPERATOR TO DEFINE THE MINIMUM NUMBER OF SMALL AND LARGE

/ NODES NEEDED.

/

/ WARNING: NODES CAN ALWAYS BE ADDED LATER BUT NEVER DELETED!!

/

/ EACH PARTITION IN THE SYSTEM MUST HAVE A LARGE NODE FOR THE PBDL.

/ LARGE NODES FIT 5 PER 400 OCTAL WORD BLOCK OF A LARGE NODE PAR-

/ TITION IF THE SYSTEM HAS FLOATING POINT HARDWARE (6/400 WORD BLOCK

/ IF FLOATING POINT IS NOT ON THE SYSTEM).  SMALL NODES FIT 25 PER

/ 400 OCTAL WORD BLOCK OF A SMALL NODE PARTITION.

/

/

/ AFTER THE POOL AND PARTITION BLOCKS HAVE BEEN CONSTRUCTED, ALL 

/ TASKS RECORDED ON SYS. DSK THAT CAN BE INSTALLED INTO THE NEWLY

/ CONFIGURED SYSTEM, ARE INSTALLED.  NORMALLY THE MCR & I/O 

/ HANDLER TASKS ARE INITIALLY INSTALLED AT THIS TIME.  AT LEAST

/ "INSTALL", "REASSIGN", AND AN I/O HANDLER MUST BE INSTALLED

/ DURING SYSTEM CONFIGURATION FOR SYSTEM DEVELOPMENT TO CONTINUE.

/

/ AFTER INSTALLATION FROM SYS. DSK, THE NUMBER OF EMPTY NODES IN THE

/ POOL IS TYPED OUT, AND THE SYSTEM IS LEFT RUNNING.

/

/

	.EJECT

/
SCONF	SKP		/MUST START HERE, BUT WANT SCF000 EASILY ACCESSIBLE
SCF000	TTYS		/SO USER CAN PATCH IT, OR KEY IN NEW VALUE
	JMS	CRTN
	JMS	CRTN
	JMS	CRTN
	JMS*	(TYPE)
	MES500
	JMS*	(TYPE
	MES577
	JMS*	(TYPE
	MES578
/
/INITIALIZE VALUES
/
	CLA!IAC			/(163)DELAY LOOP, NEW TTY OVERLAPS
/				/(163)LAST CHAR, ALLOW FOR PRINTING
/				/(163)BEFORE COMING TESTS KILL IT
	SZA!IAC
	JMP	.-1		/(163)ABOUT 1/2 SEC
	LAC	PARPNS
	DAC	PARPNT	/POINTER TO PARTITION LIST
	LAC	DEVPNS
	DAC	DEVPNT	/POINTER TO DEVICE LIST
	LAC (TEXECU+377&777400) / CALCULATE THE TOP OF THE	/(177)
			/ EXECUTIVE ROUNDED UP TO A 400 (8)	/(177)
			/ WORD BOUNDARY.			/(177)
	DAC*	(XSIZE	/SAVE THIS VALUE
	DAC	SCFCOR	/DEFAULT VALUE TOP OF EXEC
	CLX
	LAC	(21
	PAL
	DZM	SCFSYF,X /ZERO ALL DISK DEVICES
	AXS	1
	JMP	.-2
/
/ TEST FOR THE "RE-ENTRANT ECO PACKAGE" -- I.E., CHECK THE '.INH'
/ AND '.ENB' INSTRUCTIONS AND THE INTERRUPT-FREE PERIOD FOLLOWING
/ A 'JMS' INSTRUCTION
/
	.INH		/INHIBIT INTERRUPTS IF ECO EXISTS
	LAC	(402000)/TRIGGER AN API-5 INTERRUPT
	ISA
	NOP
/
/ IF NOT INHIBITED, CONTROL WILL BE TRANSFERRED TO 'SCF1' AT THIS POINT.
/
	NOP		/(IN CASE OF SLOW API)
	NOP
	LAC	(SCF2)	/LOAD AC WITH NEW API-5 TRANSFER VECTOR
	.ENB		/ENABLE INTERRUPTS (INTERRUPT FREE INST AFTER IOT)
	JMS	.+1
	0
/
/ IF NO FREE PERIOD AFTER 'JMS', CONTROL WILL BE TRANSFERRED TO 'SCF1'
/
	DAC*	(ITVTB+1)/SET NEW API-5 TRANSFER VECTOR

/

/ INTERRUPT SHOULD OCCUR AT THIS TIME, RESULTING IN A TRANSFER TO 'SCF2'

/

	JMP	.

/

SCF1	DBK		/RE-ENTRANT ECO PKG NOT PRESENT, DEBREAK FROM API-5,

	JMS*	(TYPE)	/TYPE ERR MESSAGE, AND ABORT SYSTEM CONFIGURATION.

	MES598

	HLT

	JMP	.-1

/

SCF2	DBK		/RE-ENTRANT ECO PKG EXISTS, DEBREAK FROM API-5,

	LAC	(DBK)	/SET A DEBREAK INSTRUCTION IN THE API-5 TRAP

	DAC*	(L41)	/LOCATION, AND CLEAR TRANSFER VECTOR.

	DZM*	(ITVTB+1)

/

	FPT		/DOES FLOATING POINT HARDWARE EXIST?

	JMP	.+3	/NO -- LEAVE SWITCH RESET (NOP)

	LAC	(SKP)	/YES -- SET SWITCH (SKP)

	DAC*	(FPHDWE)

/

/ TEST FOR THE EXISTENCE OF THE KM15 AND KT15 HARDWARE.

/

	IOF		/PREVENT INTERRUPTS

	CAF

	LAC*	(21)	/SAVE "JMP CALDSP" INSTRUCTION.

	DAC	SCFTMP

	DZM*	(R2)	/CLEAR "PROTECT BUT NO RELOCATE" FLAG.

	LAC	(620101)/JMP* R1

	DAC*	(21)	/SET UP LOCATION 21 TO RETURN TO SCF.

	LAC	(SCFPRC)

	DAC*	(R1)

	MPEU		/ENTER USER MODE.

	NOP		/WAIT FOR USER MODE (NOT SURE THIS IS NEEDED).

	LAS		/VIOLATE PROTECTION.

SCFTPA	JMP	SCNOPR	/NO PROTECTION FOUND.

SCFPRC	LAC*	(20)	/RELOCATE?

	AND	(77777)

	SAD	(SCFTPA)

	JMP	SCNORL	/NO, JUST PROTECT.

	LAC	(SKP)	/CHANGE NOP INTO SKP TO INDICATE THAT THIS

	DAC*	(PRHDWE)/MACHINE HAS PROTECT/RELOCATE.

	SKP

SCNORL	IDX*	(R2)	/INDICATE PROTECT BUT NO RELOCATE.

SCNOPR	LAC	SCFTMP

	DAC*	(21)	/RESTORE LOCATION 21.

	CAF		/CLEAR PROTECT FLAGS AND API.

	ION		/TURN PIC BACK ON.

	LAC	(400001)/TURN API BACK ON AND RAISE TO TASK LEVEL (API-7)

	ISA

	LAC*	(R2)	/PROTECT BUT NO RELOCATE?

	SNA

	JMP	SCF4	/NO.

	JMS	CRTN

	JMS*	(TYPE)	/TYPE "*** IF YOU HAVE KT15 (MEMORY RELOCATE) THE

	MES498

	JMS*	(TYPE)	/      *** PROTECT/RELOCATE SWITCH IS SET WRONG

	MES499

/

SCF4	LAC	(PBSZ)	/ESTABLISH PARTITION BLOCK SIZE 'SCFPBZ'

	XCT*	(FPHDWE)

	AAC	-PBFP

	DAC	SCFPBZ

	KRS		/SELECT TT0 FOR FULL DUPLEX MODE

/

/ACCEPT CLOCK FREQUENCY

/

SCF10	JMS	CRTN	/REQUEST CLOCK TICKS PER SECOND

	JMS*	(TYPE

	MES504

SCF41	JMS	SCIFAC

	JMS	FACSV	/GET NEXT CHAR

	JMS	TCX	/CR OR ALTM?

	JMP	SCF41A	/YES -- USE DEFAULT

	JMS	ADECKI	/ASSEMBLE DECIAML CONSTANT

	JMS	TCX	/CR OR ALTM. TERMINATOR?

	SKP		/YES

	JMP	SCF48	/NO -- ERROR

	PLA		/IS VALUE BETWEEN 1CPS AND 1KC?

	JMS	COMP

	.DEC

	(1

	(1000

	.OCT

	JMP	SCF49	/NO -- ERROR

SCF41B	DAC*	(TPS	/YES -- STORE THE DATA AWAY

	DAC*	(TPX1

	DAC*	(TPX2

	DAC*	(TPX3

	DAC*	(NTSCSE

	TCA

	DAC*	(CTPS

	LAW	-1	/TURN ON THE CLOCK

	DAC*	(7

	CLON

	JMP	SCF50

/

SCF41A	LAC	(D60	/PUT DEFAULT CLOCK TICKS INTO AC (60 DECIMAL)

	JMP	SCF41B	/CONTINUE

/

SCF48	JMS	SCERR	/TYPE SYNTAX ERROR AND RETRY

	JMP	SCF41

/

SCF49	JMS*	(TYPE	/TYPE INVALID NUMBER ERROR

	MES593		/MESSAGE AND RETRY

	JMP	SCF41

/

/ ACCEPT SIZE OF CORE

/

SCF50	JMS	CRTN	/REQUEST CORE SIZE

	JMS*	(TYPE)

	MES501

SCF11	JMS	SCIFAC

	JMS	FACSV

	JMS	TCX	/EMPTY LINE

	JMP	SCF13	/YES, DEFAULT TO 32K

/

	JMS	ADECKI	/ASSEMBLE DECIMAL CONSTANT

	SAD	(113)	/"K" TERMINATED?

	SKP

	JMP	SCF18	/NO -- SYNTAX ERR

	JMS	FACSV	/YES -- END OF INPUT LINE?

	JMS	TCX

	SKP

	JMP	SCF18	/NO -- SYNTAX ERR

	PLA		/YES -- IS NUMBER BETWEEN 24 & 128?

	JMS	COMP

	.DEC

	(24

	(128)

	.OCT

	JMP	SCF19	/NO -- INVALID SIZE

SCF12	DAC	SCFT3	/YES, IS IT A MULTIPLE OF 4

	AND	(777774)

	SAD	SCFT3

	SKP

	JMP	SCF19	/NO -- INVALID SIZE

	CLQ		/YES -- SET 'CSIZE' IN SCOM

	LLS	12	/(ALSO SETUP DUMMY NODE IN DEQUE

	DAC	SCFT4	/HOLD LIMIT+1

	AAC	-1	/TO SORT ALLOCATED BLOCKS OF CORE.)

	DAC*	(CSIZE)

/

/

/ ADJUST SIZE OF TDV PARTITION IF CORE SIZE IS 24K OR 28K

/

/

	LAC	(710000	/CONSTANTS OF -28K

	TAD	SCFT4	/ADD IN TOTAL CORE

	SMA!SZA		/SKIP IF LESS THAN 32K

	JMP	SCF17	/32K, LEAVE AS IS

	SZA		/CORE SIZE IS 28K?

	LAC	(-10000	/NO -- 24K

	TAD	(30000	/YES

	DAC	SCFPST

/

/

/  NOW ADJUST HOW MANY PARTITIONS >32K

/

SCF17	LAW	-1

	TAD	SCFT3

	CLL!RAR

	RTR

	AND	(14

	PAX

	LAW	-1

	DAC	SCFEND,X

	LAC	SCFEND-2,X

	CMA!IAC

	TAD	SCFT4

	DAC	SCFEND-1,X

	JMP	SCF192

/

SCF13	LAC	(40	/DEFAULT 32K

	JMP	SCF12	/REJOIN EVERYONE ELSE

/

/

SCF18	JMS	SCERR	/TYPE SYNTAX ERR MESS & RETRY

	JMP	SCF11

SCF19	JMS*	(TYPE)	/TYPE SIZE ERR MESS & RETRY

	MES592

	JMP	SCF11

/

/

/  ASK USER FOR SIZE OF MCR PARTITION

/

/  DEFAULT 3000(8), MAXIMUM 3000(8), MINIMUM 0 (I.E. NONE)

/

SCF192	JMS	CRTN

	JMS*	(TYPE

	MES536

SCF193	JMS	SCIFAC

	JMS	FACSV

	JMS	TCX	/EMTPY LINE?

	JMP	SCF20	/YES, DEFAULT, DO NOTHING

	JMS	AOCTKI	/MAKE OCTAL CONTANT IN LIMIT REG.

	JMS	TCX	/SHOULD BE NO ADDNT'L CHAR'S

	SKP		/SKIP OK

	JMP	SCF198	/SYNTAX ERROR

	PLA		/GET BACK NUMBER FOR LIMIT CHECK

	JMS	COMP

	(0

	(3000

	JMP	SCF199	/OUT OF RANGE

	SAD	(3000	/MAXIMUM? (ALSO DEFAULT)

	JMP	SCF20	/IS DEFAULT, DO NOTHING

	DAC	SCFT4	/SAVE WHILE DO DIVISIBLE BY 400 CHECK

	AND	(777400	/DIVISIBLE BY 400 IF SAME BEFORE+ AFTER

	SAD	SCFT4

	SKP		/SAME, OK

	JMP	SCF199	/SIZE ERROR

	DAC	SCFPSM	/PLACE IN SIZE OF MCR PARTITION

	TCA		/SUBTRACT THIS FROM 3000

	TAD	(3000	/TO GET SIZE OF MISC1

	SNA		/IS RESULT>0?

	JMP	SCF20	/NO -- PROCEED

	DAC	SCFPSB	/YES -- SAVE THE SIZE  OF MISC1

	LAC	(30000	/GET BASE OF MISC1

	TAD	SCFPSM	/ADD BASE OF MCR PLUS SIZE OF MCR

	DAC	SCFPBB	/TO GET BASE OF MISC1

	JMP	SCF20	/GO FIND OUT ABOUT SYSTEM DISK

SCF198	JMS	SCERR	/SYNTAX ERROR + RETRY

	JMP	SCF193

SCF199	JMS*	(TYPE	/SIZE ERROR

	MES592

	JMP	SCF193	/RETRY

/

/  

/

/

/  IN THIS SECTION OBTAIN SYSTEM DISK, AND AMOUNT OF EACH

/  OF THE THREE TYPES OF DISK.

/

SCF20	JMS	CRTN

	JMS*	(TYPE

	MES532

SCF201	JMS	SCIFAC

	JMS	FACSV

	JMS	TCX	/MT LINE

	JMP	SCF203	/YES, DEFAULT TO RF, GO TO ITS SETUP

	SAD	(122	/'R'?

	SKP		/YES

	JMP	SCF202	/NO, SYTAX

	JMS	FACSV	/GET NEXT

	SAD	(106	/'F'?

SCF203	JMP	SCF20F	/GO SET UP RF

	SAD	(120	/'P'?

	JMP	SCF20P	/GO SET UP RP

	SAD	(113	/'K'?

	JMP	SCF20K	/GO SET UP RK

	JMP	SCF202	/ILLEGAL SYNTAX

/

SCF20F	LAC	(106	/INCASE DEFAULT HERE, NOT ON FINDING 'F'

	JMS	SCFION	/MAKE PARTITION NAME FOR SYSTEM DISK

	AAC	2	/MAKE A 2;SCFION MADE AC=0

	DAC*	(SYSDSK	/RSX SYSTEM DISK TYPE

	LAW	-1

	DAC	SCFDSK	/SET UP OUR! SYSDISK INDICATOR

	LAC	(25000	/RF HANDLER ONLY TAKES 3000

	DAC	SCFPB0	/SO START IT AT 25000

	LAC	(3000	/ALSO REDUCE SIZE OF 'RFDISK'

	DAC	SCFPS0

	JMP	SCF204	/REJOIN LOOP TO GET # OF EACH DISK TYPE

/

/

SCF20P	JMS	SCFION	/MAKE SYSTEM DISK PARTITION NAME

	AAC	3	/MAKE SYSTEM DISK TYPE; AC=0

	DAC*	(SYSDSK

	DZM	SCFDSK	/OUR WHICH DISK CODE FOR RP

	JMP	SCF204	/REJOOIN

/

/

SCF20K	JMS	SCFION	/MAKE SYSTEM DISK PARTITION NAME

	AAC	24	/RSX SYSTEM DISK INDICATOR;AC=0

	DAC*	(SYSDSK

	CLA!IAC

	DAC	SCFDSK

	JMP	SCF204

/

/  ROUTINE TO MAKE NAME R?DISK FOR SYSTEM DISK PARTITION

/  CALL WITH ASCII CHAR IN AC TO REPLACE THE ?

/

SCFION	0

	LLS	6

	AND	(7700

	TAD	(220004	/'R@D'

	DAC	SCFPN0

	CLA		/FOR CALLER'S CONVENIENCE

	JMP*	SCFION

/

/

/  ROUTINE TO FIND BLOCK OF 'RSX' UFD ON SYSTEM DISK

/

SCF20C	LAC	SCFDSK	/OUR DISK TYPE

	SNA!CLA		/SKIP UNLESS RP DISK.CLEAR AC FOR TAD'S

	TAD	(45041	/47040-1777;MAKE RP BLOCK # 47040

	TAD	(1777	/1777 IS BLOCK # FOR RF AND RK

SCF20D	JMS	CONV	/CONVERT BLOCK # TO ADDR. FOR CAL

	CAL	DOTGET	/BRING IN MFD BLOCK

	JMS	.WFDP	/WAIT FOR COMPLETION

	LAC	(DBUF	/STARTING ADDR OF BUFFER

	JMS	SETXR	/CORRECTED XR FOR SCAN OF MFD FOR 'RSX'

	AAC	374	/LOOP CONTROL

	PAL		/

SCF20E	LAC	0,X	/FOUR WORD UFD ENTRIES; NAME FIRST

	SAD	(222330	/COMPARE TO 'RSX' IN SIXBIT

	JMP	SCF20G	/YES, GOT IT!

	AXS	4	/NOPE, GO TRY NEXT ONE

	JMP	SCF20E

	LAC	3,X	/RAN OUT OF BLOCK, IS THERE ANOTHER ONE?

	SAD	(-1	/IF -1, NO MORE

	JMP	SCF20X	/NO MORE, NO 'RSX', ERROR EXIT

	JMP	SCF20D	/GO BRING IN NEW BLOCK AND KEEP GOING

/

SCF20G	LAC	1,X	/GET UFD BLOCK

	DAC	SCFUFD	/AND SAVE

	LAC*	(SYSDSK	/WHAT IS THE SYSTEM DISK?

	SAD	(3	/RP?

	JMP	SCF20N	/YES

	SAD	(2	/NO -- RF?

	JMP	SCF20M	/YES

	LAC	(10	/NO -- RK (GET OFFSET OF DISK-UFD TABLE)

	SKP

SCF20N	CLA		/RP -- GET OFFSET OF DISK-UFD TABLE

	SKP

SCF20M	LAC	(20	/RF -- GET OFFSET OF DISK-UFD TABLE

	TAD*	(DUFD1	/ADD START OF DISK-UFD TABLE

	JMS	SETXR	/PREPARE XR TO ACCESS TABLE ENTRY FOR SYSTEM DISK

	LAC	(222330	/GET 'RSX" IN SIXBT (NAME OF DEFAULT UFD FOR SYSDSK

	DAC	0,X	/ENTER DEFAULT UFD NAME OF SYSTEM DISK

	JMP	SCF23	/GO GET LARGE NODE INFO

/

SCF20X	JMS*	(TYPE	/ERROR EXIT

	MES915		/NO 'RSX' UFD

	HLT

	JMP	.-1	/DISCOURAGE THE ETERNAL OPTIMISTS!

/

SCF202	JMS	SCERR	/SYNTAX MESSAGE

	JMP	SCF201	/RETRY

/

/  FIND OUT HOW MANY RF PLATTERS

/

/

SCF204	JMS	CRTN

	JMS*	(TYPE

	MES533

SCF205	JMS	SCIFAC

	JMS	ADECK	/DECIMAL CONSTANT

	JMS	TCX	/SHOULD BE NO ADDITIONAL CHAR'S

	SKP

	JMP	SCF208	/WERE, SYNTAX

	PLA

	JMS	COMP	/RANGE OF RF 0-8

	(0

	(10

	JMP	SCF209	/OUT OF RANGE MESSAGE

	AAC	-1	/STORE - IF NONE, MAX UNIT IF SOME

	DAC*	(DSIZE

	SMA

	JMP	SCF206	/GO MAKE DEVICE NAME FOR RF

	SAD	SCFDSK	/IF NONE, AND SYSTEM, ERROR

	JMP	SCF208	/ERROR

	DZM	SCFSYF	/NO RF, CLEAR OUT OF OUR DEVICES TABLE

	JMP	SCF214	/CHECK OUT RP

SCF206	LAC	(220600	/'RF@' CONVERTED TO 'RF' UNIT 0

	DAC	SCFSYF	/SLOT FOR 'RF' DEVICE NAME

	JMP	SCF214

/

SCF208	JMS	SCERR

	JMP	SCF205

/

SCF209	JMS*	(TYPE

	MES592		/SIZE ERROR

	JMP	SCF205

/

/

SCF214	JMS	CRTN

	JMS*	(TYPE

	MES534

SCF215	JMS	SCIFAC

	JMS	ADECK

	JMS	TCX

	SKP

	JMP	SCF218

	PLA

	JMS	COMP

	(0

	(10

	JMP	SCF219

	AAC	-1

	DAC*	(RPDISK

	SMA!CLA		/SKIP IF NO RP'S SPECIFIED

	JMP	.+4	/SOME WERE, HOP OVER NEXT TEST

	SAD	SCFDSK	/IS RP SYSTEM DISK

	JMP	SCF218	/YES, AND 0 UNITS SPECIFIED, COMPLAIN

	JMP	SCF224	/NO, NO FURTHER WORK TO DO

	CLX		/SET UP LOOP TO MAKE REQUIRED DEVICE NAMES

	LAC	(222000	/'RP@'  , CONVERTED TO 'RP' AND UNIT 0

	DAC	SCFSYP,X /SLOT FOR RP UNITS

	IAC		/MOVE TO DEVICE 1

	AXS	1	/LIMIT ALREADY HAS NUMBER OF UNITS FOR CONTROL

	JMP	.-3

	JMP	SCF224

/

SCF218	JMS	SCERR

	JMP	SCF215

SCF219	JMS*	(TYPE

	MES592

	JMP	SCF215

/

/  HOW MANY RK'S

/

SCF224	JMS	CRTN

	JMS*	(TYPE

	MES535

SCF225	JMS	SCIFAC

	JMS	ADECK

	JMS	TCX	/LEFTOVERS?

	SKP

	JMP	SCF228	/YES, TROUBLE

	PLA		/LIMIT HAS ASSEMBLED # FROM ADECK

	JMS	COMP	/LEGAL # OF RK PLATTERS?

	(0

	(10

	JMP	SCF229	/WRONG NUMBER

	AAC	-1	/STORE -1 IF NONE, HIGHEST UNIT# IF SOME

	DAC*	(RKDISK

	SMA!CLA!IAC	/SKIP IF NONE SPECIFIED

	JMP	.+4	/SOME WERE SPECIFIED, WE HAVE NO PROBLEM

	SAD	SCFDSK	/IS THIS SYTEM DEVICE

	JMP	SCF228	/THIS IS SYSTEM, AND NO PLATTERS, COMPLAIN!

	JMP	SCF20C	/GO COMPLETE WORK FOR DISKS

	CLX

	LAC	(221300	/SAME GAME, MAKE DEVICE CODES

	DAC	SCFSYK,X

	IAC

	AXS	1

	JMP	.-3

	JMP	SCF20C	/GO COMPLETE DISK WORK

/

/

SCF228	JMS	SCERR

	JMP	SCF225

/

SCF229	JMS*	(TYPE

	MES592

	JMP	SCF225

/

/  ACCEPT NODE INFORMATION

/

/  LARGE NODES FIRST

/
SCF23	LAC	SCFPBZ	/SET UP SIZES OF LARGE+SMALL PARTITIONS
	DAC	SCRSIZ+1	/IN LISTS OF 'SCFNSB'
	LAC	(NDSZ
	DAC	SCRSIZ	/SMALL ONES
								/(177)
/ CALCULATE THE PAGE ONE NODE POOL IF THERE IS ANY.		/(177)
/ NOTE THAT THIS IS REALLY NOT THE PAGE ONE NODE POOL BUT IT	/(177)
/ FILLS THE EMPTY SPACE LOST IN THE ROUNDING CALCULATIONS.	/(177)
								/(177)
.X=TEXECU+377&777400-TEXECU					/(177)
PG1SNP=0		/ SMALL NODE POOL SIZE (DEFAULT)	/(177)
	.IFNOZ 2*NDSZ-.X / IF LESS THAN 2 NODES IN THE POOL	/(177)
			/ FORGET IT.				/(177)
	LAC SCFCOR	/ SAVE SCFCOR.				/(177)
	DAC SCFCSV						/(177)
	LAC (TEXECU	/ FETCH TOP OF THE EXEC.		/(177)
	DAC SCFCOR	/ START NODE POOL THERE.		/(177)
	LAC (.X/NDSZ*NDSZ) / FETCH NECESSARY AMOUNT OF FREE	/(177)
			/ CORE.					/(177)
	CLL		/ INDICATE SMALL NODES.			/(177)
	JMS SCFNSB	/ MAKE NODES.				/(177)
	LAC SCFCSV	/ RESTORE SCFCOR			/(177)
	DAC SCFCOR						/(177)
PG1SNP=.X		/ SMALL NODE POOL SIZE.			/(177)
	.ENDC							/(177)
	JMS	CRTN
	JMS*	(TYPE	/PROMPT HIM
	MES530
SCF231	JMS	SCIFAC	/GET TYPED LINE
	JMS	FACSV
	JMS	TCX	/IS IT ZERO LENGTH
	JMP	SCF237	/YES DEFAULT TO 10 LARGE NODES (1000 OCTAL
/			/PARTITION TO CONTAIN THEM
	JMS	ADECKI	/MAKE UP DECIMAL CONSTANT
	JMS	TCX	/IF STUFF AFTER NUMBERS, ERROR
	SKP		/END OF LINE, OK
	JMP	SCF238	/SYNTAX ERROR
	PLA		/BRING IN ASSEMBLED NUMBER
	JMS	COMP	/BETWEEN 1 AND 600(8) 16K WORTH
	(1
	(600
	JMP	SCF239	/OUT OF RANGE
SCF233	DAC	SCFT3	/HOLD NUMBER, DEFAULT REJOINS HERE
	LAC	SCFPBZ	/LARGE NODE SIZE
	DAC	SCF232	/TO MULTIPLY BY # OF NODES
	LAC	SCFT3
	CLL		/NEED FOR MUL??
	MUL
SCF232	57		/WRITTEN OVER BEFORE USE
	LACQ
	AAC	377	/ROUND UP TO NEXT MULT OF 400
	AND	(777400
	PAL		/SAVE THIS IN LR
	TAD	(400	/ADD SOME SPACE FOR LARGE NODES
	TAD	SCFCOR	/ADD SIZE OF EXEC
	TCA		/NEGATE
	TAD	SCFPB0	/ADD BASE OF DISK HANDLER'S PARTITION
	SPA		/DID THE USER ASK FOR TOO MANY NODES?
	JMP	SCF240	/YES -- ERROR
	PLA		/NO -- RESTORE VALUE

	CLL!CML		/GOING TO CALL 'SCFNSB' TO MAKE NODES. LINK SAYS LARGE

	JMS	SCFNSB

	JMP	SCF24

SCF237	LAC	(12	/DEFAULT NUMBER OF LARGE NODES

	JMP	SCF233

/

SCF238	JMS	SCERR	/SYNTAX ERROR AND RETRY

	JMP	SCF231

/

SCF239	JMS*	(TYPE	/TYPE SIZE ERROR AND RETRY

	MES592

	JMP	SCF231

/

SCF240	JMS*	(TYPE	/TYPE TOO MANY NODES ERROR AND RETRY

	MES596

	JMP	SCF231

/

/  NOW SAME THING FOR SMALL NODE PARTITION

/

SCF24	JMS	CRTN

	JMS*	(TYPE

	MES531

SCF241	JMS	SCIFAC

	JMS	FACSV

	JMS	TCX

	JMP	SCF247	/DEFAULT 150(10) NODES 3000(8) SIZE PART.

	JMS	ADECKI

	JMS	TCX	/ERROR IF ANY NON-NUMBER CHAR'S LEFT IN LINE

	SKP

	JMP	SCF248	/OOOPS

	PLA

	JMS	COMP	/1 TO 3100(8) 16K WORTH . NOTE 1 GIVES YOU 25(10)

	(1

	(3100

	JMP	SCF249	/OUT OF RANGE, TILT!!

SCF243	DAC	SCFT3	/HOLD NUMBER

	CLL

	LAC	(NDSZ	/SMALL NODE SIZE, IN CASE NOT 10(10)

	DAC	SCF242	/FOR MULTIPLY TO GET PARTITION SIZE

	LAC	SCFT3

	MUL
SCF242	12		/WRITTEN OVER BEFORE USE
	LACQ
	DAC	SCRSV3	/SAVE CORE NEED FOR NODES TEMP.
	LAC (PG0NE-PG0NB+1) / NUMBER OF WORDS IN PAGE 0 SMALL	/(177)
			/ NODE POOL.				/(177)
	TAD (PG1SNP/NDSZ*NDSZ)	/ ADD IN SPACE FOR SMALL NODE	/(177)
			/ POOL STUCK IN THE ROUND UP SPACE.	/(177)
	TCA		/SUBTRACT THIS FROM SPACE FOR NODES CALCULATED
	TAD	SCRSV3	/ABOVE

	AAC	377	/ROUND UP TO NEXT 400(8

	AND	(777400

	PAL		/SAVE THIS FOR A MOMENT

	TAD	SCFCOR	/FIND OUT IF THERE ARE TOO MANY SPECIFIED

	TCA

	TAD	SCFPB0

	SPA		/TOO MANY?

	JMP	SCF250	/YES -- ERROR

	PLA		/NO -- RESTORE VALUE

	CLL		/LINK OFF FOR SMALL NODES

	JMS	SCFNSB	/MAKE NODES

/

/  NOW WE HAVE PUT IN NODES, IS ANY SPACE LEFT FOR PARTITION

/  UNDER DISK FILES HANDLER

/

SCF244	LAC	SCFCOR	/POINTER TO FREE SPACE ABOVE NODES

	DAC	SCFPBA	/DEFAULT, THIS IS BASE OF PARTITION

	CMA!IAC		/NEG FOR COMPARE TO BASE OF R?DISK

	TAD	SCFPB0

	DAC	SCFPSA	/DEFAULT, THIS IS SIZE OF 'XTRA' PARTITION

	SMA!SZA		/NOW, IS THERE REALLY ROOM FOR ONE

	JMP	SCF30	/YES, THERE IS, GO GET TTY'S

	LAC	(400000	/WASN'T ROOM, KILL PARTITION

	DAC	SCFPBA

	JMP	SCF30	/GO FIND OUT # OF TTY'S

/

/

SCF247	LAC	(226	/DEFAULT NUMBER OF SMALL NODES, 150(10)

	JMP	SCF243	/REJOIN MAIN LOOP

/

SCF248	JMS	SCERR	/SYNTAX ERROR

	JMP	SCF241	/RETRY

/

SCF249	JMS*	(TYPE	/SIZE ERROR

	MES592

	JMP	SCF241	/RETRY

/

SCF250	JMS*	(TYPE	/TYPE ERROR MESSAGE TOO MANY NODES AND RETRY

	MES596

	JMP	SCF24

/

/  SUBROUTINE SCFNSB CREATES A PARTITION FILLED WITH NODES

/  AND NOTIFIES SYSTEM (EITHER SNDL OF LNDL DEQUE) OF CREATION

/

/  LINK IS 0 FOR SMALL NODE CREATION, LINK IS 1 FOR LARGE

/  AC CONTAINS AMOUNT OF CORE TO BE CONVERTED TO NODES

/  SCFCOR POINTS TO FIRST FREE ADDR ABOVE EXEC

/

/  THE FOLLOWING PAIRS OF LOCATIONS MUST REMAIN AS PAIRS, AS

/   SCFNSB USES XR OF 0 FOR SMALL NODES, AND XR OF 1 FOR LARGE.

/

SCRPOO	POOL		/DEQUE INTO WHICH TO PLACE CREATED SMALL NODES

	LPOOL		/DEQUE INTO WHICH TO PLACE CREATED LARGE NODES

SCRNAM	.SIXBT	'SN0'	/SECOND HALF PARTITION NAME SMALL NODES

	.SIXBT	'LN0'	/SAME FOR LARGE

SCRLIS	SNDL		/SMALL NODES DECRIPTOR LIST DEQUE TO DECRIBE NODE PART.

	LNDL		/SMAE FOR LARGE

SCRSIZ	0		/SIZE OF SMALL NODES (INIT'ED AT SCF23

	0		/SAME FOR LARGE

SCRSVX	0		/SAVE LINK AS 0 OR 1, FOR PLACEMENT IN XR

SCRSV1	0		/TEMP STORAGE FOR TABLE AND NODE MANIPULATION

SCRSV2	0

SCRSV3	0

/

/

SCFNSB	0

	DAC	SCFT4	/SMOUNT OF CORE TO CONVERT TO NODES

	CLA!RAL		/GET LINK TO AC17

	DAC	SCRSVX	/FOR LATER INDEXING

SCR001	LAC	SCFT4	/GET REMAINING SIZE TO CREATE 

/

	SNA!SPA		/SKIP IF MORE TO DO

	JMP*	SCFNSB	/NOPE, EXIT

SCR010	LAC	SCFCOR	/POINTER TO FIRST FREE

	DAC	RCHLL	/BOTTOM OF NODE BLOCK FOR 'RCNOD'

	TAD	SCFT4	/ADD AMOUNT TO DO, GET TOP+1

	DAC	RCHUL	/FOR 'RCNOD'

	DAC	SCFCOR	/UPDATE LOWEST FREE LOCATION POINTER

	JMS	SCFSCR	/GO DO REAL WORK

	JMP*	SCFNSB	/GUANTTEED TO BE DONE IN UPPER CHUNK

/

/

/  SUBROUTINE  SCFSCR

/

/  RCHLL CONTAINS LOWER LIMIT OF CORE BLOCK TO BE NODES

/  RCHUL CONTAINS UPPER+1 OF BLOCK (BOTH THESE PASSED TO 'RCNOD'

/

/  SCRSVX  CONTAINS 0 FOR SMALL NODES, 1 FOR LARGE

/

SCFSCR	0

	LAC	RCHUL	/LOOP TO CONVERT BLOCK TO 0'S

	JMS	SETLR

/

/  TRICKY, WE WANT TO FIND IF WE ARE ABOUT TO CONVERT OURSELVES

/  INTO NODES. SETLR SUBTRACTS OUR STARTING ADDR. FROM

/  UPPER LIMIT OF NODES BLOCK, SO....

/

	SMA!SZA		/THIS WILL SKIP WHEN WE ARE OK!

	JMP	SCF999	/DISASTER, GET OUT

	LAC	RCHLL

	JMS	SETXR

	DZM	0,X

	AXS	1

	JMP	.-2

	LAC	SCRSVX	/LARGE-SMALL POINTER

	PAX

	ISZ	SCRNAM,X  /MAKE NAME ONE MORE THAN LAST ONE 'LN1' TO 'LN2'

	LAC	SCRNAM,X  / ETC. PLACE NAME IN TEMPORARY

	DAC	SCFT3

	JMS*	(PENP	/GET SMALL NODE FROM POOL TO DECRIBE PARTITION

	JMP	SCF999	/DISASTER, OUT OF SMALL NODES

	DAC	NAPNA	/SAVE NODE ADDR TO PLACE IN SYSTEM DEQUE

	JMS	SETXR	/ADDR TO XR FOR FILLING NODE

	LAC	(233123	/GET 'SYS' IN SIXBIT

	DAC	2,X

	LAC	SCFT3	/SECOND HALF

	DAC	3,X

	LAC	RCHLL	/BASE OF PARTITION

	DAC	4,X

	CMA!IAC		/CALCULATE SIZE

	TAD	RCHUL

	DAC	5,X

	DZM	6,X	/ZERO REST

	DZM	7,X

	DZM	10,X

	DZM	11,X

	LAC	SCRSVX	/GET BACK LARGE-SMALL

	PAX

	LAC	SCRLIS,X /WHICH SYSTEM DEQUE GETS THE NODE DESCRIBING PARTITION

	JMS	NAPE	/PLACE IN SYSTEM DEQUE

	LAC	SCRPOO,X /NOW WHICH SYSTEM DEQUE GETS THE NODES THEMSELVES

	DAC	RC0	/ARGUMENT HOLDER FOR 'RCNOD'

	LAC	SCRSIZ,X /SIZE OF NODES IN AC

	JMS	RCNOD	/THIS ROUTINE MAKES THE NODES, NAD PUTS IN SYSTEM

	JMP*	SCFSCR	/THAT'S ALL

/

/

/

/  ACCEPT NUMBER OF TTY'S

/

/  WE HAVE A PROBLEM HERE. THE 'ADD-A-DEVICE' ROUTINE DOESN'T

/  WORK FOR TTY'S. THUS, IF A USER SPECIFIES A SMALL NUMBER, AND

/  LATER WANTS TO ADD ON, HE CAN GET HUNG. WE ARE GOING TO

/  DEFAULT TO THE MAXIMUM ASSEMBLED INTO THE MONITOR (USUALLY 6).

/  IF THE USER HAS FEW TELETYPES, AND IS REALLY TIGHT ON CORE, HE

/  CAN GET AROUND THIS BY PATCHING RSXIMG (HE SAVES ABOUT TWO SMALL

/  NODES PER TELETYPE).  FOR A NORMAL >=24K SYSTEM:

/

/	$MICLOG SYS

/

/	$PATCH

/

/	PATCH V10A

/	>RSXIMG

/	>L 50021/000006>2

/	>EXIT

/

/	DOS-15 V3A

/	$

/

/

/  FOLLOW THE 2 WITH AN ALT-MODE; THIS REDUCES THE NUMBER

/  OF TELETYPES FROM 6 TO 2.

/

/  IF YOU ARE HANDY WITH THE CONSOLE KEYS, STOP THE COMPUTER

/  ANYTIME BEFORE ANSWERING THE LAST QUESTION, AND DEPOSIT THE

/  DESIRED NUMBER INTO 50021. THEN HIT CONTINUE, AND THE DIALOGUE

/  WILL START UP AGAIN.

/

/

SCF30	LAC	SCF000	/GET MAGIC # OF TTY'S FROM 50021 

	JMS	COMP	/CHECK IF USER PATCHED A FUNNY

	(1

	(TTYS

	JMP	SCF39	/BAD NUMBER

	DAC	SCFTTS	/SINCE DEVICE ADDER CAN'T PUT IN TTY'S LATER!!

	JMP	SCF150

/

SCF39	JMS*	(TYPE	/BAD PATCH!

	MES503

	HLT		/FIX PATCH

	JMP	SCF30	/TRY AGAIN

/

/

/

/ CONSTRUCT PHYSICAL DEVICE NODES FOR ADDITIONAL TTYS

/ (A NODE EXISTS FOR THE MANDATORY TT-0)

/

SCF150	DZM	SCFTTN	/INITIALIZE UNIT NUMBER

	LAC*	(TTYRQT)/USE AUTO-INCREMENT REG X13 TO SET

	DAC*	(X13)	/REQUEST QUEUE LISTHEAD ADDRESSES IN TABLE

/

SCF151	ISZ	SCFTTN	/SET NEXT TTY UNIT NUMBER

	LAC	SCFTTN	/IS THERE A 'PDVL' NODE FOR ALL TTY'S?

	SAD	SCFTTS

	JMP	SCF157	/YES -- SET NUMBER OF TTY'S IN SCOM

/

	JMS*	(PENP)	/NO -- PICK A NODE FROM THE POOL TO CONSTRUCT

			/A 'PDVL' NODE.  IS POOL EMPTY?

	JMP	SCF999	/YES -- ABORT SYSTEM CONFIGURATION

	DAC	NAPNA	/NO -- SAVE NODE ADDRESS FOR 'NAPE'

	JMS	SETXR	/SETUP XR TO FILL NODE

/

	LAC	(242400)/DEVICE NAME (FIRST HALF)

	DAC	D.N1,X

	DZM	D.N2,X	/DEVICE NAME (SECOND HALF)

	LAC	SCFTTN	/UNIT NUMBER

	DAC	D.UN,X

	DZM	D.AF,X	/CLEAR DEVICE-UNIT ATTACH FLAG

	LAC	NAPNA	/REQUEST QUEUE (DEQUE) LISTHEAD

	AAC	+D.QF

	DAC	D.QF,X

	DAC	D.QB,X

	DAC*	X13	/(SET REQUEST QUEUE TABLE ENTRY)

	LAC	(TTTGEV)/TRIGGER EVENT VARIABLE ADDRESS

	DAC	D.TG,X

	DZM	D.AI,X	/ASSIGN INHIBIT FLAG

/

	LAC	(PDVL)	/APPEND NODE TO 'PDVL' DEQUE

	JMS	NAPE

/

	JMP	SCF151	/TEST FOR ANOTHER NODE NEEDED

/

SCF157	LAC	SCFTTS	/SET NUMBER OF TTY'S IN SCOM

	DAC*	(TTYNUM)

/

/

/

/  TAKE DEVICES FROM DEFAULT DEVICE LIST AND MAKE THEIR 'PDVL'

/

SCF161	ISZ	DEVPNT	/MOVE POINTER TO NEXT

	LAC*	DEVPNT	/TOP TWELVE BITS TWO CHAR SIXBIT NAME

/			/BOTTOM SIX BITS UNIT NUMBER IN BINARY

	SNA		/SKIP UNLESS NULL DEVICE

	JMP	SCF161	/WAS, GO GET NEXT

	SAD	(-1	/-1 IS LIST TERMINATOR

	JMP	SCF167	/DONE, ON TO NEXT TASK

	DAC	SCFT2	/WE ARE GOING TO GIN UP SCFT1,SCFT2

/			/SO WE CAN USE EXISTING CODE

	AND	(777700	/KEEP SIX BIT NAME FOR SCFT1

	DAC	SCFT1	/THERE!

	XOR	SCFT2	/AND UNIT # FOR SCFT2

	DAC	SCFT2	/AND THERE!

/

/  AT THIS POINT SPLICE TO EXISTING CODE!

/

	LAC	(SCFT1)	/SCAN THE 'PDVL' DEQUE FOR THIS "NAME"

	DAC*	(R2)

	LAC	(PDVL)

	DAC*	(R1)

	JMS*	(SNAM)	/(R1, R2, R6, X17, XR & AC ARE ALTERED)

	SKP		/NAME FOUND?

	JMP	SCF165	/YES -- NAME/UNIT ERR

			/NO -- A 'PDVL' NODE CAN BE FORMED

/

	JMS*	(PENP)	/PICK A NODE FROM POOL -- EMPTY POOL?

	JMP	SCF999	/YES -- ABORT SYSTEM CONFIGURATION

	DAC	NAPNA	/NO -- SAVE NODE ADDRESS FOR 'NAPE'

	JMS	SETXR	/SETUP XR TO FILL NODE

	LAC	SCFT1	/DEVICE NAME (FIRST HALF)

	DAC	D.N1,X

	LAC	SCFT2	/DEVICE "NAME" (SECOND HALF)

	DAC	D.N2,X

	DAC	D.UN,X	/DEVICE UNIT NUMBER

	DZM	D.AF,X	/CLEAR DEVICE-UNIT ATTACH FLAG

	LAC	NAPNA	/REQUEST QUEUE (DEQUE) LIST HEAD

	AAC	+D.QF

	DAC	D.QF,X

	DAC	D.QB,X

	DZM	D.TG,X	/TRIGGER EVENT VARIABLE ADDRESS

	DZM	D.AI,X	/ASSIGN INHIBIT FLAG

/

/ SCAN THE PDVL FOR THE DEVICE NAME (FIRST HALF ONLY). IF FOUND, INSERT

/ THE NEW PDVL NODE THERE SO THAT ALL NODES FOR A GIVEN PHYSICAL DEVICE

/ ARE ADJACENTLY LINKED (A REQUIREMENT FOR THE I/O RUNDOWN TASK 'IORD').

/ IF NOT FOUND, APPEND THE NODE TO THE END OF THE PDVL DEQUE.

/

	LAC	(PDVL)	/SET PDVL LISTHEAD IN XR.

	JMS	SETXR

/

SCF163	LAC	0,X	/END OF DEQUE?

	SAD	(PDVL)

	JMP	SCF164	/YES -- APPEND NODE.

	JMS	SETXR	/NO -- SAVE NEW NODE'S ADR IN XR.

	LAC	2,X	/COMPARE DEVICE NAMES.

	SAD	SCFT1

	SKP		/SAME.

	JMP	SCF163	/DIFFERENT.

	LAC	0,X	/ADDRESS OF NEXT NODE.

SCF164	JMS	NAPE

	JMP	SCF161

/

SCF165	JMS*	(TYPE)	/TYPE NAME/UNIT ERR MESS & RETRY

	MES595

	JMP	SCF161

/

SCF166	JMS	SCERR	/TYPE SYNTAX ERR MESS & RETRY

	JMP	SCF161

/

SCF167	LAC	(PDVL)	/CLEAR SECOND HALF OF NAME DOUBLE-WORD

	JMS	SETXR	/IN ALL PHYSICAL DEVICE LIST NODES.

SCF168	LAC	D.FP,X	/(THESE WORDS HAVE BEEN SET TO THE

	SAD	(PDVL)	/DEVICE UNIT NUMBERS FOR INPUT SYNTAX 

	JMP	SCF169	/CHECKING.)

	JMS	SETXR

	DZM	D.N2,X

	JMP	SCF168

/

/  NOW MAKE PBDL NODES

/

SCF169	JMS	SUBPAR	/THIS SUBROUTINE DOES IT

	JMP	SCF170	/NON-SKIP WHEN DONE

	JMP	SCF169	/SKIP WHEN NOT

/

SCF170	JMS	CRTN	/TYPE "INSTALLATION OF TASKS FROM DISK"

/

/  NOTE, AT PRESENT WE ARE ASSUMING DOS HAS PLACED TAKSS TO BE

/  INSTALLED ON DISK FOR ALL THREE DISK TYPES. WE INSTALL FROM DISK

/  POSSIBLE WARNING ! ! ! ! ! ! ####  OVERFLOW RF???????

/

	JMS*	(TYPE)

	MES600

/

	.IFDEF %DTCLD

	CAL	CDTCPB	/CONNECT DECTAPE INTERRUPT

	.ENDC

	.IFUND %DTCLD

	LAC	SCFUFD	/GET POINTER TO FIRST UFD BLOCK

SCFDP1	JMS	CONV	/AND SET UP FOR A GET ON LUN 1

	.ENDC

/

	JMS	FTSK	/FIND DESCRIPTION OF FILES WITH 'TSK'

			/EXTENSIONS, RECORD THEM IN 'FDT', AND

			/INITIALIZE 'SKPNTR' TO POINT TO THE FIRST.

/

SCF171	LAC*	SKPNTR	/ARE THERE 'TSK' FILES YET TO BE TRIED?

	.IFDEF %DTCLD

	SNA

	JMP	SCF800	/NO -- FINISH SYSTEM CONFIGURATION

	.ENDC

	.IFUND %DTCLD

	SZA

	JMP	SCFDP2

	LAC	.NUFD	/LAST BLK OF UFD LIST?

	SAD	(-1	/-1 SAYS NO MORE

	JMP	SCF800	/YES; CLEAN UP.

	JMP	SCFDP1	/NO; LOOP.

	.ENDC

SCFDP2	LAC	SKPNTR	/YES -- SETUP TASK NAME FOR INSTALL

	DAC*	(X13)

	LAC*	X13

	DAC	TKNAM+0

	LAC*	X13

	DAC	TKNAM+1

/

	JMS	INSTAL	/INSTALL (OR TRY TO INSTALL) TASK

/

	LAC	SKPNTR	/AUGMENT SEEK POINTER & TEST FOR ANOTHER FILE

	AAC	+3

	DAC	SKPNTR

	JMP	SCF171

/

/ DETERMINE AND OUTPUT THE SIZE OF THE POOL

/

SCF800	DZM	SCFT1	/INCREMENT 'SCFT1' THRU NUMBER OF POOL NODES

	LAC	(POOL)

SCF801	JMS	SETXR

	LAC	0,X

	SAD	(POOL)

	JMP	SCF802

	ISZ	SCFT1

	JMP	SCF801

/

SCF802	LAC	SCFT1	/SAVE INITIAL POOL SIZE IN SCOM

	DAC*	(PLSZ)

/

	LAC	(040)	/CONVERT NUMBER OF NODES TO DECIMAL

	DAC	SCFIB+7	/AND FILL IMAGE OUTPUT BUFFER

	LAC	(SCFIB+6)

	DAC	SCFT1

	LAC*	(PLSZ)

/

SCF804	CLL

	IDIV

	12

	XOR	(060)

	DAC*	SCFT1

	LAC	SCFT1

	SAD	(SCFIB+2)

	JMP	SCF805

	AAC	-1

	DAC	SCFT1

	LACQ

	JMP	SCF804

/
SCF805	JMS	CRTN	/TYPEOUT POOL SIZE

	CAL	SCFTIB

	CAL	WFCPB

	JMS*	(TYPE)

	MES519

/

/ TYPE "SYSTEM IS RUNNING" AND TERMINATE SYSTEM CONFIGURATION ROUTINE

/

	JMS	CRTN

	JMS*	(TYPE)

	MES520

	JMS	CRTN

	JMS	CRTN

	.IFDEF %DTCLD

	CAL	DDTCPB	/DISCONNECT DECTAPE INTERRUPT

	.ENDC

	LAC	(400	/PREPARE TO SET UP THE 1ST REMOVE BLOCK

	DAC	DSKCT1

	CAL	ALLCPB

	CAL	WFCPB

	LAC	EV	/WERE THERE ANY ALLOCATE ERRORS?

	SPA

	JMP	SAVER1	/YES -- LET THE OPERATOR KNOW
	LAC	(DKUFD-1 /NO -- ZERO THE BLOCK

	DAC*	(X10

	DZM*	X10

	LAC*	(X10

	SAD	(DKUFD+376

	SKP

	JMP	.-4
	LAW	-1	/SET THE LAST WORD OF THE BLOCK TO -1
	DAC	DKUFD+377
	DAC	DKUFD+376	/ ALSO NEXT TO LAST WORD	/EAG:202

	LAC	(400	/PREPARE TO PUT THE BLOCK

	DAC	D.XUN+3

	LAC	(DKUFD

	DAC	D.XUN+2

	LAC	DSKCT1+1

	DAC	D.XUN

	LAC	DSKCT1+2

	DAC	D.XUN+1

	CAL	D.WRIT	/PUT THE BLOCK OUT ONTO DISK

	CAL	WFCPB

	LAC	EV	/WERE THERE ANY ERRORS?

	SPA

	JMP	SAVER2	/YES -- TELL THE OPERATOR

	LAC	DSKCT1+2

	LMQ		/GET THE BLOCK NO.

	LAC	DSKCT1+1

	LRSS	10

	LACQ

	DAC*	(311	/SAVE THE BLOCK NO.

	JMP	SAVOK	/OK TO EXIT NOW

SAVER1	JMS	TYPE

	SAVME1

	HLT

SAVER2	JMS	TYPE

	SAVME2

	HLT

SAVME1	SAVME2-SAVME1/2*1000

	0

	.ASCII "ALLOCATE ERROR"<15>

SAVME2	SAVOK-SAVME2/2*1000

	0

	.ASCII "PUT ERROR"<15>

SAVOK=.

	CAL	ENATDV	/ENABLE TASK "TDV...".

	LAC	(SCF)	/EFFECTIVELY REMOVE TASK BY DELETING

	DAC*	(R1)	/STL NODE

	JMS*	(NDEL)

/

	DZM*	(MCRRI)	/REQUEST RESIDENT MCR TASK

	CAL	REQCPB

/

	CAL	(10)	/EXIT TASK

/

SCF999	LAC	(BXTPL)	/INSUFFICIENT FREE CORE (EITHER OUT OF POOL

	DAC*	(POOL)	/OR STORAGE FOR ALL PARTITION BLOCKS CANNOT

	LAC	(EXTPL)	/BE FOUND -- EXTEND POOL, TYPE ERR MESSAGE,

	DAC*	(POOL+1)/AND ABORT SYSTEM CONFIGURATION

	JMS*	(TYPE)

	MES599

	HLT

	JMP	.-1

/

	.EJECT

/ TYPE -- SUBROUTINE TO OUTPUT TO LUN-3 THE MESSAGE WHOSE ADDRESS

/ FOLLOWS THE JMS.

/

TYPE	0

	LAC*	TYPE	/SET ADDRESS IN CPB

	DAC	TYPEAD

	ISZ	TYPE

/

	CAL	TYPCPB	/OUTPUT TO TTY

	CAL	TYPWPB

	JMP*	TYPE	/EXIT

/

TYPCPB	2700		/TYPE OUT CAL PARAMETER BLOCK

	TYPEV

	3

	2

TYPEAD	XX

/

TYPWPB	20

	TYPEV

/

TYPEV	0

/

	.EJECT

SCF	STKL		/STL NODE FOR SYSTEM CONFIGURATION TASK.

	.IFUND NOMAC	/THIS NODE IS DELETED FROM THE STL	/(162)

	MCR							/(162)

	.ENDC		/BEFORE					/(162)

	.IFDEF NOMAC						/(162)

	TDV							/(162)

	.ENDC							/(162)

	.SIXBT "SFG"	/THE TASK EXITS, AND IS NOT RETURNED TO THE

	.SIXBT "@@@"	/POOL.  (THE ATL NODE IS RETURNED TO THE

	440001		/POOL AT EXIT, AND IS A PART OF THE INITIAL

	SFGIC-P.IC	/POOL ASSEMBLED WITH THE SYSTEM.)  THE TASK IS

	0		/FLAGGED ACTIVE & FIXED-IN-CORE, WITH A

	0		/DEFAULT PRIORITY OF ONE.

	0

	SCONF

	.IFPNZ	NDSZMT

	.REPT	NDSZMT

	0

	.ENDC

/

/ PARTITION BLOCK

/

SFGPB4	SCONF-20	/BASE ADDRESS.

	0

	400		/TASK SIZE (NEEDED ONLY FOR KM15/KT15 TEST)

	.REPT	5

	0

SFGIC	0		/SHORT PARTITION BLOCK -- USED FOR REGISTER

	DBA		/SAVE ONLY.  (THERE ARE OTHER ACTIVE TASKS

	JMS*	(SAVE)	/THAT MAY INTERRUPT THIS TASK.  VIZ., THE

	.REPT	PBIB	/TTY HANDLER TASK.

	0

	SKP

	.REPT	PBMM

	0

	.REPT	PBFP

	0

/

/

/

/  THERE FOLLOWS A LIST OF DEFAULT PARTITIONS, TERMINATED BY -1

/

PARPNS	.+1		/TO REFILL PARPNT IN CASE OF RESTART

PARPNT	.		/POINTER TO PICK THEM UP

	.SIXBT	'MIS'	/PART. TO FILL SPACE ABOVE NODES AND BELOW R?DISK

	.SIXBT	'C0@'

SCFPBA	400000		/BASE -- UNDEFINED INITIALLY

SCFPSA	0		/SIZE -- UNDEFINED INITIALLY

SCFPN0	0		/R?DISK PARTITION (NAME WRITTEN DYNAMICALLY)

	.SIXBT	'ISK'

SCFPB0	24400		/BASE -- 25000 FOR RF

SCFPS0	3400		/SIZE -- 3000 IN CASE OF RF DISK

	.SIXBT	'MCR'	/MCR PARTITION

	.SIXBT	'@@@'

SCFPBM	30000		/BASE

SCFPSM	3000		/SIZE

	.SIXBT	'MIS'	/PART. TO FILL SPACE LEFT BY SHORT MCR PART

	.SIXBT	'C1@'

SCFPBB	400000		/BASE -- INITIALLY UNDEFINED

SCFPSB	0		/SIZE -- INITIALLY UNDEFINED

	.SIXBT	'LP@'	/LP PART.

	.SIXBT	'@@@'

SCFPB1	33000		/BASE -- 33000

SCFPS1	1400		/SIZE 1400 FOR LPT

	.SIXBT	'TAP'	/DT PART.

	.SIXBT	'E@@'

SCFPB2	34400		/BASE
SCFPS2	3400		/SIZE FOR DECTAPE OR MAGTAPE
	.IFDEF NOMAC						/(200)
	.SIXBT	'TDV'	/TDV PART.
	.SIXBT	'@@@'
SCFPBT	40000		/DEFAULT BASE 
SCFPST	40000		/DEFAULT SIZE 
	.ENDC							/(200)
	.IFUND NOMAC						/(200)
	.SIXBT "DISPAT"	/ PARTITION NAME			/(200)
	40000		/ DEFAULT SA.				/(200)
	6000		/ DEFAULT SIZE.				/(200)
	.SIXBT "TDV@@@"	/ PARTITION NAME			/(200)
SCFPBT	46000		/ DEFAULT SA.				/(200)
SCFPST	32000		/ DEFAULT SIZE.				/(200)
	.ENDC							/(200)
/
/
/  NOW A PARTITION FOR EACH BLOCK OF CORE, THAT EXISTS.
/  A -1 WILL BE WRITTEN IN TO TERMINATE
/  AND LAST PARTITION WILL HAVE ITS SIZE ADJUSTED IF NECESSARY.
/  LABEL SCFEND  LETS US ADDRESS THESE GUYS
/
SCFEND	.SIXBT	'BLK'
	.SIXBT	'1@@'
	100000
	100000
	.SIXBT	'BLK'
	.SIXBT	'2@@'
	200000
	100000
	.SIXBT	'BLK'
	.SIXBT	'3@@'
	300000
	100000
	-1		/IN CASE FULL CORE!
/
/  SOME USEFUL LOCATIONS
/
SCFUFD	0		/STARTING BLOCK # OF 'RSX' UFD
SCFCOR	0		/BOTTOM OF PRESENT PARTITION
SCFCSV	0		/ SAVE AREA FOR SCFCOR DURING PAGE 1	/(177)
			/ SMALL NODE CONSTRUCTION.		/(177)
SCFDSK	-1		/OUR WHICH SYSTEM DISK. -1=RF;0=RP;1=RK
SCFT3	0		/TEMPORARY
SCFT4	0		/SAME
/
/  NOW DEFAULT DEVICE LIST
/
DEVPNS	.+1		/TO REFILL DEVPNT
DEVPNT	.		/POINTER TO GET THEM
SCFSYF	.SIXBT	'RF@'	/THESE DEVICE NAMES ARE REBUILT DYNAMICALLY
SCFSYP	.SIXBT	'RP@'	/AS NEEDED AFTER AN INITIAL ZERO OUT.
	.SIXBT	'RPA'
	.SIXBT	'RPB'
	.SIXBT	'RPC'
	.SIXBT	'RPD'
	.SIXBT	'RPE'
	.SIXBT	'RPF'
	.SIXBT	'RPG'
SCFSYK	.SIXBT	'RK@'
	.SIXBT	'RKA'	/A MAKES 01 IN LAST 6 BITS, WHICH IS UNIT #1
	.SIXBT	'RKB'
	.SIXBT	'RKC'
	.SIXBT	'RKD'
	.SIXBT	'RKE'
	.SIXBT	'RKF'

	.SIXBT	'RKG'

	.SIXBT	'LP@'	/LP DEVICE @ IS UNIT #

	.SIXBT	'DT@'

	.SIXBT	'DTA'
	.SIXBT	'DTB'
	.SIXBT 'BD@'	/ DEFAULT BATCH DEVICE NODE.		/(175)

	-1		/FOR NOW NO OTHERS.

/

/

/  RCNOD  CONVERTS AN AREA OF CORE INTO NODES OF SPECIFIED SIZE

/    AND PLACES THE NODES INTO A SPECIFIED DEQUE.

/

/   CALL WITH THE NODE SIZE IN AC, AC MODIFIED ON RETURN.

/  RCHLL MUST HAVE THE LOWER LIMIT OF THE CORE. RCHUL MUST

/  HAVE THE UPPER LIMIT+1. RC0 MUST CONTAIN THE ADDRESS OF THE DEQUE

/  INTO WHICH THE CREATED NODES ARE TO BE PLACED.

/

RCNOD	0

	DAC	RCSIZ	/SAVE NODE SIZE

	LAW	-1	/CORRECT UPPER+1 TO UPPER

	TAD	RCHUL

	DAC	RCHUL

RCNOD1	JMS	RCPBX	/CORRECT FOR PAGE BOUNDARY

	JMS	RCFIT	/ANY MORE FIT

	JMP*	RCNOD	/NO

	LAC	RCHLL	/LOWER LIMIT IS NODE ADDR

	DAC	NAPNA	/APPEND NODE

	LAC	RC0	/TO THIS DEQUE

	JMS	NAPE

	LAC	RCHLL	/UPDATE LOWER LIMIT

	TAD	RCSIZ

	DAC	RCHLL

	JMP	RCNOD1	/KEEP GOING

/

/  TEMPORARIES

/

RCHLL	0

RCHUL	0

RCSIZ	0

RC0	0

/

/  RCFIT - SKIP RETUN IF A NODE OF SIZE RCSIZ CAN FIT BETWEEN

/  RCHLL AND RCHUL, AC MODIFIED

/

RCFIT	0

	LAC	RCSIZ

	TAD	RCHLL

	AAC	-1

	CMA!IAC

	TAD	RCHUL

	SMA

	ISZ	RCFIT

	JMP*	RCFIT

/

/  RCPBX - PREVENT A NODE FROM STRADDLING 0-17 OF A PAGE.

/  THIS IS ACCOMPLISHED BY INCREASING (IF NECESSARY) RCHLL TO

/  20 OF THE NEXT PAGE. AC AND RCHLL MAY BE MODIFIED.

/

RCPBX	0

	LAC	RCHLL	/FIND THIS NODE'S PAGE

	AND	(770000

	AAC	20	/ADD 20

	DAC	RCPBXT	/SAVE RESULT FOR LATER

	TCA		/NEGATE FOR TEST: SEE IF NODE

	TAD	RCHLL	/WILL BEGIN BEFORE LOC20 OF PAGE

	SMA

	JMP	RCPBX1	/NO -- OK

	LAC	RCPBXT	/YES -- ADJUST NODE'S ADDR

	DAC	RCHLL

RCPBX1	LAC	RCSIZ

	TAD	RCHLL

	AAC	-1

	XOR	RCHLL

	AND	(770000

	SNA

	JMP*	RCPBX	/OK AS IS

	LAC	RCHLL

	AND	(770000	/KEEP PAGE BITS

	TAD	(10020	/MOVE TO 20 OF NEXT PAGE

	DAC	RCHLL	/THAT DOES IT

	JMP*	RCPBX

/

RCPBXT	0		/TEMP STORAGE FOR NODE ADDR CHECK

/

/

/

/  SUBPAR  READS PARTITION DECRPITIONS FROM PARPNT AND

/  CONSTRUCTS PBDL NODES FOR THEM. STOPS WHEN A -1 IS ENCOUNTERED

/  AS FIRST WORD OF FOUR DESCRIBING THE NODE. IN THIS CASE A NON-SKIP

/  RETURN IS GENERATED AND NO PBDL IS CONSTRUCTED. 
/  IF THE PARTITION IN QUESTION HAS A 0 OR - BASE, IT IS IGNORED, A SKIP

/  RETURN IS GIVEN. IN ALL OTHER CASES, A PBDL IS CONSTRUCTED, AND A

/  SKIP RETURN IS GIVEN.

/

SUBP1	0		/HOLD FIRST 1/2 NAME

SUBP2	0		/HOLD SECOND 1/2 NAME

SUBP3	0		/HOLD BASE

SUBPAR	0

SCF101	ISZ	PARPNT

	LAC*	PARPNT

	SAD	(-1

	JMP*	SUBPAR	/YES

	DAC	SUBP1	/SAVE FIRST HALF NAME

	ISZ	SUBPAR	/MAKE SKIP RETURN

	ISZ	PARPNT	/GET SECOND HALF NAME

	LAC*	PARPNT

	DAC	SUBP2	/SAVE

	ISZ	PARPNT

	LAC*	PARPNT	/BASE

	DAC	SUBP3	/SAVE BASE

	ISZ	PARPNT	/MAKE PARPNT POINT TO SIZE

	SNA!SPA		/ILLEGAL BASE, DON'T DO PARTITION!!

	JMP*	SUBPAR	/YES IT WAS 

/

/

	LAC	(LPOOL	/GET A LARGE NODE

	DAC*	(R1

	JMS*	(PICK

	JMP*	SUBPAR	/NO MORE LARGE NODES; LET HIM TRY WITH

/			/WHATEVER PARTITIONS HE ALREADY HAS

	DAC	NAPNA	/SAVE ADDR. FOR LATER INSERTION IN PBDL

	JMS	SETXR	/FILL NODE SLOTS WITH XR

	LAC	SUBP1

	DAC	P.N1,X	/NAME PART 1

	LAC	SUBP2

	DAC	P.N2,X	/PART 2

	LAC	SUBP3

	DAC	P.BA,X	/BASE

	LAC*	PARPNT	/SIZE

	DAC	P.SZ,X

	DAC	P.TS,X	/DEFAULTS FOR TASK SIZE

	LAC	(SAVE	/

	DAC	13,X	/SAVE ENTRY POINT

	LAC	(DBA

	DAC	15,X

	PXA

	AAC	13

	AND	(7777

	XOR	(120000	/JMS*	(SAVE

	DAC	16,X

	LAC	(SKP

	DAC	P.SW,X

	LAC	(PBDL	/DEQUE HEAD FOR PARTITIONBLOCKS

	JMS	NAPE	/PUT IT THERE

	JMP*	SUBPAR	/ALL OTHER LOC'S WERE PREVIOUSLY 0'D

/

SETXRM=.&070000

/

SETXR	0

	TAD	(-SETXRM)

	PAX

	JMP*	SETXR

/

/  SAME FOR LIMIT REG

/

SETLR	0

	TAD	(-SETXRM

	PAL

	JMP*	SETLR

/

/

/ SCIFAC -- SUBROUTINE TO TYPE A PROMPTING CHARACTER AND

/ INITIALIZE THE FETCH-A-CHARACTER SUBROUTINE

/

SCIFAC	0

	JMS*	(TYPE)

	MES400

	JMS*	(IFAC)

	JMP*	SCIFAC

/

/ AOCTK -- SUBROUTINE TO FETCH CHARACTERS THRU A NON-OCTAL

/ TERMINATOR, AND ASSEMBLE AN OCTAL CONSTANT IN LR, AND RETURN

/ WITH THE TERMINATOR IN AC.

/

AOCTK	0

	CLLR		/CLEAR ASSEMBLY REGISTER

/

AOCTKL	JMS	FACSV	/ASSEMBLY LOOP -- FETCH A CHARACTER

AOCTKM	JMS	COMP	/OCTAL DIGIT?

	(60)

	(67)

	JMP*	AOCTK	/NO -- EXIT WITH TERMINATOR IN AC

	LRS	3	/YES -- ASSEMBLE DIGIT INTO CONSTANT

	PLA		/IN LIMIT REGISTER AND FETCH NEXT

	LLS	3	/CHARACTER

	PAL

	JMP	AOCTKL

/

/  ALTERNATE ENTRY POINT IS FIRST FACSV ALREADY CALLED

/

AOCTKI	0

	DAC	AOCTKB	/SAVE CHARACTER

	LAC	AOCTKI	/SET UP COMMON RETURN

	DAC	AOCTK

	CLLR		/DO MISSED INSTRUCTION

	LAC	AOCTKB	/RETRIEVE CHARACTER

	JMP	AOCTKM	/JOIN

AOCTKB	0		/TEMP

/

/ ADECK -- SUBROUTINE TO FETCH CHARACTERS THRU A NON-DECIMAL

/ TERMINATOR, AND ASSEMBLE A DECIMAL CONSTANT IN LR, AND RETURN

/ WITH THE TERMINATOR IN AC.

/

ADECK	0

	CLLR		/CLEAR ASSEMBLY REGISTER

/

ADECKL	JMS	FACSV	/ASSEMBLY LOOP -- FETCH A CHARACTER

ADECKM	JMS	COMP	/DECIMAL DIGIT?

	(60)

	(71)

	JMP*	ADECK	/NO -- EXIT WITH TERMINATOR IN AC

	AND	(017)	/YES -- ASSEMBLE DIGIT INTO CONSTANT

	DAC	ADECKB	/IN LIMIT REGISTER AND FETCH NEXT

	PLA		/CHARACTER

	CLL

	MUL

	12

	LACQ

	TAD	ADECKB

	PAL

	JMP	ADECKL

/

ADECKB	0

/

/  SAME THING AS ADECK, BUT CHAR INITIALLY IN AC!

/

ADECKI	0

	DAC	ADECKB	/SAVE FIRST CHAR

	LAC	ADECKI	/MAKE COMMON SUBROUTINE RETURN

	DAC	ADECK

	CLLR

/

	LAC	ADECKB	/CHAR BACK

	JMP	ADECKM	/ALTERNATE ENTRY

/

/ FACSV -- SUBROUTINE TO FETCH THE NEXT NON-BLANK CHARACTER AND SAVE

/ IT IN THE GENERAL ERROR MESSAGE, UNLESS CAR RTN OR ALTMODE

/

FACSV	0

FACSV1	JMS*	(FAC)	/FETCH CHARACTER

	JMS	TCX	/CAR RTN OR ALTMODE?

	JMP*	FACSV	/YES -- EXIT WITH CHAR IN AC.

	SAD	(040)	/NO -- BLANK?

	JMP	FACSV1	/YES -- FETCH ANOTHER CHARACTER

	RCL		/NO -- SET CHARACTER IN 20TH

	DAC	FACSVB	/POSITION IN 'MES591' AND EXIT

	LAC	MES591+11 /WITH CHARACTER IN AC.

	AND	(777400)

	XOR	FACSVB

	DAC	MES591+11

	AND	(000377)

	RCR

	JMP*	FACSV

/

FACSVB	0

/

/ SCERR -- GENERAL ERROR ROUTINE TO INDICATE POSITION OF ERROR

/ IN INPUT LINE.

/

SCERR	0

	JMS*	(TYPE)	/TYPE "^^^  SYNTAX ERR AT X -- PLEASE RETYPE"

	MES591		/WHERE X HAS BEEN SET BY 'FACSV'.

	JMP*	SCERR

/

/

/ SCFULX -- HOLE UPPER LIMIT CHECK

/

/ RETURN AT JMS+1 IF AC+LOWER LIMIT WILL OVERFLOW UPPER LIMIT

/ RETURN AT JMS+2 IF NO OVERFLOW

/

SCFULX	0

	TAD	SCFHLL

	AAC	-1

	TCA

	TAD	SCFHUL

	SMA

	ISZ	SCFULX

	JMP*	SCFULX

/

/ SCFPBX -- PAGE BOUND CHECK

/

/ RETURN AT JMS+1 IF AC+LOWER LIMIT WILL OVERFLOW A PAGE BOUND

/ RETURN AT JMS+2 IF NO OVERFLOW

/

SCFPBX	0

	TAD	SCFHLL

	AAC	-1

	XOR	SCFHLL

	AND	(770000)

	SNA

	ISZ	SCFPBX

	JMP*	SCFPBX

/

/ CRTN -- SUBROUTINE TO RETURN CARRIAGE

/

CRTN	0

	JMS*	(TYPE)

	MES2

	JMP*	CRTN

/

/ COMP -- SUBROUTINE TO COMPARE AC WITH LIMITS (INCLUSIVELY)

/

/ CALLING SEQUENCE:

/	JMS	COMP	/CALL

/	(MIN)		/ADDRESS OF MIN

/	(MAX)		/ADDRESS OF MAX

/	JMP	OUT	/RETURN AT JMS+3 IF OUT OF RANGE

/	---		/RETURN AT JMS+4 IF WITHIN RANGE

/

COMP	0

	DAC	COMPAC	/SAVE AC

	LAC*	COMP	/OUT OF RANGE IF AC<MIN

	ISZ	COMP

	DAC	COMPTV

	LAC*	COMPTV

	TCA

	TAD	COMPAC

	SPA

	JMP	COMPOR

	LAC*	COMP	/OUT OF RANGE IF AC>MAX

	DAC	COMPTV

	LAC	COMPAC

	TCA

	TAD*	COMPTV

	SMA

	ISZ	COMP	/AC WITHIN LIMITS -- RETURN AT JMS+4

COMPOR	ISZ	COMP	/AC WITHOUT LIMITS -- RETURN AT JMS+3

	LAC	COMPAC	/RESTORE AC

	JMP*	COMP

/

COMPAC	0

COMPTV	0

/

/ NAPE -- SUBROUTINE TO APPEND THE NODE WHOSE ADDRESS IS IN 'NAPNA'

/ AT THE END OF THE DEQUE WHOSE LISTHEAD IS IN AC OR, ALTERNATIVELY,

/ TO INSERT THE NODE WHOSE ADDRESS IS IN 'NAPNA' BEFORE THE NODE

/ WHOSE ADDRESS IS IN THE AC.

/

NAPNA	0	/NODE ADDRESS

/

NAPE	0

	IAC

	DAC	NAPR1

	LAC*	NAPR1

	DAC	NAPR2

	LAC*	NAPR2

	DAC*	NAPNA

	LAC	NAPNA

	DAC*	NAPR2

	DAC*	NAPR1

	ISZ	NAPNA

	LAC	NAPR2

	DAC*	NAPNA

	JMP*	NAPE

/

NAPR1	0

NAPR2	0

/

SCFHUL	0	/HOLE UPPER LIMIT

SCFHLL	0	/HOLE LOWER LIMIT

SCFRX1	0	/RECORD INDEX ONE

SCFRX2	0	/RECORD INDEX TWO

SCFTTN	0	/TTY UNIT NUMBER

SCFPBZ	0	/PARTITION BLOCK SIZE

SCFTTS	0	/NUMBER OF TTY UNITS

SCFT1	0	/TEMP CELL ONE

SCFT2	0	/TEMP CELL TWO (MUST FOLLOW 'SCFT1')

SCFTMP	0	/TEMP CELL

SCFRB	.BLOCK 12 /RECORD BUFFER

/

SCFTIB	2700	/CAL PARAMETER BLOCK TO 

	EV	/TYPE OUT IMAGE BUFFER

	2

	3

	SCFIB

/

SCFIB	004003	/IMAGE BUFFER

	.BLOCK 7

/

/ INSTALL -- SUBROUTINE TO INSTALL TASK WHOSE NAME IS IN 'TKNAM+0'

/ AND 'TKNAM+1' AND WHOSE STARTING BLOCK ON DT-0 IS IN THE 'FDT' WORD

/ POINTED TO BY 'SKPNTR'.

/

TKNAM	.SIXBT	'@@@@@@'	/TASK TO BE INSTALLED

/

	.TITLE *** INSTALL SUBROUTINE ***

/

/WRITTEN TO HANDLE BLOCK MODE (400 WORDS/BLOCK) MASS STORAGE DEVICES

/SUCH AS THE RP15 THAT WILL NOT HANDLE WORD ADDRESSABILITY. HOWEVER,

/IT WILL STILL WORK ON A WORD ADDRESSABLE DEVICE (SUCH AS RF15)

/

/THE ALLOCATION SIZE FOR THE TASK WAS IN A SPECIAL AREA JUST BEFORE THE

/ACTUAL TASK. THIS AREA WAS 10(8) WORDS LONG DUE TO THE FACT THAT THE

/LOW 3 BITS STILL HAD TO CONTAIN THE UNIT NUMBER. THE ALLOCATION WAS

/EXTENDED FOR 10(8) WORDS, AND THE STL NODE DISK ADDRESS WAS SET UP

/AS 10(8) MORE THAN IT WOULD HAVE BEEN. DUE TO THE FACT THAT ALL DISK

/TRANSFERS IN BLOCK MODE MUST START ON A SECTOR(BLOCK) BOUNDARY, THIS

/HAS NOW BEEN EXTENDED TO 400(8) WORDS. PERHAPS SOME USEFUL FUNCTION

/CAN BE DEVISED TO KEEP SOME MORE INFORMATION IN THE NOW WASTED 377(8)

/WORDS.

/

FDT=25000

X10=10

X11=11

X15=15

RELHWE=235		/CONTAINS A SKIP IF RELOCATE ON MACHINE

FPHDW=236		/CONTAINS A SKIP IF FP15 ON MACHINE

/

INSTAL=.		/BEGINNING OF INSTALL ROUTINE

I.TSKN=TKNAM		/IF ASSEMBLED WITH SCF, THEN THIS IS A SUBROUTINE

	0		/THIS IS ITS ENTRY POINT

	DZM	I.DSKA	/DISK AREA NOT ASSIGNED YET

	DZM	I.DFPR	/NO DEFAULT PRIORITY YET

/

/SCAN THE STL TO SEE IF THE TASK EXISTS ALREADY

/

	LAC	(STKL)

	DAC*	(R1)

	LAC	(I.TSKN) /ADDRESS OF THE NAME

	DAC*	(R2)

	JMS*	(SNAM)	/GO LOOK (ALMOST ALL REGISTERS WIPED OUT)

	SKP		/NOT FOUND, ALL IS WELL

	JMP	I.ER02	/FOUND, ERROR

/

/CODE TO DO THE INSTALL WORK:

/

/NOTE: ALL DISK ADDRESS CARRIED AROUND DURING PROCESSING, AND PASSED ON

/TO THE RSX EXECUTE PROGRAM VIA THE LINK TABLE ARE OF THE FORM

/ BLOCK NUMBER * 400 + UNIT NUMBER. THE 'ADD' INSTRUCTION INSTEAD OF THE

/'TAD' INSTRUCTION IS USED TO CALCULATE DISK ADDRESSES, AS THIS WILL

/INCREMENT THE UNIT NUMBER IF AN OVERFLOW OCCURS.

/

/

/

	JMS	SEEK	/SEEK THE FILE

	LAC	(377777) /FIND LINK #377777 FOR INFO

	DAC	I.LKNM	/

	DZM	I.ACNT	/COUNTING THE LINKS ON THE WAY

	JMS	I.FLNK	/GO DO IT

	LAC	INBUF+4	/BASE OF BLANK COMMON

	DAC	I.BCBS	/SAVED FOR PATCHING

/

	LAC	I.ACNT	/THE COUNT OF EXTERNAL LINKS+1 FOR THE ALLOCATION

	ALSS	10	/MULTIPLY BY 400

	TAD	INBUF+5	/NOW WE HAVE THE NUMBER OF BLOCKS *400

	AAC	377	/NEEDED TO HOLD THE IMAGE

	AND	(-400)	/ON THE DISK, WITH EACH OVERLAY

	DAC	I.ALSZ	/STARTING ON A BLOCK BOUNDARY

/

	LAC	INBUF+7	/SAVE THE BASE ADDRESS OF THE LINK TABLE

	DAC	I.LTBS

/

	LAC	INBUF+6	/AND THE SIZE OF THE RESIDENT IMAGE

	DAC	I.RISZ

/

	LAC	INBUF+11 /SAVE THE

	DAC	I.ENTR	/ENTRY POINT FOR THE TASK

	SMA		/IS FP15 REQUIRED?

	JMP	.+3	/NO

	XCT*	(FPHDW)	/SKIP IF FP IS THERE

	JMP	I.ER15	/NO, BUT IT IS NEEDED - ERROR

	DZM	I.XM		/ CLEAR XVM MODE BITS

	LAC	I.ENTR		/ IS THIS TASK EXEC MODE?

	RTL			/

	SMA			/

	JMP	I.OVXM		/ YES -- LEAVE XM BITS CLEARED

	LAC	INBUF+16	/ NO -- GET XM BITS

	DZM	INBUF+16	/ CLEAR GARBAGE OUT OF INBUF

	PAL			/ SAVE XM BITS TEMPORARILY

	AND	(1		/ IS TASK IN XVM MODE?

	SNA			/ 

	JMP	.+3		/ NO -- DON'T SET XVM MODE BITS IN STL NODE

	LAC	(000140		/ YES -- PREPARE TO SET XVM MODE BITS

	DAC	I.XM		/

	PLA			/ RESTORE AC WITH FORMER CONTENTS OF INBUF+16

	AND	(2		/ WILL TASK RUN IN IOT MODE?

	SNA			/

	JMP	I.OVXM		/ NO -- DON'T SET THE IOT BIT

	LAC	I.XM		/ YES -- PREPARE TO SET IOT BIT

	XOR	(20		/

	DAC	I.XM		/

I.OVXM=.			/

/

	LAC	INBUF+12 /MOVE THE PARTITION NAME IN

	DAC	I.PTNM

	LAC	INBUF+13

	DAC	I.PTNM+1

/

	LAC	INBUF+14 /SAVE THE BASE

	DAC	I.CORB	/ADDRESS OF THE PARTITION ACCORDING TO TKB

	DAC	I.LCOR	/SAVE THIS FOR LINK TABLE EXPANSION (&LINK #0)

/

	LAC	INBUF+15 /GET THE MAXIMUM TASK REGISTER

	AAC	377	/FORCE IT TO 400 WORD INCREMENTS

	AND	(-400)

	DAC	I.MXTR	/SAVE IT

	LAC	INBUF+15 /IF TASK SIZE IS 401,1001, ETC.,

	AND	(-400	/ADD 400 TO MAX TASK REG.

	SAD	INBUF+15

	SKP

	JMP	.+4

	LAC	I.MXTR

	TAD	(400

	DAC	I.MXTR

	LAC	I.ENTR	/NOW WE SEE IF THAT WAS A MISTAKE AND THIS IS

	RTL		/REALLY AN EXEC MODE TASK

	SPA		/SKIP ON MISTAKE

	JMP	I.OVRX	/NO, WE DID GOOD, WELL DIDN'T WE????

	LAC	INBUF+14 /PICK UP THE PARTITION BASE ADDRESS

	TCA		/NEGATE

	TAD	INBUF+15 /NOW WE HAVE THE SIZE -1 OF THE TASK

	IAC		/SO FIX IT UP

	DAC	I.MXTR	/AND REPLACE OUR ERROR

/

I.OVRX	LAC	(PBDL)	/NOW WE SCAN THE PARTITION BLOCK DESCRIPTOR LIST

	DAC*	(R1)	/FOR THIS PARTITION

	LAC	(I.PTNM) /NAME

	DAC*	(R2)	/

	JMS*	(SNAM)	/GO DO IT

	JMP	I.ER03	/NOT FOUND, WE HAVE TROUBLE HERE

	DAC	I.PBAD	/FOUND, SAVE THE ADDRESS FOR LATER

	AAC	4	/AND UP TO THE ADDRESS OF

	DAC	I.WRK	/THE PARTITION BASE ADDRESS

/

	LAC	I.ENTR	/PICK UP THE TASK ENTRY POINT AGAIN

	RTL		/AC0 IS THE PROTECTION INDICATOR

	SPA		/SKIP IF NOT PROTECTED

	JMP	I.RELT	/RELOCATED TASK, CHECK IT OUT

	LAC*	I.WRK	/NOT RELOCATED - WAS THE PARTITION BASE SPECIFIED

	SAD	INBUF+14 /CORRECTLY TO TKB?

	JMP	I.PARC	/YES -- GO CHECK THE PARTITION

	JMP	I.ER04	/NO, ERROR

I.RELM	LAC	I.DFPR	/PRIORITY REQUESTED?

	SZA		/SKIP IF NOT

	JMP	I.CBCK	/IF SO, USE IT - NOW CHECK COMMON BLOCKS

	LAC	INBUF+10 /WAS A PRIORITY SPECIFIED TO TKB?

	SNA		/SKIP IF SO

	JMP	I.ER12	/NO, NO PRIORITY AT ALL - ERROR

	DAC	I.DFPR	/YES, SAVE THIS

I.CBCK	LAC	(INBUF+15) /SET UP TO SCAN THE COMMON BLOCKS

	DAC*	(X15)	/ADDRESS OF LIST

	LAC*	X15	/PICK IT UP

	SNA		/ANYTHING THERE?

	JMP	I.ALLD	/NO, ALLOCATE THE DISK SPACE

	LAC*	(X15)	/YES, SET UP TO SCAN

	DAC*	(R2)	/THE SYSTEM COMMON BLOCK LIST

	LAC	(SCDL)	/FOR THIS COMMON BLOCK

	DAC*	(R1)	/NAME

	JMS*	(SNAM)	/GO DO IT - FOUND?

	JMP	I.ER09	/NO, ERROR

	AAC	4	/YES, SET UP TO COMPARE

	DAC*	(X10)	/THE BASE AND SIZE

	LAC*	X15	/SCAN OVER THE NAME SECOND HALF

	LAC*	X15	/ARE THE BASES THE SAME?

	SAD*	X10	/SKIP IF SO

	SKP

	JMP	I.ER09	/NO, ERROR

	LAC*	X15	/ONCE MORE

	SAD*	X10	/FOR THE SIZES

	JMP	I.CBCK+2 /ALL OK, KEEP LOOKING

	JMP	I.ER09	/NO, ERROR

/

I.RELT	XCT*	(RELHWE) /DO WE HAVE RELOCATION HARDWARE?

	JMP	I.ER14	/NO, SHOW THE ERROR

I.PARC	ISZ	I.WRK	/YES, CHECK THE SIZE OF THE PARTITION

	LAC*	I.WRK	/TO SEE IF THIS WILL FIT

	TCA		/NEGATE

	TAD	I.MXTR	/AND ADD THE HIGHEST TASK REGISTER IN

	SMA!SZA		/WILL IT FIT? SKIP IF SO

	JMP	I.ER04	/NO, TASK IS TOO LARGE - ERROR

	JMP	I.RELM	/YES IT WILL FIT, CARRY ON WITH OTHER THINGS

/

I.ALLD	CAL	I.ACPB	/ALLOCATE THE DISK SPACE NEEDED

	CAL	I.WAIT	/WAIT UNTIL COMPLETION

	LAC	I.EV	/PICK UP THE EV

	SAD	(-777)	/OUT OF POOL?

	JMP	SCF999	/YES - STOP SYSTEM CONFIG

	SPA		/ALLOCATION OK? - SKIP IF SO

	JMP	I.ER06	/NO - ERROR

	ISZ	I.DSKA	/YES, SHOW THAT WE HAVE ALLOCATED DISK SPACE

	LAC	I.ALSZ+1 /MOVE THE ADDRESS INTO THE

	DAC	I.PCPB	/PUT CPB

	LAC	I.ALSZ+2

	DAC	I.PCPB+1

	LAC	(I.BLOK-1) /CLEAR THE DISK I/O BLOCK

	DAC*	(X10)	/TO ZEROS

	LAW	-400

	DAC	I.WRK

	DZM*	X10

	ISZ	I.WRK

	JMP	.-2

	LAC	I.ALSZ	/NOW CLEAR ALL OF THE ALLOCATED DISK AREA TO

	DAC	I.WRK	/ZEROS

	CAL	I.PUTC	/PUT THE ZEROS OUT

	JMS	I.WFEV	/WAIT UNTIL DONE

	LAC	I.PCPB+1 /UP THE ADDRESS

	CLL

	TAD	(400	/TO THE NEXT BLOCK

	DAC	I.PCPB+1

	SZL		/IF OVERFLOW

	ISZ	I.PCPB	/UP THE HIGH-ORDER WORD ALSO

	LAW	-400	/COUNT DOWN

	TAD	I.WRK	/TO ZERO

	SMA!SZA		/DONE?

	JMP	.-14	/NO, KEEP ON

/

/THE DISK SPACE HAS BEEN ALOCATED, AND ALL OF IT IS ZEROED. NOW TO

/BRING THE CODE IN.

/

	LAC	I.ALSZ	/PICK UP THE SIZE OF THE ALLOCATION

	DAC	I.BLOK	/SET THIS IN AS WORD ZERO OF THE BLOCK

	LAC	I.PTNM	/NAME

	DAC	I.BLOK+1

	LAC	I.PTNM+1 /NAME

	DAC	I.BLOK+2

	LAC	I.CORB	/BASE

	DAC	I.BLOK+3

	LAC	I.ALSZ+2 /SET UP THE DISK GET/PUT CONTROL TABLE

	DAC	I.PCPB+1 /SO THE FIRST WRITE WILL SEND OUT

	LAC	I.ALSZ+1 /THE BLOCK WITH THE ALLOCATION SIZE IN IT

	DAC	I.PCPB

	XOR	I.ALSZ+2 /SET THIS BLOCK (IN CORE) AS BEING THE

	DAC	I.THIS	/FIRST ONE

	ADD	(400)	/NOW UP TO THE BLOCKS TO BE USED

	DAC	I.DSKB	/SAVE AS BASE OF LINK ZERO

	DAC	I.LBSE	/SET THIS ALSO AS THE BASE FOR THE FIRST LINK

	LAW	-1	/SHOW THAT CURRENT BLOCK HAS BEEN MODIFIED

	DAC	I.WRIT	/SO IT WILL BE WRITTEN OUT

/

/EXPAND THE LINK TABLE IF IT EXISTS

/

	JMS	I.EXPL	/DO IT

	JMS	SEEK	/RE-SEEK THE FILE

	DZM	I.LKNM	/FIND LINK #0

	JMS	I.FLNK	/

I.LOOP	JMS	I.EXPL	/EXPAND THIS LINK

	LAC	I.MXDK	/PICK UP THE MAXIMUM DISK BLOCK USED

	SZA

	JMP	.+3

	LAC	I.THIS

	DAC	I.MXDK

	ADD	(400)	/UP TO THE NEXT ONE

	DAC	I.WRK	/SAVE THIS AS THE BASE FOR THE NEXT LINK

	LAC	INBUF+3	/LAST LINK?

	SAD	(377777) /SKIP IF NOT

	JMP	I.DEXP	/YES, DONE EXPANDING THE TSK FILE

	JMS	I.LKTB	/NO, SET UP THE LINK TABLE FOR THE NEXT LINK

	JMP	I.LOOP	/ AND GO FOR MORE

/

/SUBROUTINE TO READ THROUGH UNTIL A CERTAIN LINK IS FOUND

/

I.FLNK	XX		/LINK NUMBER IS IN I.LKNM

	JMS	READ	/READ A RECORD

	LAC	INBUF+2	/IS THIS A TYPE ONE RECORD?

	AND	(IOT)

	SAD	(JMS)	/SKIP IF NOT

	JMP	I.OVRP	/IT IS, IS IT THE ONE WE WANT?

	SNA		/IT ISN'T - ERROR VIA TYPE 0 RECORD?

	JMP	I.ER10	/YES, LEAVE

	JMP	I.FLNK+1 /CYCLE ON FOR MORE

I.OVRP	LAC	INBUF+3	/TYPE ONE RECORD FOUND, IS IT THE ONE WE WANT?

	SAD	I.LKNM	/SKIP IF NOT

	JMP*	I.FLNK	/IT IS, LEAVE

	ISZ	I.ACNT	/IT IS NOT, COUNT THE LINKS FOUND

	NOP		/ANYWAY

	JMP	I.FLNK+1 /AND GO FOR MORE

/

/

/SUBROUTINE TO EXPAND A LINK. THE TYPE ONE RECORD HAS BEEN READ. UPON

/EXIT, A TYPE ONE RECORD WILL BE IN 'INBUF'.

/

I.EXPL	XX

	DZM	I.MXDK	/CLEAR OUT THE HIGHEST DISK ADDRESS USED

/

/I.LBSE SHOULD CONTAIN THE BASE DISK ADDRESS FOR THIS LINK

/I.LCOR SHOULD CONTAIN THE BASE CORE ADDRESS THAT CORESPONDS TO I.LBSE

/

I.EXLP	LAC	(INBUF+2)

	DAC	I.PNTR	/SET UP FOR 'GETW' ROUTINE

	JMS	READ	/READ A RECORD

	LAC	INBUF+2	/IS IT A TYPE TWO RECORD?

	AND	(IOT)

	SAD	(LAC)	/SKIP IF NOT

	JMP	I.TYP2	/IT IS, PROCESS IT

	SAD	(ADD)	/TYPE THREE?

	JMP	I.TYP3	/YES, PROCESS IT

	SAD	(JMS)	/TYPE ONE?

	JMP*	I.EXPL	/YES, LEAVE

	LAC	INBUF+2	/IS THIS THE EOF ON LINK EXPANSION?

	SZA		/MAYBE

	JMP	I.ER10	/NO, READ ERROR

	LAC	I.LKNM	/CHECK TO SEE IF THIS IS LINK 377777

	SAD	(377777) /SKIP IF NOT

	JMP*	I.EXPL	/IT IS, LEAVE

	JMP	I.ER10	/IT ISN'T - READ ERROR

I.TYP2	JMS	I.GETW	/PICK UP THE COUNT

	SAD	(-1)	/SKIP IF NOT THE END OF THE RECORD

	JMP	I.EXLP	/IT IS, GO FOR MORE RECORDS

	AND	(077777) /SINGLE IT OUT

	TCA		/NEGATE IT

	DAC	I.ACNT	/SAVE IT

	JMS	I.GETW

	JMS	I.GETA	/PICK UP AN ADDRESS AND READ THAT BLOCK INTO CORE

I.T2LP	JMS	I.GETW	/PICK UP A WORD

	JMS	I.PUTW	/SET IT DOWN

	ISZ	I.ACNT	/SKIP WHEN DONE

	JMP	I.T2LP	/UNTIL THEN

	JMP	I.TYP2	/GO UNTIL DONE

/

/SUBROUTINE TO PICK UP ONE WORD FROM THE BUFFER

/

I.GETW	XX

	LAC*	I.PNTR	/PICK IT UP

	ISZ	I.PNTR	/INCREMENT IT

	JMP*	I.GETW	/AND LEAVE

/

/SUBROUTINE TO PUT ONE WORD INTO THE DISK BLOCK

/(A CALL TO I.GETA SHOULD BE DONE FIRST TO SET UP THE PARAMETERS)

/

I.PUTW	XX

	DAC*	I.DPNT	/SET IT IN

	LAW	-1	/SHOW THAT THE BLOCK

	DAC	I.WRIT	/HAS BEEN MODIFIED

	ISZ	I.DPNT	/INCREMENT THE POINTER

	ISZ	I.BCNT	/SEE IF THE END OF THE BLOCK HAS BEEN REACHED

	JMP*	I.PUTW	/IT HASN'T, LEAVE

	LAC	I.THIS	/GO TO THE NEXT BLOCK

	ADD	(400)	/FOR THE CONTINUATION OF THIS ESCAPADE

	JMS	I.XDSK	/PICK UP THE BLOCK 

	LAC	(I.BLOK) /AND RESET THE

	DAC	I.DPNT	/POINTERS

	LAW	-400	/TO THE DISK

	DAC	I.BCNT	/BLOCK

	JMP*	I.PUTW	/LEAVE

/

/SUBROUTINE TO SEE THAT THE DISK BLOCK THAT WILL CONTAIN A CERTAIN ADDRESS

/IS IN CORE, AND TO SET UP POINTERS FOR I.PUTW

/CALL WITH THE DESIRED CORE ADDRESS IN THE AC - IT WON'T BE THERE ON RETURN

/

I.GETA	XX

	AND	(077777)

	TCA	/NEGATE

	TAD	I.LCOR	/ADD IN THE BASE

	TCA		/POP BACK TO POSITIVE

	DAC	I.DPNT	/SAVE

	AND	(-400)	/FIND OUT WHICH RELATIVE BLOCK

	ADD	I.LBSE	/FIND OUT WHICH ACTUAL BLOCK

	JMS	I.XDSK	/BRING THAT ONE INTO CORE

	LAC	(377)	/NOW WE PICK UP

	AND	I.DPNT	/THE OFFSET INTO THE DISK BLOCK

	AAC	-400	/CREAT THE NUMBER OF WORDS LEFT IN THE BLOCK

	DAC	I.BCNT	/SAVE THIS AS A COUNTER FOR I.PUTW

	TAD	(I.BLOK+400) /UP TO THE CORE ADDRESS IN REAL CORE

	DAC	I.DPNT	/WHERE THE WORD IS

	JMP*	I.GETA	/LEAVE

/

/SUBROUTINE TO MAKE CERTAIN THAT THE CORRECT BLOCK IS IN CORE. THE

/ONE CURRENTLY IN CORE IS WRITTEN OUT, IF IT HAS BEEN MODIFIED (I.WRIT=-1)

/

I.XDSK	XX		/ENTRY

	DAC	I.BCNT	/SAVE THIS

	XOR	I.THIS	/IS THE BLOCK THE ONE THAT IS IN CORE?

	SNA		/SKIP IF NOT

	JMP*	I.XDSK	/IT IS, LEAVE

	XOR	I.THIS	/RESORE THE ORIGINAL AC CONTENTS

	LMQ		/FIND OUT IF THE BLOCK JUST ABOUT TO BE READ IN

	LLS	12	/IS HIGHER NUMBERED THAN THE ONE SHOWN IN I.MXDK

	DAC	I.GETW	/SAVE THIS

	LAC	I.MXDK	/PICK UP THE CURRENT MAXIMUM

	LMQ

	LLS	12	/CREATE A PROPER COMPARISON NUMBER

	TCA		/NEGATE

	TAD	I.GETW	/ADD IN THE ONE WE ARE ABOUT TO GET

	RAL		/SAVE THE SIGN

	LAC	I.BCNT	/PICK UP THE ONE WE WANT

	SNL		/SKIP IF IT IS LOWER

	DAC	I.MXDK	/IF HIGHER OR EQUAL, RESET I.MXDK

	ISZ	I.WRIT	/HAS THE CURRENT RECORD BEEN MODIFIED?

	JMP	.+3	/NO, SO JUST READ THE NEW ONE IN

	CAL	I.PUTC	/PUT OUT THE CURRENT BLOCK

	JMS	I.WFEV	/WAIT UNTIL DONE

	DZM	I.WRIT	/CLEAR THE 'THE BLOCK HAS BEEN MODIFIED' FLAG

	LAW	777400	/PICK UP THE

	AND	I.BCNT	/BLOCK NUMBER

	DAC	I.PCPB+1 /AND SET IT IN THE DISK CONTROL TABLE

	XOR	I.BCNT	/PICK UP THE UNIT NUMBER

	DAC	I.PCPB	/AND SET IT IN ALSO

	XOR	I.PCPB+1 /NOW SET THE CURRENT BLOCK POINTER

	DAC	I.THIS	/TO POINT TO WHERE WE ARE NOW

	CAL	I.GETC	/GET THE NEW BLOCK

	JMS	I.WFEV	/WAIT

	JMP*	I.XDSK	/AND LEAVE

/

/

I.TYP3	XOR	INBUF+2	/PICK UP THE TOTAL NUMBER OF PATCHES

	SPA!SNA		/SKIP IF THERE ARE ANY

	JMP	I.EXLP	/NO, LOOK FOR SOMETHING ELSE TO DO

	DAC	I.TOTP	/SAVE THIS

I.T3LP	ISZ	I.PNTR	/FIND OUT HOW MANY

	JMS	I.GETW	/PATCHES ON THIS RECORD

	SPA!SNA!TCA	/SKIP IF THERE ARE ANY

	JMP	I.EXLP	/NO, CARRY ON WITH THE NEXT RECORD

	DAC	I.CCNT	/YES, SAVE THE COUNT

	TAD	I.TOTP	/AND SUBTRACT THIS FROM THE TOTAL

	DAC	I.TOTP

I.T3LQ	LAC*	I.PNTR	/PICK UP THE ADDRESS

	AND	(077777) /WHERE THE PATCH GOES

	JMS	I.GETA	/MAKE SURE THAT IT IS IN CORE

	JMS	I.GETW	/FIND OUT WHAT THE FUNCTION IS

	AND	(IOT)

	SAD	(JMS)	/IS IT ADDRESS FIELD MODIFICATION?

	JMP	I.T3AD	/YES, DO IT

	SAD	(LAC)	/IS IT BLANK COMMON OFFSET?

	JMP	I.T3CO	/YES

	SZA		/IS IT SIMPLE REPLACEMENT?

	JMP	I.ER10	/NO, MUST BE A READ ERROR

	JMS	I.GETW	/PICK UP THE WORD

I.T3BK	DAC*	I.DPNT	/SET IT IN THE DISK BLOCK

	LAW	-1	/SET THE 'MODIFIED BLOCK' FLAG

	DAC	I.WRIT	/TO SHOW THAT WE CHANGED THE BLOCK

	ISZ	I.CCNT	/COUNT THE PATCHES

	JMP	I.T3LQ	/NOT YET DONE, GO FOR MORE

	LAC	I.TOTP	/ARE WE COMPLETELY DONE?

	SPA!SNA		/SKIP IF NOT

	JMP	I.EXLP	/YES, READ A TYPE ONE RECORD

	JMS	READ	/NO, RESET FOR THE NEXT PATCH RECORD

	LAC	(INBUF+2)

	DAC	I.PNTR	/SET UP FOR 'GETW'

	LAC	INBUF+2	/MAKE CERTAIN THAT THIS IS

	AND	(IOT)	/A TYPE THREE RECORD

	SAD	(ADD)	/SKIP IF NOT

	JMP	I.T3LP	/IT IS, FINISH UP

	JMP	I.EXLP+3 /IT ISN'T, WHAT HAPPENED???

I.T3AD	LAC	I.ENTR	/PICK UP THE TASK ENTRY POINT

	RAL		/BANK/PAGE BIT TO AC0

	SMA!CLA

	LAC	(010000) /PAGE MODE, MUST KEEP THE INDEX BIT

	XOR	(760000) /CREATE A MASK

	PAL		/SAVE THIS

	AND*	I.DPNT	/PICK UP THE INSTRUCTION FIELD ONLY

	LMQ		/SAVE THIS

	PLA		/BRING THE MASK BACK

	CMA		/FLIP IT OVER

	AND*	I.PNTR	/BRING IN THE NEW ADDRESS FIELD

	OMQ		/AND BRING THE INSTRUCTION OUT

	ISZ	I.PNTR	/UP THE POINTER

	JMP	I.T3BK	/AND PUT THIS AWAY

I.T3CO	JMS	I.GETW	/PICK UP THE WORD

	TAD	I.BCBS	/ADD IN THE BASE OF BLANK COMMON

	JMP	I.T3BK	/AND PUT THE WORD AWAY

/

/

/SUBROUTINE TO SET UP THE LINK TABLE FOR THE LINK ABOUT TO BE PROCESSED

/

I.LKTB	XX

	LAC	I.CORB	/SET UP TO ACCESS ON LINK 0 LEVEL

	DAC	I.LCOR	/AS THIS IS LINK TABLE MODIFICATION

	LAC	I.DSKB

	DAC	I.LBSE

	LAC	I.LTBS	/PICK UP THE BASE ADDRESS OF THE LINK TABLE

	IAC		/PLUS ONE

I.LKLP	DAC	I.PNTR	/SAVE THIS

	JMS	I.GETA	/BRING THIS INTO CORE

	LAC*	I.DPNT	/IS THIS THE END OF THE LINK TABLE?

	SAD	I.LTBS	/SKIP IF NOT

	JMP	I.LKUP	/IT IS, SET UP FOR THE NEXT LINK

	LAC	I.PNTR	/PICK UP THE

	AAC	7	/LINK NUMBER WORD

	JMS	I.GETA	/

	LAC*	I.DPNT	/IS THIS THE LINK WE ARE WORKING ON NOW?

	SAD	INBUF+3	/SKIP IF NOT

	JMP	I.LKBS	/IT IS, SET UP THE DISK ADDRESS ON THIS ONE

I.LKMR	LAC	I.PNTR	/IT ISN'T, UP TO THE NEXT ONE

	AAC	13	/IN THE TABLE

	JMP	I.LKLP

/

/NOTE: EARLIER VERSIONS USED THE MINIMUM ADDRESS WORD TO FLAG THE LINKS

/THAT HAD BEEN UPDATED. HOWEVER, WITH THE LOW END OF THE DISK ALLOCATED

/TO THE SYSTEM IMAGE, IT IS VERY UNLIKELY THAT THE LINK NUMBERS WILL

/REACH THE SAME MAGNITUDE AS THE DISK ADDRESS THAT REPLACES IT.

/THEREFORE, THE SAD SHOULD BE ENOUGH.

/

I.LKBS	LAC	I.WRK	/SET THE BASE ADDRESS OF THIS LINK

	JMS	I.PUTW	/IN THE LINK TABLE

	LAC*	I.DPNT	/AND SET THE MINIMUM ADDRESS OF THE LINK

	DAC	I.TMP	/IN A SAFE PLACE FOR SETTIN I.LCOR WHEN DONE

	JMP	I.LKMR	/NOW LOOK AT THE NEXT LINK

/

I.LKUP	LAC	I.TMP	/SET THE CORE BASE ADDRESS FOR THIS LINK

	DAC	I.LCOR	/IN FOR DISK ADDRESS ADJUSTING

	LAC	I.WRK	/SET THE DISK BASE ADDRESS CORRESPONDING TO

	DAC	I.LBSE	/I.LCOR IN ALSO

	JMP*	I.LKTB	/AND LEAVE

/

/

/THE WHOLE THING IS DONE, NOW TO MAKE THE STL ENTRY FOR THIS TASK

/AND LEAVE THIS BLOODY MESS.

/

I.DEXP=.

	ISZ	I.WRIT	/DOES THE DISK BLOCK NEED RE-WRITING?

	JMP	I.DOVR	/NO, GO CLEAN UP

	CAL	I.PUTC	/YES, WRITE IT OUT

	JMS	I.WFEV	/AND WAIT FOR IT

I.DOVR	JMS*	(PENP)	/PICK AN EMPTY BEER CAN FROM THE POOL

	JMP	I.ER05	/AND SHOW AN ERROR IF NO LITTER IS AROUND

	DAC*	(R2)	/OTHERWISE, IF ONE IS FOUND, MAKE IT LOOK RESPECTABLE

	IAC		/BY CLEVERLY DISGUISING IS AS AN STL NODE FOR

	DAC*	(X11)	/THIS NEW TASK IN THE SYSTEM

	LAC	I.XM	/SET THE XVM MODE BITS IN THE STL NODE

	XOR	I.MXTR	

	DAC	I.MXTR

	LAC	TKNAM

	DAC*	X11

	LAC	TKNAM+1

	DAC*	X11

	LAC	(I.DFPR-1)

	DAC*	(X10)

	LAW	-6

	DAC	I.ACNT	/BY MOVING IT FROM THE NEAT BLOCK IT IS IN

	LAC*	X10	/FRESHLY PICKED

	DAC*	X11	/NODE

	ISZ	I.ACNT

	JMP	.-3

/

	LAC	(STKL)	/NOW ADD THIS TO

	DAC*	(R1)	/THE STL (R2 IS SET FROM ABOVE) (THANK GOD)

	JMS*	(NADD)

/

	JMP*	INSTAL	/DONE, LEAVE IF SCF SUBROUTINE

I.ERRR	DAC	I.ERRA	/SET THE ADDRESS OF THE MESSAGE TO PRINT

	JMS*	(TYPE)	/START PRINTING

	MES900		/THEE ERROR

	LAC	(SCFIB+1)	/NOW TO CREATE THE TASK NAME IN

	DAC*	(X10)	/IMAGE MODE

	LAC	TKNAM

	JMS	EREXS1	/FIRST THREE

	LAC	TKNAM+1

	JMS	EREXS1	/LAST THREE

	CAL	SCFTIB	/WRITE IT OUT

	CAL	WFCPB	/WAIT

	JMS*	(TYPE)	/NOW FINISH THE 'TASK XXXXXX NOT INSTALLED'

	MES901

	JMS*	(TYPE)	/PUT OUT THE REASON

I.ERRA	XX

	LAC	I.DSKA	/DISK SPACE ALLOCATED?

	SNA		/SKIP IF SO

	JMP	.+3	/OVER IF NOT

	CAL	I.DCPB	/DEALLOCATE IT IF SO

	CAL	I.WAIT

	JMP*	INSTAL	/AND LEAVE

/

EREXS1	XX

	LMQ

	JMS	EREXS2

	JMS	EREXS2

	JMS	EREXS2

	JMP*	EREXS1

/
EREXS2	XX

	LLS	6

	AND	(77)

	SNA

	AAC	177

	XOR	(40)

	TAD	(40)

	DAC*	X10

	JMP*	EREXS2
/
								/EAG:202
	.IFDEF L.SCF						/EAG:202
								/EAG:202
	.DEFIN ABUF,TEXT,?B					/EAG:202
	  .NOLST						/EAG:202
	  B-./2*1000+2 ; 0					/EAG:202
	  .ASCII \@TEXT@\<15>					/EAG:202
B=.								/EAG:202
	  .LST							/EAG:202
	.ENDM							/EAG:202
								/EAG:202
	.ENDC							/EAG:202
								/EAG:202
								/EAG:202
	.IFUND L.SCF						/EAG:202
								/EAG:202
	.DEFIN	ABUF,TEXT,?B

	B-./2*1000+2 ; 0

	.ASCII	\@TEXT@\<15>

B=.
	.ENDM
								/EAG:202
	.ENDC							/EAG:202
								/EAG:202
								/EAG:202
I.ER02	LAC	(I.ME02)
	JMP	I.ERRR

I.ER03	LAC	(I.ME03)

	JMP	I.ERRR	/ERROR ROUTINES - PICK UP THE MESSAGE ADDRESS

I.ER04	LAC	(I.ME04) /AND GO OFF TO DO THE WORK

	JMP	I.ERRR

I.ER05	LAC	(I.ME05)

	JMP	I.ERRR

I.ER06	LAC	(I.ME06)

	JMP	I.ERRR

I.ER07	LAC	(I.ME07)

	JMP	I.ERRR

I.ER08	LAC	(I.ME08)

	JMP	I.ERRR

I.ER09	LAC	(I.ME09)

	JMP	I.ERRR

I.ER10	LAC	(I.ME10)

	JMP	I.ERRR

I.ER12	LAC	(I.ME12)

	JMP	I.ERRR

I.ER14	LAC	(I.ME14)

	JMP	I.ERRR

I.ER15	LAC	(I.ME15)

	JMP	I.ERRR

/

/ERROR MESSAGES:

/

I.ME01	ABUF	<SYNTAX ERROR>

I.ME02	ABUF	<TASK ALREADY IN SYSTEM>

I.ME03	ABUF	<PARTITION NOT IN SYSTEM>

I.ME04	ABUF	<TASK WOULD OVERFLOW PARTITION>

I.ME05	ABUF	<OUT OF POOL>

I.ME06	ABUF	<OUT OF DISK>

I.ME07	ABUF	<INPUT CHECKSUM ERR>

I.ME08	ABUF	<INPUT PAR ERR>

I.ME09	ABUF	<SYS COM BLK ERR>

I.ME10	ABUF	<READ ERR ON LUN 5>

I.ME11	ABUF	<DISK ERR>

I.ME12	ABUF	<NO DEFAULT PRIORITY>

I.ME13	ABUF	<FILE NOT FOUND ON LUN 5>

I.ME14	ABUF	<RELOCATION HARDWARE NOT AVA>

I.ME15	ABUF	<FLOATING POINT UNIT NOT AVA>

/

/SUBROUTINE TO WAIT FOR I.EV AND ANNOUNCE A DISK ERROR IF NEGATIVE WHEN

/COMPLETE.

/

I.WFEV	XX

	CAL	I.WAIT	/WAIT

	LAC	I.EV

	SMA		/ERRORS?

	JMP*	I.WFEV	/NO, LEAVE

I.ER11	LAC	(I.ME11)	/DISK ERROR

	JMP	I.ERRR	/ANNOUNCE IT AND CLEAN UP

/

/

/VARIABLES, CONSTANTS, AND CPBS WITH BUFFERS AS A SIDELINE

/

I.XM	0	/XVM MODE BITS

I.ACNT	0	/SCRATCH LOCATIONS

I.TMP	0

I.BCNT	0

I.CCNT	0

I.WRK	0

I.DPNT	0	/POINTER USED PRIMARILY BY I.PUTW

I.MXDK	0	/MAXIMUM DISK BLOCK USED BY THE CURRENT LINK

I.THIS	0	/DISK ADDRESS OF CURRENT BLOCK IN CORE

I.WRIT	0	/-1 WHEN CURRENT BLOCK HAS BEEN MODIFIED, 0 IF NOT

I.DSKA	0	/INDICATOR THAT THE DISK AREA HAS BEEN ALLOCATED (0 IF NOT)

I.LBSE	0	/DISK BASE ADDRESS FOR CURRENT LINK

I.LCOR	0	/CORE ADDRESS CORRESPONDING TO I.LBSE

I.LKNM	0	/NUMBER OF LINK BEING SOUGHT BY I.FLNK

I.PTNM	0 ; 0   /PARTITION NAME

I.TOTP	0	/COUNTER FOR PATCH RECORDS

I.LTBS	0	/LINK TABLE BASE ADDRESS

I.DFPR	0	/PRIORITY OF TASK

I.PBAD	0	/PARTITION DESCRIPTOR BLOCK ADDRESS

I.DSKB	0	/DISK BASE ADDRESS

I.RISZ	0	/RESIDENT IMAGE SIZE

I.MXTR	0	/MAXIMUM TASK REGISTER (CHANGED TO SIZE FOR STL NODE)

I.ENTR	0	/TASK ENTRY PC (WITH BANK/PAGE AND EXEC/NORM MODE BITS)

/

I.BCBS	0	/BASE OF BLANK COMMON FOR PATCHING

I.PNTR	0	/POINTER USED BY I.GETW

I.CORB	0	/CORE BASE ADDRESS (CORRESPONDING TO I.DSKB)

/

I.WAIT	20	/CPB FOR WAITING

	I.EV		/FOR THE EV

/

I.EV	0	/GENERAL PURPOSE EV

/

I.ACPB	1500	/ALLOCATE DISK SPACE CPB

	I.EV

	1	/ALLOCATE ON DISK - LUN 1

	I.ALSZ	/ADDRESS OF ALLOCATE/DEALLOCATE DISK CONTROL TABLE

/

I.DCPB	1600	/DEALOCATE DISK SPACE CPB (IN CASE OF ERRORS)

	I.EV

	1

	I.ALSZ	/OTHERWISE, SAME AS I.ACPB

/

I.ALSZ	0	/ALLOCATE/DEALLOCATE CONTROL TABLE

	0 ; 0

/

I.GETC	3000	/GET (DISK) CPB

	I.EV

	1

	I.PCPB	/GET/PUT CONTROL TABLE

/

I.PUTC	3100	/PUT (DISK) CPB

	I.EV

	1

	I.PCPB	/SAME AS I.GETC

/

I.PCPB	0	/GET/PUT CONTROL TABLE

	0	/DISK ADDRESS IS PUT HERE

	I.BLOK	/ALL I/O TO/FROM DISK IS DONE THROUGH THE I.BLOK BUFFER

	400	/AND IS EXACTLY ONE BLOCK LONG

/

I.BLOK	.BLOCK	400	/DISK I/O BUFFER

/

INBUF	.BLOCK	42	/INPUT BUFFER

TCX	0

	SAD	(015)	/SUBROUTINE TO SKIP IF AC DOES NOT

	JMP*	TCX	/CONTAIN A TERMINATOR

	SAD	(175)

	JMP*	TCX

	ISZ	TCX

	JMP*	TCX

ERR10=I.ER10		/TO ALLOW LABEL REFERENCING

BXTPL	.+NDSZ		/EXTENSION FOR POOL TO TYPE ERROR MESSAGE

	POOL

	.REPT NDSZM2

	0

/

	EN

/

EXTPL	POOL

	.-1-NDSZ

	.REPT NDSZM2

	0

/

	.EJECT

/
	TEXT 400,< >>,<175>,L.SCF
	TEXT 498,<*** IF YOU HAVE KT15 (MEMORY RELOCATE) THE>,<15>,L.SCF
	TEXT 499,<*** PROTECT/RELOCATE SWITCH IS SET WRONG>,<15>,L.SCF
	TEXT 500,<XVM/RSX VERSION 1B CONFIGURATOR;>,<15>,L.SCF	/(162)
	TEXT 577,<NUMBERS IN DECIMAL UNLESS NOTED;>,<15>,L.SCF
	TEXT 578,<'CR' GIVES VALUE IN '[]'S.>,<15>,L.SCF
	TEXT 501,<SPECIFY CORE SIZE[32K]>,<175>,L.SCF
	TEXT 503,<ILLEGAL NUMBER OF TTY'S PATCHED IN>,<15>,L.SCF
	TEXT 504,<SPECIFY NUMBER OF CLOCK TICKS PER SECOND[60]>,<175>,L.SCF
	TEXT 519,<NODES IN POOL>,<15>,L.SCF
	TEXT 520,<SYSTEM IS RUNNING>,<15>,L.SCF
	TEXT 530,<HOW MANY LARGE NODES?[10]>,<175>,L.SCF
	TEXT 531,<HOW MANY SMALL NODES?[150]>,<175>,L.SCF
	TEXT 532,<SYSTEM DISK; [RF], RP, RK>,<175>,L.SCF
	TEXT 533,<HOW MANY RF PLATTERS?[0]>,<175>,L.SCF
	TEXT 534,<HOW MANY RP DISKS?[0]>,<175>,L.SCF
	TEXT 535,<HOW MANY RK DISKS?[0]>,<175>,L.SCF
	TEXT 536,<MCR PARTITION SIZE, OCTAL[3000]>,<175>,L.SCF
	TEXT 591,<^^^ SYNTAX ERR AT "X" -- RETYPE>,<15>,L.SCF
	TEXT 592,<^^^ INVALID SIZE -- RETYPE>,<15>,L.SCF
	TEXT 593,<^^^ INVALID NUMBER -- RETYPE>,<15>,L.SCF
	TEXT 594,<^^^ NAME ALREADY USED -- RETYPE>,<15>,L.SCF
	TEXT 595,<IMPOSSIBLE, CALL MAYNARD>,<15>,L.SCF
	TEXT 596,<NODES WOULD OVERFLOW DISK PARTITION>,<15>,L.SCF
	TEXT 598,<*** RE-ENTRANT ECO PACKAGE NEEDED>,<15>,L.SCF
	TEXT 599,<INSUFFICIENT CORE OR NODES,TRY AGAIN>,<15>,L.SCF
	.IFUND %DTCLD
	TEXT 600,<INSTALLATION OF TASKS FROM SYSTEM DISK>,<15>,L.SCF
	.ENDC
	.IFDEF %DTCLD
	TEXT 600,<INSTALLATION OF TASKS FROM DT-0>,<15>,L.SCF
	.ENDC
	TEXT 900,<TASK ">,<175>,L.SCF
	TEXT 901,<" NOT INSTALLED, >,<175>,L.SCF
	TEXT 902,<TASK ALREADY IN SYSTEM>,<15>,L.SCF
	TEXT 903,<PARTITION NOT IN SYSTEM>,<15>,L.SCF
	TEXT 904,<TASK WOULD OVERFLOW PARTITION>,<15>,L.SCF
	TEXT 906,<OUT OF DISK STORAGE>,<15>,L.SCF
	TEXT 907,<INPUT CHECKSUM ERR>,<15>,L.SCF
	TEXT 908,<INPUT PARITY ERR>,<15>,L.SCF
	TEXT 910,<READ ERROR>,<15>,L.SCF
	TEXT 911,<DISK WRITE ERROR>,<15>,L.SCF
	TEXT 912,<NO DEFAULT PRIORITY>,<15>,L.SCF
	TEXT 913,<RELOCATION HARDWARE NOT AVAILABLE>,<15>,L.SCF
	TEXT 914,<FLOATING POINT UNIT NOT AVAILABLE>,<15>,L.SCF
	TEXT 915,<'RSX' UFD NOT ON SYSTEM DISK>,<15>,L.SCF
/
/ DKGET -- SUBROUTINE TO READ DISK PER 'GETCPB'

/

DKGET	0

	JMS	D.SETU	/SET UP THE INFO IN A WAY WE CAN CHANGE

D.GLOP	JMS	D.GETI	/SET UP THE RIGHT DISK BLOCK IN CORE ANS ALL OF

			/THE PARAMETERS NEEDED TO MOVE

	LAC*	D.DSKA	/READING - MOVE FROM DISK

	DAC*	D.CORA	/TO CORE

	ISZ	D.DSKA

	ISZ	D.CORA

	ISZ	D.CNT	/DONE?

	JMP	.-5	/NO

	LAC	D.CWC	/HAS THE WC GONE TO ZERO?

	SMA!SZA		/SKIP IF SO

	JMP	D.GLOP	/NO, KEEP ON LOOKING

	JMP*	DKGET	/YES - LEAVE

/

D.SETU	XX

	LAC	DKXUN

	DAC	D.CUN

	LAC	DKXDA

	DAC	D.CDA

	LAC	DKXCA

	DAC	D.CORA

	LAC	DKXWC

	DAC	D.CWC

	JMP*	D.SETU

/

D.GETI	XX

	LAW	-400

	AND	D.CDA

	XOR	D.CUN

	XOR	D.THIS	/IS IT THE ONE IN CORE?

	SNA		/SKIP IF NOT

	JMP	D.GOTX	/IT IS - NO NEED TO GO TO THE DISK

	ISZ	D.MODI	/HAS THE BLOCK IN CORE BEEN MODIFIED?

	JMP	D.GOV	/NO, SKIP THE WRITE

	CAL	D.WRIT	/WRITE IT OUT

	CAL	WFCPB	/WAIT

	LAC	EV	/OK?

	SPA		/SKIP IF SO

	JMP	D.DKER	/NO - DISK ERROR

D.GOV	LAW	-400

	AND	D.CDA

	DAC	D.XDA

	LAC	D.CUN

	DAC	D.XUN

	XOR	D.XDA

	DAC	D.THIS	/SET UP THE NEW ONE AS BEING IN CORE

	CAL	D.READ	/READ IT IN

	CAL	WFCPB	/WAIT

	LAC	EV

	SPA		/OK?

	JMP	D.DKER	/NO

D.GOTX	LAC	(377

	AND	D.CDA

	DAC	D.OFST	/OFFSET INTO THE BLOCK

	TAD	(I.BLOK

	DAC	D.DSKA	/SET UP THE ADDRESS

	LAC	D.OFST

	AAC	-400

	DAC	D.OFST

	TAD	D.CWC	/ALL IN THIS BLOCK?

	DAC	D.CWC

	SMA		/YES, AND TOO MUCH MORE

	JMP	D.GXIT	/NO, OR EXACTLY,  LEAVE

	LAC	D.OFST

	TCA

	TAD	D.CWC

	TCA

	DAC	D.OFST

D.GXIT	LAC	D.OFST	/NOW UP THE PARAMETERS

	TCA		/FOR THE TRANSFER

	CLL

	TAD	D.CDA	/UP THE DISK ADDRESS

	DAC	D.CDA	/RESET

	SZL		/OVERFLOW?

	ISZ	D.CUN	/YES - UP THE UNIT NUMBER

	DZM	D.MODI	/CLEAR THE MODIFICATION FLAG

	JMP*	D.GETI	/LEAVE

D.CUN

D.CDA

D.CWC

D.CORA

D.CNT

D.OFST=D.CNT

D.XUN	0		/DISK CONTROL TABLE FOR REAL TRANSFERS

D.XDA	0

	I.BLOK

	400

D.THIS	-1		/CURRENT BLOCK

D.DSKA

D.MODI	0		/NOT YET MODIFIED

D.DKER	JMS*	(TYPE)

	D.MESG

	XX

	JMP	.-1

D.MESG	D.MEND-./2*1000+2 ; 0

	.ASCII	'***** DISK I/O ERROR - ABORT'<15>

D.MEND=.

/

/ DKPUT -- SUBROUTINE TO WRITE DISK PER 'PUTCPB'

/

DKPUT	0

	JMS	D.SETU	/SET UP

D.PLOP	JMS	D.GETI	/SET THE BLOCK PARAMETERS

	LAC*	D.CORA	/WRITING - MOVE FROM DORE

	DAC*	D.DSKA	/TO DISK

	ISZ	D.CORA

	ISZ	D.DSKA

	ISZ	D.CNT	/DONE?

	JMP	.-5	/NO

	LAC	D.CWC	/HAS THE WC GONE TO 0?

	SMA!SZA!CLC	/YES - SKIP

	JMP	D.PLOP	/NO - CONTINUE

	DAC	D.MODI	/SHOW THAT THE BLOCK HAS BEEN MODIFIED

	JMP*	DKPUT

/

/ CAL PARAMETER BLOCKS

/

WFCPB	20		/WAIT FOR 'EV'

	EV

/
REQCPB	1		/ REQUEST RSX WARM BOOTSTRAP AND SAVE.	/(172)
	0
	.SIXBT "..."
	.SIXBT "SAV"						/(172)

	0

/

ENATDV	22		/ENABLE TASK "TDV...".

	0

	.SIXBT "TDV"

	.SIXBT "..."

	.IFDEF %DTCLD

/

CDTCPB	11		/CONNECT DECTAPE INTERRUPT LINE

	0

	4

	DTINT

/

DDTCPB	12		/DISCONNECT DECTAPE INTERRUPT LINE

	0

	4

	DTINT

	.ENDC

/

ALLCPB	1500		/ALLOCATE DISK STORAGE

	EV

	1

	DSKCT1

/

DALCPB	1600		/DEALLOCATE

	EV

	1

	DSKCT1

/

D.READ	3000		/GET -- DISK-TO-CORE XFR

	EV

	1

	D.XUN		/POINTER TO THE BUILT-UP CONTROL TABLE

/

D.WRIT	3100		/PUT -- CORE-TO-DISK XFR

	EV

	1

	D.XUN		/SAME AS ABOVE

/

EV	0		/GENERAL EVENT VARIABLE

/

/ DISK (DEVICE DEPENDENT) CONTROL TABLES

/

DSKCT1=.    /ALLOCATE-DEALLOCATE CONTROL TABLE

DKARS	0		/REQUIRED STORAGE IN WORDS

DKAUN	0		/UNIT OF ALLOCATED AREA

DKABA	0		/BASE ADDRESS OF ALLOCATED AREA

/

DSKCT2=.    /GET-PUT CONTROL TABLE

DKXUN	0		/UNIT NUMBER

DKXDA	0		/DISK ADDRESS

DKXCA	0		/CORE ADDRESS

DKXWC	0		/WORD COUNT

/

/ DISK BIT MAP -- 256 WORDS OF DISK STORAGE ARE REPRESENTED BY EACH

/ BIT -- 16 BITS PER MAP-WORD -- 4096 STORAGE WORDS ARE REPRESENTED 

/ BY EACH MAP-WORD -- 64 MAP-WORDS PER DISK UNIT.  THE BIT MAP IS

/ RECORDED AT DISK ADDRESS 777400 (THE 1ST 1/4 OF THE HIGHEST 256 WORDS).

/

DKBMAP	.BLOCK 100

/

/ 1ST UFD BLOCK.

/

	.LOC	DKBMAP

DKUFD	.BLOCK	400

/

	.EJECT

/ DECTAPE HANDLER

/

FW=000000	/FORWARD

RV=040000	/REVERSE

NG=000000	/NO GO (STOP)

GO=020000	/GO

NM=000000	/NORMAL MODE

CM=010000	/CONTINUOUS MODE

MV=000000	/MOVE

SE=001000	/SEARCH

RD=002000	/READ DATA

WD=004000	/WRITE DATA

DI=000000	/DISABLE DT INTERRUPTS

EI=000400	/ENABLE DT INTERRUPTS

CE=000000	/CLEAR ERR FLAG

PE=000200	/PRESERVE ERR FLAG

CD=000000	/CLEAR DONE FLAG

PD=000100	/PRESERVE DONE FLAG

/

DTCA=707541	/CLEAR STATUS REGISTER-A

DTRA=707552	/READ STATUS REGISTER-A

DTRB=707572	/READ STATUS REGISTER-B

DTXA=707544	/XOR AC INTO STATUS REG-A

DTLA=707545	/LOAD STATUS REG-A FROM AC

DTDF=707601	/SKIP ON DECTAPE DONE FLAG

DTEF=707561	/SKIP ON DECTAPE ERR FLAG

/

WCA	30	/WORD COUNT REGISTER ADDRESS

CAA	31	/CURRENT ADDRESS REGISTER ADDRESS

/

/ FTSK -- FIND FILES WITH "TSK" EXTENSIONS AND RECORD THE STARTING

/ BLOCK NUMBER AND THE TWO WORD TASK NAME IN THE FILE DESCRIPTION

/ TABLE ('FDT').  THE 'FDT' IS TERMINATED BY A ZERO ENTRY.

/

/

FTSK	0

	.IFDEF %DTCLD

	LAC	DTUN	/SELECT DECTAPE UNIT

	DTLA

	LAC	(RD!SE)	/SET RW-FLAG TO READ

	DAC	RWSW

	LAC	(JMP FXBLK) /FIND & READ BLOCK #100

	DAC	DISPX

	LAC	(100)

	JMS	WFDT

	.ENDC

	.IFUND %DTCLD

	CAL	DOTGET	/GET A UFD BLOCK FROM THE PACK

	JMS	.WFDP

	LAC	DBUF+377

	DAC	.NUFD	/POINTER TO NEXT UFD BLOCK (OR -1)

	.ENDC

/

	LAC	(FDT-1)/SETUP 'FSBN' INDEX

	DAC*	(X13)

	.IFDEF %DTCLD

	LAC	(DBUF+40)/SETUP XR & LR TO SCAN DIRECTORY

	.ENDC

	.IFUND %DTCLD

	LAC	(DBUF

	.ENDC

	AND	(007777)

	PAX

	.IFDEF %DTCLD

	TAD	(340)

	.ENDC

	.IFUND %DTCLD

/

/  WARNING FLAG ??><4><?? WHY NOT 374????

/

	TAD	(370

	.ENDC

	PAL

/

FTSK1	LAC	2,X	/"TSK" EXTENSION?

	SAD	(242313)

	SKP

	JMP	FTSK2	/NO -- AUG XR

	.IFDEF %DTCLD

	LAC	3,X	/YES -- IS EXISTENCE BIT SET?

	SMA

	.ENDC

	.IFUND %DTCLD

	LAC	0,X		/CHECK IF FILE EXISTS

	SNA

	.ENDC

	JMP	FTSK2	/NO -- AUG XR

	.IFDEF %DTCLD

	AND	(7777)	/YES -- RECORD FILE STARTING BLOCK NUMBER

	.ENDC

	.IFUND %DTCLD

	LAC	3,X

	AND	(77777

	.ENDC

	DAC*	X13	/AND TWO WORD TASK NAME

	LAC	0,X

	DAC*	X13

	LAC	1,X

	DAC*	X13

/

	.IFDEF %DTCLD

FTSK2	AXS	4	/AUGMENT X-REG -- END OF DIRECTORY?

	.ENDC

	.IFUND %DTCLD

FTSK2	AXS 10		/8 WORD ENTRIES IN THE UFD

	.ENDC

	JMP	FTSK1	/NO -- NEXT ENTRY

	DZM*	X13	/YES -- TERMINATE 'FDT'

	LAC	(FDT)	/AND SET SEEK POINTER 'SKPNTR'

	DAC	SKPNTR

/

	JMP*	FTSK	/EXIT

/

SKPNTR	0		/SEEK POINTER ('FDT' INDEX)

/

/ SEEK -- OPEN THE FILE WHOSE STARTING BLOCK NUMBER IS POINTED TO

/ BY 'SKPNTR' TO BE READ.

/

SEEK	0

	.IFDEF %DTCLD

	LAC	DTUN	/INITIALIZE FOR FORWARD DIRECTION READ

	DTLA

	LAW	-2

	DAC	DIROVS

	LAC	(JMS DIRFW)

	DAC	DIRFWV

	.ENDC

	.IFUND %DTCLD

	LAC*	SKPNTR

	JMS	DPNBLK

	.ENDC

	.IFDEF %DTCLD

/

	LAC*	SKPNTR	/SET 'NBT' & 'LBT' FOR STARTING BLOCK OF FILE

	DAC	LBT

	DAC	NBT

/

	LAC	(JMP FXBLK) /FIND & READ FIRST BLOCK OF FILE

	DAC	DISPX

	LAC	NBT

	JMS	WFDT

	.ENDC

	LAC	(DBUF)	/SET UNPACKING POINTER

	DAC	RDBFP

	JMP*	SEEK

/

/ READ -- WAIT FOR BLOCK READIN IF NECESSARY.  UNPACK AND 

/ TRANSFER A LOGICAL RECORD TO 'INBUF'.  INITIATE NEXT BLOCK

/ READ IF LAST RECORD OF BLOCK AND NOT LAST BLOCK OF FILE

/

READ	0

	LAC	(INBUF)	/SETUP LINE BUFFER ADDRESS

	DAC	UBUFA

	LAC	(21)	/SETUP MAX WORD-PAIR COUNT

	DAC	MAXWPC

/

READ1	DZM	CKSUM	/SETUP FOR A NEW RECORD

	LAC	UBUFA

	AAC	-1

	DAC*	(X10)

	DZM	RDVBTS

	.IFUND %DTCLD

	LAW -1		/DON'T ASSUME THAT THE 376TH WORD OF THE

	SAD	MAXCNT	/INPUT BUFFER IS 0 (BECAUSE IN DOS FILES

	JMP	READ4	/IT'S NOT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

	.ENDC

	JMS	RDFW	/FETCH FIRST WORD OF HEADER

	SAD	(1005)	/IS IT AN EOF?

	JMP	RDEOFX	/YES - SHOW IT

	LMQ

	ECLA!LLS 11

	SZA		/ZERO WORD-PAIR COUNT?

	JMP	READ2	/NO -- UNPACK RECORD FROM BUFFER

READ4	LAC	NBT

	SPA!CLA!CMA	/IS BLOCK NUMBER LEGAL?

			/BLOCK NUMBER IS NOT ALWAYS POSITIVE IF

			/AN ERROR HAS OCCURRED WHILE READING

			/SO THERE THIS TEST EXISTS

	JMP	ERR10	/DECTAPE ERROR

	LAC	NBT

	.IFDEF %DTCLD

	JMS	WFDT

	.ENDC

	.IFUND %DTCLD

	JMS	DPNBLK

	.ENDC

	LAC	(DBUF)

	DAC	RDBFP

	JMP	READ1

RDEOFX	DAC	INBUF	/SET THE EOF HEADER

	TCA		/AND CHECKSUM

	DAC	INBUF+1

	DZM	INBUF+2	/CLEAR THE FLAG

	LAW	-1	/BACK UP ONE

	TAD	RDBFP	/ON THE POINTER

	DAC	RDBFP	/SO WE WILL CONTINUE TO RETURN EOF

	JMP*	READ	/LEAVE

READ2	TCA		/SAVE 2'S COMPL WORD PAIR COUNT

	DAC	RDWPC

	TAD	MAXWPC	/IS RECORD TOO LONG?

	SMA!CLA

	JMP	READ3	/NO -- FETCH CHECKSUM WORD

	AAC	60	/YES -- INDICATE TRUNCATED RECORD

	JMS	RDSVB

	LAC	MAXWPC

	JMP	READ2

/

RDL1	JMS	RDFW

READ3	JMS	RDFW	/WORD PAIR COUNT OKAY -- FETCH CHECKSUM

/

RDXX	ISZ	RDWPC	/END OF RECORD?

	JMP	RDL1	/NO -- NEXT WORD PAIR

	LAC	CKSUM	/YES -- CHECKSUM OKAY?

	SNA!CLA

	JMP	RDXR	/YES -- SET VALIDITY BITS IN HEADER

	AAC	40	/NO -- INDICATE ERROR

	JMS	RDSVB

RDXR	LAC*	UBUFA	/SET VALIDITY BITS IN HEADER

	AND	(777717)

	XOR	RDVBTS

	DAC*	UBUFA

/

	JMP*	READ	/EXIT READ SUBROUTINE

/

/

	.IFUND %DTCLD

DPNBLK	0

	JMS	CONV

	CAL	DOTGET

	JMS	.WFDP

	LAW	-377	/RESET MAX READABLE WRDS/BLK COUNTER

	DAC	MAXCNT

	JMP*	DPNBLK

	.ENDC

/

RDSVB	0		/SET VALIDITY BITS SUBROUTINE

	DAC	RDSVB1

	LAC	RDVBTS

	SZA

	JMP*	RDSVB

	LAC	RDSVB1

	DAC	RDVBTS

	JMP*	RDSVB

/

RDVBTS	0

RDSVB1	0

/

RDWPC	0

RDBFP	0

CKSUM	0

/

RDFW	0

	LAC*	RDBFP

	DAC*	X10

	TAD	CKSUM

	DAC	CKSUM

	LAC*	RDBFP

	ISZ	RDBFP

	.IFUND %DTCLD

	ISZ MAXCNT

	NOP		/JUST IN CASE

	.ENDC

	JMP*	RDFW

/

/ WFDT -- SUBROUTINE TO WAIT FOR 'DTEV' TO BE SET NON-ZERO.

/         IF POSITIVE, OPERATION WAS PERFORMED.  IF NEGATIVE,

/         OPERATION WAS NOT PERFORMED, CLOSE UNIT, SET USER'S EVENT 

/         VARIABLE TO THE NEGATIVE QUANTITY, AND FETCH NEXT

/         REQUEST.

/

	.IFDEF %DTCLD

WFDT	0

	JMS	DISP

	CAL	WFDTEV

	LAW	-5

	DAC	ERCNT

	LAC	DTEV

	DZM	DTEV

	SMA

	JMP*	WFDT

/

	SAD	(-5)	/IS IT A SELECT ERROR

	SKP		/YES TELL USER

	JMP	ERR10	/DECTAPE ERROR

	CAL	NTRDY	/PRINT MESSAGE ON LUN 3

	CAL	WFDTEV	/WAIT FOR MESSAGE TO FINISH

	DZM	DTEV	/CLEAR EVENT VARIABLE

	LAC	OVSNRP	/SETUP OVERSHOOT PROTECTION DIRECTION

	SZA

	JMP	.+3

	LAC	(JMP FD1)

	SKP

	LAC	(JMP FD2)

	DAC	DISPX

/

MTWF	CAL	MTRQ	/10 TICK MARK TIME REQUEST

	DTXA+10		/CLEAR EF AND DT FLAGS

	CAL	WFDTEV	/WAIT FOR MARK TIME

	DTEF		/FLAGS CLEAR?

	SKP		/YES EXIT

	JMP	MTWF	/NO DO ANOTHER WAIT

	DZM	DTEV	/CLEAR EVENT VARIABLE

	JMP	WFDT+1

/

/ INTERRUPT BLOCK

/

DTINT	0

	DBA

	DAC	DTSVAC	/SAVE AC DURING INTERRUPT SERVICE

	JMS	DISP	/SERVICE INTERRUPT

	LAC	DTSVAC	/RESTORE AC BEFORE RETURNING

	DBR

	JMP*	DTINT	/RETURN TO NEXT TASK

/

/ DISPATCH

/

DISP	0

DISPX	XX		/DISPATCH SWITCH

/

/ FXBLK -- FIND & TRANSFER BLOCK WHOSE NUMBER IS IN AC

/

FXBLK	DAC	FDBLK	/SAVE BLOCK NUMBER

/

FD1	LAC	FDBLK	/SEARCH FORWARD

	JMS	SEARCH

	JMP	RWBLK	/BLOCK FOUND -- EXIT

	LAC	(FW!RV)	/OVERSHOOT -- SET REVERSE

	DTXA

	DAC	OVSNRP	/(DEPENDENT UPON INT FREE INST AFTER IOT)

FD2	LAC	DIROVS	/MOVE TAPE BACK TWO

	TAD	FDBLK

	JMS	SEARCH

	NOP		/OVERSHOOT IF BLK-2 IS 

	LAC	(FW!RV)	/SET FORWARD AND SEARCH FOR BLOCK

	DTXA

	DZM	OVSNRP	/(DEPENDENT UPON INT FREE INST AFTER IOT)

	JMP	FD1

/

/ DESIRED BLOCK NUMBER HAS BEEN FOUND, R/W BLOCK.  FLAGS ARE LEFT

/ SET UNTIL FUNCTION IS SWITCHED FORM SEARCH TO READ/WRITE SO THAT A

/ TIMING ERROR WILL OCCUR IF THE SWITCH IS NOT MADE BEFORE THE DATA 

/ AREA HAS REACHED THE R/W HEADS.

/

RWBLK	LAW	-400	/SET WORD COUNT FOR A STANDARD DECTAPE BLOCK (256 WDS)

	DAC*	WCA

	LAC	(JMP XFRFIN)/SET DISPATCH SWITCH

	DAC	DISPX

	LAC	RWSW	/CLEAR FLAGS AND SWITCH FROM SEARCH TO READ/WRITE

	DTXA		/(IOT MUST IMMEDIATELY PRECEDE 'JMP* DISP')

	JMP*	DISP	/EXIT -- WAIT FOR INTERRUPT

/

/ REQUESTED BLOCK HAS BEEN READ -- SETUP FOR NEXT BLOCK REQUEST

/

XFRFIN	DTEF		/ERR FLAG?

	SKP

	JMP	RETRY	/YES -- RETRY

	LAC	(NG!GO!DI!EI!CE!CD)/RESET GO-BIT, DISABLE INTERRUPTS,

	DTXA		/AND CLEAR DT FLAGS.

	LAC	NBT	/UPDATE 'NBT' & 'LBT'

	DAC	LBT

	LAC	DBUF+377

	DAC	NBT

	ISZ	DTEV	/SET EVENT VARIABLE POSITIVE

DIRFWV	NOP		/CHECK DIRECTION FOR NEXT BLOCK

/

XFINX	LAC	(401000)	/SET 6

	ISA

	LAC	(JMP FXBLK)	/SET DISPATCH SWITCH

	DAC	DISPX

	JMP*	DISP	/EXIT

/

FDBLK	0

DIROVS	-2	/OVERSHOOT BACKSPACE COUNT

/

/ DIRFW & DIRRV -- REVERSE THE DECTAPE DIRECTION WHEN NECESSARY

/

DIRFW	0

	TCA

	TAD	LBT

	SPA

	JMP*	DIRFW

	LAC	(2)

	DAC	DIROVS	/CHANGE DIRECTION

	LAC	(FW!RV)	/OF DECTAPE TO WRITE BACKWARDS

	DTXA

	LAC	(JMS	DIRRV)	/SET UP TRANSFER SWITCH

	DAC	DIRFWV

	JMP*	DIRFW

/

DIRRV	0

	TCA		/IN REVERSE DIRECTION

	TAD	LBT	/CHECK TO SEE IF DIRECTION CHANGE NEEDED

	SMA

	JMP*	DIRRV	/NO PROCEED

	LAW	-2

	DAC	DIROVS	/YES RESET POINTERS

	LAC	(FW!RV)

	DTXA		/AND REVERSE DECTAPE

	LAC	(JMS	DIRFW)

	DAC	DIRFWV

	JMP*	DIRRV

/

/ SEARCH -- SUBROUTINE TO SEARCH IN THE CURRENT DIRECTION FOR THE BLOCK

/           WHOSE BLOCK NUMBER IS IN AC.  RETURN WHEN THE BLOCK HAS BEEN FOUND.

/           THE DT FLAGS ARE CLEARED UPON ENTRY

/

/           IF BLOCK IS FOUND, RETURN AT JMS+1 WITH FLAGS LEFT SET

/           IF OVERSHOT, RETURN AT JMS+2 WITH GO-BIT & FLAGS CLEARED

/

SEARCH	0

	DAC	RBUF	/SAVE NUMBER OF REQUIRED BLOCK

SRCH2	LAC	(JMP SR1) /SET DISPATCH SWITCH

	DAC	DISPX

	DZM*	WCA	/SET WORD COUNT TO AVOID OVERFLOW

	LAC	(BBUF)	/SET CORE ADDRESS TO STORE BLOCK NUMBERS IN 'BBUF'

	DAC*	CAA

/

	DTRA		/ALTER NECESSARY BITS OF DT STATUS REGISTER A SUCH

			/THAT FUNCTION IS SEARCH, MODE IS NORMAL, THE GO-BIT IS SET,

			/INTERRUPTS ARE ENABLED, & THE FLAGS ARE CLEARED

			/(THE DIRECTION IS UNCHANGED).

	AND	(GO!NG!NM!CM!MV!SE!RD!WD!EI!DI)

	XOR	(GO!NM!SE!EI!PE!PD)

	DTXA		/(IOT MUST IMMEDIATELY PRECEDE 'JMP* DISP')

/

	JMP*	DISP	/EXIT -- WAIT FOR INTERRUPT

/

/ A BLOCK HAS BEEN READ

/

SR1	DTEF		/ERR FLAG?

	JMP	SR3	/NO -- DESIRED BLOCK CHECK

	DTRB		/YES -- END ZONE?

	AND	(270000)

	SNA

	JMP	SROVS	/YES -- EXIT AT JMS+2

RETRY	DTRB		/READ THE ERROR STATUS

	ISZ	ERCNT	/INCREMENT ERROR COUNT

	SKP!RTL		/PUT SELECT ERROR BIT IN BIT 0

	JMP	FATAL	/FATAL ERROR CAN'T RECOVER

	RAL	

	SPA!CLL		/IS IT A SELECT ERROR?

	JMP	SELER	/YES -- GO OUTPUT MESSAGE

	DTXA+10		/NO TRY AGAIN AND SEE IF IT CAN BE DONE THIS TIME

	JMP	SRCH2

/

FATAL	DTCA		/CLEAR DECTAPE STATUS

	LAW	-12

	DAC	DTEV

	JMP	XFINX	/SET EVENT VARIABLE TO NEGATIVE TO SIGNIFY FATAL ERROR

SELER	LAW	-5	/RESET THE ERROR COUNT

	DAC	DTEV

	LAC	(DI!EI)	/DISABLE INTERRUPT

	DTXA

	LAC	(401000)

	ISA		/SET SIGNIFICANT EVENT

	JMP*	DISP	/EXIT

SR3	LAC	BBUF	/DETERMINE DIFFERENCE BETWEEN DESIRED BLOCK

	AND	(1777)	/MASK OFF ILLEGAL BLOCK NUMBERS

	TCA		/AND JUST DETECTED BLOCK NUMBERS.

	TAD	RBUF

	SNA!CLL		/DESIRED BLOCK?

	JMP*	SEARCH	/YES -- EXIT SEARCH AT JMS+1 WITH FLAGS SET

	TCA

	SMA		/CALCULATE DIFFERENCE BETWEEN DESIRED BLOCK

	TCA!STL		/AND BLOCK FOUND

	DAC*	WCA	/PUT IN TWO'S COMPLEMENT IN BLOCK COUNTER (WORD COUNT)

/			/NO -- HAS DESIRED BLOCK BEEN OVERSHOT?

	DTRA

	AND	(FW!RV)

	SNA

	JMP	SR4

	SNL

	JMP	SROVS	/YES (OVERSHOOT) -- EXIT SEARCH AT JMS+2

	JMP	SR5	/NO (OVERSHOOT) -- CLEAR FLAGS & WAIT FOR NEXT INTERRUPT

SR4	SZL

	JMP	SROVS	/YES (OVERSHOOT) -- EXIT SEARCH AT JMS+2

SR5	LAC	(NM!CM)	/NO (OVERSHOOT) -- SET CONTINUOUS MODE SEARCH

	DTXA

	JMP*	DISP	/EXIT -- WAIT FOR INTERRUPT

/

/ CONTROL WILL BE TRANSFERRED TO 'SR1' AT NEXT INTERRUPT

/

SROVS	LAC	(GO!NG!CD!CE)	/RESET GO-BIT, CLEAR FLAGS, AND

	DTXA			/EXIT SEARCH ROUTINE AT JMS+2

	ISZ	SEARCH

	JMP*	SEARCH

	.ENDC

/

/

/

/

RBUF	0		/DESIRED BLOCK NUMBER (SEARCH)

/

	.IFDEF %DTCLD

NBT	0		/NEXT BLOCK TO BE TRANSFERRED

LBT	0		/LAST BLOCK TRANSFERRED

	.ENDC

/

BBUF	0		/BLOCK NUMBER BUFFER

DBUF	.BLOCK 400	/DECTAPE BLOCK BUFFER (MUST FOLLOW 'BBUF')

	.IFDEF %DTCLD

RWSW	0		/READ-WRITE SWITCH (CONSTANT TO SWITCH FROM SEARCH

	.ENDC

	.IFUND %DTCLD

MAXCNT	0

NBT=DBUF+377

	.ENDC

			/TO READ OR WRITE VIA XOR A-REG)

/

	.IFDEF %DTCLD

DTEV	0		/DECTAPE EVENT VARIABLE

DTUN	0		/TAPE UNIT NUMBER (BITS 0-2)

	.ENDC

MAXWPC	0		/MAX WORD-PAIR COUNT

UBUFA	0		/USER BUF ADDRESS

	.IFDEF %DTCLD

DTSVAC	0

/

ERCNT	-5

OVSNRP	0		/OVERSHOOT PROTECT FLAG

/

MTRQ	13		/MARK TIME REQUEST

	DTEV

	10		/10 TICKS

	1

/

NTRDY	2700

	DTEV

	3

	2

	NTMS-2

/

NTMS	.ASCII	"**** READY"

NTRD	.ASCII	" DT 0"<15>

/

WFDTEV	20

	DTEV

	.ENDC

.WFDP	0

	CAL	.WFEV

	LAC	..EV

	SMA

	JMP*	.WFDP

	DAC	CONV

	CAL	DP.ERR

	CAL	.WFEV

	LAC	CONV

	HLT

	JMP	SCONF

/

/

DOTGET	3000

	..EV

	1

	.GETCT

/

/

.GETCT	XX

.GTCT1	XX

	DBUF

	400

/

/  WARNING FLAG ??><5><?? IS OK FOR RF TOO?????

/

CONV

	LMQ

	ECLA!LLSS!10

	DAC	.GETCT

	LACQ

	DAC	.GTCT1

	JMP*	CONV

/

/

..EV

.NUFD

/

/

DP.ERR	2700

	..EV

	3

	2

	NTMS-2

/

	.IFUND	%DTCLD

/

NTMS	.ASCII "DISK PACK ERROR; EV IN AC."<15>

	.ENDC

/
.WFEV	20
	..EV
								/EAG:202
								/EAG:202
	.IFUND L.ALL						/EAG:202
	.NOLST							/EAG:202
	.ENDC							/EAG:202
								/EAG:202

	.LTORG
/
/
	.LST							/EAG:202

/

	.END
