	.TITLE *** MULTIACCESS TDV POLLER ***
/
/ 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 PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON EXCEPT
/ FOR USE ON SUCH SYSTEM AND TO ONE WHO AGREES TO THESE LICENSE TERMS.
/ TITLE TO AND OWNERSHIP OF THE SOFTWARE SHALL AT ALL TIMES REMAIN
/ IN DEC.
/
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE
/ AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
/ CORPORATION.
/
/ DEC ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS
/ SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DEC.
/
	.TITLE *** EDIT LEGEND ***
/ 000	08-MAR-76 (RCHM)	INITIAL IMPLEMENTATION COMPLETE
/				RICHARD C. H. MUNROE.
/ 001	10-MAR-76 (RCHM)	ADD PARTITION FIT AND NEW JOB	/(001)
/				STATUS INDICATING WAITING FOR	/(001)
/				PARTITION.			/(001)
/ 002	16-MAR-76 (RCHM)	CHANGE MESSAGE FOR T.TERR	/(002)
/				REMOVE EXEC MODE STUFF FROM	/(002)
/				P.FIT, SINCE IT'S NOT NECESSARY./(002)
/				INSTALL ANOTHER JOB STATE TO	/(002)
/				DIFFERENTIATE THE CASE IN SHICH	/(002)
/				IT WILL BE NECESSARY TO CALL	/(002)
/				REMOVE, VS THE CASE IN WHICH IT	/(002)
/				WILL NOT BE NECESSARY TO CALL	/(002)
/				REMOVE.				/(002)
/ 003	16-MAR-76 (RCHM)	INSTALL CODE TO STOP MULTIACCESS/(003)
/				IF MA.STP IN THE SCOM REGION	/(003)
/				IS SET. ALSO FORMALIZE THE	/(003)
/				REMOVE SEQUENCE.		/(003)
/ 004	17-MAR-76 (RCHM)	CLEAN UP SOME MINOR NITS AND	/(004)
/				INSTALL THE TASK SIZE COUNTING	/(004)
/				ROUTINE TO BE CALLED FROM ALL	/(004)
/				THINGS USING THE PARTITION FIT	/(004)
/				ROUTINES IF A REQUEST IS TO BE	/(004)
/				GENERATED.			/(004)
/ 005	18-MAR-76 (RCHM)	FIRST SET OF MISCELANEOUS 	/(005)
/				DEBUGGING CHANGES AND CORRECTIONS/(005)
/ 006	19-MAR-76 (RCHM)	MOVE REQUEST CPB INTO POLLER	/(006)
/				UPON RECODNITION OF THE WAIT END/(006)
/				TO AVOID BAD CAL PROBLEMS.	/(006)
/ 007	22-MAR-76 (RCHM)	INSERT TIME IN WAIT QUE CODE FOR/(007)
/				BATCH INTERFACE.		/(007)
/				ALSO REMOVE THE ASSEMBLY PARA-	/(007)
/				METER "TMO". THIS WILL BE A	/(007)
/				CALCULATED ENTITY IN INIT.	/(007)
/ 008	22-MAR-76 (RCHM)	PUT IN EXIT FLAG AND SCHEDULING	/(008)
/				COUNTER FOR STATE 11 AND 12.	/(008)
/ 009	22-MAR-76 (RCHM)	REORGANIZE DATA AREA FOR THE	/(009)
/				EXISTANCE OF THE CONTROL AND	/(009)
/				STATISTICS TABLE.		/(009)
/ 010	26-MAR-76 (RCHM)	INSTALL HANDLER FOR DYNAMIC 	/(010)
/				BUFFER STORAGE REGION TO HANDLE	/(10)
/				OVERLAY I/O PROBLEMS.		/(010)
/ 011	01-APR-76 (RCHM)	FIX SINGLE UNIT ABORT CAL.	/(011)
/				CHOP LENGTH TEST OUT OF TDVTYP.	/(011)
/				ALSO USE CAL INDEXED IN ORDER TO/(010)
/				SAVE ROOM IN THE CODE FOR MOVING/(010)
/				THE CAL PARAMETER BLOCK FOR THE	/(010)
/				REQUEST.			/(010)
/ 012	01-APR-76 (SCR)		HOOKS FOR ASSIGN		/(012)
/ 013	13-APR-76 (RCHM)	BAD EV ADDRESS IN WRITE		/(013)
/ 014	16-APR-76 (SCR)		INSTALL DEV			/(014)
/ 015	20-APR-76 (RCHM)	REMOVE TDV@@@ EXCLUSION.	/(015)
/ 016	25-APR-76 (RCHM)	IF A PARTITION FIT ERROR OCCURS	/(016)
/				RESET THE PARTITION SELECTION	/(016)
/				CRITERIA.			/(016)
/ 017	27-APR-76 (RCHM)	GRACEFUL EXIT CODE.		/(017)
/ 018	11-MAY-76 (RCHM)	REMOVE PARTITION WAIT FROM	/(018)
/				RESIDENT CODE INTO OPTIONAL	/(018)
/				OVERLAY FORM.			/(018)
/ 019	20-MAY-76 (RCHM)	REMOVE LINE FEEDS AND $ SIGNS	/(019)
/				FROM THE FRONT OF EACH COMMAND	/(019)
/				INPUT LINE.			/(019)
/ 020	20-MAY-76 (RCHM)	LOGOFF A USER WHO GETS A MINUS	/(020)
/				EVENT VARIABLE IN RESPONSE TO A	/(020)
/				COMMAND READ.			/(020)
/ 021	02-JUN-76 (RCHM)	FIX FOR A STALL BEFORE KILLING	/(021)
/				MULTIACCESS AND PUT IN THE BATCH/(021)
/				CONTROL WORD, AS DESCRIBED TO 	/(021)
/				EAG.				/(021)
/ 022	15-JUL-76 (RCHM)	CHANGE THE DEFAULT STATE OF 	/(022)
/				U.SSM TO -1 SINCE 0 IS A VALID	/(022)
/				TIME				/(022)
/								/(023)
/ 023	30-JUL-76 (EAG)		INSERT FLAG BIT TO CAUSE	/(023)
/				BATCH TO IGNORE THE TDV		/(023)
/				COMMAND PROMPT.			/(023)
/
/ 024	12-AUG-76 (EAG)		CAUSE TDV TO IGNORE COMMANDS	/(024)
/				WHOSE FIRST CHARACTER IS A	/(024)
/				SPACE.				/(024)
/
	.TITLE *** MACROS USED BY TPOLLR ***
/
/ MACRO TO DEFINE OFFSETS INTO THE USER CONTEXT AREA.
/
	.DEFIN UCAOFF
U.JSW=0				/OFFSET TO JOB STATUS WORD.
U.MAEV=1			/OFFSET TO EVENT VARIABLE
U.MAMTE=2			/OFFSET TO MARK TIME EVENT VARIABLE.
U.OEV=3				/OFFSET TO OVERLAY EVENT VARIABLE.
U.DSK=4				/OFFSET TO DISK NAME
U.DUN=5				/OFFSET TO DISK UNIT NUMBER
U.UFD=6				/OFFSET TO UFD NAME.
U.CTSK=7			/OFFSET TO CURRENT TASK NAME
U.PSC=11			/OFFSET TO PARTITION SELECTION CRITERIA.
U.ULOF=14			/OFFSET TO USER NUMBER AND LUN OFFSET.
U.TTYN=15			/OFFSET TO USER TERMINAL NUMBER.
U.TB=16				/OFFSET TO USER TERMINAL BUFFER.
U.CPB=62			/OFFSET TO MULTI-ACCESS CPB.
U.SSM=74			/SECONDS SINCE MIDNIGHT INTO STATE 11
				/ OR 12 (HUNG ON PARTITION)
U.TW=75				/TOTAL TIME IN SECONDS SPENT IN STATE 11
				/ OR 12.
U.OVID=76			/OVERLAY IDENTIFIER (LAST OVERLAY CALLED)
U.CKS=77			/CHECKSUM OF INPUT BUFFER FOR TIMED READ.
U.LEN=100			/LENGTH OF UCA.
	.DEFIN UCAOFF
	.ENDM
	.ENDM
/
/ MACRO WHICH DEFINES SYSTEM TASK LIST ENTRIES
/ THIS ALSO DEFINES ALL BITS FOR EACH FLAG WORD.
/
	.DEFIN STLOFF
S.FP=0			/FORWARD LINKAGE.
S.BP=1				/BACKWARD LINKAGE.
S.N1=2				/TASK NAME
S.N2=3				/TASK NAME
S.DP=4				/FLAGS AND DEFAULT PRIORITY.
S.PB=5				/PARTITION BLOCK ADDRESS
S.DA=6				/DISK ADDRESS AND UNIT.
S.DB=7				/RESIDENT CODE LENGTH (DISK TRANSFER)
S.TS=10				/TASK SIZE.
S.EP=11				/TASK ENTRY POINT.
/
/ DEFINE S.DP BIT EXTRACTION MASKS.
/
S.ETA=400000			/EXTRACT TASK ACTIVE
S.EROX=200000			/EXTRACT REMOVE ON EXIT.
S.ETDI=100000			/EXTRACT TASK DISABLED.
S.EFIX=40000			/EXTRACT TASK FIXED IN CORE.
S.EPLC=20000			/EXTRACT PARTITION LOST IN RECONFIG.
S.ERCP=10000			/EXTRACT RECONFIGURATION IN PROGRESS.
S.ETEX=4000			/EXTRACT TASK HAS EXITTED.
S.EDP=1777			/EXTRACT DEFAULT PRIORITY.
/
/ DEFINE S.TS BIT EXTRACTION MASKS.
/
S.ETS=777400			/EXTRACT TASK SIZE.
S.ERD=200			/EXTRACT RELOCATE DISABLE.
S.EXM=140			/EXTRACT XVM MODE.
S.EIOT=20			/EXTRACT IOT PERMISSION.
/
/ DEFINE S.EP BIT EXTRACTION MASKS.
/
S.ELC=400000			/EXTRACT LINK CONTENTS.
S.EPB=200000			/EXTRACT PAGE/BANK INDICATOR.
S.EEN=100000			/EXTRACT EXEC/NORMAL MODE.
S.EEP=77777			/EXTRACT ENTRY POINT ADDRESS.
	.DEFIN STLOFF
	.ENDM
	.ENDM
 
/ DEFINE AN OVERLAY TABLE ENTRY.
/ PARAMETERS:
/
/	1. OVERLAY NAME (3 CHARACTERS)
/	2. (DEFAULT IS "LAC UCAADR") AC CONTENTS LOADER.
/	3. CALL TO OVERLAY.
/	4. TAIL END PROCESSOR. (DEFAULT IS RESTORE XR AND LR)
 
	.DEFIN OVTENT,NAME,AC,CALLN,TAIL,?A
	.NOLST
