Google
 

Trailing-Edge - PDP-10 Archives - ap-c796e-sb - initia.mac
There are 10 other files named initia.mac in the archive. Click here to see a list.
SUBTTL	AUTHOR:P.CONKLIN /PMW/JNG/WLH
; OLD AUTHOR INITIALS:/RCC/DAL/PFC

;***COPYRIGHT (C) 1970,1971,1972,1973,1974,1975,1976,1977
;	DIGITAL EQUIPMENT CORP., MAYNARD, MASS.***


INTWHO==0		; LAST MODIFIER
INTVER==7		; MAJOR VERSION
INTMIN==0		; MINOR VERSION
INTEDT==146		; EDIT LEVEL

	SALL				; CLEAN ASSEMBLY LISTINGS

	SEARCH	JOBDAT,MACTEN,UUOSYM

	TITLE. (INT,INITIA,SYSTEM START-UP PROGRAM)
	INTTTL
	INTPTX

; JOB DATA AREA
	INT137

; SHOW VERSIONS OF UNIVERSAL FILES
	%%JOBD==%%JOBD			; SHOW VERSION OF JOBDAT
	%%MACT==%%MACT			; VERSION OF MACTEN
	.REQUEST  REL:HELPER		; USES HELPER [10(146)]

;ASSEMBLY INSTRUCTIONS:
;	.LOAD INITIA



;ASSEMBLY PARAMETERS

ND	L$PDL,20	;LENGTH OF PUSH-DOWN LIST
ND	L$TTBF,^D100	;SIZE OF TTY OUTPUT BUFFER IN WORDS
ND	N$HSGF,^D50	;NUMBER OF FILES WHICH CAN BE REMEMBERED
ND	N$STRS,^D36	;NUMBER OF STRUCTURES IN S/L (MAX)
SUBTTL	TABLE OF CONTENTS

COMMENT	^
AUTHOR:P.CONKLIN /PMW/JNG/WLH  26-MAY-76..............   1
CHARACTER ROUTINE (GETCHA)............................  12
CHKPNT PROCESSOR......................................  11
CODE TO HANDLE SPECIAL STARTUP CONDITIONS.............   5
COMMAND LINE PROCESSOR................................  12
DAEMON PROCESSOR......................................  11
DECIMAL READ ROUTINE..................................  12
DEFINITIONS...........................................   4
DEFINE SYSTEMS WHICH NEED SPECIAL SET-UP..............   8
DIAL COMMAND HANDLER..................................   9
ERROR HANDLERS........................................  14
FILEX PROCESSOR.......................................  11
HANDLE COMMAND LINE...................................   5
HELP ROUTINE..........................................  11
INITIALIZATION........................................   5
INPUT ROUTINES........................................  12
KILL JOB ROUTINE......................................  11
LOGIN TO 1,2 AND RUN CUSP NAMED IN T4.................  11
MAIN PROGRAM--HANDLE COMMAND SCANNING AND DISPATCH....   5
NO COMMAND HANDLER....................................   9
OCTAL READ ROUTINE....................................  12
OMOUNT PROCESSOR......................................  11
OPSER PROCESSOR.......................................  11
PAGE COMMAND HANDLER..................................   9
PRINTR PROCESSOR......................................  11
RCV/XMT SPEED COMMAND HANDLER.........................   9
REVISION HISTORY......................................   3
ROUTINES FOR VARIOUS COMMANDS.........................   9
ROUTINE TO SETUP TTY..................................   9
ROUTINE TO KJOB IF SYSTEM GOING DOWN..................  11
ROUTINE TO TYPE PAGE:N OR NOPAGE......................  12
ROUTINE TO FORMAT SPEED...............................  12
ROUTINE TO FORMAT DECIMAL.............................  12
ROUTINE TO FORMAT BIT VALUES..........................  12
SIXBIT NAME ROUTINE (GETSIX)..........................  12
SIXBIT WORD ROUTINE (GETWRD)..........................  12
SKIP TO VALUE ROUTINE.................................  12
SPECIAL PROCESSORS....................................  11
SPECIAL TTY SETUP SEQUENCES...........................  14
STANDARD COMMAND TABLES...............................   9
START UP CUSP NAMED IN T2.............................  11
STORAGE AREA..........................................  14
SUBROUTINE TO IDENTIFY AND SAVE COMMAND...............   7
SUBROUTINE TO LIST STRUCTURE NOTES....................  11
SUBROUTINES TO LIST SYSTEM,BATCH AND TEXT NOTICES.....  11
SUBROUTINE TO TYPE TTY SETTINGS.......................  12
SUBROUTINE TO READ FROM COMMAND TTY...................  12
SUBROUTINE TO TYPE CONTENTS OF FILE...................  12
SUBROUTINE TO LOOKUP A FILE (MAYBE IN HISEG)..........  12
SUBROUTINE TO FIND A FILE IN HISEG TABLES.............  12
SUBROUTINE TO INTERLOCK THE HISEG.....................  12
SUBROUTINE TO READ FROM FILE..........................  12
SUBROUTINES...........................................  12
SUBROUTINE TO LOGIN A JOB.............................  12
SUBROUTINE TO TYPE SIGN ON MESSAGE....................  12
SUBROUTINE TO TYPE KSYS MESSAGE.......................  13
SYSDPY PROCESSOR......................................  11
SYSTEM TABLES.........................................   8
TABLE OF CONTENTS.....................................   2
TABLE SEARCH ROUTINE..................................  12
TERMINET ROUTINE......................................  12
TTY CONTROL LIST ROUTINE..............................  10
TTY EXPANSION ROUTINE (XPNTTY)........................  12
TTY SETUP PROCESSORS..................................  12
TYPEOUT ROUTINES......................................  14
^
SUBTTL	REVISION HISTORY

;%3	OCT, 71

;40	UPDATE DEC APR TABLES
;41	(10-11146) CORRECT FILEX PPN
;42	CONVERT TO C AND MAKE REENTRANT
;43	ADD APR S/N TO SIGNON MESSAGE
;44	HANDLE CASE OF .HELLO (TTY DATASET ANSWER)
;45	CHANGE TERMINET OPTION TO COMMAND LINE
;46	ADD STRUCTURE COMMAND TO COMMAND LINE
;47	LOOK AT FILE SYS:TTY.INI. LINES ARE ALL, OTHER, TTYX,TTYX-Y
;50	ADD ALL TRMOP'S FROM TTY.INI
;51	ADD HELP
;52	ADD KSYS OPTION
;53	ADD JOB # AND USER NAME IF LOGGED IN
;54	ADD ".LOGIN A,B" WHEN LOGGING IN
;55	ADD NOTICE OPTION
;56	ADD TTY OPTION
;57	GET REAL S/L IF POSSIBLE
;60	IMPLEMENT DIAL OPTION
;61	ALLOW CONTINUATION IN FILE TTY.INI AND COMMENTS ON
;	ALL COMMANDS
;62	ENSURE . IS ALWAYS TYPED JUST ONCE AT EXIT
;63	USE C AS A UNIVERSAL
;64	ADD NONAME
;65	ADD NORUN
;66	ADD NOSETTTY
;67	IF LOGGED IN, ALSO USE SWITCH.INI
;70	ALLOW TT: FOR TTY:
;71	DEFAULT TO NOSETTTY IF LOGGED IN
;72	SEPARATE USER SETTABLE TTY STUFF IN TTY TYPEOUT
;73	FIX BUGS REPORTED IN QAR-1563 (WPI)
;74	ALLOW () IN .INI OPTIONS
;%4(74)	JUNE, 1974
				CONT.
;75	HAVE INITIA REMEMBER TTY.INI AND STR.TXT IN HISEG
;76	CHANGE ALL OUTCHR UUO'S TO SUBROUTINE CALLS AND DO
;	BUFFERED TTY OUTPUT FOR SPEED
;77	ADD RTCOMPAT TO LIST OF TTY SWITCHES
;100	USE NON-BLOCKING TTY I/O TO AVOID GETTING HUNG IN 'TO'
;	STATE.
;101	(10-13,784) GET JOB NUMBER CORRECTLY IF JOBSTS FAILS
;102	(10-13,784) ADD OPTION FOR DAEMON
;103	OUTPUT "OR ATTACH" ONLY IF SOME DETACHED JOBS
;104	(SER 922) DON'T PRINT SPEED:0
;105	(10-13,595) REMOVE INICER MESSAGE ON NULL COMMAND
;106	(10-14,000) FIX BUG WHICH MISSED OTHER IN SWITCH.INI
;107	SUPPRESS "PLEASE LOGIN" IF SCHED 7
;110	(CER S70-725) WHEN LISTING USER NAME, ALSO GIVE PPN
;111	HANDLE UP TO 36 STRS IN S/L
;112	SET DEFAULT PHY & VIRT LIMITS TO 1000P
;113	REMOVE KSYS CALL OF KJOB (OPSER 5A DOES IT)
;114	DON'T LOGIN [1,2] UNLESS LOCAL TERMINAL
;115	PREVENT LOOP IF UNMATCHED '(' IN TTY.INI OR SWITCH.INI
;116	IMPLEMENT BATCH KEYWORD
;117	FIX HILOOK BUG
;120	IMPLEMENT TEXT KEYWORD
;121	BE SUSPICIOUS OF DEAD HI-SEG INTERLOCKS -- SLOWS SYS START UP
;122	ADD SYSV52 AND SYSV61 [TTY.INI COMMANDS--SYSVFT AND SYSVSO]
;123	FIX PROBLEM WITH CORE UUO FAILURE
;124	DON'T GIVE ALL PRIVILEGES TO REMOTE OPR
;125	UNKNOWN.
;126    CHANGES  TO  IMPLEMENT  'DETECT  XXXX'   FOR   SPEED
;       DEPENDENT SETUP OF DIAL-UP LINES, 'LINSPD' FOR LINES
;       RUNNING AT SPECIFIED BAUD, AND  'OTHSPD'  FOR  LINES
;       NOT AT THE SPECIFIED BAUD.
;127	ADD NETWORK CAPABILITIES FOR DIRECT ACCESS TO PHYSICAL TTY'S
;130	MERGE EDITS 126-127.
;131-132 CLEAN UP LISTING.
;133	CLEAR EOF BIT BEFORE READING ACCOUNTING FILE.
;134	FIX BUG IN NTKSYS ROUTINE..USED WRONG
;	UUO TO GET STATION STATUS.
;135	FIX BUG THAT SETUP NETWORK LINES IMPROPERLY.
;136	INSTALL CONTROL-C INTERCEPT SO HIGH SEGMENT DOESN'T
;	GET LEFT IN AN INTERLOCKED STATE.
;137	DON'T TYPE NETWORK STUFF UNLESS WERE ON A NODE,
;	QAR#631.
;	FIX CTY BUG IN XPNTTY ROUTINE.
;	USE TITLE. MACRO FROM MODUNV.UNV.
;140	MINOR FIXUPS...QAR'S 10-00671 & 10-00681
;141	MAKE SURE THAT NO LINE, LOCAL OPR OR NOT, GETS TO
;	BE A REMOTE OPR, IF IT'S ON NODE 0.
;142	1) EDIT 136 ALLOWS CONTROL-C INTERCEPT TO HAPPEN FOR ALL
;	JOBS RUNNING AT SYSTEM STARTUP TIME....DON'T DO THAT.
;	TURN THE INTERCEPT OFF AGAIN AS SOON AS WE FIND OUT
;	THAT WE'RE GOING TO WAIT FOR SOMEONE ELSE TO DO THE
;	DIRTY WORK!
;	2) PURGE REMOTE STATION STUFF..RUNNING OF REMLOD ETC.
;	AND CHANGE CODE FOR CENTRAL OPR TO GET CENTRAL OPR AND
;	NOT LOCAL OPR.
;143	CLEAN UP LISTING. REMOVE VRSN. MACRO.
;144	FIX FAULTY COMPARE AT NOTFND ROUTINE. CAUSED REMOTE
;	STATION OPR TERMINAL NOT TO COME UP.
;145	MAKE 144 WORK. CHANGE TO VERSION 7 FOR DISTRIBUTION.
;	CHANGE KEYWORD "BLANK" TO "BLANKS" IN STANDARD COMMAND TABLES.
;146	1) FIX TO HANDLE TTY0 AT CENTRAL SITE.
;	2) GET HELPER.REL FROM REL: RATHER THAN DSK:  IN ".REQUEST"
;	   PSEUDO-OP.
;	3) ELIMINATE REFERENCE TO MODUNV.UNV FILE.
;	   MACROS DEFINED IN MACTEN.UNV.
SUBTTL	DEFINITIONS

;AC NAMES

F=0	;FLAGS
T1=1	;TEMPORARIES
T2=2
T3=3
T4=4
T5=5
T6=6
T7=7
T8=10
I=11	;INDEX INTO HISEG TABLES
OC=12	;TEMP FOR TTYSTR LUUO

WD=13	;LAST INPUT WORD
CH=14	;LAST INPUT CHARACTER
BP=15	;BOMB OUT PC
ME=16	;TTY NAME OF THIS TTY
P=17	;PUSHJ-DOWN LIST POINTER


;INPUT/OUTPUT CHANNELS

IO==0	;USED FOR TEMP FILES
TI==1	;TTY.INI
TTY==2	;TTY OUTPUT
				CONT.
;FLAG BITS

F.LOGI==1B0		;LOGGED IN
F.LOGX==1B1		;OK IF ALREADY LOGGED IN
F.CCL==1B2		;FORCE CCL STARTING POINT
F.NOHD==1B3		;SUPPRESS HEADER TYPEOUT
F.PRIV==1B4		;GIVE JOB ALL PRIVILEGES
F.CCLC==1B5		;CALLED FROM CCL MODE
F.REMO==1B6		;REMOTE OPR
F.ANSW==1B8		;JUST ANSWERED TTY MODEM
F.ICMD==1B9		;INITIA COMMAND
F.ECMD==1B10		;END OF COMMAND LINE
F.EOF==1B11		;END OF FILE
F.NO==1B12		;NO XXX
F.CERR==1B13		;COMMAND ERROR
F.BIN==1B14		;READ IN BINARY
F.ALIN==1B15		;SOME LINE FOUND IN TTY.INI
F.RTTY==1B16		;RESCANNED TTY, BUT NOT REEATEN ALL YET
F.TSOL==1B17		;TYPED SOMETHING ON THIS LINE

F.PARN==1B18		;PAREN LIST OF TTYS
F.PHYS==1B19		;RUN JOB VIA PHYSICAL RUN
F.NJBS==1B20		;SET IF NO JOBSTS UUO


;USEFUL OPDEFS

OPDEF	BOMB$	[JSP BP,E$$BMB]	;DEBUGGING AID--PERMANENT FEATURE
OPDEF	TTYOUT	[1B8]	;IMMEDIATE MODE OUTCHR LUUO
OPDEF	TTYSTR	[2B8]	;OUTSTR LUUO

	TWOSEG
	RELOC	400000
SUBTTL	INITIALIZATION

INITIA:	TDZA	F,F		;ALLOW FOR CCL ENTRY
	MOVX	F,F.NOHD!F.CCLC	;IF CCL CALL, SUPPRESS HEADER
	RESET			;CLEAR THE WORLD
	SETZB	1,ZER		;CLEAR OUT STORAGE
	MOVE	P,[ZER,,ZER+1]
	BLT	P,EZER
	MOVE	P,[1,,2]
	BLT	P,P
	MOVE	P,[IOWD L$PDL,PDL]  ;INITIALIZE PUSH-DOWN LIST
	OPEN	TTY,[UU.AIO+.IOASC
		     SIXBIT /TTY/
		     XWD TTYOBF,0]
	  JRST	LOGOF$		;CAN NOT FIX THIS
	MOVE	T1,[BF.VBR+TTYBUF+1] ;SETUP BUFFER HEADER
	MOVEM	T1,TTYOBF	; TO POINT TO OUR
	MOVE	T1,[POINT 7,0,35] ; OVERSIZED TTY
	MOVEM	T1,TTYPNT	; BUFFER
	MOVE	T1,[L$TTBF+1,,TTYBUF+1]
	MOVEM	T1,TTYBUF+1	;STORE POINTER IN BUFFER
	MOVE	T1,[PUSHJ P,LUUO] ;SET UP LOCATION 41
	MOVEM	T1,.JB41

	MOVSI	T1,'CTY'	; GET NODE,LINE FOR CENTRAL STATION
	PUSHJ	P,GTNTN$
	MOVEM	T1,NL.CTY

; NOW GET THE SIXBIT TTY NAME FOR THE CTY
	TLZ	T1,-1		; CLEAR OUT THE NODE
	PUSHJ	P,CVTSIX	; CONVERT TO SIXBIT
	LSH	T1,-^D18	; SHIFT NUMBER INTO RIGHT HALF
	HRLI	T1,'TTY'	; PLANT TTY
	MOVEM	T1,CTYTTY	; AND STORE AWAY FOR LATER

	MOVE	T1,['OPR0  ']	; GET NODE,LINE FOR CENTRAL OPR [142]
	PUSHJ	P,GTNTN$
	MOVEM	T1,NL.OPR

	GETLIN	ME,0
	MOVE	T1,ME
	PUSHJ	P,GTNTN$
	MOVEM	T1,NL.ME

	LSH	T1,-^D18	; SHIFT NODE TO RIGHT HALF
	PUSHJ	P,CVTSIX	; CONVERT TO SIXBIT-LEFT JUSTIFIED
	LSH	T1,-^D18	; SHIFT RESULT TO RIGHT HALF
	HRLI	T1,'OPR'
	PUSHJ	P,GTNTN$	; GET OUR, POSSIBLY LOCAL, OPR
	MOVEM	T1,NL.LOP
				CONT.
	MOVX	T1,%CNSER	;GET APR
	GETTAB	T1,		; SERIAL
	  MOVEI	T1,0		; NUMBER
	MOVEM	T1,APRSN	;SAVE FOR LATER

	GETPPN	T1,		;GET THIS JOB'S PPN
	  JFCL			;(IN CASE OF JACCT)
	MOVEM	T1,MYPPN	;SAVE FOR LATER USE
	PJOB	T2,		;GET THIS JOB'S NUMBER
	MOVEM	T2,JOBN		;SAVE FOR LATER
	MOVNS	T2		;COMPLEMENT FOR UUO
	JOBSTS	T2,		;GET THIS JOB'S STATUS
	  JRST	[TXO   	F,F.NJBS ;INDICATE JOBSTS FAILED	[101]
		 MOVX   T2,%LDHLP ;CAN'T TELL--GET
		 GETTAB T2,	;HELP PPN (UNLOGGED JOB)
		   MOVE T2,[2,,5] ; FROM SYSTEM
		 CAME   T2,MYPPN ;SEE IF SAME
		 TXO    F,F.LOGI ;NO--MUST BE LOGGED IN
		 JRST   INIT.1]	;AND PROCEED			[101]
	TXNE	T2,JB.ULI	;SEE IF LOGGED IN YET
	TXO	F,F.LOGI	;YES. REMEMBER THAT

