	.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 DOCU

/ WITHOUT NOTCE"aND SHOUT 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=200207	/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(cONDTONAL

/				XFRCME, MODIF TT] FR 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 1$7		/(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)
/ 207	13-APR-77 (JMW)		TTY: IMAGE ASCII PROBLEMS,	/(207)
/				INPUT ONLY ERROR		/(207)
/ 	23 NOV 77 (PDH)		MAKE CHANGES FOR I/O COUNT, AND	/(207)
/				FOR FULL DUPLEX, LOCAL0COPY TTY	/(207)
/
/ DATE OF LAST EDIT:  NOV 23, 1977
/ 
	.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.LC=10		/ FULL DUPLEX TERMINAL HAS LOCAL COPY	/(207)
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	TTRD01		/(JMW:207) SET INPUT BIT, JOIN	/(207)
	LAC	TT.PCL,X	/(163)PRINTER CLEAR TABLE
	AAC	4
	DAC	TT.PRT,X	/(163)IOT SET UP
TTRD01	LAC	(TTB.IN		/(JMW:207)SET UP INPUT BIT	/(207)
	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
	AAC	-2		/(JMW:207) DELETE HEADER FROM 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
	PLX			/(JMW:207) RESTORE XR		/(207)
	IDX	TTWD03,X	/INCREMENT THE STORAGE POINTER.
/
	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 W	TH0cHaS2iN AC
)2rGUUYNE EXiUs AT LEVE 3 !! AC IS MODIFIED, TTCHAR MAQ"bE MODAF	ED
/	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, WICH IM-

/	PLIES UhAT +KEYbOARD"(INPUT MUST BE SENT

/	BACK TN 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
	LAC	TTWD00,X	/ FIND ABOUT ECHOING CHARACTERS	/(207)
	AND	(TTB.OU!TTB.LC	/ AND FULL DUPLEX, LOCAL COPY	/(207)
	SMA!SZA							/(207)
	JMP	TTPRN3		/ AT THIS POINT, 'TTB.OU' IS	/(207)
				/ NOT SET, THEREFORE MUST BE	/(207)
				/ KEYBOARD INPUT TO BE ECHOED,	/(207)
				/ BUT 'TTB.LC' IS SET, MEANING	/(207)
-	-. WE HaWU LOCAL)cFP}, SO WE)VO(00w)

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

CAE
[6mZgZXe[6[6F9]%^KqQGVt-?>mN5x9{yU!{<-]6
9ZZ	WN8Ovx=6>^h9_EN/h@;V![%{5U6/>!v	-5rRWNBZo[y7&/E{V!Z!~5ZZ	WNO|i^wUEe5Zywh/$7M~Xy\9w'>|-F$=ZZ	WNOvZzy5-(OR?e~V-9]d/=_KklH%~V6O=wKk'=Vt![>G(-u!v'=~UfN%ZZ	WNO|iE=
u5Zywh/F[Vu!T!goU^5}M9~UMN9ZZ	WNOv7=Y5d/=_Jat5ee5P;~g|5_L59>]N5v5mnA8.a4^zBvZo_%gKu8-qu5	
u!U9U7M=]9;}!_>mM5=mO->mM%x-OnU{5;B]!vd59;K-}~{XfoD9~Y6k5~M/nMy5'M9[u{?U]5K9w:{-Yd9_97j9~M-N%[9=nU{5;KZU~[VK,.m?Yb^O!ZemM5~U~e><!{K=~_V]5_9;|5_9{t5w5	>]-]oQ>N-t9NE1~]{-UWl5]!{Kf-2c@