A	.SIXBT "NAME"
	.IFPNZ .-A-1
	.END ERROR -- OVERLAY NAME LONGER THAN 3 CHARACTERS.
	.ENDC
	AC
	.IFPNZ .-A-2
	.END ERROR -- TOO MANY INSTRUCTIONS FOR AC FIELD.
	.ENDC
	.IFZER .-A-1
	LAC UCAADR
	.ENDC
	JMS* CALLN
	TAIL
	.IFPNZ .-A-4
	.END ERROR -- TOO MANY INSTRUCTIONS FOR TAIL END FIELD.
	.ENDC
	.IFZER .-A-3
	JMS RES.XL
	.ENDC
	.LST
	.ENDM
	.TITLE *** DIRECT ASSEMBLY TIME ASSIGNMENTS ***
 
LOG=141707		/ "LOG" FUNCTION IN 6 BIT.
MA.CT=226		/ ABSOLUTE ADDRESS OF MA.CT IN EXEC.
MA.CY=227		/ ABSOLUTE ADDRESS OF MA.CY IN EXEC.
MA.BLU=224		/ ABSOLUTE ADDRESS OF THE OFFSET TO THE
			/ BEGINNING OF THE MULTIACCESS LUN AREA.
MA.ELU=225		/ ABSOLUTE ADDRESS OF THE OFFSET TO THE
			/ END OF THE MULTIACCESS LUN AREA.
MA.UCA=221		/ ABSOLUTE ADDRESS OF THE POINTER TO THE
			/ BEGINNING OF THE UCA.
SSM=160			/ POINTER TO SECONDS SINCE MIDNIGHT.	/(007)
NADD=107		/ POIJTER TO NODE ADD ROUTINE IN EXEC.	/(001)
NDEL=112		/ POINTER TO NODE DELETE ROUTINE IN EXEC/(001)
POOL=240		/ POINTER TO FREE LIST IN EXEC.		/(001)
TDV.EQ=217		/ ABSOLUTE ADDRESS OF EXIT QUE LIST HEAD.
TTYS=176		/ ABSOLUTE ADDRESS OF NUMBER OF TTY'S
T.OTES=4		/ OVERLAY TABLE ENTRY SIZE.
	UCAOFF		/ DEFINE THE OFFSETS TO THE UCA WORDS.
	STLOFF		/ DEFINE STL OFFSETS.			/(001)
R1=101			/ REENTRENT REGITSTER 1.		/(001)
R2=102			/ REENTRANT REGISTER 2.			/(001)
SNAM=123		/ ENTRY TO SCAN LIST FOR NAME.		/(001)
X10=10			/ POINTER TO AUTOINCREMENT REGISTER 10.
X11=11			/ SAME FOR AR 11.			/(006)
.INH=705522
.ENB=705521
ECLA=641000		/ EAE CLEAR THE AC.			/(001)
CALX=10000		/ CAL INDEXED.				/(010)
IDX=ISZ			/ NON SKIPPING ISZ.			/(010)
LF=12								/(019)
DOLLAR=44							/(019)
	.TITLE *** VARIABLES AND CONSTANTS ***
 
/ EXTERNAL GLOBALS WHICH POINT TO OVERLAYS.
 
	.GLOBL ABORT	/^Y PROCESSOR.
	.GLOBL ASSIGN	/ASSIGN PROCESSOR
	.GLOBL DEV	/'DEV'ICES PROCESSOR, USER LUN SPACE	/(014)
	.GLOBL EXIT	/ EXIT NODE PROCESSOR.
	.GLOBL INIT	/ INITIALIZATION OVERLAY.
	.GLOBL LOGOFF	/ LOGOFF.
	.GLOBL LOGON1	/ LOGIN PART 1.
	.GLOBL LOGON2	/ LOGIN PART 2.
	.GLOBL PARTS	/ "PAR" AND "KPA" COMMAND PROCESSOR.
	.GLOBL SYDISP	/ SYSTEM TASK DISPATCHER.
	.GLOBL STOPIT	/ GRACEFUL HALT PROCESSOR.		/(017)
	.GLOBL XQT1	/ EXECUTE PROCESSOR PART 1.
	.GLOBL XQT2	/ EXECUTE PROCESSOR PART 2.
	.GLOBL PWAIT	/ PARTITION WAIT ROUTINE.		/(018)
 
/ INTERNAL GLOBALS
 
	.GLOBL MA.LBM	/ MULTIACCESS LUN BIT MAP
	.GLOBL RT.LBM	/ REAL TIME LUN BIT MAP
	.GLOBL TTY.UC	/ MAPPING FROM TTY NUMBER TO UCA ADDRESS.
	.GLOBL MA.CTL	/ BEGINNING OF CONTROL TABLE FOR SCOM.	/(009)
	.GLOBL MA.NJB	/ NUMBER OF TASKS PROCESSED.		/(009)
	.GLOBL MA.NUS	/ TOTAL NUMBER OF USERS HAVING LOGGED	/(009)
			/ ONTO MULTIACCESS.			/(009)
	.GLOBL MA.STL	/ POINTER TO TDV STL ENTRY.		/(001)
	.GLOBL MA.STP	/ POINTER TO MULTIACCESS STOP WORD.	/(009)
	.GLOBL MA.TMO	/ TIME BEFORE TIME OUT OCCURS.		/(007)
	.GLOBL MA.TW1	/ TIME SPENT IN WAIT QUE (HIGH 18 BITS)	/(009)
	.GLOBL MA.TW1	/ TIME SPENT IN WAIT QUE (LOW 18 BITS)	/(009)
	.GLOBL MA.USR	/ BIT MASK CORRESPOENDING TO TTY.UC	/(009)
	.GLOBL TDVTYP	/ OVERLAY TERMINAL OUTPUT FACILITY.	/(010)
	.GLOBL TS.CTB	/ POINTER TO THE TASK SIZE COUNTER TABLE/(004)
	.GLOBL TS.CTR	/ ENTRY POINT TO THE TASK SISE CNT RTN.	/(004)
	.GLOBL T.LUNS	/ BASE OF TDV R/W LUNS.
	.GLOBL T.PEND	/ TDV PARTITION END.
	.GLOBL MA.PPS	/ NUMBER OF CLOCK TICKS TO WAIT BETWEEN	/(007)
			/ POLLER WAKE UPS.			/(007)
	.GLOBL BEGFREE						/(010)
	.GLOBL ENDFREE						/(010)
	.GLOBL BEGBUF						/(010)
	.GLOBL ENDBUF						/(010)
	.GLOBL BT.USR						/(021)
 
/ VARIABLES USED BY THE SCANNER.
 
JBSTDP	0		/ POINTER INTO THE JOB STATE DISPATCH TABLE.
/
/ JOB STATE DISPATCH TABLE. EACH ENTRY IN THE JBSDTB CORRESPONDS TO
/ ONE OF THE POSSIBLE VALUES OF THE JOB STATUS WORD.
/
JBSTAB	JMP SCN.98	/0  IDLE STATE. ADVANCE TO THE NEXT UCA.
	JMP JBS.01	/1  TIMED READ FOR LOGIN.
	JMP JBS.02	/2  WAITING FOR TDV COMMAND LINES.
	JMP JBS.03	/3  WAITING FOR FININS TO COMPLETE.
	JMP SCN.98	/4  USER TASK IS ACTIVE FOR THIS UCA.
	JMP SCN.98	/5  NORMAL MODE SYSTEM TASK IS ACTIVE.
	JMP JBS.06	/6  A READ FOR COMMAND INPUT IS TO BE ISSUED.
	JMP JBS.07	/7  A ^Y WAS ISSUED FOR A JOB IN STATE 3.
	JMP SCN.98	/10 EXEC MODE SYSTEM TASK IS ACTIVE.
	JMP JBS.11	/11 A SYSTEM TASK IS WAITING FOR A PART-/(001)
			/   ITION. THE CPB AREA OF THE UCA	/(002)
			/   WILL CONTAIN THE STL NODE ADDRESS	/(002)
			/   AND THE MAPPED REQUEST CPB FOR THE	/(002)
			/   TASK IN QUESTION. THIS STATE IS SET	/(002)
			/   ONLY BY SYDISP.			/(002)
	JMP JBS.11	/12 A USER TASK IS WAITING FOR A 	/(002)
			/   PARTITION. THIS STATE IS HANDLED	/(002)
			/   IN A SIMILAR FASHION TO JOB STATE 11/(002)
			/   JOB STATE 12 IS ONLY SET UP	/(002)
			/   BY XQT PART 2.			/(002)
 
MA.LBM	0		/ MULTIACCESS BIT MAP SET TO 1 FOR EACH AVAIL-
			/ ABLE LUN BLOCK IN THE MULTIACCESS LUN SPACE.
 
MA.STL	0		/ POINTER TO STL ENTRY FOR MULTIACCESS	/(001)
			/ TDV. SET UP BY INIT.			/(001)
 
 
MA.STS	SKP		/ STOP SWITCH. SET TO NOP IF MA.STP IN	/(003)
			/ SCOM IS SET NON-ZERO.			/(003)
 
SAV.LR	0		/ SAVE ARE FOR LIMIT REGISTER
 
SAV.XR	0		/ SAVE AREA FOR INDEX REGISTER.
 
TDVADJ	0		/ CONSTANT USED TO MAKE INDEXING WORD.
 
T.LUNS	0		/ LUN # ATTACHED TO TTY 0 BY THE INIT OVERLAY.
 