INIT.1:	MOVX	T1,%LDSYS	;GET SYS:
	GETTAB	T1,		; PPN
	  MOVE	T1,[1,,4]	;(DEFAULT)
	MOVEM	T1,SYSPPN	;SAVE FOR LATER

	MOVX	T1,%LDFFA	;GET [1,2]
	GETTAB	T1,		;PPN
	  MOVE	T1,[1,,2]	;(DEFAULT)
	MOVEM	T1,FFAPPN	;SAVE FOR LATER

	MOVE	T1,JOBN		;GET JOB NUMBER
	TRMNO.	T1,		;GET TTY INDEX
	  MOVEI	T1,0		;BAD NEWS
	MOVEM	T1,TERNUM	;SAVE FOR LATER
	; GET OUR SPEED AND SAVE IT FOR LATER
	MOVE	T2,T1		; PUT OUR LINE NUMBER IN T2
	MOVEI	T1,.TORSP	; GET RECEIVE SPEED
	MOVE	T3,[2,,T1]
	TRMOP.	T3,
	 SETO	T3,		; IF FAILS, USE ONES
	MOVEM	T3,MYSPD
				CONT.
SUBTTL	CODE TO HANDLE SPECIAL STARTUP CONDITIONS

;HERE TO SEE IF THIS IS DUE TO A SYSTEM GOING DOWN OPERATION
;THE IDEA IS THAT INITIA WILL HAVE BEEN INVOKED BY OPSER
;OVER A PTY IN ORDER TO CALL KJOB IN A DETACHED FASHION

REPEAT 0,<	;NO LONGER NEEDED (SINCE OPSER V.5A)		[113]
	MOVX	T1,%NSKTM	;GET THE KSYS COUNTER
	GETTAB	T1,		; FROM THE MONITOR
	  JRST	NTKSYS		;IF NOT, MUST BE PRE-KSYS
	JUMPGE	T1,NTKSYS	;SEE IF BEYOND SHUT DOWN
	SETOM	T1		;YES--SEE IF WE ARE A SUBJOB
	CTLJOB	T1,		; BY SEEING IF WE ARE CONTROLLED
	  JRST	NTKSYS		;NOT KSYS IF NO SUCH UUO
	TLNE	ME,-1		;SEE IF DETACHED
	JUMPL	T1,NTKSYS	;JUMP IF ATTACHED TO REAL TTY
	JRST	KSYS		;KILL OFF IF DET. OR CONTROLLED
>; END REPEAT 0							[113]

NTKSYS:	MOVE	T1,NL.ME	; GET OUR NODE/LINE
	TLNN	T1,-1		; NODE ZERO? [141]
	JRST	NOTREM		; YES, CAN'T BE REMOTE OPR THEN [141]
	CAMN	T1,NL.LOP	; AM I A REMOTE OPR?
	CAMN	T1,NL.OPR	; ..
	JRST	NOTREM		; NO
	TXO	F,F.REMO	; YES, FLAG AS A REMOTE OPERATOR [142]
				CONT.
;HERE TO SEE IF CALLED FROM FORCED .HELLO COMMAND OR
;IF NORMAL COMMAND WITH ARGUMENTS.

NOTREM:	TLNE	ME,-1		;SEE IF DETACHED
	TXNE	F,F.CCLC	;OR IF CCL CALL
	JRST	INIC.4		;RIGHT--NO RESCAN

;HERE TO SEE IF WE HAVE COMMANDS ON LINE

	MOVEI	T1,TTYIN	;SET FOR TTY INPUT
	MOVEM	T1,GETCH	; IN CHARACTER GETTER
	RESCAN	1		;RETRY LINE
	  SKPINC		;SEE IF SOMETHING THERE
	    JRST INIC.3		;NOTHING--CHECK FOR FORCED CALL
	TXO	F,F.RTTY	;INDICATE COMMITMENT TO REEAT LINE
	PUSHJ	P,GETWRD	;SEE IF INITIA
	CAIN	CH,":"		;SEE IF DEVICE
	JRST	.-2		;YES--TRY AGAIN
	XOR	WD,['INITIA']	;SEE IF INITIA COMMAND
	TDNN	WD,T1		; OR ABBREVIATION
	JRST	INIC.2		;YES--GO SET FLAG
INIC.1:	CAIN	CH,"("		;SEE IF THIS FORM
	JRST	INIC.2		;YES--FLAG COMMAND
	PUSHJ	P,GETWRD	;NO--MOVE ON FOR (...) FORM
	TXNE	F,F.ECMD!F.EOF	;SEE IF END OF LINE YET
	JRST	INIC.4		;YES--GIVE UP
	JRST	INIC.1		;NO--LOOP ONWARDS
INIC.2:	TXO	F,F.ICMD	;SET COMMAND FLAG
	JRST	INIC.4		;AND PROCEED

;HERE IF NO COMMAND IN INPUT BUFFER.

INIC.3:			;COULD CHECK FOR .HELLO HERE
	TXNN	F,F.LOGI	;SEE IF LOGGED IN
	TXO	F,F.ANSW	;NO--INDICATE ANSWER MODE
				CONT.
;HERE WHEN DONE WITH COMMAND ANALYSIS AND READY TO ISSUE
;THE SYSTEM SIGNON MESSAGE

INIC.4:	SETZM	GETCH		;CLEAR CHARACTER GETTER
SUBTTL	MAIN PROGRAM--HANDLE COMMAND SCANNING AND DISPATCH

;HERE TO LOOK FOR FILE SYS:TTY.INI

	MOVEI	T5,0		;CLEAR TO ASCII MODE
	MOVSI	T6,'SYS'	;DEVICE SYS:
	MOVEI	T7,IBF		;POINT TO BUFFER HEADER
	MOVSI	T1,'TTY'	;FILE NAMED
	MOVSI	T2,'INI'	;  TTY.INI[-]
	SETZB	T3,T4		;  ..
	PUSHJ	P,HILOOK	;LOOK IN HISEG OR ON DSK:
	  JRST	TYIN.2		;IGNORE FILE IF MISSING
	MOVEI	T1,FILINC	;SET FOR FILE INPUT
	MOVEM	T1,GETCH	; FOR CHARACTER GRABBER
	TXZ	F,F.ECMD!F.EOF!F.ALIN ;CLEAR SCANNING FLAGS	[106]

;HERE TO LOOP OVER LINES IN FILE TO FIND ONE FOR THIS TTY

TYIN.1:	PUSHJ	P,FILELC	;CONDITIONALLY DO THIS LINE
	JUMPGE	CH,TYIN.1	;UNLESS EOF, LOOP THROUGH FILE
	SETZM	GETCH		;CLEAR CHARACTER GETTER
	SETZM	LOWPTR		;CLEAR PTR TO HISEG
TYIN.2:	RELEAS	TI,		;RELEASE FILE
				CONT.
;HERE TO LOOK FOR ENTRY IN DSK:SWITCH.INI[,]/PHY IF LOGGED IN

	TXNN	F,F.LOGI	;SEE IF LOGGED IN
	JRST	SWIN.3		;NO--SKIP SWITCH.INI
	MOVX	T1,UU.PHS	;YES--SET /PHYSICAL
	MOVSI	T2,'DSK'	;DSK:
	MOVEI	T3,IBF		;BUFFER HEADER
	OPEN	TI,T1		;OPEN
	  JRST	SWIN.3		;IGNORE IF CAN'T OPEN
	MOVE	T1,['SWITCH']	;FILE
	MOVSI	T2,'INI'	; SWITCH.INI
	MOVEI	T3,0		; ..
	MOVE	T4,MYPPN	; [,]
	LOOKUP	TI,T1		;GET FILE
	  JRST	SWIN.3		;IGNORE IF NOT THERE
	MOVEI	T1,FILINC	;SET FOR FILE INPUT
	MOVEM	T1,GETCH	; FOR CHARACTER GRABBER
	TXZ	F,F.ECMD!F.EOF!F.ALIN ;CLEAR SCANNING FLAGS	[106]

;HERE TO LOOP OVER LINES IN FILE TO FIND ONE FOR INITIA THIS TTY

SWIN.1:	PUSHJ	P,GETWRD	;GET FIRST WORD OF LINE
	CAME	WD,['INITIA']	;SEE IF FOR INITIA
	JRST	[PUSHJ P,FILELS	;NO--SKIP LINE
		 JRST  SWIN.2]	;AND FINISH LINE
	CAIE	CH,":"		;YES--SEE IF OPTION
	JRST	[PUSHJ P,FILELN	;NO--ASSUME ALL
		 JRST  SWIN.2]	;AND FINISH LINE
	PUSHJ	P,FILELC	;YES--DO IF THIS TTY
SWIN.2:	JUMPGE	CH,SWIN.1	;LOOP TO EOF
	SETZM	GETCH		;CLEAR CHARACTER GRABBER
SWIN.3:	RELEAS	TI,		;FREE CHANNEL
				CONT.
;HERE TO LOOK FOR THIS PROCESSOR S/N IN TABLE

	PUSHJ	P,DOCMD		;GO HANDLE COMMAND LINE
	PUSHJ	P,DOTTYS	;GO DO TTY SETUP
	SKIPE	T1,JUMPPR	;SEE IF PROCESSOR SET
	JRST	(T1)		;YES--GO DO THAT
	MOVE	T1,APRSN	;GET APR S/N
	MOVSI	T2,-APRTBL	;INITIALIZE FOR SEARCH ON APR S/N
	CAME	T1,APRTAB(T2)	;TEST FOR MATCH
	AOBJN	T2,.-1		;NO--LOOP UNTIL DONE
				;IF NOT FOUND, USE CATCHALL SET

;HERE TO LOOK THROUGH SPECIAL PROCESSING TABLE

	HRRZ	T3,APRTBV(T2)	;GET ADDRESS OF JUMP TABLE
	HLRZ	T2,APRTBV(T2)	;GET ADDRESS OF NAME TABLE
	HRLI	T2,T1		;ADD INDEXING
	HRLI	T3,T1		; ..

	MOVSI	T1,-SPTABL	;INITIALIZE FOR SEARCH ON NAME
TTYS.1:	SKIPN	T4,@T2		;FETCH TTY NAME, CHECK FOR END
	JRST	NOTFND		;END OF TABLE
	CAME	ME,T4		;TEST FOR MATCH
	AOBJN	T1,TTYS.1	;NO--LOOP UNTIL DONE
	JUMPGE	T1,NOTFND	;YES--IF NOT FOUND, GIVE UP
	HLRZ	T2,@T3		;SEE IF ANY TTY SET-UP NEEDED
	SKIPE	T2		;NO--SKIP
	PUSHJ	P,(T2)		;YES--SEND IT VIA SPECIAL ROUTINES
	HRRZ	T2,@T3		;GET SPECIAL PROCESSOR
	JUMPN	T2,(T2)		;GO TO IT IF NEEDED


;HERE IF NO SPECIAL PROCESSING REQUESTED IN TABLES
;SEE IF DEVICE OPR:, IF SO, BRING UP OPSER IN CCL MODE.
;THIS WILL CAUSE OPSER TO READ THE AUTO FILE AUTOMATICALLY.

NOTFND:	MOVX	T1,%CNOPR	;GET NAME OF
	GETTAB	T1,		; DEVICE OPR:
	  JRST	GEN		; IGNORE IF UNKNOWN
	TXNN	F,F.REMO	;YES--SEE IF REMOTE OPR
	CAMN	T1,ME		;NO--SEE IF LOCAL OPR
	JRST	OPSER1		;YES--GO DO OPSER CCL
				CONT.
;HERE FOR NON-INTERESTING TERMINAL

GEN:	MOVX	T1,%CNSTS	;GET SYSTEM STATES		[107]
	GETTAB	T1,		; FROM MONITOR			[107]
	  MOVEI	T1,0		;(ASSUME OK)			[107]
	TXNN	T1,ST%BON!ST%NRL!ST%NLG ;IF LOGIN ALLOWED,	[107]
	TXNN	F,F.ANSW	;SEE IF FORCED COMMAND
	JRST	GEN.4		;NO--JUST FINISH UP		[103]
	TTYSTR	[ASCIZ \Please LOGIN\]
	TXNE	F,F.NJBS	;SEE IF JOBSTS WORKED		[103]
	JRST	GEN.2		;NO--SKIP THIS LOGIC		[103]
	MOVEI	T1,1		;YES--START AT JOB 1		[103]
GEN.1:	MOVE	T2,T1		;GET THIS JOB NUMBER		[103]
	TRMNO.	T2,		;GET ITS TERMINAL		[103]
	  JRST	[JUMPN  T2,GEN.2 ;FAILED--IF NO ANSWER, GIVE UP	[103]
		 MOVN   T2,T1	;GET JOB			[103]
		 JOBSTS T2,	;GET ITS STATUS			[103]
		   JRST GEN.3	;OK IF NONE			[103]
		 HRLZ   T3,T1	;GET JOB NUMBER			[103]
		 HRRI   T3,.GTPPN ;GET ITS PPN			[103]
		 GETTAB T3,	;(FROM MONITOR)			[103]
		   MOVEI T3,0	; ..				[103]
		 CAME   T3,FFAPPN ;UNLESS [1,2],		[103]
		 JUMPL  T2,GEN.2 ; IF DETACHED, ISSUE MESSAGE	[103]
		 JRST   .+1]	;ELSE, CONTINUE LOOP		[103]
	AOJA	T1,GEN.1	;LOOP				[103]
GEN.2:	TTYSTR	[ASCIZ / or ATTACH/]
GEN.3:	TTYSTR	CRLFM

GEN.4:	JRST	KILJOB		;JUST TYPE SYSTEM START-UP MESSAGE
				; AND RETURN TO MONITOR
SUBTTL	HANDLE COMMAND LINE

;SUBROUTINE TO HANDLE COMMAND LINE

DOCMD:	TXNE	F,F.RTTY	;IF NO COMMAND LEFT, RETURN	[105]
	TXNN	F,F.ICMD	;SEE IF COMMAND
	POPJ	P,		;NO--GIVE UP
	MOVEI	T1,TTYIN	;SET FOR TTY
	MOVEM	T1,GETCH	; IN CHARACTER GRABBER
	MOVEI	CH,0		;CLEAR CHARACTER GRABBER
	TXZ	F,F.ECMD!F.EOF!F.ALIN ;CLEAR SCANNING FLAGS	[106]
DOCM.1:	TXNN	F,F.ECMD!F.EOF	;SEE IF END OF COMMAND
	CAIN	CH,")"		;SEE IF END OF COMMAND YET
	JRST	DOCM.3		;YES--ALL DONE
	PUSHJ	P,GETWRD	;GET NEXT COMMAND WORD
	JUMPE	WD,DOCM.2	;LOOP IF NULL
	MOVE	T2,[IOWD CMDLL,CMDT]	;POINT TO POSSIBILITIES
	PUSHJ	P,FNDCMD	;FIND AND STORE COMMAND
	INTERR	(CER,Command Error,<JRST KILJOB>)
DOCM.2:	CAIN	CH,"-"		;SEE IF -XYZ
	PUSHJ	P,NO$		;YES--SET NOXYZ
	TXZN	F,F.CERR	;SEE IF ERROR
	JRST	DOCM.1		;NO--LOOP

;HERE AT END OF COMMAND--CLEAN UP LINE

DOCM.3:	TXZE	F,F.ECMD!F.EOF	;SEE IF END OF LINE
	JRST	DOCM.4		;YES--RETURN
	PUSHJ	P,GETWRD	;NO--GET NEXT WORD
	JRST	DOCM.3		;LOOP UNTIL DONE
DOCM.4:	SETZM	GETCH		;CLEAR CHARACTER GRABBER
	POPJ	P,		;RETURN
;ROUTINES TO HANDLE A LINE IN A FILE
;FILELC--CONDITIONAL BASED ON FIRST WORD BEING THIS TTY
;FILELN--ALWAYS
;FILELS--NEVER
;ALL RETURN AT END OF LINE

FILELC:	HLL	T8,NL.ME	;GET OUR NODE NUMBER
	HRR	T8,TERNUM	;AND THE 10'S TTY NUMBER
	TXZ	T8,.UXTRM	;CLEAR OUT 200000 BIT
	TXZ	F,F.PARN	;CLEAR PAREN INDICATOR
FILE.1:	PUSHJ	P,GETSIX	;GET NAME OR NODE NUMBER
	CAMN	WD,['OTHER ']	;SEE IF OTHER
	TXNE	F,F.ALIN	;YES--SEE IF NOTHING YET
	CAMN	WD,['ALL   ']	;SEE IF FOR THIS TTY
	JRST	FILELN		;ALL--GO DO IT
	; CHECK FOR A FEW MORE
	CAMN	WD,['DETECT']	; SEE IF FOR DETECTION
	 JRST	FILDET
	CAMN	WD,['LINSPD']	; SEE IF ALL SUCH SPEEDS
	 JRST	FILASP
	CAMN	WD,['OTHSPD']	; SEE IF OTHER SUCH SPEEDS
	 JRST	FILOSP
	CAIE	CH,"_"		;CHECK FOR A NODE NAME
	JRST	FILE.2
	MOVE	T8,NL.ME	;GET OUR NODE # AND RELATIVE LINE #
	MOVEI	T1,2		;TWO ARGS
	MOVE	T2,WD		;COPY THE NODE NAME
	MOVE	T6,[XWD 2,T1]	;GET THE NODE NUMBER
	NODE.	T6,		;GET IT
	 SETO	T6,		;FORCE A FAILURE ON SEARCH
	HLRZ	WD,NL.ME	;GET COPY OF OUR NODE NUMBER
	CAMN	T6,WD		;SAME AS THAT SPECIFIED?
	JRST	FILE.1		;YES, SO PROCESS THIS LINE
	JRST	FILELS		;NO, WE ENCOUNTER A BUMMER