/*******							/(009)
/*******	UNDER NO CIRCUMSTANCES CHANGE, DELETE OR REORDER/(009)
/*******	THE INFORMATION BETWEEN THIS SET OF ASTERISCED	/(009)
/*******	COMMENTS AND THE NEXT OCCURENCE OF 3 ASTERISCED	/(009)
/*******	LINES. THIS TABLE IS POINTED TO BY WORD 230 IN	/(009)
/*******	SCOM AND THE OPERATING SYSTEM WILL MAKE CERTAIN	/(009)
/*******	ASSUMPTIONS ABOUT THE DATA AND ITS RELATIVE	/(009)
/*******	OCCURENCE WITHIN THE TABLE.			/(009)
/*******							/(009)
 
MA.CTL=.		/ BEGINNING OF CONTROL AND STATUS TABLE	/(009)
 
MA.STP	0		/ STOP MULTIACCESS WORD. SET TO NON	/(009)
			/ ZERO TO STOP MULTIACCESS.		/(009)
 
MA.USR	0		/ TERMINAL ACTIVE MASK. CORRESPONDS TO	/(009)
			/ TTY.UC WITH A BIT ON FOR EACH NON -1	/(009)
			/ ENTRY IN TTY.UC.			/(009)
 
RT.LBM	0		/ REAL TIME LUN BIT MAP SET TO 1 FOR EACH LUN
			/ BLOCK UNAVAILABLE TO MULTIACCESS BECAUSE OF
			/ RT LUN ASSIGNMENTS.
 
MA.TW1	0		/ TOTAL TIME BY ALL JOBS IN WAIT QUE	/(009)
			/ HIGH 18 BITS.				/(009)
 
MA.TW2	0		/ TOTAL TIME BY ALL JOBS IN WAIT QUE	/(009)
			/ LOW 18 BITS.				/(009)
 
MA.NJB	0		/ TOTAL NUMBER OF TASKS EXECUTED AND	/(009)
			/ EXECUTING (INCREMENTED UPON REQ)	/(009)
 
MA.NUS	0		/ TOTAL NUMBER OF USERS HAVING LOGGED	/(009)
			/ ONTO MULTIACCESS.			/(009)
CT.IO	0		/ CONTROL T I/O IN PROGRESS FLAGS.	/(010)
 
BEGFREE	0		/ BEGINNING OF CURRENT FREE AREA IN DSR./(010)
 
ENDFREE	0		/ END OF CURRENT FREE AREA IN DSR.	/(010)
			/ ENDFREE >= BEGFREE ALWAYS.		/(010)
 
BEGBUFF	0		/ BEGINNING OF DSR.			/(010)
 
ENDBUFF	0		/ LAST BUSY ENTRY (DUMMY ENTRY) IN DSR.	/(010)
 
T.PEND	0		/ ABSOLUTE ADDRESS OF THE LAST WORD IN	/(011)
			/ THE AREA OF CORE RESERVED FOR UCAS.	/(011)
 
	.REPT 22	/ ALWAYS USE 18 (10) ENTRIES.
TTY.UC	-1		/ INDICATE NO UCA FOR THE CURRENT TERMINAL.
 
	.REPT 42	/ 34 (10) ENTRIES IN THE TASK SIZE	/(004)
TS.CTB	0		/ TABLE.				/(004)
								/(021)
BT.USR	0		/ WORD CORRESPONDING TO MA.USR BUT	/(021)
			/ THE BIT GETS SET ONLY UPON SUCCESSFUL	/(021)
			/ LOGIN.				/(021)
 
/*******							/(009)
/*******	END OF STATUS AND CONTROL TABLE.		/(009)
/*******							/(009)
 
T.TMP1	0		/ EITHER SIXBIT REPRESENTATION OF THE TASK TO
			/ BE INVOKED OR THE XR VALUE WHICH POINTS TO THE
			/ OVERLAY TABLE ENTRY BEING EXECUTED BY TDV.
			/ OR THE WORD COUNT FOR THE CHECKSUM ROUTINE.
 
T.TMP2	0		/ GENERAL SCRATCH			/(018)
 
T.OVLY	OVTENT	ASG,,ASSIGN	/(012) ASSIGN, ALLOW 3 CALLING OPTIONS
	OVTENT	ASN,,ASSIGN	/(012)
	OVTENT	ASS,,ASSIGN	/(012)
	OVTENT	DEV,,DEV	/(014) DEVICES ENTRY POINT 'DEV'
	OVTENT KPA,,PARTS
	OVTENT OFF,,LOGOFF
	OVTENT PAR,,PARTS
	OVTENT XQT,,XQT1
T.OVLS=.-T.OVLY		/ OVERLAY TABLE SIZE IN WORDS.
 
T.PROM	402000		/ HEADER WORD PAIR FOR PROMPT MESSAGE,	/(023)
	0		/ FLAGGED SO BATCH WILL IGNORE THIS.	/(023)
	.ASCII "TDV>"<175>					/(001)
 
CRSTR	002000							/(001)
	000000							/(001)
	.ASCII <15>						/(001)
 
SC.CTR	0		/ NUMBER OF ENTRIES BEFORE ATTEMPTING	/(008)
			/ A P.FIT. ASSUMING THAT 1 JOB IS HUNG	/(008)
			/ ON A PARTITION, THIS LOOP WILL OCCUR	/(008)
			/ EVERY 4TH ENTRY OF THE POLLER.	/(008)
 
EXITF	0		/ SET TO NON-ZERO EVERY TIME A TASK EXIT/(008)
			/ OCCURS, OR IS ABOUT TO OCCUR.		/(008)
 
NEXT	0		/ SET TO -1 TO INDICATE BEGINNIG OF 	/(010)
			/ BUFFER (DSR) FORGARBAGE SCAN.		/(010)
 
MASK	0		/ BIT MASK FOR CLEARING AND SETTING OF	/(010)
			/ THE CNTRL T I/O ACTIVE BIT.		/(010)
 
BUFLEN	0		/ TOTAL NUMBER OF WORDS TO ALLOCATE FOR	/(010)
			/ THE DYNAMIC BUFFER REQUEST.		/(010)
 
DELTA	0		/ DIFFERENCE IN WORDS OF BUFLEN AND THE	/(010)
			/ CURRENT AREA BRACKETTED BY BEGFREE AND/(010)
			/ END FREE.				/(010)
 
MSGADR	0		/ POINTER TO THE MESSAGE TO BE PLACED IN/(010)
			/ THE DYNAMIC STORAGE REGION.		/(010)
								/(021)
DELAY	0		/ DELAY INTERVAL, IN POLLER CYCLES	/(021)
			/ BEFORE ATTEMPTING A SHUT DOWN OF THE	/(021)
			/ THE POLLER.				/(021)
	.TITLE *** CAL PARAMETER BLOCKS USED BY TPOLLR ***
 
/ WRITE FOR TDV PROMPT.
 
WRITE	2700
	0							/(013)
	XX		/ CALCULATED LUN.
	2		/ IOPS ASCII.
	T.PROM		/ "TDV>"
 
CR	2700		/ WRITE FOR CARRIAGE RETURN.		/(001)
	0							/(001)
	XX		/ LUN NUMBER , CALCULATED.		/(001)
	2							/(001)
	CRSTR		/ CARRIAGE RETURN.			/(001)
 
/ READ FOR TDV COMMAND.
 
READ	2600
	XX		/ EV ADDRESS IS CALCULATED.
	XX		/ LUN NUMBER IS CALCULATED.
	2		/ IOPS ASCII.
	XX		/ BUFFER ADDRESS IS CALCULATED.
	U.CPB-U.TB	/ BUFFER LENGTH
 
/ WAIT FOR SIGNIFICANT EVENT CAL.
 
SIGEVT	5
 
/ SINGLE UNIT ABORT.
 
SUAB	1700							/(011)
	0
	XX		/ LUN TO BE CALCULATED.
 
/ MARK TIME FOR TIME OUT.
 
TMOMKT	13
	XX		/ EVENT VARIABLE ADDRESS TO BE CALCULATED.
MA.TMO	XX		/ NUMBER OF TICKS TO WAIT (CALCULATED)	/(007)
	2		/ SECONDS.
 
PLRMK	13		/ USE A MARK TIME RATHER THAN A SIGEVT	/(001)
	PLRMKE		/ WAIT LOOP.				/(001)
MA.PPS	XX		/ NUMBER OF TICKS BEFORE POLL.		/(007)
	1		/ TICKS UNITS.				/(001)
 
PLRWT	20		/ WAIT FOR.				/(001)
	PLRMKE		/ POLLER MARK TIME.			/(001)
 
PLRMKE	0		/ POLLER MARK TIME EVENT VARIABLE.	/(001)
 
REQATO	01		/ REQUEST AUTORM ON TASK REMOVE.	/(003)
	0		/ NO EVENT VARIABLE.			/(003)
	.SIXBT "AUTORM"	/ TASK NAME.				/(003)
	0		/ DEFAULT PRIORITY.			/(005)
 
/								/(010)
/ THIS CPB GETS BUILT AND USED BY THE DYNAMIC STORAGE REGION FOR/(010)
/ TERMINAL I/O FROM OVERLAYS.					/(010)
/								/(010)
 
TTOCAL	2700		/ WRITE TO A TERMINAL.			/(010)
MSGBUF	XX		/ EVENT VARIABLE ADDRESS.		/(010)
TTYN	XX		/ LUN NUMBER AND TTY NUMBER.		/(010)
MODE	XX		/ DATA MODE.				/(010)
MSGNAD	XX		/ POSITION OF OUTPUT ITEM WITHIN	/(010)
			/ DYNAMIC STORAGE REGION.		/(010)
MSGLEN	XX		/ LENGTH OF OUTPUT DATA ITEM IN WORDS.	/(010)
	.TITLE *** TDV POLLER INITIALIZATION ***
 
/ THE POLLER IS CALLED AT THIS ENTRY POINT ONLY ON INITIAL PROGRAM
/ LOAD. THE OVERLAY INIT IS CALLED WHICH WILL SET UP THE UCA, SCOM,
/ THE LUN BIT MAPS AND THE LUNS FOR TDV TO ACKNOWLEDGE TERMINALS.
 
T.INIT	JMS* INIT	/ CALL THE INITIALIZATION OVERLAY.
	LAC (.)		/ FIGURE OUT INDEXING FUDGE FACTOR.	/(001)
	AND (70000)	/ EXTRACT PAGE AND BANK BITS.		/(001)
	CMA!IAC		/ SET UP TO SUBTRACT PAGE AND BANK BITS./(005)
	DAC TDVADJ	/ FUDGE FACTOR NOW ALL SET UP.	/(001)
	JMP T.MAIN	/ ENTER THE MAIN SCANNER LOOP. NOTE THAT SINCE
			/ ^T FORCES IPL THEN WORK WILL ALWAYS BE AVAIL-
			/ ABLE AT THIS TIME.
	.TITLE *** TDV POLLER LOOP ***
 
/ THE SCANNING LOOP LOOKS AT DATA IN SCOM (^T, ^Y, TDV.EQ) AND THE
/ UCA TO DRIVE VARIOUS ACTION SYSTEMS WHICH WILL CAUSE THE USER
/ INTERACTION.
 
T.WAIT	CAL PLRMK	/ WAIT FOR 4 CLOCK TICKS.		/(001)
	CAL PLRWT	/ WAIT FOR THE CLOCK TO TICK.		/(001)
T.MAIN	LAC MA.STP	/ FETCH STOP WORD FROM CONTROL TABLE.	/(009)
	SNA!STL		/ SET THE LINK IN CASE OF STOP ON.	/(003)
	CLL		/ INDICATE NO STOP CODE.		/(003)
	LAC (SKP)	/ DEFAULT CASE IS SKIP.			/(003)
	SZL		/ ARE WE TO HALT TDV?			/(003)
	XOR (1000)	/ YES, INDICATE IT.			/(003)
	DAC MA.STS	/ SET STOP SWITCH.			/(003)
	.TITLE	*** JOB STATUS WORD SCAN LOOP ***
	LAC* (MA.UCA)	/ FETCH UCA ADDRESS FROM SCOM.		/(009)
	TAD TDVADJ	/ ADJUST FOR CURRENT PAGE (SET UP BY INIT)
	PAX		/ SET UP INDEXING.
	LAC T.PEND	/ FETCH END OF PARTITION (UCA BUILT FROM TOP
			/ DOWN).
	TAD TDVADJ	/ SET UP LIMIT FOR INDEXING.
	PAL		/ LIMIT REGISTER NOW SET UP.
 
/ THE FIRST DATA ITEM TO INVESTIGATE IS THE ^Y WORD. IF A TASK IS TO BE
/ ABORTED, LET IT GET ONTO THE EXIT QUE SO THAT THE RESOURCE MAY BE
/ FREED BEFORE ANYTHING ELSE GOES ON.
 
SCN.03	LAC* (MA.CY)	/ FETCH CTRL-Y WORD FROM SCOM.
	SNA		/ ANY ONE STRUCK CTRL-Y?
	JMP SCN.01	/ NO, GO CHECK NEXT DATA ITEM.
 
/ CTRL-Y HAS BEEN STRUCK INDICATING THAT A JOB IS TO BE ABORTED. CALL
/ THE ABORT PROCESSOR OVERLAY AND THEN CONTINUE WITH THE SCAN LOOP.
 
	JMS SAV.XL	/ SAVE XR AND LR.
	JMS* ABORT	/ ABORT JOB(S).
	JMS RES.XL	/ RESTORE XR AND LR.
 
/ THE SECOND DATA ITEM TO INVESTIGATE IS THE TDV EXIT QUE (TDV.EQ). IF
/ ANY TASK HAS EXITTED IT MUST BE RIGHT TO FREE UP IT'S RESOURCES PRIOR
/ TO ATTEMPTING ANYTHING ELSE.
 
SCN.01	LAC* (TDV.EQ)	/ FETCH THE EXIT QUE LIST HEAD.
	SAD (TDV.EQ)	/ IS THERE ANYTHING IN THE QUE?
	JMP SCN.02	/ NO, GO BEGIN JOB STATUS WORD SCAN.
	ISZ EXITF	/ INDICATE THAT A TASK IS EXITTING	/(008)
	NOP		/ IN CASE OF TOO MANY TASK EXITS.	/(008)
	JMS SAV.XL	/ SAVE XR AND LR.
	JMS* EXIT	/ GO PROCESS EXIT QUE.
	JMS RES.XL	/ RESTORE XR AND LR.
SCN.02	LAC U.JSW,X	/ FETCH JOB STATUS WORD FROM UCA.
	TAD (JBSTAB)	/ CALCULATE ENTRY INTO JOB STATE DISPATCH TABLE.
	DAC JBSTDP	/ SET UP POINTER TO DISPATCH TABLE.
	LAC U.MAEV,X	/ FETCH EVENT VARIABLE FOR ALL PROCESSORS.
	XCT* JBSTDP	/ PERFORM JOB STATE FUNTION.
	.TITLE	*** JOB STATE 1 PROCESSING ***
 
/ LOGIN HAS OCCURED TO THE POINT OF ISSUING A READ AND A MARK TIME.
/ THE READ IS TO BE CANCELED UPON THE EXPIRATION OF THE MARKTIME AND
/ THE JOB FORCED THROUGH THE "OFF" COMMAND PROCESSOR.
/
/ IF THE READ HAS COMPLETED, INVOKE THE LOGIN PROCESSOR. IF THE LOGIN
/ PROCESSOR COMPLETES NORMALLY (U.OEV >=0) CONTINUE. IF THE LOGIN FAILS
/ THE LOGOFF PROCESSOR WILL BE INVOKED.
 
JBS.01	SZA		/ DONE YET?
	JMP SCN.04	/ YES, GO INVOKE LOGIN PART2.
	LAC U.MAMTE,X	/ FETCH MARK TIME EVENT VARIABLE.
	SNA		/ DONE YET?
	JMP SCN.98	/ NO.
 
/ MARK TIME HAS ELAPSED. IF NO CHARACTERS HAVE BEEN ENTERED SINCE
/ THE BEGINNING OF THE TIMED PERIOD, CALCEL THE READ AND INVOKE THE
/ LOGOFF PROCESSOR. OTHERWISE REISSUE THE MARK TIME AND CONTINUE WITH
/ THE UCA SCAN.
 
	JMS CKSUM	/ CALCULATE CHECKSUM FOR BUFFER. FIRST
			/ CHECKSUM IS CALCULATED BY LOGON PART 1.
	SZL		/ IS THE CHECKSUM THE SAME?
	JMP SCN.09	/ NO, RESTART THE TIMER.
SCN.22	JMS SAV.XL	/ SAVE INDEX AN LIMIT REGISTERS.	/(005)
	JMS TA		/ CALCULATE LUN NUMBER.			/(001)
	DAC SUAB+2	/ SET UP SINGLE UNIT ABORT.
	JMS EVA		/ THIS CAL MUST GET ISSUED.		/(001)
	DAC SUAB+1	/ SET UP EVENT VARIABLE POINTER.	/(001)
SCN.19	CAL SUAB	/ ISSUE SINGLE UNIT ABORT.		/(001)
	JMS STALL	/ MAKE SURE IT GOT ISSUED.		/(001)
	JMP SCN.19	/ TRY AGAIN.				/(001)
SCN.05	JMS UCAADR	/ CALCULATE UCA ADDRESS.
	JMS* LOGOFF	/ CALL LOGOFF PROCESSOR.
	JMS RES.XL	/ RESTORE XR AND LR.
	JMP SCN.98	/ GO TO NEXT UCA ELEMENT.
 
/ AT LEAST ONE CHARACTER HAS BEEN ENTERED INTO THE DATA AREA OF THE
/ TERMINAL BUFFER. RESTART THE TIMER AND CONTINUE WITH THE SCAN.
 
SCN.09	JMS SAV.XL	/ SAVE THE XR AND LR.			/(005)
	JMS UCAADR	/ CALCULATE THE UCA ADDRESS.
	AAC U.MAMTE	/ CALCULATE THE ADDRESS OF THE MARK TIME EVENT
			/ VARIABLE.
	DAC TMOMKT+1	/ SET UP THE MARK TIME EVENT VARIABLE.
	SKP		/ AVOID WAIT FOR SIGNIFICANT EVENT.
SCN.10	CAL SIGEVT	/ WAIT FOR SIGNIFICANT EVENT IN CASE OF EMPTY
			/ POOL
	CAL TMOMKT	/ CRANK UP MARK TIME.
	JMS RES.XL	/ RESTORE XR AND LR.
	LAC U.MAMTE,X	/ FETCH MARK TIME EVENT VARIABLE.
	SAD (-777)	/ EMPTY POOL?
	JMP SCN.10	/ YES, MUST HAVE TIMER OUTSTANDING.
	JMP SCN.98	/ GO TO NEXT UCA.
 
/ READ HAS COMPLETED, INVOKE LOGIN PART 2.
 
SCN.04	JMS SAV.XL	/ SAVE THE XR AND LR.			/(005)
	JMS UCAADR	/ CALCULATE UCA ADDRESS.
	JMS* LOGON2	/ INVOKE SECOND HALF OF LOGIN PROCESSOR.
	JMS RES.XL	/ RESTORE THE XR AND LR.
	LAC U.OEV,X	/ CHECK THE STATUS OF THE OVERLAY.
	SMA		/ DID IT COMPLETE OK?
	JMP SCN.98	/ YES, GO TO NEXT UCA.
	JMP SCN.05	/ NO, LOG THE GUY OFF.
	.TITLE	*** JOB STATE 2 PROCESSING ***
 
/ A READ IS PENDING FOR THE CURRENT UCA. IF THE READ HAS COMPLETED
/ PROCESS IT AND INVOKE EITHER AN OVERLAY OR THE SYSTEM TASK DISPATCHER.
 
JBS.02	XCT MA.STS	/ ARE WE TO STOP THE POLLER?		/(003)
	JMP SCN.22	/ YES.					/(003)
	SNA		/ NO, IS THE READ DONE YET?		/(003)
	JMP SCN.98	/ NO, ADVANCE TO THE NEXT UCA ELEMENT.
								/(020)
	SMA		/ DID THE READ FAIL FOR OTHER THAN -777	/(020)
	JMP SCN.32	/ NO, INPUT OK CONTINUE PROCESSING.	/(020)
	JMS SAV.XL	/ SET UP TO CALL "OFF" COMMAND PROCESSOR/(020)
	JMS UCAADR	/ CALCULATE THE UCA ADDRESS.		/(020)
	JMS* LOGOFF	/ CALL THE LOGOFF PROCESSOR.		/(020)
	JMP SCN.33	/ CONTINUE WITH THE UCA SCAN.		/(020)
 
/ A MESSAGE IS IN THE TELETYPE BUFFER, FETCH THE FIRST THREE CHARACTERS
/ AND PERFORM A SCAN OF THE OVERLAY DEFINITION TABLE.
 
SCN.32	SAD (2)		/ IF AN ALTMODE WAS DEPRESSED, RETURN	/(020)
 			/ CARRIAGE.				/(005)
	JMP SCN.17	/ CONTINUE WITH PROCESSING.		/(001)
	JMS TA		/ FIGURE OUT TERMINA ADDRESS.		/(001)
	DAC CR+2	/ STORE LUN NUMBER.			/(001)
	JMS SAV.XL	/ SAVE XR AND LR FOR REST OF CALLS.	/(001)
	CAL CR		/ RETURN CARRIAGE.			/(001)
	JMS RES.XL	/ RESTORE INDEXING.			/(001)
								/(019)
SCN.17	LAC U.TB+3,X	/ FETCH 2ND WORD OF 1ST 5/7 WORD PAIR.	/(019)
	LMQ		/ PUT IT IN THE MQ.			/(019)
	LAC U.TB+2,X	/ FETCH THE FIRST HALF OF THE 5 CHAR.	/(019)
	DAC T.TMP1	/ AND SAVE IT FOR LF AND $ PROCESSING.	/(019)
	XOR (LF*4000)	/ CHECK FOR LINE FEED.			/(019)
	AND (774000)						/(019)
	SZA		/ WAS THE FIRST CHARACTER A LINE FEED?	/(019)
	JMP SCN.30	/ NO, CONTINUE WITH TESTS.		/(019)
	LAC T.TMP1	/ FETCH FIRST HALF OF CHARACTERS.	/(019)
	LLS 7		/ REMOVE THE LINE FEED.			/(019)
	DAC T.TMP1	/ AND SAVE IT.				/(019)
SCN.30	LAC T.TMP1	/ FETCH THE ALTERED CHARACTER STRING.	/(019)
	XOR (DOLLAR*4000) / CHECK FOR $ SIGN.			/(019)
	AND (774000)						/(019)
	SZA		/ WAS IT A $ SIGN.			/(019)
	JMP SCN.31	/ NO.					/(019)
	LAC T.TMP1	/ FETCH CHARACTER STRING.		/(019)
	LLS 7		/ REMOVE $ SIGN.				/(019)
	DAC T.TMP1	/ SAVE THE ALTERED CHARCTER STRING.	/(019)
SCN.31	LAC T.TMP1	/ FETCH THE ALTERED CHARACTER STRING.	/(019)
	AND (774000)	/ REXTRACT FIRST 7 BIT CHARACTER.	/(001)
	SAD (064000)	/ IS THE INPUT LINE ONLY A CARRIAGE RET	/(001)
	JMP SCN.15	/ YES, TREAT IT LIKE THE LOG COMMAND.	/(001)
	SAD (764000)	/ IS IT AN ALT MODE?			/(001)
	JMP SCN.15	/ YES.					/(001)
	SAD (40*200*20)	/ DOES THE INPUT LINE BEGIN WITH A	/(024)
	JMP SCN.15	/ YES -- IGNORE THE INPUT LINE.		/(024)
SCN.16	LAC T.TMP1	/ NO, FETCH THE REST OF THE CHARACTERS.	/(019)
	LRS 3		/ PUT 3RD SIXBIT CHARACTER INTO MQ.
	RAR		/ LOOSE BIT 7 OF ASCII CHARACTER.
	LRS 6		/ PUT 2ND SIXBIT CHARACTER INTO MQ.
	RAR		/ LOOSE BIT 7 OF ASCII CHARACTER.
	LRS 6		/ 3 SIXBIT CHARACTERS IN MQ.
	LACQ		/ LOAD AC WITH SIX BIT CHARACTER STRING.
	SAD (LOG)	/ CHECK FOR STRING "LOG"
	SKP		/ THE SAME.
	JMP SCN.06	/ DIFFERENT.
 
/ SPECIAL CASE. THE LOG FUNCTION IS HANDLED SEPARATELY. IT FUNCTIONS
/ ONLY AS A MECHANISM BY WHICH THE USER MAY COMMENT HIS RUN.
 
SCN.15	LAC (6)		/ FETCH JOB STATE 6.			/(001)
	DAC U.JSW,X	/ SET UP STATUS WORD.
	JMP SCN.98	/ MOVE TO NEXT UCA.
 
/ A FUNCTION, NOT "LOG" HAS BEEN REQUESTED. SCAN THE OVERLAY TABLE
/ FOR THE MAPPING. IF AN OVERLAY IS FOUND, CALL THE OVERLAY AND GO
/ TO THE NEXT UCA AREA UPON COMPLETION.
/ THE FORMAT OF THE OVERLAY TABLE IS FULLY DESCRIBED ABOVE.
 
SCN.06	DAC T.TMP1	/ SAVE TDV FUNCTION NAME.
	DAC U.CTSK,X	/ SET UCA UP WITH TASK NAME (FIRST THREE)
	JMS SAV.XL	/ SAVE XR AND LR.
	JMS UCAADR	/ CALCULATE UCA ADDRESS.
	DAC UCAADR	/ SAVE UCA ADDRESS IN UCA CALCULATION ROUTINE.
	LAC (T.OVLY)	/ FETCH TABLE ADDRESS.
	TAD TDVADJ	/ FUDGE FOR INDEXING.
	PAX		/ SET UP XR.
	TAD (T.OVLS)	/ CALCULATE LR.
	PAL		/ SET UP LR.
 
/ SCAN LOOP FOR OVERLAY TABLE.
 
	LAC T.TMP1	/ FETCH FUNCTION NAME.
SCN.07	SAD 0,X		/ IS THIS THE FUNCTION NAME?
	SKP		/ YES
	JMP SCN.08	/ NO.
	PXA		/ FETCH XR FOR LATER.
	DAC T.TMP1	/ SALT AWAY FOR AFTER RETURN.
	XCT 1,X		/ SET UP AC FOR CALL TO OVERLAY.
	XCT 2,X		/ CALL OVERLAY.
	LAC T.TMP1	/ FETCH OLD OVERLAY TABLE POINTER.
	PAX		/ SET UP INDEXING.
	XCT 3,X		/ PERFORM ANY TAIL END PROCESSING.
			/ RESTORE XR AND LR (DEFAULT TAIL END)
	JMP SCN.98	/ MOVE TO NEXT UCA.
SCN.08	AXS T.OTES	/ MOVE TO THE NEXT OVERLAY TABLE ENTRY.
	JMP SCN.07	/ NOT DONE.
 
/ THE REQUESTED TASK WAS NOT A TDV POLLER OVERLAY, CALL THE SYSTEM
/ DISPATCHER.
 
	LAC UCAADR	/ FETCH POINTER TO THE UCA.
	JMS* SYDISP	/ CALL SYSTEM TASK DISPATCHER
SCN.33	JMS RES.XL	/ RESTORE XR AND LR.			/(020)
	JMP SCN.98	/ GO TO NEXT UCA.
	.TITLE *** JOB STATE 3 PROCESSING ***
 
/ THE XQT DIRECTIVE HAS CAUSED A REQUEST TO FININS TO BE GENERATED.
/ THE CURRENT UCA IS WAITING FOR THE REQUEST TO COMPLETE BEFORE
/ CONTINUING PROCESSING.
 
JBS.03	XCT MA.STS	/ ARE WE TO STOP TDV?			/(003)
	JMP SCN.24	/ YES, GO SET WAITING FOR ABORT.	/(003)
	SNA		/ FININS DONE YET?			/(003)
	JMP SCN.98	/ NO.
	JMS SAV.XL	/ YES, SAVE XR AND LR.
	JMS UCAADR	/ CALCULATE UCA ADDRESS.
	JMS* XQT2	/ CALL XQT PROCESSOR PART 2.
	JMS RES.XL	/ RESTORE XR AND LR.
	JMP SCN.98	/ CONTINUE WITH SCAN.
 
/ SOMEONE SET THE MULTIACCESS KILL BIT. WE NOW HAVE TO MAKE	/(003)
/ SURE THAT WE GET THE REMOVE SET UP. FIRST SET UP A WAITING	/(003)
/ FOR ABORT CONDITION FOR THIS USER.				/(003)
 
SCN.24	LAC (7)		/ SET UP JOB STATE 7.			/(003)
	DAC U.JSW,X	/ JOB STATE NOW SET UP.			/(003)
	JMP SCN.98	/ GO CONTINUE PROCESSING.		/(003)
	.TITLE 	*** JOB STATE 6 PROCESSING ***
 
/ A READ IS TO BE ISSUED FOR THE UCA CURRENTLY POINTED TO BY THE
/ XR. UPON ISSUANCE OF THE READ, THE JOB STATE WILL BE CHANGED TO 2.
 
JBS.06	XCT MA.STS	/ ARE WE TO ABORT MULTIACCESS?		/(005)
	JMP SCN.22	/ YES, GO KILL THIS USER.		/(003)
	JMS TA		/ CALCULATE TERMINAL ADDRESS.		/(001)
	DAC READ+2	/ SET LUN INTO CPB.
	DAC WRITE+2	/ SET LUN INTO CPB.
	JMS SAV.XL	/ SAVE XR AND LR.
	JMS EVA		/ CALCULATE EVENT VARIABLE ADDRESS.	/(001)
	DAC READ+1	/ SET EV IN READ CPB.
	AAC U.TB-U.MAEV	/ CALCULATE ADDRESS OF TERMINAL BUFFER.
	DAC READ+4	/ SET UP CPB.
	CAL WRITE	/ CRANK UP WRITE.
 
/ TDV> HAS GONE OUT TO TERMINAL ISSUE READ.
 
SCN.12	CAL READ	/ CRANK UP READ.
	JMS STALL	/ WAIT FOR NEXT SIGNIFICANT EVENT IF	/(001)
	JMP SCN.12	/ AN ERROR OCCURS ON WRITE.		/(001)
	LAC (2)		/ FETCH NEW JOB STATE.
	DAC U.JSW,X	/ SET UP NEW JOB STATUS WORD.
	JMP SCN.98	/ ADVANCE TO THE NEXT UCA.
	.TITLE	*** JOB STATE 7 PROCESSING ***
 
/ A JOB IS AWAITING COMPLETION OF FININS IN ORDER TO ABORT THE JOB.
/ SET UP THE ^Y WORD AS IF A ^Y HAD BEEN HIT FOR THE TERMINAL AND
/ CALL THE ABORT PROCESSOR.
 
JBS.07	SNA!CLL		/ FININS DONE YET?
	JMP SCN.98	/ NO, CONTINUE WITH SCAN.		/(005)
	JMS SAV.XL	/ SAVE THE XR AND LR.
	XCT MA.STS	/ ARE WE TO ABORT MULTIACCESS?		/(003)
	JMP SCN.23	/ YES, GO SET UP FOR REMOVE.		/(005)
	LAC U.MAEV,X	/ CHECK IF A REMOVE IS NECESSARY.	/(005)
	SPA		/ AC = STL NODE ADDRESS IF YES.		/(005)
	JMP SCN.15	/ NO, SET JOB INTO STATE 6 AND CONTINUE	/(005)
	DAC U.CPB,X	/ A REMOVE MUST BE DONE, SET UP UCA FOR	/(005)
	JMP SCN.20	/ DISPATCH TO AUTORM.			/(005)
 
/ A JOB UNDERGOING FININS HAS COMPLETED WITH IT'S BUILD AND THE	/(003)
/ MCR OPERATOR HAS DISCONTINUED MULTIACCESS. SEE IF A REMOVE IS	/(003)
/ NECESSARY AND SET IT UP IF IT IS.				/(003)
 
SCN.23	LAC U.MAEV,X	/ FETCH EVENT VARIABLE.			/(003)
	SPA		/ AC WILL BE POSITIVE IF A REMOVE IS	/(003)
			/ REQUIRED.				/(003)
	JMP SCN.22	/ NO REMOVE NECESSARY, GO RUN THIS USER	/(003)
			/ THROUGH LOGOUT.			/(003)
	DAC U.CPB,X	/ SET UP STL POINTER.			/(003)
	JMP SCN.20	/ GO REMOVE THIS TASK.			/(003)
	.TITLE	*** JOB STATE 11 PROCESSING ***			/(001)
 
/ A JOB DID NOT GET A PARTITION AT THE INVOKATION OF SYDISP	/(001)
/ (THE SYSTEM DISPATCHER) OR XQT PART 2 (THE USER TASK EXECUTION/(001)
/ PROCESSOR). THE JOB IS PUT INTO JOB STATE 11 AND THE OVERLAY	/(001)
/ RETURNS TO THE POLLER. THE TASK INVOKING STATE 11 IS REQUIRED	/(001)
/ TO PLACE THE STL NODE ADDRESS (ABSOLUTE) INTO THE FIRST WORD	/(001)
/ OF THE CAL PARAMETER BLOCK AREA IN THE UCA REQUESTING THE	/(001)
/ TASK. A REQUEST FOR THE TASK WILL BE IN WORDS 1 THROUGH 5 OF	/(001)
/ THE CPB.							/(001)
 
JBS.11	LAC EXITF	/ CHECK IF ANYTHING HAS EXXITED.	/(008)
	SZA		/ AC = 0 IF NO.				/(008)
	JMP SCN.25	/ YES, GO TRY A PARTITION FIT.		/(008)
	ISZ SC.CTR	/ SHOULD WE CHECK ON GENERAL PRINCIPLES?/(008)
	JMP SCN.98	/ NO, CONTINUE THE SCAN.		/(008)
SCN.25	DZM EXITF	/ CLEAR THE EXIT FLAG.			/(008)
	LAW -10		/ RESET SC.CTR.				/(008)
	DAC SC.CTR						/(008)
	JMS SAV.XL	/ TREAT THIS THING JUST LIKE IT WAS AN	/(008)
	XCT MA.STS	/ ARE WE STOPPING MULTIACCESS.		/(003)
	JMP SCN.18	/ YES.					/(003)
	JMS UCAADR	/ FETCH UCA ADDRESS FOR OVERLAY.	/(018)
	JMS* PWAIT	/ CALL PARTITION WAIT ROUTINE.		/(018)
	JMP SCN.13	//NORMAL RETURN AT API LEVEL 5.		/(001)
 
/ AN ERROR HAS BEEN DETECTED. IF THE AC IS POSITIVE (=0) THE	/(001)
/ FIT ROUTINE FAILED TO FIND A FREE PARTITION. LEEVE THE JOB IN	/(001)
/ STATE 11 AND CONTINUE WITH THE SCAN. OTHERWISE SET THE USER	/(001)
/ INTO STATE 6 AND CONTINUE WITH THE SCAN.			/(001)
 
	SMA		/ THE AC MUST BE NEGATIVE FOR A TERMINAL/(001)
			/ ERROR.				/(001)
	JMP SCN.14	/ LEAVE ROUTINE.			/(001)
SCN.18	JMS RES.XL	/ RESTORE INDEXING.			/(001)
	LAC U.PSC,X	/ SHOULD WE RESET THE PSC VALUSE?	/(016)
	SPA		/ AC >= 0 IF YES.			/(016)
	JMP SCN.11	/ NO.					/(016)
	DZM U.PSC,X	/ INDICATE DELTA PSC.			/(106)
	LAC (1400)	/ SET UP SYSTEM DEFAULT DELTA.		/(016)
	DAC U.PSC+1,X						/(016)
SCN.11	LAC U.JSW,X	/ SEE IF WE HAVE TO CLEAN UP DISK.	/(016)
	SAD (12)	/ XQT PART 2 SETS JOB STATE TO 12.	/(002)
	JMP SCN.20	/ GO CALL REMOVE TO CLEAN UP DISK AND	/(002)
			/ STL.					/(002)
	LAC U.CPB,X	/ FETCH STL NODE ADDRESS.		/(001)
	DAC* (R1)	/ SET UP TO REMOVE NODE.		/(001)
	JMS* (NDEL)	/ DELETE NODE FROM STL.			/(001)
	JMS RES.XL	/ RESTORE INDEXING.			/(001)
	LAC U.CPB,X	/ PREPARE TO PUT NODE BACK ON FREE LIST	/(001)
	DAC* (R2)	/ NODE ADDRESS.				/(001)
	LAC (POOL)	/ FREE NODE LIST HEAD.			/(001)
	DAC* (R1)	/ LIST HEAD ADDRESS.			/(001)
	JMS* (NADD)	/ RETURN NODE TO FREE LIST.		/(001)
SCN.21	JMS RES.XL	/ RESTORE INDEXING.			/(002)
	JMP SCN.15	/ SET JOB INTO STATE 6 AND CONTINUE	/(005)
 
/  NORMAL RETURN. STL NODE HAS NOW GOT A PARTITION BLOCK ADDR	/(001)
/ IN IT. SET UP A REQUEST CAL FOR THE TASK.			/(001)
 
SCN.13	JMS RES.XL	//RESTORE XR AND LR.
	LAC (5)		//FETCH NORMAL MODE JOB STATE.		/(001)
	DAC U.JSW,X	//SET UP NEW JOB STATUS WORD.		/(001)
	LAC U.SSM,X	//FETCH START OF WAIT QUE TIME.		/(007)
	CMA!IAC		//MAKE IT NEGATIVE.			/(007)
	TAD* (SSM)	//ADD IN CURRENT SECONDS SINCE MIDNIGHT./(007)
	SPA!SNA		//MIDNIGHT WRAPAROUND?			/(007)
	.DEC							/(007)
	TAD (86400)	//YES, CALCULATE REAL NUMBER OF SECONDS./(007)
	.OCT							/(007)
	DAC T.TMP1	/ SAVE DELTA TIME FOR LATER.		/(009)
	TAD U.TW,X	//ADD IN TOTAL WAIT TIME.		/(007)
	DAC U.TW,X	//UPDATE TOTAL WAIT TIME.		/(007)
	CLA!CMA		//RESET THE SECONDS SINCE MIDNIGHT	/(022)
	DAC U.SSM,X	//FOR BATCH.				/(022)
	DBK		//LOWER FROM API 5.			/(001)
	CALX U.CPB+1	///REQUEST THE STALLED PROGRAM.		/(010)
	ISZ MA.NJB	/ INCREMENT THE NUMBER OF JOBS RUNNING.	/(009)
	NOP		/ JUST IN CASE OF AN OVERFLOW.		/(009)
	CLL		/ CLEAR THE LINK IN CASE OF MULTIPLE 	/(009)
	LAC T.TMP1	/ PRECISION ARITHMETIC. FETCH THE TIME	/(009)
	TAD MA.TW2	/ DELTA AND ADD IN THE TOTAL WAIT TIME.	/(009)
	SZL		/ DID WE OVERFLOW?			/(009)
	ISZ MA.TW1	/ YES, CONTINUE.			/(009)
	NOP		/ INCASE OF DOUBLE OVERFLOW.		/(009)
	JMS RES.XL	/ RESTORE INDEXING.			/(001)
	LAC U.MAEV,X	/ EVENT VARIABLE FOR REQUEST CAL.	/(001)
	SMA		/ EVERYTHING OK?			/(001)
	JMP SCN.98	/ YES.					/(001)
	JMS T.TERR	/ TELL USER.				/(001)
	JMP SCN.18	/ GO KILL NODE.				/(001)
SCN.20	LAC U.CPB,X	/ FETCH STL NODE ADDRESS.		/(003)
	TAD TDVADJ	/ ADJUST STL NODE FOR ACCESS TO IT.	/(003)
	PAX		/ SET UP XR WITH NODE ADDRESS.		/(003)
	.INH							/(004)
	DZM S.N1,X	///ZERO NAME.				/(003)
	DZM S.N2,X	///					/(003)
.X=S.EROX!S.ETDI!S.EPLC!S.ETEX					/(003)
	LAC (.X)	///MAKE SURE TASK WON'T START UP AGAIN.	/(003)
	.ENB							/(004)
	DAC S.DP,X	///FOR AUTORM				/(003)
	CAL REQATO	/ REQUEST AUTOREM TO UPDATE REMBLK	/(003)
	JMP SCN.21	/ PART 2. AND GO SET UP READ.		/(002)
SCN.14	JMS RES.XL	//RESTORE XR AND LR.			/(001)
	JMP SCN.98	/ CONTINUE WITH SCAN.			/(001)
	.TITLE *** ERROR PRINTING ROUTINE FOR FAILED REQUEST ***/(001)
 