FILE.2:	JUMPE	WD,[CAIN CH,"("	;IF NULL, SEE IF LIST [10(146)]
		    TXOE F,F.PARN ;YES--SET PAREN FLAG
		    JRST FILELS	;NO--SKIP THIS LINE
		    JRST FILE.1] ;YES--LOOP FOR TTY
	PUSHJ	P,XPNTTY	;FORMAT THE TTY NAME
	PUSHJ	P,CVTBIN	;MAKE BINARY IN THE RIGHT HALF
	HLL	WD,NL.ME	;GET OUR NODE NUMBER
	CAIE	CH,"-"		;SEE IF TTYX-Y MODE
	JRST	FILE.3		;NO--GO SEE IF SINGLE
	MOVE	T7,WD		;SAVE FIRST COMPONENT
	PUSHJ	P,GETSIX	;GET NEXT HALF
	JUMPG	WD,[HLRZS WD	;IF DIGITS, MOVE RIGHT
		    HRLI   WD,'TTY'	;MERGE IN LEFT HALF (TTY)
		    JRST  .+1]	;AND PROCEED
	PUSHJ	P,XPNTTY	;EXPAND TT: TO TTY:
	PUSHJ	P,CVTBIN	;BINARY RIGHT HALF
	HLL	WD,T7		;INSERT THE NODE NUMBER
	CAMLE	T7,WD		;SEE IF
	EXCH	T7,WD		; IN ORDER (ELSE, SWAP)
	CAMG	T7,T8		;SEE HOW WE
	CAMGE	WD,T8		;COMPARE
	JRST	FILE.5		;NO--SKIP THIS ONE
	JRST	FILE.4		;YES--DO IT
FILE.3:	CAME	WD,T8		;SINGLE--SEE IF US
	JRST	FILE.5		;NO--PROCEED
FILE.4:	TXO	F,F.ALIN	;YES--INDICATE SOMETHING
	JRST	FILELN		;DO THIS LINE
FILE.5:	CAIN	CH,","		;TEST IF LIST
	TXNN	F,F.PARN	; INSIDE PARENS
	JRST	FILELS		;NO--SKIP LINE
	JRST	FILE.1		;YES--GO TRY ANOTHER SHOT
				CONT.
FILELN:	TXZE	F,F.PARN	;DO COMMAND--SEE IF IN LIST
	JRST	[CAIN  CH,")"	;YES--SEE IF DONE YET
		 JRST  .+1	;YES--PROCEED
		 PUSHJ P,GETSIX	;NO--GET ANOTHER WORD
		 CAIN CH,.CHLFD	;[115] CHECK FOR END-OF-LINE
		 JRST	FILE.6	;[115] FOUND IT, STOP LOSING SEARCH
		 JUMPE CH,FILE.6	;[115] STOP ON END-OF-FILE TOO
		 JRST	.]	;AND LOOP
	PUSHJ	P,DOFILE	;DO THIS COMMAND
FILELS:	JUMPLE	CH,FILE.7	;IF END OF FILE, SKIP ON
	CAIN	CH,.CHLFD	;IF END OF LINE,
	JRST	FILE.7		;  SKIP ON
	PUSHJ	P,GETWRD	;ELSE, SKIP THIS LINE
	JRST	FILELS		; AND LOOP

;HERE WHEN TIME TO PROCEED ON THROUGH FILE

FILE.6:	PUSHJ	P,ERRFCR	;[115] UNMATCHED LEFT PAREN -- COMPLAIN
FILE.7:	TXZ	F,F.ECMD	;CLEAR END OF COMMAND LINE
	TXZ	F,F.PARN	;CLEAR PAREN INDICATOR
	POPJ	P,		;RETURN

	; ROUTINES TO SCAN LINES BASED ON SPEEDS

SCNSPD:	; SCAN OFF THE SPEED PART
	PUSHJ	P,SKIPTV	;SKIP TO VALUE
	PUSHJ	P,GETSIX	;GET SIXBIT WORD
	MOVE	T2,[IOWD SPEEDL,SPEEDT]
	PUSHJ	P,FNDWRD	;FIND SPEED
	 SKIPA			; TRY SPEED UNKNOWN
	POPJ	P,		;RETURN
	MOVNI	T2,2		; USE -2 FOR ERROR, -1 FOR UNKNOWN
	MOVE	T3,['UNKNOW']	; SEE IF UNKNOWN
	AND	T3,T1		; GET TO RIGHT LENGTH
	CAMN	WD,T3		; SEE IF SAME
	 SETO	T2,		; YES, USE -1
	POPJ	P,

FILASP:	PUSHJ	P,SCNSPD	; GET THE SPEED INDICATED
	CAME	T2,MYSPD	; SAME AS MINE?
	 JRST	FILE.5		; NO, TRY ANOTHER LINE
	JRST	FILE.4		; YES, DO THIS LINE

FILOSP:	PUSHJ	P,SCNSPD	; GET THE SPEED
	CAMN	T2,MYSPD	; SAME AS MINE?
	 JRST	FILE.5		; YES, TRY ANOTHER
	JRST	FILE.4		; NO, SO DO THIS ONE

FILDET:	PUSHJ	P,SCNSPD	; GET SPEED
	CAME	T2,MYSPD	; SAME AS MINE?
	 JRST	FILE.5		; NO
	TXNN	F,F.ANSW	; ARE WE DOING .HELLO?
	 JRST	FILE.5		; NO
	JRST	FILE.4		; YES

;SUBROUTINE TO HANDLE LINE OF COMMAND FILE
;CALLED AFTER FIRST WORD OF LINE IS FOR US

DOFILE:	TXNE	F,F.ECMD!F.EOF	;SEE IF END OF COMMAND
	POPJ	P,		;YES--RETURN
	PUSHJ	P,GETWRD	;GET NEXT WORD
	JUMPE	WD,DOFI.1	;IF NULL, IGNORE IT
	MOVE	T2,[IOWD CMDL,CMDT]	;FULL COMMAND TABLE
	PUSHJ	P,FNDCMD	;FIND AND STORE COMMAND
	  JRST	ERRFCR		;ERROR IF MISSING
DOFI.1:	CAIN	CH,"-"		;SEE IF - XYZ
	PUSHJ	P,NO$		;YES--SET NOXYZ
	TXZN	F,F.CERR	;SEE IF ERROR
	JRST	DOFILE		;NO--LOOP

ERRFCR:	INTWRN	(FCR,File command error)
	OUTSTR	[ASCIZ /
/]
	POPJ	P,0
SUBTTL	SUBROUTINE TO IDENTIFY AND SAVE COMMAND

;CALL:	MOVE	T2,[IOWD LENGTH,LIST]
;	PUSHJ	P,FNDCMD
;NON-SKIP RETURN IF ERROR
;SKIP RETURN IF DONE
;VALUES CAN BE SEPARATED BY : OR SPACE(S)

FNDCMD:	MOVE	T7,T2		;SAVE A COPY OF LIST
FNDC.1:	PUSHJ	P,FNDWRD	;LOOK WD UP IN TABLE
	  JRST	[XOR   WD,['NO    ']
		 TLNE  WD,777700  ;SEE IF NOXYZ
		 POPJ  P,	;NO--ERROR
		 PUSHJ P,NO$	;YES--SET FLAG
		 LSH   T1,^D12	;ADJUST MASK
		 LSH   WD,^D12	;ADJUST REST OF WORD
		 MOVE  T2,T7	;RESTORE LIST OF WORDS
		 JRST  FNDC.1]	;AND TRY AGAIN
	SKIPGE	T1,CMDP(T2)	;GET PROCESSOR
	HRRZM	T1,JUMPPR	;IF -1,,ADDR, GIVES FINAL ROUTINE
	TXNE	F,F.NO		;SEE IF NO XXX
	JUMPL	T1,CPOPJ	;IF ROUTINE, ERROR
	HLRE	T2,T1		;GET POSSIBLE VALUE
	JUMPLE	T2,FNDC.2	;IF JUMP/ROUTINE, GO HANDLE
	TXZE	F,F.NO		;SEE IF NO XXX
	TRC	T2,3		;YES--INTERCHANGE 1-2
	CAIE	T2,1		;SEE IF YES
	CAIN	T2,2		;SEE IF NO
	MOVEM	T2,(T1)		;YES--STORE VALUE
	CAIG	T2,3		;SEE IF BIT VALUE
	JRST	CPOPJ1		;YES--ALL OK
	CAIE	T2,4		;SEE IF DECIMAL VALUE
	POPJ	P,		;NO--MUST BE ERROR
	PUSH	P,T1		;SAVE LOCATION
	PUSHJ	P,SKIPTV	;SKIP TO VALUE
	PUSHJ	P,GETDEC	;GET DECIMAL VALUE
	POP	P,T2		;RESTORE LOCATION
	HRROM	T1,(T2)		;STORE VALUE
	JRST	CPOPJ1		;GIVE GOOD RETURN
FNDC.2:	TLNN	T1,-1		;SEE IF 0,,ADDR
	PUSHJ	P,(T1)		; CALL ROUTINE
	TXZE	F,F.CERR	;SEE IF COMMAND ERROR
	POPJ	P,		;YES--GIVE ERROR
	JRST	CPOPJ1		;NO--GIVE SUCCESS
SUBTTL	DEFINE SYSTEMS WHICH NEED SPECIAL SET-UP

	DEFINE	APRS,<
	X 546
;OTHERS MAY BE ADDED--EACH REQUIRES A SP MACRO
>



;DEFINE TABLE OF APR S/N TO PROCESS

	DEFINE	X(A),<
			XLIST
			EXP A
			LIST
>


	RADIX	10
APRTAB:	APRS
APRTBL==.-APRTAB
	RADIX	8



;DEFINE LIST OF TTY NAME TABLE AND PROCESSING TABLE

	DEFINE	X(A),<
			XLIST
			XWD TT'A,JJ'A
			LIST
>

APRTBV:	APRS
	XWD	TTXXX,JJXXX	;CATCHALL

SUBTTL	SYSTEM TABLES

;SYSTEM 546 TABLES
	DEFINE	SP546,<
>

;CATCHALL TABLES FOR UNRECOGNIZED SYSTEMS
	DEFINE	SPXXX,<
>
				CONT.
;PEEL OUT THE TTY NAMES

T.==0

	DEFINE	X(A),<
	XLIST
TT'A:	SP'A
	0
	IFG	.-TT'A-T.,<T.==.-TT'A>
	LIST
>

	DEFINE	Y(A,B,C),<EXP SIXBIT /A/>

	APRS
	X XXX

SPTABL==T.		;SAFETY FACTOR FOR LOOP


;PEEL OUT JUMP TABLES

	DEFINE	X(A),<	XLIST
JJ'A:	SP'A
	LIST>

	DEFINE	Y(A,B,C),<XWD C,B>

	APRS
	X XXX
SUBTTL	STANDARD COMMAND TABLES

;FOR EACH KEYWORD, DEFINE LOCATION OF
;PROCESSOR AND WHETHER OR NOT COMMAND CAN GIVE
;W	KEY,PROCESSOR,X,Y
;		X=C IF COMMAND ALLOWED
;		Y=J IF CALLED WITH JRST
;		  B IF SET A BIT
;		  I IF INVERT (OFF) A BIT
;		  D IF DECIMAL NUMBER

	DEFINE	CMDLST(J,B,I,D),<
W	ALTMODE,ALT,,I
W	AUTOMATIC,OPSER1,,J
W	BATCH,FLBAT,C,B
W	BLANKS,BLANK,,I
W	CHKPNT,CHKPNT,,J
W	CRASH,FILEX,,J
W	CRLF,CRLF,,I
W	DAEMON,DAEMON,,J
W	DEBREAK,DEBR,,B
W	DIALOUT,DIAL$,,
W	DISPLAY,DISP,,B
W	ECHO,ECHO,,I
W	ELEMENT,ELEM,,D
W	FILL,FILL,,D
W	FORM,FORM,,B
W	GAG,GAG,,I
W	H,HELP,C,
W	HDX,HDX,,B
W	HELP,HELP,C,
W	KSYS,FLKSYS,C,B
W	LC,LC,,I
W	NAME,FLNAME,C,I
W	NO,NO$,C,
W	NORUN,GEN,C,J
W	NOTICE,FLNOTC,C,B
W	OMOUNT,OMOUNT,,J
W	OPSER,OPSER,,J
W	PAGE,PAGCMD,,
W	RCVSPEED,RCV$,,
W	REMOTE,REM,,B
W	RTCOMPATABILITY,RTCOMP,,B
W	SETTTY,FLSET,C,I
W	SLAVE,SLAVE,,B
W	SPEED,SPEED$,,
W	STRUCTURES,FLSTR,C,B
W	SYSDLT,SYSDLT,,J
W	SYSDPA,SYSDPA,,J
W	SYSDPB,SYSDPB,,J
W	SYSDPY,SYSDPY,,J
W	SYSHZL,SYSHZL,,J
W	SYSVFT,SYSV52,,J
W	SYSVSO,SYSV61,,J
W	TABS,TAB,,B
W	TAPE,TAPE,,B
W	TERMINET,TRMNET,C,
W	TEXT,FLTEXT,C,B
W	TIDY,TIDY,,B
W	TTY,FLTTY,C,B
W	UC,LC,,B
W	UN,NO$,C,
W	WIDTH,WIDTH,,D
W	XMTSPEED,XMT$,,
>
				CONT.
	XALL
	DEFINE	W($KEY,$PROC,$COM,$JUMP),<
IFIDN	<$COM><C>,<
	EXP	<SIXBIT /$KEY/>	; $KEY
>>

	;TABLE OF COMMAND NAMES
CMDT:	CMDLST	(-1,1,2,4)
CMDLL==.-CMDT

	DEFINE	W($KEY,$PROC,$COM,$JUMP),<
IFDIF	<$COM><C>,<
	EXP	<SIXBIT /$KEY/>	; $KEY
>>
	CMDLST	(-1,1,2,4)
CMDL==.-CMDT


	DEFINE	W($KEY,$PROC,$COM,$JUMP),<
IFIDN	<$COM><C>,<
	XWD	$JUMP,$PROC		; $KEY
>>

	;LIST OF PROCESSORS
CMDP:	CMDLST	(-1,1,2,4)

	DEFINE	W($KEY,$PROC,$COM,$JUMP),<
IFDIF	<$COM><C>,<
	XWD	$JUMP,$PROC		;$KEY
>>
	CMDLST	(-1,1,2,4)
	SALL

SUBTTL	ROUTINES FOR VARIOUS COMMANDS

SUBTTL	NO COMMAND HANDLER

NO$:	TXOE	F,F.NO		;SET NO FLAG
	TXO	F,F.CERR	;IF ON, ERROR
	POPJ	P,		;RETURN

SUBTTL	RCV/XMT SPEED COMMAND HANDLER

SPEED$:	MOVEI	T7,3		;BOTH SPEEDS
	JRST	SPEED		;GO HANDLE
RCV$:	MOVEI	T7,2		;REC SPEED
	JRST	SPEED		;GO HANDLE
XMT$:	MOVEI	T7,1		;XMT SPEED
SPEED:	PUSHJ	P,SKIPTV	;SKIP TO VALUE
	PUSHJ	P,GETSIX	;GET SIXBIT WORD
	MOVE	T2,[IOWD SPEEDL,SPEEDT]
	PUSHJ	P,FNDWRD	;FIND SPEED
	  TXO	F,F.CERR	;ERROR IF UNKNOWN
	TXZE	F,F.NO		;SEE IF NO
	TXO	F,F.CERR	;YES--COMMAND ERROR
	TRNE	T7,2		;SEE IF RCV
	HRROM	T2,RCV		;YES
	TRNE	T7,1		;SEE IF XMT
	HRROM	T2,XMT		;YES
	TRNE	T7,2		; IF RECEIVE SPEED
	 HRRZM	T2,MYSPD	; CHANGE MYSPEED
	POPJ	P,		;RETURN

SPEEDT:	SIXBIT	/0/
	SIXBIT	/50/
	SIXBIT	/75/
	SIXBIT	/110/
	SIXBIT	/134/
	SIXBIT	/150/
	SIXBIT	/200/
	SIXBIT	/300/
	SIXBIT	/600/
	SIXBIT	/1200/
	SIXBIT	/1800/
	SIXBIT	/2400/
	SIXBIT	/4800/
	SIXBIT	/9600/
	SIXBIT	/EXTA/
	SIXBIT	/EXTB/
SPEEDL==.-SPEEDT
SUBTTL	PAGE COMMAND HANDLER

PAGCMD:	PUSHJ	P,SKIPTV	;SKIP TO VALUE IF ANY
	CAIN	CH,":"		;SEE IF VALUE
	JRST	PAGCM1		;YES--SETTING NUMBER
	CAIL	CH,"0"		;OR
	CAILE	CH,"9"		; DECIMAL
	JRST	PAGCM2		;NO--MUST JUST BE ON/OFF
PAGCM1:	TXZE	F,F.NO		;NUMBER
	TXO	F,F.CERR	;NO IS ERROR
	PUSHJ	P,GETDEC	;GET DECIMAL PAGE COUNT
	HRROM	T1,PAGE		;SET PAGE NUMBER
PAGCM2:	TXZE	F,F.NO		;ON/OFF--SEE IF OFF
	TDZA	T1,T1		;NO SO OFF
	MOVEI	T1,1		;ELSE ON
	HRROM	T1,PAGEON	;SET FOR PAGE FLAG
	POPJ	P,		;RETURN

SUBTTL	DIAL COMMAND HANDLER

DIAL$:	PUSHJ	P,SKIPTV	;SKIP TO VALUE
	SETOM	DIAL		;FILL WITH MARKERS
	SETOM	DIAL+1		;..
	MOVE	T7,[POINT 4,DIAL]
	MOVEI	T6,^D18		;PROTECTIVE COUNT
DIAL.1:	PUSHJ	P,GETCHA	;GET NEXT DIGIT
	CAIE	CH,"	"	;SEE IF TAB
	CAIN	CH," "		; OR SPACE
	JRST	DIAL.1		;YES--DISCARD
	CAIN	CH,"-"		;SEE IF SEPARATOR
	JRST	DIAL.1		;YES--DISCARD
	CAIE	CH,"("		;SEE IF
	CAIN	CH,")"		; AREA CODE SEPARATOR
	JRST	DIAL.1		;YES--DISCARD
	CAIN	CH,"*"		;SEE IF DELAY MARKER
	JRST	[MOVEI CH,16	;YES--INDICATE THAT
		 JRST  DIAL.2]	;AND STORE
	CAIL	CH,"0"		;SEE IF
	CAILE	CH,"9"		; DIGIT
	POPJ	P,		;NO--MUST BE END