/ ERROR CODE IN AC. ASSUMES THAT SAV.XL HAS BEEN CALLED.	/(001)
 
T.TERR	XX							/(001)
	CMA!IAC		/ CONVERT THE EVENT VARIABLE TO + #.	/(002)
	LRSS!CLQ 6	/ SHIFT TWO LOW ORDER DIGITS INTO MQ.	/(010)
	ALS 4							/(001)
	LLS 3							/(010)
	ALS 4							/(001)
	XOR (301406)	/ MAGIC CONSTANT FOR CONVERSION TO 5/7	/(010)
	DAC EBUF	/ SAVE FIRST 2 4/7 CHARACCTERS.		/(001)
	LACQ		/ FETCH 3/7 CHARACTER.			/(001)
	XOR (6400)	/ SET UP CR.				/(001)
	DAC EBUF+1	/ COMPLETE MESSAGE. NOW SEND IT.	/(001)
	JMS TA		/ FETCH TERMINAL ADDRESS.		/(001)
	DAC TWRIT+2	/ SET LUN IN CPB.			/(001)
	CAL TWRIT	/ WRITE MESSAGE TO USER.		/(001)
	JMS RES.XL	/ RESTORE INDEXING.			/(001)
	JMP* T.TERR	/ RETURN TO CALLER.			/(001)
 
/ CPB FO TERR.
 
TWRIT	2700							/(001)
	0
	XX							/(001)
	2							/(001)
	.+1							/(001)
	EBUF+2-.*400&777000					/(001)
	0
	.ASCII "REQUEST ERROR -- EV = -"			/(002)
EBUF	0							/(001)
	0							/(001)
	.TITLE	*** END OF TDV POLLER LOOP ***
 
/ ALL OTHER THINGS HAVE BEEN CHECKED, CHECK FOR ^T REQUESTS AND
/ HONOR THEM IF POSSIBLE.
 
SCN.98	LAC* (MA.CT)	/ FETCH ^T WORD.
	XCT MA.STS	/ ARE WE CANCELLING MULTIACCESS?	/(003)
	JMP SCN.99	/ YES, DO NOT HONOR ^T REQUESTS.	/(003)
	SNA		/ ANY WANTING ON?
	JMP SCN.99	/ NO, GO TO NEXT UCA.
	LAW -74		/ WAIT FOR 60 (10) POLLER CYCLES BEFORE	/(021)
	DAC DELAY	/ SHUTTING DOWN THE POLLER.		/(021)
	JMS SAV.XL	/ SAVE THE XR AND LR.
	JMS* LOGON1	/ CALL LOGON PART 1.
	JMS RES.XL	/ RESTORE THE XR AND LR.