DIAL.2:	IDPB	CH,T7		;STORE DIGIT
	SOJG	T6,DIAL.1	;SEE IF OVERFLOW
	TXO	F,F.CERR	;YES--SET ERROR
	SETZM	DIAL		;AND CLEAR
	SETZM	DIAL+1		; RESULT
	POPJ	P,		;RETURN

SUBTTL	ROUTINE TO SETUP TTY

DOTTYS:	SKIPN	T1,FLSET	;SEE IF
	TXNN	F,F.LOGI	; (IF DIDN'T SAY, AND LOGGED IN, ASSUME NO)
	TRNE	T1,1		; USER SAID NOSETTTY
	JRST	DOTT.2		;RIGHT--SKIP THIS
	MOVE	T1,FFAPPN	;GET [1,2]
	CHGPPN	T1,		;CHANGE TO IT FOR
	  JFCL			; PRIVILEGED TRMOP.S
	MOVSI	T7,-DOTTYU	;SET LOOP LENGTH
DOTT.1:	MOVE	T1,[3,,T2]	;POINTER FOR TRMOP
	HLRZ	T2,DOTTYT(T7)	;GET TRMOP FUNCTION
	TRZ	T2,NUS		;CLEAR FLAG BIT
	CAIL	T2,1000		;SEE IF READ TRMOP.
	ADDI	T2,.TOSET	;YES--CHANGE TO SET
	MOVE	T3,TERNUM	;GET TERMINAL NUMBER
	HRRZ	T5,DOTTYT(T7)	;GET POINTER TO VALUE
	HRRZ	T4,(T5)		;GET VALUE IF ANY
	SKIPE	(T5)		;UNLESS NULL,
	TRMOP.	T1,		; SET VALUE
	  JFCL			;IGNORE ERRORS
	AOBJN	T7,DOTT.1	;LOOP FOR ALL FUNCTIONS
	MOVE	T1,MYPPN	;RECOVER ORIGINAL PPN
	CHGPPN	T1,		;CHANGE BACK TO IT
	  JFCL			;(IGNORE IF CAN'T)

	MOVE	T1,[4,,T2]	;POINTER FOR TRMOP
	MOVEI	T2,.TODSC	;INDICATE CALL
	MOVE	T3,TERNUM	;GET OUR NUMBER
	MOVE	T4,DIAL		;GET FIRST HALF OF NUMBER
	SKIPE	T5,DIAL+1	;IF SET,
	TRMOP.	T1,		; MAKE CALL
	  JFCL			;IGNORE ERRORS

DOTT.2:	PUSHJ	P,SIGNON	;ISSUE SIGNON MESSAGE
	MOVE	T1,FLKSYS	;SEE IF
	TRNE	T1,1		; USER WANTS KSYS
	PUSHJ	P,TYKSYS	;YES--ISSUE IT
	MOVE	T1,FLTEXT				;[120]
	TRNE	T1,1					;[120]
	PUSHJ	P,TEXT					;[120]
	MOVE	T1,FLBAT	;SEE IF BAT
	TRNE	T1,1
	PUSHJ	P,BATCH		;[116]
	MOVE	T1,FLSTR	;SEE IF STRUCT
	TRNE	T1,1		; ..
	PUSHJ	P,STRUCT	;YES--TYPE STRUCTURE NOTES
	MOVE	T1,FLTTY	;GET TTY FLAG
	TRNE	T1,1		;SEE IF SET
	PUSHJ	P,TYPTTY	;YES--TYPE TTY SETTINGS
	MOVE	T1,FLNOTC	;GET NOTICE FLAG
	TRNE	T1,1		;SEE IF SET
	PUSHJ	P,NOTICE	;YES--TYPE NOTICE.TXT
	POPJ	P,		;RETURN

SUBTTL	TTY CONTROL LIST ROUTINE
;FORMAT IS XWD TRMOP.,VALUE

NUS==(1B0)	;FLAG NOT SETTABLE BY USER
		;(USED ONLY FOR TYPEOUT)

DOTTYT:
	.TOELE,,ELEM	;TTY ELEMENT
	.TOLCT,,LC	;TTY LC
    NUS!.TOSLV,,SLAVE	;TTY SLAVE
	.TOTAB,,TAB	;TTY TAB
	.TOFRM,,FORM	;TTY FORM
	.TOLCP,,ECHO	;TTY NO ECHO
	.TONFC,,CRLF	;TTY NO CRLF
	.TOWID,,WIDTH	;TTY WIDTH:N
	.TOSND,,GAG	;TTY NO GAG
    NUS!.TOHLF,,HDX	;TTY HDX (HALF-DUPLEX)
    NUS!.TORMT,,REM	;TTY REMOTE (NOT LOCAL)
	.TODIS,,DISP	;TTY DISPLAY
	.TOFLC,,FILL	;TTY FILL:N
	.TOTAP,,TAPE	;TTY TAPE
	.TOPAG,,PAGEON	;TTY PAGE
	.TOPSZ,,PAGE	;TTY PAGE:N
	.TOBLK,,BLANK	;TTY NO BLANKS
	.TOALT,,ALT	;TTY ALT
	.TORSP,,RCV	;TTY RCV:XX
	.TOTSP,,XMT	;TTY XMT:XX
	.TODBK,,DEBR	;TTY DEBREAK
	.TOTDY,,TIDY	;TTY TIDY
	.TORTC,,RTCOMP	;TTY RTCOMP
DOTTYU==.-DOTTYT

SUBTTL	ROUTINE TO KJOB IF SYSTEM GOING DOWN

REPEAT 0,<	;NO LONGER NEEDED				[113]
KSYS:	MOVE	T1,[3,,['KJO',,0
			IOWD KSYSL,KSYSC]]
	TMPCOR	T1,		;WRITE  KJOB COMMAND TO TMPCOR
	  JRST	.+2		;CAN'T--TRY DISK
	JRST	KJOB1		;DID--CALL KJOB AT CCL ENTRY

;HERE WHEN CAN'T DO IT IN TMPCOR--TRY THE DISK

	OPEN	IO,DSKOPN	;OPEN DISK CHANNEL
	  BOMB$		;GIVE UP IF CAN'T
	MOVE	T1,JOBN		;GET FILE NAME
	MOVEI	T4,3		;BY TIME-HONORED NAME MAKER
KSYSFN:	IDIVI	T1,^D10		;GET NEXT DIGIT
	ADDI	T2,'0'		;CONVERT TO SIXBIT
	LSHC	T2,-6		;CONCATENATE WITH ANSWER
	SOJG	T4,KSYSFN	;LOOP UNTIL DONE WITH 3 DIGITS
	HRRI	T3,'KJO'	;APPEND FILE CODE
	MOVSI	T4,'TMP'	;GET EXTENSION
	SETZB	T5,T6		;CLEAR DIRECTORY
	ENTER	IO,T3		;MAKE  FILE
	  BOMB$		;GIVE UP IF ILLEGAL
	OUTPUT	IO,[IOWD KSYSL,KSYSC
			0]
	RELEASE	IO,		;COMPLETE OPERATION

;HERE WHEN CCL FILE WRITTEN AND TIME TO CALL KJOB

KJOB1:	MOVE	T2,[SIXBIT /KJOB/]  ;GET CUSP NAME
	JRST	CUSP1		;RUN IT AT CCL ENTRY

DSKOPN:	1B0+17		;PHYSICAL DISK OPEN
	'DSK   '
	0

KSYSC:	ASCIZ	\KJOB KSYS.LOG=/W/B
\
KSYSL==.-KSYSC
>; END REPEAT 0							[113]

SUBTTL	SPECIAL PROCESSORS

;HERE TO START UP FILEX UNDER [10,1] TO SAVE CRASH

SUBTTL	FILEX PROCESSOR
FILEX:	MOVX	T2,%LDCRP	;GET NUMBER OF CRASH STORAGE AREA
	GETTAB	T2,		;FROM THE MONITOR
	  MOVE	T2,[10,,1]	;(FOR PRE 5.3)
	TLNE	T2,777760	;HACK TO GET AROUND 5.2 BUG
	MOVE	T2,[10,,1]	;WHICH GAVE JUNK IN 16,,16
	MOVE	T4,[SIXBIT /FILEX/]  ;GET CUSP NAME
	JRST	LOGCSP		;GO LOGIN AND RUN CUSP

SUBTTL	OMOUNT PROCESSOR
OMOUNT:	MOVE	T4,[SIXBIT /OMOUNT/]  ;GET CUSP NAME
	JRST	CUSP12		;GO LOGIN AND RUN IT

SUBTTL	DAEMON PROCESSOR
DAEMON:	MOVE	T4,[SIXBIT /DAEMON/]  ;GET THE CUSP NAME
	JRST	CUSP12		;GO LOGIN AND RUN IT

SUBTTL	CHKPNT PROCESSOR
CHKPNT:	MOVE	T4,[SIXBIT /CHKPNT/]  ;GET THE CUSP NAME
	JRST	CUSP12		;GO LOGIN AND RUN IT

SUBTTL	OPSER PROCESSOR
OPSER1:	TXO	F,F.CCL		;FORCE CCL ENTRY POINT
OPSER:	MOVE	T4,[SIXBIT /OPSER/]  ;GET CUSP NAME
	JRST	CUSP12		;LOGIN AND RUN IT
				CONT.
SUBTTL	PRINTR PROCESSOR
PRINTR:	MOVE	T4,[SIXBIT /PRINTR/]  ;GET THE CUSP NAME
	JRST	CUSP12		;AND LOGIN AND START IT

SUBTTL	SYSDPY PROCESSOR
SYSDLT:	SKIPA	T4,[SIXBIT /SYSDLT/]  ;DELTA DATATERM
SYSHZL:	MOVE	T4,[SIXBIT /SYSHZL/]  ;HAZELTINE 2000
	JRST	SYSDPX		;GO DO IT
SYSDPA:	SKIPA	T4,[SIXBIT /SYSDPA/]  ;VT05A
SYSDPB:	MOVE	T4,[SIXBIT /SYSDPB/]  ;VT05B
	JRST	SYSDPX
SYSV52:	SKIPA	T4,[SIXBIT /SYSV52/]	;VT52		[122]
SYSV61:	MOVE	T4,[SIXBIT /SYSV61/]	;VT61		[122]
	JRST	SYSDPX
SYSDPY:	MOVE	T4,[SIXBIT /SYSDPY/]  ;VT06
SYSDPX:	TXO	F,F.LOGX	;FLAG OK TO RUN UNDER ANY NUMBER

SUBTTL	LOGIN TO 1,2 AND RUN CUSP NAMED IN T4
CUSP12:	PUSH	P,T4		;SAVE T4
	PUSHJ	P,LOGI12	;LOG INTO 1,2 TO DISPLAY PRIVILEGED INFORMATION
	JRST	CUSPXX		;GO FINISH RUNNING CUSP

;HERE TO DO ARBITRARY LOGIN TO (T2) AND RUN CUSP IN (T4)

LOGCSP:	PUSH	P,T4		;SAVE COPY OF CUSP NAME
	PUSHJ	P,LOGIN$	;GO DO LOGIN

CUSPXX:	POP	P,T2		;RESTORE T2
				CONT.
SUBTTL	START UP CUSP NAMED IN T2

CUSP:	PUSH	P,T2		;SAVE NAME
	TTYSTR	[ASCIZ /.R /]
	PUSHJ	P,TYPSIX	;TYPE NAME
	TTYSTR	CRLFM
	POP	P,T2		;RECOVER NAME
	TXNN	F,F.CCL		;SEE IF FORCED CCL ENTRY POINT
	TLZA	T1,-1		;CLEAR RUN OFFSET
CUSP1:	MOVSI	T1,1		;SET RUN OFFSET FOR CCL ENTRY
	MOVEM	T2,RUNBLK+1	;SAVE CUSP NAME
	MOVSI	T2,(SIXBIT /SYS/)  ;GET CUSPS FROM SYS
	MOVEM	T2,RUNBLK	;SAVE DEVICE
	HRRI	T1,RUNBLK	;SET POINTER FOR RUN UUO
	MOVEM	F,SAVEF		;SAVE FLAGS FOR LATER
	PUSHJ	P,TTYPBF	;DUMP TTY BUFFER
	MOVE	T2,[RUN T1,]	;GET RUN UUO
	TXNE	F,F.PHYS	;SEE IF PHYSICAL NEEDED
	TXO	T2,UU.PHY	;YES--SET IT
	XCT	T2		;GO RUN THE CUSP
	MOVE	P,[IOWD L$PDL,PDL]  ;IN CASE OF FAILURE--LOGOUT
	MOVEI	ME,0		;CLEAR GARBAGE
	MOVE	F,SAVEF		;RESTORE FLAGS
	INTERR	(NFD,,<JRST .+1>)
	MOVE	T2,RUNBLK+1	;GET CUSP NAME
	PUSHJ	P,TYPSIX	;TYPE IT OUT
	TTYSTR	[ASCIZ / not found
/]

SUBTTL	KILL JOB ROUTINE

KILJOB:	TXNE	F,F.RTTY	;SEE IF STILL SOME TO REEAT
	PUSHJ	P,TTYIND	;YES--EAT IT UP
	TXNN	F,F.LOGI	;SEE IF LOGGED IN
	TTYSTR	[ASCIZ	/
./]				;NO--GIVE CONVENTIONAL DOT
LOGOF$:	PUSHJ	P,TTYPBF	;EMPTY TTY BUFFER
LOGO1$:	LOGOUT	1,		;EXIT WITH JUST A DOT

LOGOU$:	LOGOUT			;DESTROY THE JOB

SUBTTL	SUBROUTINE TO LIST STRUCTURE NOTES

STRUCT:	MOVEI	T7,0		;PRESET FOR SYSSTR
	MOVE	T6,.JBFF	;SAVE FREE CORE
STRUCL:	MOVEM	T6,.JBFF	;RESTORE FREE CORE
	SYSSTR	T7,		;GET NEXT STR IN SYSTEM
	  POPJ	P,		;GIVE UP IF NOT LEVEL-D
	JUMPE	T7,CPOPJ	;RETURN WHEN DONE
	PUSH	P,T6		;SAVE TWO AC'S
	PUSH	P,T7		; ..
	MOVX	T5,UU.PHS	;ACCESS /PHYSICAL
	MOVE	T6,T7		;GET STR NAME
	MOVEI	T7,IBF		;POINT TO INPUT BUFFER HEADER
	MOVSI	T1,'STR'	;PREPARE
	MOVSI	T2,'TXT'	; FILE
	MOVEI	T3,0		; STR.TXT[1,4]
	MOVE	T4,SYSPPN	; ON EACH STRUCTURE
	PUSHJ	P,HILOOK	;LOOKUP FILE ON DISK OR HISEG
	  JRST	STRUCO		;IGNORE IF MISSING OR SCREWY
	MOVE	T2,(P)		;GET STR NAME
	PUSHJ	P,TYPSIX	;TYPE IT
	TTYSTR	[ASCIZ /:	/]
	PUSHJ	P,TYPFIL	;GO TYPE FILE
STRUCO:	POP	P,T7		;RESTORE STR NAME
	POP	P,T6		;RESTORE .JBFF
	SETZM	LOWPTR		;FORGET ABOUT FILE
	RELEAS	TI,		;RELEASE CHANNEL
	HLLZS	.JBINT		;CLEAR INTERCEPT
	TXZ	F,F.EOF		;CLEAR EOF FLAG
	JRST	STRUCL		;LOOP FOR NEXT STR

SUBTTL	HELP ROUTINE

HELP:	MOVE	T1,['INITIA']
	PUSHJ	P,.HELPR##	;GO GIVE HELP
	JRST	KILJOB		;GO KILL JOB
SUBTTL	SUBROUTINES TO LIST SYSTEM,BATCH AND TEXT NOTICES

;ROUTINE TO TYPE OUT INITIA.TXT FROM SYS:			[120]

TEXT:	MOVEI	T5,0		;READ IN ASCII MODE		[120]
	MOVSI	T6,'SYS'	;SYS:
	MOVEI	T7,IBF		;INPUT BUFFER
	MOVE	T1,['INITIA']	;LOOKUP
	MOVSI	T2,'TXT'	; FILE
	SETZB	T3,T4		; SYS:INITIA.TXT[-]
	PUSHJ	P,HILOOK	;FIND FILE IN HISEG
	  POPJ	P,		;GIVE UP IF NO FILE
	PUSHJ	P,TYPFIL	;TYPE CONTENTS OF FILE
	SETZM	LOWPTR		;FORGET FILE
	RELEAS	TI,		;RELEASE CHANNEL
	TXZ	F,F.EOF		;CLEAR EOF INDICATOR
	POPJ	P,		;RETURN				[120]

NOTICE:	MOVEI	T5,0		;READ IN ASCII MODE
	MOVSI	T6,'SYS'	;SYS:
	MOVEI	T7,IBF		;INPUT BUFFER
	MOVE	T1,['NOTICE']	;LOOKUP
	MOVSI	T2,'TXT'	; FILE
	SETZB	T3,T4		; SYS:NOTICE.TXT[-]
	PUSHJ	P,HILOOK	;FIND FILE IN HISEG
	  POPJ	P,		;GIVE UP IF NO FILE
	PUSHJ	P,TYPFIL	;TYPE CONTENTS OF FILE
	SETZM	LOWPTR		;FORGET FILE
	RELEAS	TI,		;RELEASE CHANNEL
	TXZ	F,F.EOF		;CLEAR EOF INDICATOR
	POPJ	P,		;RETURN

;ROUTINE TO LIST CURRENT BATCH SYSTEM  (IF ANY)

BATCH:	MOVE T1,[%SIQSR]	;GALAXY TEST		[116]
	GETTAB	T1,
	SKIPA			;FAIL GETTAB JUST CHECK BATCON, LPTSPL
	JUMPN	T1,BATGAL	;NON-0, TYPE "GALAXY"
	MOVE	T7,[%CNLMX]	;NOT GALAXY, GET LOGMAX FOR NAME SEARCH
	GETTAB	T7,		;INTO T7
	POPJ	P,		;FAIL? FORGET THE WHOLE THING
	MOVEI	T1,.GTPRG	;PROGRAM NAME TABLE
	SETZM	T2		;COUNTER
	SETZM	T4
BAT1:	MOVEI	T3,.GTPRG		;PROGRAM-NAME TABLE TABLE NUMBER
	AOS	T2		;COUNT TO NEXT JOB
	HRL	T3,T2		;USE AS INDEX INTO TABLE
	GETTAB	T3,		;GET PROGRAM NAME
	JFCL			;QUITE POSSIBLE NOT ACTIVE JOB NUMBER
	CAMN	T3,[SIXBIT /LPTSPL/]
	JRST	LPSET		;LPTSPL RUNNING, REMEMBER IT
	CAMN	T3,[SIXBIT /BATCON/]
	JRST	BATSET		;BATCON RUNNING, REMEMBER IT
BAT2:	CAME	T2,T7		;DONE?
	JRST BAT1		;NO, CHECK NEXT
	SKIPN	T4		;BATCON IOR LPTSPL?
	JRST BATNO		;NO, "NO BATCH SUPPORT"
	CAIN	T4,3		;BOTH OF THEM?
	JRST BATBOT		;YES, "MPB SPOOLING AND BATCH"
	CAIN	T4,1		;JUST LPTSPL?
	JRST BATSPL		;YES, "MPB SPOOLING SYSTEM"
	POPJ	P,		;NO, BATCON ALONE IS MEANINGLESS

LPSET:	TROA	T4,1		;SET LPTSPL BIT
BATSET:	TRO	T4,2		;SET BATCON BIT
	CAIN	T4,3		;GOT BOTH?
	JRST BATBOT		;YES, TYPE AND QUIT
	JRST	BAT2		;NO, CONTINUE

BATNO:	TTYSTR	[ASCIZ /	 NO BATCH SUPPORT/]
	TTYSTR	CRLFM
	POPJ	P,

BATGAL:	TTYSTR	[ASCIZ /	 GALAXY SPOOLING AND BATCH SYSTEM/]
	TTYSTR	CRLFM
	POPJ	P,

BATBOT:	TTYSTR	[ASCIZ /	 MPB SPOOLING AND BATCH SYSTEM/]
	TTYSTR	CRLFM
	POPJ	P,

BATSPL:	TTYSTR	[ASCIZ /	 MPB SPOOLING SYSTEM/]
	TTYSTR	CRLFM
	POPJ	P,
;END OF [116]

SUBTTL	SUBROUTINE TO TYPE TTY SETTINGS

TYPTTY:	SETZM	T8		;CLEAR OUTER LOOP
TYPT.1:	MOVSI	T7,-DOTTYU	;LOOP OF TTY SETUP TABLE
	MOVEI	WD,0		;PRESET COUNTER OF SUCCESSES
TYPT.2:	MOVE	T1,[2,,T2]	;ARG POINTER
	HLRZ	T2,DOTTYT(T7)	;GET FUNCTION
	TRC	T2,(T8)		;COMPARE WITH OUTER LOOP
	TRNE	T2,NUS		;SEE IF WRONG ONE
	JRST	TYPT.6		;RIGHT--SKIP THIS TIME
	CAIGE	T2,1000		;SEE IF READ FUNCTION
	JRST	TYPT.6		;NO--IGNORE IT
	HRRZ	T6,DOTTYT(T7)	;GET STORAGE
	MOVSI	T5,-TYPTTU	;LOOP OVER SPECIAL FORMATTERS
TYPT.3:	HRRZ	T4,TYPTTT(T5)	;GET ITS STORAGE
	CAME	T4,T6		;SEE IF SAME
	AOBJN	T5,TYPT.3	;NO--LOOP
	MOVE	T6,TYPTTW(T5)	;YES OR END--GET NAME
	HLR	T5,TYPTTT(T5)	;GET ADDRESS OF FORMATTER
	JUMPL	T5,TYPT.5	;IF FOUND, GO DO IT
	HRRZ	T6,DOTTYT(T7)	;RESTORE MATCHING VALUE
	MOVSI	T5,-CMDL	;ELSE LOOP OVER COMMAND TABLE
TYPT.4:	HRRZ	T4,CMDP(T5)	;GET ITS STORAGE
	CAME	T4,T6		;SEE IF SAME
	AOBJN	T5,TYPT.4	;NO--LOOP
	JUMPG	T5,TYPT.6	;IGNORE IF NOT IN EITHER TABLE
	MOVE	T6,CMDT(T5)	;GET NAME
	HLRE	T5,CMDP(T5)	;GET FORMAT INDICATOR
	JUMPLE	T5,TYPT.6	;IF SPECIAL ROUTINE, IGNORE
	CAIL	T5,3		;SEE IF 4
	MOVEI	T5,3		;YES--MERGE INTO SEQUENCE
	MOVE	T5,[TYPBON	;1=BIT ON
		    TYPBOF	;2=BIT OFF
		    TYPVAL]-1(T5) ;3/4=DECIMAL VALUE
;HERE WHEN STYLE IDENTIFIED
TYPT.5:	MOVE	T3,TERNUM	;GET TTY NUMBER
	TRMOP.	T1,		;READ VALUE
	  JRST	TYPT.6		;IGNORE IF ERROR
	TRNN	WD,7		;SEE IF MULTIPLE OF 8
	SKIPN	WD		; BUT NOT FIRST
	SKIPA			;NO--PROCEED
	TTYSTR	CRLFM
	AOS	WD		;ADVANCE COUNTER
	PUSHJ	P,(T5)		;FORMAT OUTPUT
TYPT.6:	AOBJN	T7,TYPT.2	;LOOP OVER TRMOP TABLE
	TTYSTR	CRLFM
	TRON	T8,NUS		;SET FOR SECOND PASS
	JRST	TYPT.1		;IF FIRST TIME, GO DO SECOND TIME
	POPJ	P,		;RETURN
TYPTTT:			;TABLE OF SPECIAL FORMATTERS,,VALUE
	TYPAGA,,PAGEON
	TYPAGB,,PAGE
	TYPSPD,,RCV
	TYPSPD,,XMT
TYPTTU==.-TYPTTT

TYPTTW:			;TABLE OF NAMES OF ABOVE
	SIXBIT	/PAGE/
	SIXBIT	/PAGE/
	SIXBIT	/RCV/
	SIXBIT	/XMT/

SUBTTL	ROUTINE TO TYPE PAGE:N OR NOPAGE

TYPAGA:	MOVEM	T1,PAGEON	;SAVE FOR PAGE:N LOGIC
	JUMPE	T1,TYPBON	;IF NO PAGE, GO TYPE
	POPJ	P,		;ELSE, RETURN
TYPAGB:	SKIPN	PAGEON		;SEE IF NO PAGE
	POPJ	P,		;YES--RETURN
	JUMPE	T1,TYPBOF	;NO--IF PAGE:0 TYPE PAGE
	JRST	TYPVAL		;ELSE, TYPE DECIMAL PAGE

SUBTTL	ROUTINE TO FORMAT SPEED

TYPSPD:	ANDI	T1,17		;PROTECT AGAINST JUNK
	JUMPE	T1,CPOPJ	;IGNORE IF ZERO			[104]
	PUSH	P,T1		;SAVE VALUE
	MOVE	T2,T6		;GET NAME
	PUSHJ	P,TYPSIX	;TYPE IN SIXBIT
	TTYSTR	[ASCIZ /SPEED:/]
	POP	P,T1		;RECOVER SPEED INDEX
	MOVE	T2,SPEEDT(T1)	;GET SPEED
	PUSHJ	P,TYPSIX	;TYPE IN SIXBIT
	PJRST	TYPSPC		;END WITH SPACE

SUBTTL	ROUTINE TO FORMAT DECIMAL

TYPVAL:	PUSH	P,T1		;SAVE VALUE
	MOVE	T2,T6		;GET NAME
	PUSHJ	P,TYPSIX	;TYPE IN SIXBIT
	TTYOUT	":"		;SEPARATE FROM VALUE
	POP	P,T1		;RESTORE VALUE
	PUSHJ	P,TYPDEC	;TYPE IN DECIMAL
	PJRST	TYPSPC		;END WITH SPACE

SUBTTL	ROUTINE TO FORMAT BIT VALUES

TYPBOF:	TRC	T1,1		;VALUE NORMALLY ON SO SWITCH
TYPBON:	TRNN	T1,1		;SEE IF SET
	TTYSTR	[ASCIZ /NO/]	;NO--INDICATE
	MOVE	T2,T6		;GET NAME
	PUSHJ	P,TYPSIX	;TYPE IN SIXBIT
TYPSPC:	TTYOUT	" "		;ISSUE SPACE
	POPJ	P,
SUBTTL	TTY SETUP PROCESSORS


;NOTE--ALL MUST PRESERVE T1, T3

SUBTTL	TERMINET ROUTINE
;TRMNET -- SETUP TERMINET 300 TABS

TRMNET:	MOVEI	T2,TRMIMG	;GET SPECIAL TEXT TO SEND
	PUSHJ	P,SNDIMG	;SEND TO UNIT
	SETOM	T2		;FLAG FOR THIS UNIT
	GETLCH	T2		;GET LINE CHARACTERISTICS
	TXO	T2,GL.TAB	;SET TABS FLAG
	SETLCH	T2		;SET LINE CHARACTERISTICS
	POPJ	P,		;RETURN

SUBTTL	INPUT ROUTINES

;SUBROUTINE TO FIND A WORD IN A TABLE
;CALL:	MOVE	WD,WORD IN SIXBIT
;	MOVE	T1,MASK OF WHAT TYPED
;	MOVE	T2,[IOWD LEN,TABLE]
;	PUSHJ	P,FNDWRD
;	ERROR RETURN
;	FOUND WITH T2=INDEX OF RESULT
;USES T3, T4, T5

SUBTTL	TABLE SEARCH ROUTINE
FNDWRD:	MOVE	T3,T2		;SAVE POINTER
	MOVEI	T5,0		;CLEAR ABBREVIATION POINTER
FNDW.1:	MOVE	T4,1(T3)	;GET NEXT TRIAL
	XOR	T4,WD		;COMPARE
	JUMPE	T4,FNDW.3	;GOOD MATCH
	TDNE	T4,T1		;SEE IF OK AS ABBREVIATION
	JRST	FNDW.2		;NOT ABBREVIATION
	SKIPE	T5		;SEE IF ABBREVIATION KNOWN
	SETOM	T5		;YES--SET FLAG
	SKIPN	T5		;SEE IF ANY ABBREVIATION
	HRRZ	T5,T3		;SAVE POINTER
FNDW.2:	AOBJN	T3,FNDW.1	;LOOP OVER LIST
	SKIPG	T3,T5		;RECOVER ABBREVIATION
	POPJ	P,		;ERROR RETURN IF NONE
FNDW.3:	SUBI	T3,(T2)		;GET INDEX
	MOVEI	T2,(T3)		;COPY RESULT
CPOPJ1:	AOS	(P)		;SUCCESS
	POPJ	P,		;RETURN
;SUBROUTINE TO SKIP TO VALUE IF ANY
;SKIPS ONE : OR SEVERAL SPACES/TABS

SUBTTL	SKIP TO VALUE ROUTINE
SKIPTV:	CAIN	CH,":"		;SEE IF :
	POPJ	P,		;YES--OK TO PROCEED
SKTV.1:	CAIE	CH," "		;SEE IF SPACE
	CAIN	CH,"	"	; OR TAB
	JRST	[PUSHJ P,GETCHA	;YES--SKIP ON
		 JRST  SKTV.1]	;AND LOOP
	HRROM	CH,REEAT	;REEAT LAST CHAR
	POPJ	P,		;RETURN

;ROUTINE TO READ A DECIMAL NUMBER
;RETURNS VALUE IN T1; USES T2

SUBTTL	DECIMAL READ ROUTINE
SUBTTL	OCTAL READ ROUTINE
GETOCT:	SKIPA	T2,[10]	; LOAD OCTAL BASE
GETDEC:	MOVEI	T2,^D10	; LOAD DECIMAL BASE
	MOVEI	T1,0		; CLEAR RESULT
	PUSHJ	P,GETCHA	;GET LEAD CHARACTER
	CAIE	CH,"#"		;SEE IF OCTAL FORCER
	JRST	GTDC.1		;NO--START ACCUMULATION
	MOVEI	T2,10		;YES--CHANGE TO OCTAL RADIX
	PUSHJ	P,GETCHA	;AND REPLACE FIRST CHARACTER
GTDC.1:	CAIL	CH,"0"		;SEE IF
	CAIL	CH,"0"(T2)	; NUMERIC
	JRST	GTDC.2		;NO--MUST BE DONE
	IMULI	T1,(T2)		;YES--ROUND UP
	ADDI	T1,-"0"(CH)	;INCLUDE THIS DIGIT
	PUSHJ	P,GETCHA	;GET NEXT CHARACTER
	JRST	GTDC.1		;LOOP
GTDC.2:	CAIN	CH,"."		;SEE IF DECIMAL SUFFIX
	PUSHJ	P,GETCHA	;YES--SKIP IT
	POPJ	P,		;RETURN VALUE
;SUBROUTINE TO GET A SIXBIT NAME
;RETURNS SIXBIT NAME IN WD, TERMINATOR IN CH, MASK IN T1

SUBTTL	SIXBIT NAME ROUTINE (GETSIX)
GETSIX:	SETZB	T1,WD		;CLEAR RESULTS
GETSI1:	PUSHJ	P,GETCHA	;GET NEXT CHARACTER
	CAIL	CH,"0"		;SEE IF
	CAILE	CH,"9"		; NUMERIC
	SKIPA			;NO
	JRST	GETSI2		;YES
	CAIL	CH,"A"		;SEE IF ALPHA
	CAILE	CH,"Z"+40	; ..
	JRST	GETSI3		;NO--EXIT
	CAILE	CH,"Z"
	CAIL	CH,"A"+40
	SKIPA
	JRST	GETSI3		;NO--EXIT
	TRZ	CH,40		;FORCE UPPER CASE
GETSI2:	TLOE	T1,(77B5)	;MASK NEXT CHAR ON
	JRST	GETSI1		;LOOP
	ROT	T1,6		;POSITION MASK
	LSH	WD,6		;POSITION SIXBIT NAME
	IORI	WD,-40(CH)	;INCLUDE NEXT CHAR
	JRST	GETSI1		;LOOP FOR MORE
GETSI3:	CAIN	CH," "		;SEE IF BLANK SEPARATOR
	JUMPE	T1,GETSIX	;IF BLANK FIELD, SKIP LEADING BLANKS
	JUMPE	T1,CPOPJ	;RETURN IF NULL
	TLNE	T1,(77B5)	;SEE IF LEFT ADJUSTED
	POPJ	P,		;YES--RETURN
	LSH	T1,6
	LSH	WD,6
	JRST	GETSI3
;SUBROUTINE TO CHANGE TTXXX: INTO TTYXXX:
;THIS ALLOWS 2 LETTER GENERIC DEVICE NAMES
;ROUTINE ALSO INSERTS LEADING 0 IN TTY NUMBERS TO SIMPLIFY
;COMPARES

SUBTTL	TTY EXPANSION ROUTINE (XPNTTY)
XPNTTY:	CAMN	WD,[SIXBIT /CTY/]
	MOVE	WD,CTYTTY	; GET TTY NNN FOR CTY [137]
	MOVE	T1,WD		; COPY WORD
	TLC	T1,'TT0'	;TEST TT THEN DIGIT
	TRNN	T1,77		;MUST BE LE 5 CHARS
	TLNE	T1,777770	;AND THAT FORM
	JRST	XPNT.1		;NOT--LEAVE ALONE
	MOVE	T1,WD		;MAKE ANOTHER COPY
	LSHC	T1,-^D24	;IS--SEPARATE GENERIC PART
	LSH	T1,6		;MOVE OVER
	TRO	T1,'Y'		;INCLUDE THE Y
	LSHC	T1,^D18		;REJOIN
	MOVE	WD,T1		;RESTORE TO NORMAL AC
XPNT.1:	TRNN	WD,77		;SEE IF LESS THAN 6 CHARS
	TRNN	WD,-1		;SEE IF GREATER THAN 3
	POPJ	P,		;NO--RETURN
	HRRZ	T1,WD		;YES--GET RIGHT HALF
	TRC	T1,'0  '	;REMOVE DIGIT OFFSET
	TRNE	T1,7700		;SEE IF SECOND DIGIT
	TRC	T1,'0 '		;YES--REMOVE ITS OFFSET
	TRNE	T1,707070	;VERIFY ALL DIGITS
	POPJ	P,		;NO--LEAVE ALONE
	HRRZ	T1,WD		;OK--GET CLEAN COPY
	SKIPA			;ALL DIGITS
	LSH	T1,-6		; ADJUST
	TRNN	T1,77		; DIGITS
	JRST	.-2		; ..
	TRNN	T1,770000	;SEE IF FILL NEEDED
	TRO	T1,'0  '	;YES--FILL WITH 0
	TRNN	T1,7700		;SEE IF MORE FILL
	TRO	T1,'0 '		;YES--AGAIN
	HRR	WD,T1		;RETURN TO ANSWER
	POPJ	P,		;RETURN

SUBTTL	CVTSIX
;SUBROUTINE CVTSIX - CONVERT OCTAL NUMBERS IN THE RANGE
; 0-777 TO LEFT-JUSTIFIED SIXBIT. ON ENTRY T1=BINARY, ON
; RETURN T1=SIXBIT VALUE
; NOTE: THIS SUBROUTINE STRIPS TRAILING ZEROS.
CVTSIX:	TDZ	T1,[-1,,777000] ; CLEAR OUT GARBAGE
	MOVE	T3,[POINT 6,T1]	; PREPARE BYTE POINTER
CVTLOP:	IDIVI	T1,10	; DIVIDE OCTAL
	HRLM	T2,(P)		; STACK REMAINDER
	SKIPE	T1		; QUIT WHEN DONE
	PUSHJ	P,CVTLOP	; ELSE LOOP
	HLRZ	T2,(P)		; UNSTACK
	TRO	T2,20		; SIXBITIZE
	IDPB	T2,T3		; STORE IN LEFT HALF OF T1
	POPJ	P,0

;SUBROUTINE CVTBIN - CONVERT RIGHT HALF OCTAL TO SIXBIT
;CALL	MOVE	WD,ARG
;	PUSHJ	P,CVTBIN
;RETURN	CPOPJ

CVTBIN:	PUSH	P,WD+1
	TDZ	WD,[XWD -1,707070]
	LSHC	WD,-3
	LSH	WD,-3
	LSHC	WD,-3
	LSH	WD,-3
	LSHC	WD,6
	POP	P,WD+1
	POPJ	P,
;SUBROUTINE TO GET A SIXBIT WORD
;RETURNS WORD IN WD, TERMINATOR IN CH, MASK IN T1

SUBTTL	SIXBIT WORD ROUTINE (GETWRD)
GETWRD:	SETZB	T1,WD		;CLEAR RESULTS
GETWR1:	PUSHJ	P,GETCHA	;GET NEXT CHARACTER
	CAIL	CH,"A"		;SEE IF ALPHA
	CAILE	CH,"Z"+40	; ..
	JRST	GETWR2		;NO--EXIT
	CAILE	CH,"Z"
	CAIL	CH,"A"+40
	SKIPA
	JRST	GETWR2		;NO--EXIT
	TRZ	CH,40		;FORCE UPPER CASE
	TLOE	T1,(77B5)	;MASK NEXT CHAR ON
	JRST	GETWR1		;LOOP
	ROT	T1,6		;POSITION MASK
	LSH	WD,6		;POSITION WORD
	IORI	WD,-40(CH)	;INCLUDE NEXT CHAR
	JRST	GETWR1		;LOOP FOR MORE
GETWR2:	CAIN	CH," "		;SEE IF BLANK SEPARATOR
	JUMPE	T1,GETWRD	;YES--IF BLANK, SKIP LEADING SPACES
	JUMPE	T1,CPOPJ	;RETURN IF NULL
	TLNE	T1,(77B5)	;SEE IF LEFT ADJUSTED
	POPJ	P,		;YES--RETURN
	LSH	T1,6
	LSH	WD,6
	JRST	GETWR2


;SUBROUTINE TO GET NEXT CHARACTER
;RETURNS CHARACTER IN CH

SUBTTL	CHARACTER ROUTINE (GETCHA)
GETCHA:	SKIPE	REEAT		;SEE IF REPEATING CHAR
	JRST	[HRRE  CH,REEAT  ;REPEAT IT
		 SETZM REEAT	;ONLY ONCE
		 POPJ  P,]	;RETURN
	SETOM	CH		;PRESET EOF
	TXNE	F,F.EOF		;SEE IF EOF ALREADY
	POPJ	P,		;YES--RETURN
	MOVEI	CH,.CHLFD	;PRESET EOL
	TXNE	F,F.ECMD	;SEE IF END ALREADY
	POPJ	P,		;RETURN IF SO
	SKIPE	CH,GETCH	;SEE IF INPUT ROUTINE
	PUSHJ	P,(CH)		;YES--GO READ
	  TXOA	F,F.ECMD	;END OF LINE--SET FLAG
	POPJ	P,		;ELSE, RETURN
	MOVEI	CH,0		;CLEAR CH IF END
	POPJ	P,		;RETURN

SUBTTL	SUBROUTINE TO READ FROM COMMAND TTY
;SKIP RETURNS WITH VALUE IN CH
;NON-SKIPS IF END OF LINE (BREAK)

TTYIN:	GETLIN	ME,		;GET CURRENT LINE
	TLNE	ME,-1		;IF DETACHED, ALL DONE
	INCHSL	CH		;GET CHARACTER
	  JRST	TTYI.2		;ALL DONE IF BUFFER EMPTY
	JUMPE	CH,TTYIN	;IGNORE IF NULL
	CAIE	CH,.CHCRT	;ALSO IF C.RET.
	CAIN	CH,.CHDEL	; OR NULL
	JRST	TTYIN		; IGNORE
	CAIE	CH,"!"		;SEE IF COMMENT
	CAIN	CH,";"		; OR OTHER FORM
	JRST	TTYIND		;YES--GO DISCARD LINE
TTYI.1:	CAIE	CH,.CHBEL	;IF BELL
	CAIN	CH,.CHESC	; OR ESCAPE,
	JRST	TTYI.2		;IT IS ALL DONE
	CAIL	CH,.CHLFD	;IF LESS THAN LINE FEED
	CAILE	CH,.CHFFD	; OR GREATER THAN FORM FEED
	JRST	CPOPJ1		; THEN OK
TTYI.2:	TXZ	F,F.RTTY	;INDICATE SUCCESSFUL REEATING
	POPJ	P,		;ELSE, ALL DONE
TTYIND:	INCHSL	CH		;GET CHARACTER TO DISCARD
	  JRST	TTYI.2		;RETURN IF DONE
	PUSHJ	P,TTYI.1	;ANALYZE RESULT
	  POPJ	P,		;RETURN IF EOL
	JRST	TTYIND		;LOOP UNTIL DONE

SUBTTL	COMMAND LINE PROCESSOR
; SUBROUTINE TO INPUT FROM FILE DISCARDING
; COMMENTS AND HANDLING CONTINUATIONS

FILINC:	SKIPE	CH,FILICH	;SEE IF LEFT OVER CHARACTER
	JRST	FILI.1		;YES--REUSE IT
	PUSHJ	P,FILI.3	;NO--GET NEXT FROM FILE
	  POPJ	P,		;AT END, RETURN
FILI.1:	SETZM	FILICH		;CLEAR LEFT OVERS
	CAIE	CH,"-"		;SEE IF CONTINUATION
	JRST	CPOPJ1		;NO--GOOD RETURN
FILI.2:	PUSHJ	P,FILI.3	;YES--SKIP ON
	  JRST	FILINC		;IF END, GET CONTINUATION
	CAIE	CH,"	"	;IGNORE TRAILING
	CAIN	CH," "		; SPACES AND TABS
	JRST	FILI.2		;LOOP
	MOVEM	CH,FILICH	;NOT EOL, MUST BE REAL -
	MOVEI	CH,"-"		;RETURN IT
	JRST	CPOPJ1		;SAVING NEXT CHAR FOR LATER ON

;SUBROUTINE TO STRIP COMMENTS

FILI.3:	PUSHJ	P,FILIN		;GET NEXT CHAR
	  POPJ	P,		;IF EOL, INDICATE THAT
	CAIE	CH,"!"		;ELSE SEE IF COMMENT
	CAIN	CH,";"		; OR OLD FORM
	SKIPA			;YES
	JRST	CPOPJ1		;NO--GOOD RETURN
FILI.4:	PUSHJ	P,FILIN		;SKIP REST OF LINE
	  POPJ	P,		;GIVE EOL RETURN
	JRST	FILI.4		;LOOP

SUBTTL	SUBROUTINE TO TYPE CONTENTS OF FILE

TYPFIL:	TXO	F,F.TSOL	;INDICATE NOT AT START OF LINE
	TXZ	F,F.ECMD!F.EOF	;INDICATE NOT AT EOF
TYPF.1:	PUSHJ	P,FILIN		;GET NEXT CHARACTER
	  JUMPL	CH,TYPF.2	;RETURN AT EOF
	CAIN	CH,.CHLFD	;IF LINE FEED,
	TXZA	F,F.TSOL	;AT EOL, CLEAR LINE FULL FLAG
	TXOA	F,F.TSOL	;NOT EOL, INDICATE SOMETHING TYPED
	TTYOUT	.CHCRT		; OUTPUT C.RET.
	TTYOUT	(CH)		;OUTPUT CHARACTER
	JRST	TYPF.1		;LOOP UNTIL DONE

TYPF.2:	TXZE	F,F.TSOL	;SEE IF ANYTHING ON THIS LINE
	TTYSTR	CRLFM
	POPJ	P,		;NOW RETURN
;SUBROUTINE TO LOOKUP A FILE (MAYBE IN HISEG)
;CALL WITH:
;	T1 THRU T4 SET TO 4-WORD LOOKUP BLOCK
;	T5 THRU T7 SET TO OPEN BLOCK
;	PUSHJ	P,HILOOK
;	  RETURN HERE IF FILE NOT FOUND
;	RETURN HERE IF FILE EXISTS (LOWPTR SET TO BYTE PTR OR 0)
HILOOK:	TXNN	F,F.ANSW	;IS THIS A FORCED COMMAND?
	JRST	HILK.7		;NO--DO THE SLOW THING
	PUSHJ	P,HIFIND	;IS THIS IN THE HISEG TABLES?
	  JRST	HILK.2		;NO--GO MEMORIZE THE FILE
HILK.1:	SKIPN	T1,HS$PTR(I)	;DOES THE FILE EXIST?
	POPJ	P,0		;NO--GIVE NON-SKIP RETURN
	MOVEM	T1,LOWPTR	;REMEMBER BYTE POINTER TO STRING
	JRST	CPOPJ1		;GIVE GOOD RETURN
;HERE TO REMEMBER A FILE
HILK.2:	PUSHJ	P,HILOCK	;INTERLOCK THE HISEG
	  JRST	HILK.7		;GIVE UP IF CAN'T LOCK
	PUSHJ	P,HIFIND	;GO FIND THE FILE IN THE HISEG TABLE
				; ON THE CHANCE THAT IT SNUCK IT.
	  SKIPA			;NO--THAT IS WHAT I THOUGHT
	JRST	HILK.1		;YES--IT HAS SNUCK IT
	MOVSI	I,-N$HSGF	;MAKE AN AOBJN POINTER
HILK.3:	SKIPE	HS$DEV(I)	;IS THIS SLOT FREE?
	AOBJN	I,.-1		;NO--KEEP LOOKING
	JUMPGE	I,HILK.7	;TABLE FULL?
	PUSH	P,T6		;REMEMBER DEVICE, BUT NOT SO THAT HIFIND [117]
				;FINDS IT BEFORE FILE ACTUALLY GETS IN
				;(PUT IT IN HS$DEV(I) ON COMPLETION)
	MOVEM	T1,HS$FIL(I)	;REMEMBER FILE NAME
	MOVEM	T2,HS$EXT(I)	;REMEMBER EXTENSION
	MOVEM	T4,HS$PPN(I)	;REMEMBER PPN
	OPEN	TI,T5		;OPEN DEVICE
	  JRST	HILK.8		;FILE NOT FOUND		[117]
	LOOKUP	TI,T1		;FIND THE FILE
	  JRST	HILK.8		;FILE NOT FOUND		[117]
				CONT.
;HERE TO COPY FILE INTO THE HISEG
	HLRZ	T2,.JBHRL	;FIND WHERE IN HIGH SEGMENT
	TRO	T2,400000	;PUT IN HIGH-SEG BIT
	MOVE	T1,HIPTR	;GET POINTER TO STRING
	TRNN	T1,-1		;IF NOT SET...
	HRRI	T1,1(T2)	;...GET FIRST FREE IN HIGH SEG
	MOVEM	T1,HIPTR	;INITIALIZE IT
	MOVEM	T1,HS$PTR(I)	;REMEMBER FOR THE FUTURE
	TXZ	F,F.ECMD!F.EOF	;FLAG NOT AT EOF
HILK.4:	HRRZ	T1,HIPTR	;GET POINTER TO STRING
	ADDI	T1,10		;AVOID USUAL END EFFECTS
	HRRZ	T2,.JBHRL	;GET SIZE OF HISEG
	CAMG	T1,T2		;WILL WE NEED MORE CORE
	JRST	HILK.5		;NO--KEEP GOING
	HRLZ	T1,T1		;DO A CORE UUO FOR HISEG
	CORE	T1,		; ..
	  JRST	[SETZM HS$DEV(I);FORGET THE FILE
		 POP	P,T6
		 SETZM	LOWPTR	;[123] FILE NOT FOUND
		 JRST	CPOPJ1]	;[123] BUT STILL SET UP
;**;[123]		 JRST  HILK.7]	; ..
HILK.5:	PUSHJ	P,FILIN		;GET A BYTE
	  JUMPL	CH,HILK.6	;EOF?
	IDPB	CH,HIPTR	;STORE THE BYTE IN THE HISEG
	JRST	HILK.4		;KEEP LOOKING
HILK.6:	SETZM	CH		;FLAG END OF FILE
	IDPB	CH,HIPTR	; ..
	IDPB	CH,HIPTR	; ..
HILK.8:	POP	P,HS$DEV(I)	;NOW, REMEMBER DEVICE IN TABLE	[117]
	JRST	HILK.1		;RETURN TO STORE POINTERS

;HERE IF USER IS LOGGED IN -- JUST DO THE LOOKUPS
HILK.7:	SETZM	LOWPTR		;MAKE SURE WE READ FILE
	OPEN	TI,T5		;OPEN THE DEVICE
	  POPJ	P,0		;FILE NOT FOUND
	LOOKUP	TI,T1		;LOOK FOR THE FILE
	  POPJ	P,0		;FILE NOT FOUND
	JRST	CPOPJ1		;FILE SETUP
;SUBROUTINE TO FIND A FILE IN HISEG TBALES
;CALL WITH:
;	T1 = FILE NAME
;	T2 = EXTENSION
;	T4 = PPN
;	T6 = DEVICE
;	PUSHJ	P,HIFIND
;	  HERE IF NOT IN TABLE
;	HERE IF IN TABLE (INDEX IN I)
HIFIND:	MOVSI	I,-N$HSGF	;AOBJN PTR
HFND.1:	CAME	T6,HS$DEV(I)	;RIGHT DEVICE
	JRST	HFND.2		;NO.
	CAME	T1,HS$FIL(I)	;RIGHT FILE
	JRST	HFND.2		;NO.
	CAME	T2,HS$EXT(I)	;RIGHT EXTENSION
	JRST	HFND.2		;NO
	CAMN	T4,HS$PPN(I)	;RIGHT PPN
	JRST	CPOPJ1		;YES--WE WON
HFND.2:	AOBJN	I,HFND.1	;LOOP OVER WHOLE TABLE
	POPJ	P,0		;NOT THERE
;SUBROUTINE TO INTERLOCK THE HISEG
;CALL WITH:
;	PUSHJ	P,HILOCK
;	  ERROR RETURN IF CAN'T GET HISEG
;	RETURN HERE
;NOTE: HISEG IS RELEASED ON POPJ
;
HILOCK:	MOVE	T8,[[XWD 4,INTLOC
		    XWD 0,ER.ICC!ER.OFL
		    0
		    0],,INTBLK]
	BLT	T8,INTBLK+3
	MOVEI	T8,INTBLK	; POINT TO TRAP BLOCK
	MOVEM	T8,.JBINT	; SET FOR TRAPPING!
TR.SET:	MOVEI	T8,0		;CLEAR USER WRITE PROTECT
	SETUWP	T8,		; ..
	  JRST	[SETZM NOINT
		POPJ	P,0]
	PUSH	P,T8+1		;SAVE AN AC
	MOVEI	T8,^D180	;WAIT FOR 3 MIN
	IDIV	T8,JOBN		;ADJUST FOR SLEEP TIME
	MOVEM	T8,WAITCT	;STORE AWAY
	POP	P,T8+1		;RESTORE AC
HLCK.1:	SETOM	NOINT		; NOT INTERRUPTABLE [142]
	AOSN	LOCKWD		;GET THE INTERLOCK
	JRST	HLCK.2		;IF THE RESULT IS ZERO WE WON
	SETZM	NOINT		;DIDN'T GET INTERLOCK, MAKE
				; INTERRUPTABLE AGAIN [142]
	MOVE	T8,JOBN		;GET OUR JOB NUMBER
	SLEEP	T8,		;GO TO SLEEP
	SOSN	WAITCT		;TRIED ENOUGH
	  JRST	UNLOCK		; ERROR RETURN
	MOVE	T8,LOCKWD	;GET INTERLOCK COUNT
	CAIG	T8,^D100	;LOOKING SUSPICIOUS?
	  JRST	HLCK.1		;NO, KEEP TRYING
	PUSH	P,LOKJOB	;SAVE A COPY FOR CHECKING
	PUSH	P,LOKTTY	;GET HIM TOO
	HRLZ	T8,-1(P)	;POINT TO INTERLOCKER'S JBTSTS
	GETTAB	T8,		;GET IT
	  JRST	FORCE		;??? FORCE THE LOCK
	TLC	T8,440000	;RUN+JNA
	TLCE	T8,440000	;BOTH ON?
	  JRST	FORCE		;NO, SOMETHING WRONG
	HRLZ	T8,-1(P)	;SET UP JOB # AGAIN
	HRRI	T8,.GTPRG	;LOOK FOR PROGRAM NAME
	GETTAB	T8,		;GET IT
	  JRST	FORCE		;TOO BAD
	CAME	T8,['INITIA']	;RIGHT GUY?
	  JRST	FORCE		;NO, TOO BAD
	MOVE	T8,(P)		;GET OWNER'S TTY UDX
	DEVTYP	T8,		;LOOK AT TTY'S PROPERTIES
	  JRST	FORCE		;TOO BAD
	LDB	T8,[POINTR(T8,TY.JOB)]	;GET JOB # USING IT
	CAME	T8,-1(P)	;RIGHT GUY?
	 JRST	FORCE		;NO, GOT HIM!!
	SUB	P,[2,,2]	;RESTORE THE PDL
	JRST	HLCK.1		;GOOD LOCK, RETURN
HLCK.2:	POP	P,T8		;GET RETURN PC
	PUSH	P,JOBN		;GET OUR JOB #
	POP	P,LOKJOB	;STORE FOR OTHERS
	PUSH	P,TERNUM	;AND OUR LINE
	POP	P,LOKTTY	;SAVE IT AWAY
	PUSHJ	P,1(T8)		;SKIP CALL COROUTINE
UNLOCK:	  SOS	(P)		;INDICATE FAILURE
	SETOM	LOCKWD		;RESET INTERLOCK
	MOVEI	T8,1		;GO AND WRITE PROTECT
	SETUWP	T8,		; THE HISEGMENT AGAIN
	  JFCL
	SETZM	.JBINT		; TURN OFF TRAPPING
	SETZM	NOINT		; CLEAR NO INTERRUPT WORD
	JRST	CPOPJ1		;GIVE SKIP RETURN

;HERE TO FORCE THE LOCK
FORCE:	SETOM	LOCKWD		;BOOM!
	SUB	P,[2,,2]	;RESTORE PDL
	JRST	HLCK.1		;RE-JOIN THE COMPETITION

; HERE TO PROCESS CONTROL-C INTERCEPT
INTLOC:	MOVEM	T1,TEMP1	; SAVE T1
	HLRZ	T1,INTBLK+3	; GET REASON FOR INTERRUPT
	CAIN	T1,ER.OFL	; DSK OFF LINE?
	JRST	OFLPRC		; YES, GO PROCESS IT
	CAIE	T1,ER.ICC	; NO, CONTROL-C INTERRUPT?
	HALT			; NO, MY GOD!
	SKIPL	NOINT		; INTERRUPTABLE?
	EXIT		; YES, SO QUIT IF THAT'S WHAT HE WANTS
	OUTSTR	[ASCIZ /
Interlocked/]
OFLENT:	EXCH	T1,TEMP1	; RESTORE T1
	PUSH	P,INTBLK+2	; SETUP FOR POPJ RETURN
	SETZM	INTBLK+2	; SET FOR ANOTHER TRAP
BADTRP:	POPJ	P,0		; RETURN TO SEQUENCE
; HERE ON DSK OFF LINE INTERRUPTS
OFLPRC:	MOVEI	T1,STRUCO	; GET DESIRED RETURN ADDRESS
	MOVEM	T1,INTBLK+2	; AND FUDGE IT
	JRST	OFLENT		; GO DO THE STANDARD STUFF

SUBTTL	SUBROUTINE TO READ FROM FILE
;SKIP RETURNS WITH VALUE IN CH
;NON-SKIPS IF END OF LINE (CH=-1 AT EOF)

FILIN:	TXNE	F,F.EOF		;SEE IF EOF
	JRST	FLIN.3		;YES--REPEAT THAT
	ILDB	CH,LOWPTR	;GET A BYTE FROM HISEG
	JUMPN	CH,FLIN.1	;JUMP IF VALID DATA
	SKIPE	LOWPTR		;SKIP IF WE NEVER SETUP HISEG
	JRST	FLIN.3		;ELSE THIS IS THE EOF MARK
	SOSGE	IBF+.BFCTR	;COUNT DOWN BYTES
	JRST	FLIN.2		;EMPTY--GET NEXT BUFFER
	IBP	IBF+.BFPTR	;INCREMENT TO NEXT BYTE
	TXNE	F,F.BIN		;SEE IF BINARY FILE
	JRST	[LDB  CH,IBF+.BFPTR
		 JRST CPOPJ1]	;IF SO, RETURN WORD
	MOVE	CH,@IBF+.BFPTR	;GET NEXT WORD
	TRNE	CH,1		;SEE IF SEQUENCED
	JRST	[AOS IBF+.BFPTR	;YES--SKIP 5
		 MOVNI CH,5	; MORE CHARS
		 ADDM CH,IBF+.BFCTR
		 JRST FILIN]	;AND TRY AGAIN
	LDB	CH,IBF+.BFPTR	;GET CHARACTER
	JUMPE	CH,FILIN	;IGNORE NULLS
	CAIE	CH,.CHCRT	;ALSO C.RET.
	CAIN	CH,.CHDEL	; AND DELETE
	JRST	FILIN		;--JUST LOOP FOR NEXT
FLIN.1:	CAIL	CH,.CHLFD	;IF LESS THAN LINE FEED
	CAILE	CH,.CHFFD	; OR GT FORM FEED,
	JRST	CPOPJ1		; GIVE SKIP RETURN
	POPJ	P,		;ELSE, GIVE END OF LINE

FLIN.2:	IN	TI,		;INPUT NEXT BUFFER
	  JRST	FILIN		;LOOP IF OK
	STATZ	TI,IO.ERR	;SEE IF ERROR BITS
	INTERR	(IOE,<I/O Error>,<JRST FLIN.3>)
FLIN.3:	SETOM	CH		;SET FLAG
	TXO	F,F.EOF		;SET END FLAG
	POPJ	P,		;RETURN

SUBTTL	SUBROUTINES
SUBTTL	SUBROUTINE TO LOGIN A JOB
;CALL:	T2/ PROJECT,,PROGRAMMER NUMBER
;	T4/ "USER" NAME IN SIXBIT
;	PUSHJ	P,LOGIN$
;RETURNS IF SUCCESSFUL

LOGI12:	TXO	F,F.PRIV	;FLAG TO GET ALL PRIVILEGES
	MOVE	T2,FFAPPN	;GET [1,2]
	TXNN	F,F.REMO	;SEE IF REMOTE OPR
	JRST	LOGI.1		;NO--PROCEED
	HLRZ	T1,NL.ME	;YES--GET STATION NUMBER
	HRLI	T2,100(T1)	;USE [100+SN,2]
	JRST	LOGIN$		;AND GO LOGIN
;HERE IF LOGIN TO [1,2]
LOGI.1:	TXNE	F,F.LOGI	;SEE IF LOGGED IN		[114]
	JRST	LOGIN$		;YES--NO SPECIAL TEST		[114]
	SETOM	T3		;NO--GET MY TTY			[114]
	GETLCH	T3		; CHARACTERISTICS		[114]
	TXNE	T3,GL.ITY!GL.DSL!GL.REM!GL.RBS ;MAKE SURE LOCAL	[114]
	JRST	KILJOB		;NO--GO EXIT INSTEAD		[114]
LOGIN$:	TXNN	F,F.LOGI	;SEE IF ALREADY LOGGED IN
	JRST	LOGI.2		;NO--GO LOG IT IN
	TXNN	F,F.LOGX	;SEE IF OK TO BE DIFFERENT
	CAMN	T2,MYPPN	;NO--SEE IF DIFFERENT
	POPJ	P,		;NO--RETURN
	JRST	KILJOB		;YES--GO EXIT INSTEAD
LOGI.2:	MOVE	T1,[-3,,T2]	;SETUP POINTER FOR UUO
	TXNN	F,F.PRIV	;SEE IF PRIVILEGES NEEDED
	TDZA	T3,T3		;NO--CLEAR THEM
	MOVSI	T3,-1		;YES--SET ALL DEC PRIVILEGES.
;LOGI.2+3 1/2 [124] EAR 2/11/76
	TXNE	F,F.REMO	;[124] UNLESS REMOTE OPR
	MOVE	T3,[JP.NSP]	;[124] WHO ONLY NEEDS UNSPOOLING
	MOVEM	T2,REQPPN	;SAVE REQUESTED PPN
	LOGIN	T1,		;TRY

	TTYSTR	[ASCIZ /.LOGIN /]
	HLRZ	T1,REQPPN	;GET PROJECT
	PUSHJ	P,TYPOCT	;TYPE IN OCTAL
	TTYOUT	","		;SEPARATE
	HRRZ	T1,REQPPN	;GET PROGRAMMER
	PUSHJ	P,TYPOCT	;TYPE IN OCTAL
	TTYSTR	CRLFM
				CONT.
;HERE TO FIND THE PPN IN SYS:AUXACC.SYS IF POSSIBLE
;IF ANY PROBLEMS, PROCEED ONWARD AND DUPLICATE THE SYS S/L

	MOVEI	T1,.IOBIN	;READ IN BINARY
	MOVSI	T2,'SYS'	;SYS:
	MOVEI	T3,IBF		;INPUT BUFFER HEADER
	OPEN	TI,T1		;GET DEVICE
	  JRST	STRN.6		;GIVE UP IF UNAVAILABLE!
	MOVE	T1,['AUXACC']	;FILE
	MOVSI	T2,'SYS'	; NAMED
	SETZB	T3,T4		; SYS:AUXACC.SYS[-]
	LOOKUP	TI,T1		;GET IT
	  JRST	STRN.6		;GIVE UP IF MISSING
	TXO	F,F.BIN		;TELL INPUTTER BINARY
	TXZ	F,F.EOF		;CLEAR EOF FLAG [133]
	PUSHJ	P,FILIN		;GET FIRST WORD
	  JRST	STRN.6		;IF NULL FILE, GIVE UP
	JUMPN	CH,STRN.6	;ONLY FORMAT V.0 WORKS
;BACK HERE TO LOOP OVER PPNS IN FILE
STRN.1:	PUSHJ	P,FILIN		;GET INDICATOR
	  JRST	STRN.6		;OUR PPN MISSING!
	AOJN	CH,STRN.6	;-1 IS FLAG
	PUSHJ	P,FILIN		;GET SIZE
	  JRST	STRN.6		;BAD FILE
	SOSGE	T6,CH		;GET COUNT LESS PPN
	JRST	STRN.6		;ERROR IF NEGATIVE SIZE
	PUSHJ	P,FILIN		;GET PPN
	  JRST	STRN.6		;BAD FILE
	MOVE	T1,CH		;GET PPN
	XOR	T1,REQPPN	;COMPARE TO DESIRED
	TRC	CH,-1		;SEE IF FILE IS WILD
	TRNN	CH,-1		;TEST WILD
	TRZ	T1,-1		;YES--PROGRAMMER ALWAYS MATCHES
	JUMPE	T1,STRN.3	;JUMP IF MATCH!!!
;LOOP TO SKIP ENTRY WE WANT TO IGNORE
STRN.2:	PUSHJ	P,FILIN		;DISCARD
	  JRST	STRN.6		;(BAD FILE)
	SOJG	T6,STRN.2	;UNTIL COUNT EXHAUSTED
	JRST	STRN.1		;THEN TRY NEXT PPN
				CONT.
;HERE WHEN ENTRY MATCHES
STRN.3:	IDIVI	T6,5		;GET STR COUNT
	JUMPN	T7,STRN.6	;ERROR IF NOT MULTIPLE OF 5
	MOVEI	T7,1		;START INDEX INTO ANSWER
;LOOP OVER STRS FOR THIS PPN
STRN.4:	JUMPE	T6,STRN.5	;EXIT WHEN DONE
	CAIGE	T7,ENDSTR-STRBLK  ;SEE IF OVERFLOW
	PUSHJ	P,FILIN		;NO--GET NEXT STR
	  JRST	STRN.5		;EXIT IF EOF (EVEN THO ERROR)
	MOVEM	CH,STRBLK(T7)	;SAVE STR NAME
	SETZM	STRBLK+1(T7)	;CLEAR PPN OF THIS STR
	PUSHJ	P,FILIN		;GET/IGNORE NEXT WORD
	  JRST	STRN.5		;(ERROR)
	PUSHJ	P,FILIN		;GET/IGNORE NEXT WORD
	  JRST	STRN.5		;(ERROR)
	PUSHJ	P,FILIN		;GET/IGNORE NEXT WORD
	  JRST	STRN.5		;(ERROR)
	PUSHJ	P,FILIN		;GET STATUS BIT WORD
	  JRST	STRN.5		;(ERROR)
	MOVEM	CH,STRBLK+2(T7)	;SAVE BITS
	MOVE	T1,[1,,T2]	;POINTER FOR DSKCHR
	MOVE	T2,STRBLK(T7)	;GET STR NAME
	DSKCHR	T1,		;GET ITS STATUS
	  SETOM	T1		;ERROR
	TXC	T1,<.DCTFS_<ALIGN.(DC.TYP)>>
	TXNN	T1,<DC.SAF!DC.NNA!DC.TYP>  ;MUST BE MULTI-ACCESS
			; ,ACCESSIBLE, AND A FILE-STRUCTURE
	ADDI	T7,3		;YES--ADVANCE ANSWER POINTER
	SOJG	T6,STRN.4	;LOOP OVER ALL STRS THIS PPN
;HERE WHEN A LIST HAS BEEN BUILT IN CORE
STRN.5:	RELEAS	TI,		;RELEASE INPUT CHANNEL
	TXZ	F,F.BIN!F.EOF	;CLEAR BINARY INDICATOR AND EOF
	MOVE	T1,T7		;POSITION COUNTER
	JRST	STRN.8		;PROCEED TO TELL MONITOR

;HERE WHEN CAN'T USE SYS:AUXACC.SYS FOR ANY REASON
STRN.6:	RELEAS	TI,		;RELEASE INPUT CHANNEL
	TXZ	F,F.BIN!F.EOF	;CLEAR BINARY INDICATOR AND EOF
				CONT.
;HERE TO COPY THE SYS: SEARCH LIST

	SETZM	GETSTR		;SET GOBSTR ARGS TO JOB 0
	MOVE	T1,SYSPPN	;GET [1,4]
	MOVEM	T1,GETSTR+1	;SET SYS PPN AS PPN IN QUESTION
	SETOM	GETSTR+2	;SET TO START OF LIST
	MOVNI	T1,2		;PRESET ANSWER BLOCK

STRN.7:	MOVE	T3,[5,,GETSTR]	;GET POINTER FOR GOBSTR
	ADDI	T1,3		;ADVANCE ANSWER POINTER
	CAIGE	T1,ENDSTR-STRBLK  ;SEE IF FULL
	GOBSTR	T3,		;NO--GET NEXT STR
	  JRST	STRN.8		;CAN'T--GO SEE IF CAN SET IT UP
	SKIPE	T3,GETSTR+2	;GET STR NAME
	CAMN	T3,[-1]		;CHECK FOR FENCE
	JRST	STRN.8		;YES--GO SEE IF CAN SET IT UP
	MOVEM	T3,STRBLK(T1)	;OK--STORE STR
	MOVE	T3,GETSTR+3	;GET PPN JUST IN CASE IT EVER COUNTS
	MOVEM	T3,STRBLK+1(T1)  ;STORE IN STRUUO BLOCK
	MOVE	T3,GETSTR+4	;GET STATUS BITS
	MOVEM	T3,STRBLK+2(T1)  ;STORE IN BLOCK
	JRST	STRN.7		;LOOP BACK FOR MORE

STRN.8:	SETZM	STRBLK		;SET FUNCTION FOR STRUUO
	MOVE	T3,['DSKB  ']	;SET FOR DSKB JUST IN CASE NONE
	SKIPN	STRBLK+1	;SEE IF ANY STR SETUP
	MOVEM	T3,STRBLK+1	;NO--FILL IN DEFAULT
	HRLZI	T1,(T1)		;GET LENGTH OF LIST
	TLNN	T1,-2		;SEE IF ANYTHING THERE
	HRLZI	T1,4		;NO--SET FOR AT LEAST ONE STR
	HRRI	T1,STRBLK	;POINT TO BLOCK
	STRUUO	T1,		;TELL MONITOR
	  JFCL			;WELL--NICE TRY
	MOVE	T1,[.STUVM,,[1000,,1000]] ;SET PHYS & VIRT LIMITS
	SETUUO	T1,		; TO ALLOW JOB TO GO VIRTUAL
	  JFCL			;IGNORE ERROR
	POPJ	P,		;RETURN IF SUCCESSFUL

SUBTTL	SUBROUTINE TO TYPE SIGN ON MESSAGE
;CALL:	PUSHJ	P,SIGNON
;USES ALL TEMPS

SIGNON:	MOVE	T1,FLNAME	;SEE IF USER
	TRNN	T1,1		;  SAID NONAME
	TXNE	F,F.NOHD	;SEE IF HEADER SUPPRESSED
	POPJ	P,		;YES--RETURN QUICKLY
	TTYSTR	CRLFM
	MOVSI	T7,-5		;SETUP POINTER TO READ
	MOVX	T6,%CNFG0	;SYSTEM HEADER LINE

SIGN.1:	MOVE	T5,T6		;MAKE POINTER
	GETTAB	T5,		;GET THE HEADER
	  MOVEI	T5,0		;DON'T REALLY CARE IF THIS FAILS
	MOVEM	T5,T1(T7)	;STORE IN ARRAY
	ADD	T6,[1,,0]	;ADVANCE INDEX
	AOBJN	T7,SIGN.1	;LOOP FOR TITLE

	MOVEI	T6,0		;GUARANTEE CLEAN END
	TTYSTR	T1		;TYPE HEADER
	TTYOUT	" "		;SEND A SPACE
	MSTIME	T4,		;GET TIME OF DAY
	IDIVI	T4,^D1000	;CONVERT TO SECONDS
	IDIVI	T4,^D3600	;GET HOURS
	PUSHJ	P,TYPD2		;TYPE HOURS
	MOVE	T4,T5		;RE-POSITION REMAINDER
	IDIVI	T4,^D60		;GET MINUTES
	PUSHJ	P,TYPD2C	;TYPE COLON, MINUTES
	MOVE	T4,T5		;GET SECONDS
	PUSHJ	P,TYPD2C	;TYPE COLON, SECONDS
	TTYOUT	" "		;SEND A SPACE
	MOVE	T2,ME		;GET TTY NAME
	PUSHJ	P,TYPSIX	;TYPE IT
	TTYSTR	[ASCIZ / system /]
	MOVE	T1,APRSN	;GET APR S/N
	MOVNI	T7,6*2		;PRESET FOR 6 CPU'S
SIGN.2:	PUSHJ	P,TYPDEC	;LIST IN DECIMAL
	AOS	T1,T7		;TRY NEXT CPU
	ADD	T1,[%CCSER+6*2+1]  ;GET APR S/N
	GETTAB	T1,		; FROM MONITOR
	  MOVEI	T1,0		;STOP IF NO CPU
	JUMPLE	T1,SIGN.3	;END LOOP IF JUNK
	TTYOUT	"/"		;SEPARATE
	AOJL	T7,SIGN.2	;LOOP UNTIL DONE
SIGN.3:	PJOB	T1,0		; GET OUR TTY NUMBER [137]
	TRMNO.	T1,0		; ..
	  SETZ	T1,0		; OOPS
	TXZ	T1,.UXTRM	; CLEAR UNIV. IONDX
	HRRZ	T2,NL.ME
	CAMN	T1,T2		; SAME?
	JRST	SIGN3A		; YES, DON'T DO THE NETWORK STUFF [137]
	TTYSTR	[ASCIZ /
Connected to Node /]
	MOVE	T2,[2,,T3]	; NODE. UUO ARGUMENT POINTER
	MOVEI	T3,2		; COUNT
	HLRZ	T4,NL.ME	; MY NODE
	NODE.	T2,0
	 MOVE	T2,['CENTRA']
	PUSHJ	P,TYPSIX	; TYPE NODE NAME [140]
	TTYSTR	[ASCIZ /(/]
	HLRZ	T1,NL.ME	; GET NODE NUMBER
	PUSHJ	P,TYPOCT
	TTYSTR	[ASCIZ /) Line # /]
	HRRZ	T1,NL.ME
	PUSHJ	P,TYPOCT
SIGN3A:	TTYSTR	CRLFM		; [137]
				CONT.
	TXNN	F,F.LOGI	;SEE IF LOGGED IN
	POPJ	P,		;NO--ALL DONE
	TTYSTR	[ASCIZ /Job /]
	MOVE	T1,JOBN		;GET JOB NUMBER
	PUSHJ	P,TYPDEC	;TYPE IN DECIMAL
	HRROI	T2,.GTNM1	;GET USER'S NAME
	GETTAB	T2,		; FROM MONITOR
	  JRST	SIGN.4		;IGNORE IF UNAVAILABLE
	JUMPE	T2,SIGN.4	;OR MISSING
	TTYSTR	[ASCIZ /   User /]
	PUSHJ	P,TYPSX6	;TYPE SIX CHARACTERS
	HRROI	T2,.GTNM2	;GET 2ND HALF OF NAME
	GETTAB	T2,		; FROM MONITOR
	  MOVEI	T2,0		;(IMPOSSIBLE)
	PUSHJ	P,TYPSIX	;TYPE IN SIXBIT AND RETURN
	TTYSTR	[ASCIZ /   [/]	;THEN ISSUE PPN			[110]
	HLRZ	T1,MYPPN	;GET MY PROJECT			[110]
	PUSHJ	P,TYPOCT	;ISSUE IN OCTAL			[110]
	TTYOUT	","		;SEPARATE WITH COMMA		[110]
	HRRZ	T1,MYPPN	;GET MY PROGRAMMER		[110]
	PUSHJ	P,TYPOCT	;ISSUE IN OCTAL			[110]
	TTYOUT	"]"		;END PPN			[110]
SIGN.4:	TTYSTR	CRLFM
	POPJ	P,

SUBTTL	SUBROUTINE TO TYPE KSYS MESSAGE
;CALL:	PUSHJ	P,TYKSYS
;USES ALL TEMPS

TYKSYS:	MOVX	T1,%NSKTM	;GET TIME TO GO
	GETTAB	T1,		; FROM MONITOR
	  POPJ	P,		;RETURN IF NOT IMPLEMENTED
	SKIPE	T1		;SEE IF SET
	CAIL	T1,^D24*^D60	; AND LESS THAN 24 HRS.
	POPJ	P,		;NO--RETURN
	JUMPL	T1,TYKS.2	;SEE IF ALREADY DOWN
	TTYSTR	[ASCIZ /Timesharing will cease in /]
	PUSH	P,T1		;SAVE TIME
	IDIVI	T1,^D60		;GET HOURS
	JUMPE	T1,TYKS.1	;JUMP IF LT 1 HOUR
	PUSHJ	P,TYPDEC	;TYPE IN DECIMAL
	TTYSTR	[ASCIZ / hours /]
TYKS.1:	MOVE	T1,(P)		;GET TIME AGAIN
	IDIVI	T1,^D60		;GET MINUTES
	MOVE	T1,T2		; INTO RIGHT AC
	PUSHJ	P,TYPDEC	;TYPE IN DECIMAL
	TTYSTR	[ASCIZ / minutes, at /]
	MSTIME	T1,		;GET TIME OF DAY
	IDIVI	T1,^D60000	;GET MINUTES OF DAY
	POP	P,T2		;RESTORE KSYS TIMER
	ADD	T1,T2		;FIND TIME OF DAY
	CAIL	T1,^D24*^D60	;SEE IF TOMORROW
	SUBI	T1,^D24*^D60	;YES--CORRECT TIME
	IDIVI	T1,^D60		;GET HOURS
	PUSH	P,T2		;SAVE MINUTES
	MOVE	T4,T1		;POSITION HOURS
	PUSHJ	P,TYPD2		;TYPE HOURS AS TWO DIGITS
	POP	P,T4		;RESTORE MINUTES
	PUSHJ	P,TYPD2C	;TYPE AS :TWO DIGITS
	JRST	TYKS.3		;AND FINISH LINE
;HERE IF KSYS TIMER ALREADY RUN OUT
TYKS.2:	TTYSTR	[ASCIZ /Timesharing is over/]
TYKS.3:	TTYSTR	[ASCIZ /.
/]
	POPJ	P,

SUBTTL	ERROR HANDLERS
				;AND RETURN TO MONITOR

;HERE IF LOGICAL INCONSISTENCY IN PROGRAM--NOTE BP=ADDR. OF PROBLEM

E$$BMB:	INTERR	(BMB,<Bomb out >,<JRST .+1>)
	MOVEI	T1,(BP)		;GET ADDRESS
	SUBI	T1,INITIA+1	;CONVERT TO RELATIVE
	PUSHJ	P,TYPOCT	;ISSUE IN OCTAL
EBMB.1:	OUTSTR	CRLFM		;END LINE
	SUBI	BP,INITIA+1	;SUBTRACT RELOCATION AND PC INCREMENT
	LIGHTS	BP,		;FOR DEBUGGING, SEND TO LIGHTS
	JRST	KILJOB		;GO KILL OFF JOB

SUBTTL	TYPEOUT ROUTINES

;SUBROUTINE TO TYPE TWO DECIMAL DIGITS
;WARNING--THIS DOES NOT HANDLE NEGATIVE NUMBERS OR NUMBERS
;	GREATER THAN 99.
;CALL:	MOVE	T4,NUMBER
;	PUSHJ	P,TYPD2
;USES T1, T2

TYPD2C:	TTYOUT	":"

TYPD2:	MOVE	T1,T4		;GET NUMBER
	IDIVI	T1,^D10		;GET TENS
	TTYOUT	"0"(T1)		;TYPE IT
	TTYOUT	"0"(T2)		;TYPE IT
CPOPJ:	POPJ	P,



;SUBROUTINE TO TYPE A DECIMAL/OCTAL NUMBER
;CALL:	MOVE	T1,NUMBER
;	PUSHJ	P,TYPDEC/OCT
;USES T1,T2,T3

TYPOCT:	SKIPA	T3,[10]		;SET OCTAL RADIX
TYPDEC:	MOVEI	T3,^D10		;SET DECIMAL RADIX
TYPRAD:	SKIPGE	T1		;IF NEGATIVE,
	TTYOUT	"-"		; ISSUE MINUS
TYPR.1:	IDIVI	T1,(T3)		;GET LOWEST DIGIT
	MOVMS	T2		;GET POSITIVE OF REMAINDER
	HRLM	T2,(P)		;STACK IT
	SKIPE	T1		;UNLESS DONE
	PUSHJ	P,TYPR.1	;  TRY AGAIN
	HLRZ	T1,(P)		;GET TOP DIGIT
	TTYOUT	"0"(T1)		;OUTPUT IT
	POPJ	P,		;RETURN
;SUBROUTINE TO TYPE 6 SIXBIT CHARACTERS
;CALL:	MOVE	T2,WORD
;	PUSHJ	P,TYPSX6
;USES T1, T2, T3

TYPSX6:	MOVEI	T3,6		;SET COUNT
TYPS.1:	MOVEI	T1,0		;CLEAR NEXT CHARACTER
	LSHC	T1,6		;GET NEXT CHAR
	TTYOUT	40(T1)		;TYPE IT
	SOJG	T3,TYPS.1	;LOOP UNTIL COUNT DONE
	POPJ	P,		;THEN RETURN

;SUBROUTINE TO TYPE A SIXBIT WORD
;CALL:	MOVE	T2,WORD
;	PUSHJ	P,TYPSIX
;USES T1, T2

TYPSIX:	MOVEI	T1,0		;CLEAR NEXT CHAR
	LSHC	T1,6		;GET NEXT CHAR
	TTYOUT	40(T1)		;TYPE  IT
	JUMPN	T2,TYPSIX	;LOOP UNTIL ALL DONE
	POPJ	P,		;THEN RETURN
;SUBROUTINE TO TYPE AN ASCII STRING IN IMAGE MODE
;CALL:	MOVEI	T2,STRING POINTER
;	PUSHJ	P,SNDIMG
;	RETURN
;USES T2, T6, T7


SNDIMG:	HRLI	T2,(POINT 7,)	;TURN INTO BYTE POINTER
SNDI.1:	ILDB	T7,T2		;GET NEXT CHARACTER
	JUMPE	T7,CPOPJ	;RETURN IF NULL
			;THE FOLLOWING COMES FROM 5.04 UUOCON(PEVEN8)
	MOVEI	T6,(T7)		;MAKE A COPY OF BYTE
	LSH	T6,-4		;FOLD INTO LOW 4 BITS
	XORI	T6,(T7)		; ..
	TRCE	T6,14		;CHECK BITS
	TRNN	T6,14		; 32 AND 33
	TRC	T7,200		;IF EVEN, COMPLIMENT RESULT
	TRCE	T6,3		;CHECK BITS
	TRNN	T6,3		; 34 AND 35
	TRC	T7,200		;IF EVEN, COMPLEMENT RESULT
	IONEOU	T7		;SEND OUT VIA IMAGE MODE
	JRST	SNDI.1		;LOOP BACK FOR MORE
;THIS IS THE LUUO HANDLER
;IT SCRATCHES OC AND PRESERVES ALL OTHERS

LUUO:	LDB	OC,[POINT 9,.JBUUO,8] ;GET OPCODE
	CAIN	OC,1		;IS IT TTYOUT
	JRST	$TTOUT		;YES--GO PROCESS IT

;HERE ON A TTYSTR LUUO
	MOVSI	OC,(POINT 7,)	;SETUP BYTE POINTER
	HLLM	OC,.JBUUO	; IN LOW CORE
$TTSTR:	ILDB	OC,.JBUUO	;GET A BYTE
	JUMPE	OC,CPOPJ	;RETURN ON NULL
	PUSHJ	P,LUUO.1	;TYPE IT
	JRST	$TTSTR		;LOOP OVER STRING

;HERE ON A TTYOUT LUUO
;WARNING--THIS IS IMMEDIATE MODE, UNLIKE OUTCHR
$TTOUT:	HRRZ	OC,.JBUUO	;GET THE BYTE
LUUO.1:	SOSG	TTYCNT		;COUNT DOWN SPACE IN BUFFER
	PUSHJ	P,TTYPBF	;WRITE THE DATA
	IDPB	OC,TTYPNT	;STORE THE BYTE
	POPJ	P,		;RETURN

;SUBROUTINE TO DUMP THE TTY OUTPUT BUFFER
TTYPBF:	OUT	TTY,		;DO THE OUTPUT
	  POPJ	P,		;ALL IS OK
	STATZ	TTY,IO.ERR	;ANY ERRORS?
	JRST	LOGO1$		;YES--SEEMS SORT OF BAD
	PUSH	P,T1		;SAVE AN AC
	PUSH	P,[EXP ^D10]	;NUMBER OF MINUTES TO WAIT
TTYP.1:	MOVE	T1,[HB.RIO+^D6000]
	HIBER	T1,
	  JRST	LOGO1$		;MUST WORK
	OUT	TTY,		;TRY AGAIN
	  JRST	TTYP.2		;WE ARE DONE
	SOSLE	(P)		;KEEP WAITING
	JRST	TTYP.1		;YES--WAIT
	CLRBFO			;NO--BOMB OUT
	JRST	LOGO1$		;GO LOGOUT
TTYP.2:	POP	P,T1
	POP	P,T1
	POPJ	P,
SUBTTL	GTNTN. ROUTINE

; SUBROUTINE TO GET NODE,,LINE# FOR DEVICE SPECIFIED IN T1 IN T1
GTNTN$:	GTNTN.	T1,0		; TRY DIRECTLY
	SKIPA			; NOW THE HARD WAY
	POPJ	P,0		; RETURN
	PUSH	P,T1		; SAVE DEVICE NAME
	IONDX.	T1,0		; GET THE LINE # + 200000
	  SETZ	T1,0		; NICE TRY
	TXZ	T1,.UXTRM	; CLEAR BIT 1
	EXCH	T1,(P)		; GET DEVICE AGAIN IN T1
	WHERE	T1,0		; GET THE NODE NUMBER
	  SETZ	T1,0		; NICE TRY
	HRLM	T1,(P)
	POP	P,T1
	POPJ	P,0		; RETURN

SUBTTL	SPECIAL TTY SETUP SEQUENCES

;TERMINET 300--SET TABS AT 4,12,... (4 IS THEN C.RET.POINT)

TRMIMG:	BYTE	(7)15,12,33,62,177,177,15,40,40,40,33,61,40,40,40,40,40,40,40,40,33,61,40,40,40,40,40,40,40,40,33,61,40,40,40,40,40,40,40,40,33,61,40,40,40,40,40,40,40,40,33,61,40,40,40,40,40,40,40,40,33,61,40,40,40,40,40,40,40,40,33,61,40,40,40,40,40,40,40,40,33,61,40,40,40,40,40,40,40,40,33,61,15,0

SUBTTL	STORAGE AREA

;STORAGE AREA

	XLIST	;LITERALS
	LIT
	LIST

CRLFM:	ASCIZ	/
/


;TABLES SHARED AMONG ALL COPIES OF INITIA
LOCKWD:	EXP	-1		;INTERLOCK FOR HISEG
LOKJOB:	BLOCK	1		;JOB # THAT HAS INTERLOCK
LOKTTY:	BLOCK	1		;ABOVE JOB'S TTY LINE
HIPTR:	POINT	7,0		;BYTE POINTER TO TEXT STORAGE
HS$DEV:	BLOCK	N$HSGF		;DEVICE NAMES
HS$FIL:	BLOCK	N$HSGF		;FILE NAMES
HS$EXT:	BLOCK	N$HSGF		;EXTENSIONS
HS$PPN:	BLOCK	N$HSGF		;PPN'S
HS$PTR:	BLOCK	N$HSGF		;BYTE POINTER TO CONTENTS OF
				; THE FILE.  IF THIS WORD IS 0
				; THE FILE DOES NOT EXIST
	RELOC
ZER:!			;START OF AREA TO ZERO ON RESTART
PDL:	BLOCK	L$PDL+1	;PUSH-DOWN LIST
GETCH:	BLOCK	1	;ADDRESS OF TTY INPUT ROUTINE IF ANY
REEAT:	BLOCK	1	;CHARACTER TO REEAT
FILICH:	BLOCK	1	;REUSABLE CHARACTER IN STRIPPER
JUMPPR:	BLOCK	1	;ADDRESS OF SPECIAL STARTUP ROUTINE
SYSPPN:	BLOCK	1	;PPN OF SYS:
MYPPN:	BLOCK	1	;PPN OF THIS JOB
TERNUM:	BLOCK	1	;INDEX OF THIS TTY
JOBN:	BLOCK	1	;OUR JOB NUMBER
MYSPD:	BLOCK	1	;MY RECEIVE SPEED AS DETECTED
FFAPPN:	BLOCK	1	;PPN OF [1,2]
REQPPN:	BLOCK	1	;REQUESTED PPN

; SYMBOLIC LOCATIONS OF THE FORM "NL.???" STORE VALUES IN THE FORM
; XWD NODE,LINE
NL.CTY:	BLOCK	1	; CENTRAL STATION (CTY)
NL.OPR:	BLOCK	1	; CENTRAL OPR
NL.LOP:	BLOCK	1	; OUR LOCAL OPR
NL.ME:	BLOCK	1	; OUR LOCATION
CTYTTY:	BLOCK	1	; SIXBIT TTY NAME FOR CTY
APRSN:	BLOCK	1	;APR SERIAL NUMBER
IBF:	BLOCK	3	;BUFFER HEADER BLOCK
RUNBLK:	BLOCK	6	;RUN UUO PARAMETERS
INTBLK:	BLOCK	4	;INTERCEPT BLOCK
TEMP1:	BLOCK	1	; TEMPORARY STORAGE FOR INTERCEPT
NOINT:	BLOCK	1	; IF NEGATIVE DON'T INTERRUPT
SAVEF:	BLOCK	1	;PLACE TO HOLD F
FLKSYS:	BLOCK	1	;FLAG TO TYPE KSYS TIME
FLNAME:	BLOCK	1	;FLAG NONAME (SUPPRESS HEADER LINE)
FLSET:	BLOCK	1	;FLAG NOSETTTY (SUPRESS TTY SETUP)
FLSTR:	BLOCK	1	;FLAG TO DO STRUCTURE NOTES
FLTEXT:	BLOCK	1	;FLAG TO PRINT TEXT MSG			[120]
FLBAT:	BLOCK	1	;FLAG TO DO BATCH SYSTEM TEXT		[117]
FLNOTC:	BLOCK	1	;FLAG TO TYPE NOTICE.TXT
FLTTY:	BLOCK	1	;FLAG TO TYPE TTY SETTINGS
DIAL:	BLOCK	2	;NUMBER TO DIAL
ELEM:	BLOCK	1	;TTY ELEMENT
LC:	BLOCK	1	;TTY LC
SLAVE:	BLOCK	1	;TTY SLAVE
TAB:	BLOCK	1	;TTY TAB
FORM:	BLOCK	1	;TTY FORM
ECHO:	BLOCK	1	;TTY ECHO
CRLF:	BLOCK	1	;TTY CRLF
WIDTH:	BLOCK	1	;TTY WIDTH
GAG:	BLOCK	1	;TTY GAG
HDX:	BLOCK	1	;TTY HDX
REM:	BLOCK	1	;TTY REMOTE
DISP:	BLOCK	1	;TTY DISPLAY
FILL:	BLOCK	1	;TTY FILL
TAPE:	BLOCK	1	;TTY TAPE
PAGEON:	BLOCK	1	;TTY PAGE
PAGE:	BLOCK	1	;TTY PAGE:N
BLANK:	BLOCK	1	;TTY BLANK
ALT:	BLOCK	1	;TTY ALT
RCV:	BLOCK	1	;TTY RCVSPEED
XMT:	BLOCK	1	;TTY XMTSPEED
DEBR:	BLOCK	1	;TTY DEBREAK
TIDY:	BLOCK	1	;TTY TIDY
RTCOMP:	BLOCK	1	;TTY RTCOMP
LOWPTR:	BLOCK	1	;POINTER TO HISEG TEXT
WAITCT:	BLOCK	1	;NUMBER OF TIMES TO TRY FOR HISEG LOCK
				CONT.
TTYOBF:	BLOCK	1	;TTY OUTPUT RUNG HEADER
TTYPNT:	BLOCK	1	;TTY OUTPUT BYTE POINTER
TTYCNT:	BLOCK	1	;TTY OUTPUT BYTE COUNT
TTYBUF:	BLOCK	L$TTBF+3 ;SIZE OF OUTPUT BUFFER
GETSTR:	BLOCK	5	;ARGUMENT BLOCK FOR GOBSTR UUO
STRBLK:	BLOCK	1+3*N$STRS	;ARGUMENT BLOCK FOR STRUUO
ENDSTR==.
EZER==.-1

	END	INITIA