SCN.99	AXS U.LEN	/ GO TO NEXT UCA.
	JMP SCN.03	/ NOT DONE YET.
								/(017)
/ SEE IF ALL THE USERS HAVE EXITTED MULTIACCESS.		/(017)
								/(017)
	LAC MA.USR	/ FETCH TTY BIT MAP.			/(017)
	SNA		/ AC >< 0 IF ANY USERS ARE ON THE SYSTEM/(021)
	ISZ DELAY	/ NO USERS ON, ARE WE DONE WAITING?	/(021)
	JMP T.WAIT	/ NO, CONTINUE WITH STALL LOOP.		/(021)
	JMS* STOPIT	/ STALL EXPIRED, KILL THE POLLER.	/(021)
/ ***	STOPIT NEVER RETURNS   ***				/(021)
	.TITLE *** UTILITY SUBROUTINES ***
 
/ SUBROUTINE TO CALCULATE TERMINAL ADDRESS (LUN NUMBER) AND	/(001)
/ SUBROUTINE TO CALCULATE EVENT VARIABLE ADDRESS.		/(001)
/ ALSO SUBROUTINE TO WAIT FOR A SIGNIFICANT EVENT IF A NEGATIVE	/(001)
/ EVENT VARIABLE OCCURS.					/(001)
 
TA	XX							/(001)
	LAC T.LUNS						/(001)
	TAD U.TTYN,X	/ ADD IN TERMINAL NUMBER.		/(001)
	JMP* TA		/ RETURN TO CALLER.			/(001)
 
EVA	XX		/ ASSUMES THAT SAV.XL HAS BEEN CALLED.	/(001)
	JMS UCAADR	/ CALCULATE UCA ADDRESS.		/(001)
	AAC U.MAEV	/ ADD IN OFFSET TO EVENT VARIABLE.	/(001)
	JMP* EVA	/ RETURN TO CALLER.			/(001)
 
STALL	XX		/ ASSUMES THAT SAV.XL HASS BEEN CALLED	/(001)
	JMS RES.XL	/ RESTORE XR AND LR.			/(001)
	LAC U.MAEV,X	/ FETCH EVENT VARIABLE.		/(001)
	SAD (-777)	/ WERE WE OUT OF NODES?			/(001)
	JMP STALL1	/ YES.					/(001)
	ISZ STALL	/ SET UP FOR RETURN ADDRESS.		/(001)
	JMP* STALL	/ TAKE NORMAL RETURN.			/(001)
STALL1	CAL SIGEVT	/ WAIT FOR THE NEXT SIGNIFICANT EVENT.	/(001)
	JMS RES.XL	/ RESTORE THE XR AND LR.		/(001)
	JMP* STALL	/ TAKE THE ERROR EXIT.			/(001)
	.EJECT							/(001)
 
/ SAVE AND RESTORE XR AND LR.
/
/ AC IS DESTROYED, XR AND LR ARE PLACED IN SAV.XR AND SAV.LR RESPECTIVELY.
 
SAV.XL	XX
	PXA		/ FETCH XR.
	DAC SAV.XR	/ SAVE XR.
	PLA		/ FETCH LR.
	DAC SAV.LR	/ SAVE LR.
	JMP* SAV.XL
 
RES.XL	XX
	LAC SAV.XR	/ FETCH XR.
	PAX		/ RESTORE XR.
	LAC SAV.LR	/ FETCH LR.
	PAL		/ RESTORE LR.
	JMP* RES.XL
	.EJECT
 
/ ROUTINE TO CALCULATE ABSOLUTE UCA ADDRESS. THIS ROUTINE ASSUMES THAT
/ SAV.XL HAS BEEN CALLED AND THAT THE XR CONTAINED THE INDEXING CONSTANT
/ FOR THE UCA ADDRESS.
 
UCAADR	XX
	LAC TDVADJ	/ FETCH INDEXING FUDGE FACTOR.
	CMA!IAC		/ MAKE IT POSITIVE.
	TAD SAV.XR	/ CALCULATE ADDRESS OF XR.
	JMP* UCAADR	/ AC CONTAINS ABSOLUTE ADDRESS FOR XR.
	.EJECT
/								/(004)
/ ROUTINE TO COUNT TASK SIZES IN HISTOGRAM TABLE TS.CTB	/(004)
/ CALLED BY THE PARTITION FIT ROUTINE EVERY TIME A SUCCESSFUL	/(004)
/ FIT IS ABOUT TO OCCUR.					/(004)
/								/(004)
 
TS.CTR	XX							/(004)
	CLL		/ TASK SIZE IN AC. CLEAR LINK FOR SHIFT./(004)
	LRS 12		/ DIVIDE TASK SIZE BY 1K.		/(004)
	AAC -41		/ CHECK FOR TASK SIZE < 33K.		/(004)
	SMA		/ IS THE TASK SIZE LESS THAN 33K?	/(004)
	CLA		/ NO, DUMP ALL BIG TASKS INTO ONE CELL.	/(004)
	AAC 41		/ RETURN TASK SIZE.			/(004)
	TAD (TS.CTB)	/ CALCULATE OFFSET INTO COUNTING TABLE.	/(004)
	DAC T.TMP2	/ USE PFIT TEMPORARY.			/(004)
	ISZ* T.TMP2	/ INCREMENT COUNTER.			/(004)
	NOP		/ IN CASE OF OVERFLOW.			/(004)
	JMP* TS.CTR	/ RETURN TO CALLER.			/(004)
	.EJECT							/(004)
 
/ ROUTINE TO CALCULATE CHECKSUM FOR A GIVEN UCA TERMINAL BUFFER.
/ THIS ROUTINE ASSUMES THAT THE XR POINTS TO THE BEGINNING OF THE
/ UCA TO BE CHECKSUMMED. THE OUTPUT OF THIS ROUTINE IS THE LINK
/ WHICH WILL BE SET TO 0 IF THE CHECKSUMS ARE EQUAL OR 1 IF THEY ARE
/ DIFFERENT.
 
CKSUM	XX
	PXA		/ FETCH XR POINTER TO UCA.
	CMA!IAC		/ MAKE NEGATIVE.
	TAD TDVADJ	/ CALCULATE - ADDRESS FOR UCA BEGINNING.
	CMA!IAC		/ AC CONTAINS POSITIVE ADDRESS FOR UCA.
	AAC U.TB+1	/ SET UP TO ACCESS TERMINAL BUFFER THROUGH X10.
	DAC* (X10)	/ XR10 NOW SET UP.
.X=U.TB-U.CPB+2		/ NUMBER OF WORDS IN TERMINAL BUFFER.
	LAW .X		/ FETCH COUNT.
	DAC T.TMP1	/ USE TEMPORARY 1 FOR STORAGE.
	CLA		/ CLEAR AC.
CKSUM1	TAD* X10	/ ADD WORD FROM BUFFER.
	ISZ T.TMP1	/ DONE WITH LOOP?
	JMP CKSUM1	/ NO.
	STL		/ ASSUME BUFFER IS DIFFERENT.
	SAD U.CKS,X	/ IS IT THE SAME?
	CML		/ YES, CLEAR THE LINK.
	DAC U.CKS,X	/ UPDATE THE CHECKSUM.
	JMP* CKSUM	/ RETURN TO CALLER.
	.TITLE *** COMMON TYPE ROUTINE FOR TDV OVERLAYS ***	/(010)
 
/ CALLING SEQUENCE:						/(010)
/								/(010)
/	JMS* TDVTYP						/(010)
/	LAC TTYN	/ TERMINAL UNIT NUMBER			/(010)
/	LAC (MSG)	/ MESSAGE ADDRESS. MUST BE AN IOPS	/(010)
/	LAC (MODE)	/ IOPS OR IMAGE ASCII MODE INDICATOR	/(010)
/			/ MUST BE 2 OR 3.			/(010)
/			/ MESSAGE OF SOME FORM.			/(010)
/	...		/ RETURN POINT.				/(010)
/								/(010)
/ ANY OVERLAY CALLING THIS ROUTINE WILL BE GUARENTEED THAT THE	/(010)
/ I/O REQUEST BEING ISSUED WILL BE QUEUED.			/(010)
 
TDVTYP	XX							/(010)
	XCT* TDVTYP	/ FETCH THE TERMINAL NUMBER		/(010)
	DAC TTYN	/ SAVE THE TERMINAL NUMBER.		/(010)
	IDX TDVTYP	/ ADVANCE THE ARGUMENT POINTER.		/(010)
	SMA		/ CHECK THE BIT?			/(010)
	JMP TYP.05	/ NO.					/(010)
	JMS CLRBTS	/ GO SCAN FREE AREA FOR DONE I/O.	/(010)
	LAC TTYN	/ CHECK TO SEE IF PREVIOUS I/O COMPLETE	/(010)
	CMA!CLL		/ SET UP FOR SHIFT			/(010)
	TAD (LRS)	/ CONSTRUCT SHIFT INSTRUCTION.		/(010)
	DAC .+2		/ PUT INSTRUCTION IN MAINLINE.		/(010)
	LAC (400000)	/ PUT BIT IN AC PROPERLY.		/(010)
	XX		/ SHIFT (IMPURE)			/(010)
	DAC MASK	/ SAVE MASK FOR LATER.			/(010)	
	AND CT.IO	/ CHECK CORRESPOINDING I/O PENDING BIT.	/(010)
	SZA		/ IS I/O DONE?				/(010)
	JMP* TDVTYP	/ NO, RETURN TO CALLER.			/(010)
TYP.05	XCT* TDVTYP	/ FETCH THE MESSAGE ADDRESS.		/(010)
	DAC MSGADR	/ STORE THE MESSAGE ADDRESS.		/(010)
	IDX TDVTYP	/ ADVANCE THE ARGUMENT POINTER TO RETURN/(010)
	XCT* TDVTYP	/ FETCH MODE INDICATOR.			/(010)
	DAC MODE	/ SAVE MODE IN CPB.			/(010)
 
/ THE ROUTINE ARGUMENTS HAVE BEEN FETCHED. CALCULATE THE BUFFER	/(010)
/ LENGTH AND THE MESSAGE LENGTH.				/(010)
 
	LAC* MSGADR	/ FETCH HEADER WORD PAIR.		/(010)
	SWHA		/ MOVE PAIR COUNT INTO LOW BITS.	/(010)
	RAL		/ CALCULATE NUMBER OF WORDS.		/(010)
	AND (776)	/ EXTRACT MESAGE LENGTH IN WORDS.	/(010)
	DAC MSGLEN	/ SAVE MESSAGE LENGTH FOR LATER		/(010)
	AAC 2		/ INCLUDE THE EVENT VARIABLE AND LENGTH	/(011)
	DAC BUFLEN	/ FIELD IN THE BUFFER LENGTH		/(010)
	DZM NEXT	/ SET UP FOR INITIAL CALL TO INSERT.	/(010)
	JMP .+3		/ SKIP WAIT CYCLE.			/(010)
TYP.10	CAL PLRMK	/ WAIT FOR 1 PRIME POLLER CYCLE.	/(010)
	CAL PLRWT	/ WAIT FOR CYCLE TO COMPLETE.		/(010)
	JMS FREEUP	/ EXPAND FREE AREA IF POSSIBLE.		/(010)
	JMS INSERT	/ MOVE MESSAGE TO BUFFER.		/(010)
	JMP TYP.10	/ NO BUFFER, WAIT.			/(010)
 
/ THE EVENT VARIABLE, LENGTH FIELD, AND MESSAGE HAVE BEEN	/(010)
/ MOVED TO THE FREE AREA. SET UP A CAL TO OUTPUT THE MESSAGE.	/(010)
 
	LAC TTYN	/ FETCH THE TDV I/O TERMINAL TO USE.	/(010)
	SMA		/ SHOULD WE SET THE I/O IN PROGRESS BIT	/(010)
	JMP TYP.15	/ NO.					/(010)
	LAC CT.IO	/ FETCH THE I/O BUSY FLAGS.		/(010)
	XOR MASK	/ SET THE BIT (GUARENTEED TO BE CLEAR)	/(010)
	DAC CT.IO	/ RESTORE THE ALTERED MASK.		/(010)
	LAC TTYN	/ FETCH THE TELETYPE NUMBER.		/(010)
	CMA		/ MAKE IT POSITIVE.			/(010)
TYP.15	TAD T.LUNS	/ ADD IN BASE OF LUN.			/(010)
	DAC TTYN	/ SET UP LUN NUMBER IN CPB.		/(010)
	SKP		/ AVOID WAIT FOR SIGNIFICANT EVENT.	/(010)
TTY.20	CAL SIGEVT	/ IN CASE OF EMPTY POOL.		/(010)
	CAL TTOCAL	/ OUTPUT MESSAGE.			/(010)
	LAC* MSGBUF	/ FETCH EVENT VARIABLE.			/(010)
	SAD (-777)	/ EMPTY NODE POOL?			/(010)
	JMP TTY.20	/ YES, WAIT FOR POOL TO EMPTY.		/(010)
	JMP* TDVTYP	/ RETURN TO CALLER.			/(010)
	.TITLE *** EXPAND FREE AREA FOR MESSAGE BUFFERS ***	/(010)
 
/ THIS ROUTINE ASSUMES THE FOLLOWING THINGS.			/(010)
/								/(010)
/ 1.	BEGFREE POINTS TO THE FIRST FREE BUFFER AREA.		/(010)
/ 2.	END FREE POINTS TO THE FIRST BUSY BUFFER AREA FOLLOWING	/(010)
/	BEGFREE.						/(010)
/ 3.	THE BUFFER AREA IS TERMINATED BY A DUMMY BUSY AREA.	/(010)
 
FREEUP	XX							/(010)
	LAC* ENDFREE	/ CHECK THE CURRENT LAST ENTRY FOR	/(010)
	SNA		/ ACTIVITY.				/(010)
	JMP FREE10	/ CANNOT EXPAND THE FREE AREA.		/(010)
	LAC ENDFREE	/ THE LAST ENTRY IS NOW IDLE, INCREASE	/(010)
	DAC* (X10)	/ ENDFREE AND TRY LOOP AGAIN.		/(010)
	DAC* (X11)	/ SET UP INCASE CLEAR GETS CALLED.	/(010)
	LAC* X10	/ FETCH UNIT AND OFFSET FLAG.		/(010)
	SPA		/ SHOULD WE CLEAR I/O BIT?		/(010)
	JMS CLEAR	/ CLEAR CT.IO BIT.			/(010)
FREE05	AND (7777)	/ EXTRACT OFFSET.			/(010)
	TAD ENDFREE	/ ALL DONE FOR NEXT PASS.		/(010)
	DAC ENDFREE	/ UPDATE END OF FREE AREA.		/(010)
	JMP FREEUP+1	/ GO OVER LOOP AGAIN.			/(010)
FREE10	LAC BEGFREE	/ FETCH BEGINNING ADDRESS.		/(010)
	DAC* (X11)	/ SET UP OUTPUT FOR NEW AREA.		/(010)
	CMA!IAC		/ CALCULATE THE NEW DELTA		/(010)
	TAD ENDFREE	/ NEW DELTA WILL BE > 0.		/(010)
	SPA!SNA		/ CHECK FOR DELTA > 0.			/(010)
	JMP* FREEUP	/ DELTA IS 0, RETURN.			/(010)
	DAC* X11	/ SET UP FREE COUNT.			/(010)
	DAC* BEGFREE	/ SET AREA NOT BUSY.			/(010)
	JMP* FREEUP	/ RETURN TO CALLER			/(010)
	.TITLE *** ROUTINE TO INSERT BUFFER INTO FREE AREA ***	/(010)
 
/ THIS ROUTINE ASSUMES THE FOLLOWING:				/(010)
/								/(010)
/ 1.	ENDFREE IS >= BEGFREE					/(010)
/ 2.	ALL ENTRIES ARE INITIALLY WELL FORMATTED.		/(010)
 
INSERT	XX							/(010)
	LAW -1		/ SET UP LOOP.				/(010)
	TAD NEXT	/ IF THIS IS THE FIRST PASS THROUGH	/(010)
	DAC NEXT	/ INSERT, NEXT WILL BE 0. FOR ALL OTHER	/(010)
			/ PASSES NEXT WILL BE > 0. THIS AVOIDS	/(010)
			/ SPURIOUS DOUBLE PASSES THROUGH THE	/(010)
			/ FIRST AREA IN THE DSR.		/(010)
INS.10	LAC ENDFREE	/ FETCH END OF FREE AREA.		/(010)
	CMA!IAC		/ MAKE IT NEGATIVE.			/(010)
	TAD BEGFREE	/ CALCULATE - FREE AREA.		/(010)
	TAD BUFLEN	/ ADD IN TOTAL BUFFER LENGTH.		/(010)
	SMA!SZA!CMA!IAC	/ WILL THE BUFFER FIT AND MAKE POSITIVE./(010)
	JMP NOTINS	/ NO, GO GARBAGE COLLECT.		/(010)
	DAC DELTA	/ SAVE DELTA FOR LATER.			/(010)
	LAC BEGFREE	/ FETCH BEGINNING OF FREE AREA.		/(010)
	DAC MSGBUF	/ STORE START OF MSG AREA.		/(010)
	DAC* (X11)						/(010)
	AAC 2		/ SET UP MESSAGE ADDRESS IN CPB.	/(010)
	DAC MSGNAD	/ CELL IN CPB.				/(010)
	LAC MSGADR	/ FETCH MESSAGE ADDRESS.		/(010)
	AAC -1		/ SET UP INPUT POINTER.			/(010)
	DAC* (X10)						/(010)
	LAC MSGLEN	/ FETCH MESSAGE LENGTH.			/(010)
	CMA		/ MAKE IT NEGATIVE TO 			/(010)
	DAC T.TMP2	/ USE IT AS A COUNTER(+1 FUDGE)		/(010)
	LAC TTYN	/ FETCH TTY NUMBER			/(010)
	LRSS!CLQ 6	/ SHIFT UNIT NUMBER INTO MQ.		/(010)
	LAC BUFLEN	/ FETCH TOTAL BUFFER LENGTH.		/(010)
	OMQ		/ SET UNIT NUMBER IN HIGH BITS.		/(010)
	DAC* X11	/ SET UP IN OUTPUT AREA.		/(010)
	LAC* X10	/ MOVE MESSAGE TO BUFFER		/(010)
	ISZ T.TMP2						/(010)
	JMP .-3		/ GO UNTIL MESSAGE MOVED.		/(010)
	LAC* (X11)	/ OUTPUT POINTER TO LAST WORD MOVED.	/(010)
	IAC		/ ADD ONE.				/(010)
	DAC BEGFREE	/ SET UP NEW BEG FREE AREA.		/(010)
	LAC DELTA	/ CHECK DELTA.				/(010)
	SPA!SNA		/ SHOULD WE STORE NEW DELTA?		/(010)
	JMP INS.99	/ RETURN.				/(010)
	DAC* X11	/ SET UP DONE BLOCK.			/(010)
	DAC* X11	/ SET UP FREE WORD COUNT.		/(010)
INS.99	IDX INSERT						/(010)
	JMP* INSERT						/(010)
 
/ WE DID NOT FIT, GO THROUGH INITIAL GARBAGE COLLECTION.	/(010)
 
NOTINS	ISZ NEXT	/ WHICH TIME THROUGH IS THIS?		/(010)
	JMP NOT.20	/ SECOND.				/(010)
	LAC BEGBUF	/ POINT TO BEGINNING OF STORAGE AREA.	/(010)
	SKP							/(010)
 
/ WE STILL DIDN'T FIND A FIT, GO UNTIL WE DO.			/(010)
 
NOT.20	LAC ENDFREE	/ FETCH END OF BUFFER.			/(010)
NOT.25	SAD ENDBUF	/ ALL DONE WITH BUFFER?			/(010)
	JMP NOT.80	/ YES, FIT FAILED.			/(010)
	DAC BEGFREE	/ SET UP FREE LIST POINTER.		/(010)
	DAC* (X10)	/ ACCESS SECOND WORD.			/(010)
	LAC* BEGFREE	/ FETCH IDLE/BUSY FLAG.			/(010)
	SZA		/ BUSY.					/(010)
	JMP NOT.30	/ NO.					/(010)
	LAC* X10	/ FETCH COUNT WORD.			/(010)
	AND (7777)	/ STRIP UNIT NUMBER.			/(010)
	TAD BEGFREE	/ ADD IN OFFSET.			/(010)
	JMP NOT.25	/ TRY AGAIN.				/(010)
NOT.30	LAC BEGFREE	/ FETCH BEGINNING.			/(010)
	DAC ENDFREE	/ SET UP END AT SAME PLACE.		/(010)
	JMS FREEUP	/ FREE UP SPACE IF POSSIBLE.	/(010)
	JMP INS.10	/ TRY LOOP AGAIN.			/(010)
NOT.80	LAC BEGBUF	/ COULDN'T FIT, CONDITION FOR NEXT PAUSE/(010)
	DAC BEGFREE						/(010)
	DAC ENDFREE						/(010)
	JMP* INSERT	/ TAKE ERROR RETURN.			/(010)
	.TITLE **** ROUTINE TO SCAN BUFFERS FOR COMPLETE I/O ***/(010)
 
CLRBTS	XX							/(010)
	LAC BEGBUF	/ BEGIN AT THE BEGINNING OF THE BUFFER	/(010)
CLR.10	SAD ENDBUF	/ BUFFER COMPLETELY SCANNED?		/(010)
	JMP* CLRBTS	/ YES, RETURN.				/(010)
	DAC T.TMP2	/ USE A TEMPORARY AS A POINTER.		/(010)
	DAC* (X10)	/ SET UP TO FETCH OFFSET.		/(010)
	DAC* (X11)	/ SET UP INCASE CLEAR IS CALLED.	/(010)
	LAC* T.TMP2	/ MESSAGE DONE?				/(010)
	SZA		/ AC = 0 IF NO.				/(010)
	JMP CLR.20	/ YES, GO FREE BITS.			/(010)
	LAC* X10	/ FETCH OFFSET TO NEXT AREA.		/(010)
CLR.15	AND (7777)	/ STRIP UNIT NUMBER.			/(010)
	TAD T.TMP2	/ ADD IN OFFSET TO NEXT AREA.		/(010)
	JMP CLR.10	/ CONTINUE LOOP				/(010)
CLR.20	LAC* X10	/ FETCH OFFSET.				/(010)
	SPA		/ DON'T CLEAR BIT UNLESS NECESSARY.	/(010)
	JMS CLEAR	/ CLEAR CT.IO AND BUFFER POINTER.	/(010)
	JMP CLR.15	/ GO TO NEXT BUFFER AREA.		/(010)
	.TITLE *** CLEAR CT.IO AND BUFFER UNIT NUMBER ***	/(010)
 
CLEAR	XX							/(010)
	PAL		/ SAVE BUFFER NONSENSE IN LIMIT REG.	/(010)
	LRSS 14		/ SHIFT UNIT NUMBER DOWN TO LOW BITS	/(010)
	CMA		/ MAKE POSITIVE.			/(010)
	TAD (LRS)	/ BUILD SHIFT FOR BITS.			/(010)
	DAC .+2							/(010)
	LAC (377777)	/ PREPARE TO TURN BIT OFF.		/(010)
	XX		/ SHIFT MASK (IMPURE)			/(010)
	AND CT.IO	/ TURN OFF BIT.				/(010)
	DAC CT.IO	/ STORE NEW BIT MASK.			/(010)
	PLA		/ FETCH OFFSET AND UNIT			/(010)
	AND (7777)	/ CLEAR UNIT TO AVOID MULTIPLE BIT CLEAR/(010)
	DAC* X11	/ CLEAR UNIT NUMBER IN OFFSET.		/(010)
	JMP* CLEAR						/(010)
	.END T.INIT
