Google
 

Trailing-Edge - PDP-10 Archives - BB-FI82B-DD_1989 - 35,1414/cnfgkl.mac
There is 1 other file named cnfgkl.mac in the archive. Click here to see a list.
TITLE	CNFGKL - PROGRAM TO DEFINE MONITOR, TTY AND REMOTE CONFIGURATIONS - V052
SUBTTL	T. IACOBONE		AUG 82
EDITNO==223		;EDIT NO.
VERSION==052		;MAJOR VERSION NO.
VMINOR==1		;MINOR VERSION NUMBER
VWHO==0			;WHO LAST EDITED

;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED
;  OR COPIED IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE.
;
;COPYRIGHT (C) 1982 BY DIGITAL EQUIPMENT CORP., MAYNARD, MASS.

JOBVER==137		;LOC OF VERSION NO IN JOB DATA AREA
	LOC	JOBVER
	BYTE	(3)VWHO(9)VERSION(6)VMINOR(18)EDITNO	;VERSION NUMBER
	RELOC

;THE CODE FOR THIS PROGRAM IS EXTRACTED FROM MONGEN.MAC V052
;EDIT 223, TOPS10 7.01A. THE PURPOSE OF THE PROGRAM IS TO REDUCE THE
;VERBOSITY OF MONGEN FOR THE AVERAGE MARLBORO TECHNICIAN/OPERATOR.
;SYMBOLS WHICH ARE PARAMETERS OF MONGEN ITSELF(PREFIX MP)
IFNDEF MP.MVN,<MP.MVN==^D701>	;MONITOR VERSION NUMBER
		;WHICH THIS MONGEN IS DESIGNED TO GENERATE
		;OTHER MONGEN VERSIONS GENERATE OTHER MONITOR VERSIONS
IFNDEF MP.PDL,<MP.PDL==40>	;PD LIST LENGTH
IFNDEF MP.AMX,<MP.AMX==^D10>	;MAX NO. OF ANSWERS INSIDE PARENS
IFNDEF MP.SMX,<MP.SMX==^D4>	;MAX SYSTEM SUPPORTED IN 7.01A
		; 1070=0, 1080=1, 1090=2, 1091=3, 2020=4
IFNDEF MP.LMX,<MP.LMX==^D80>	;MAX. NO. OF CHAR ALLOWED IN INPUT LINE
		; NOT COUNTING EOL OR NULL
IFNDEF MP.FTA,<MP.FTA==^D25>	;MAX NUMBER OF FEATURE TEST SWITCHES THAT MAY BE ADDED

COMMENT	"

ASSEMBLY INSTRUCTIONS:

.COMPIL MONGEN

LOADING INSTRUCTIONS:

.LOAD MONGEN

DEBUGGING INSTRUCTION:

.DEBUG MONGEN

BY DEPOSITING NON-ZERO IN LOCATION DEBUG WITH DDT, MONGEN WILL
 OUTPUT ALL FILE STUFF TO TTY TOO INSIDE <>.
"
;MONGEN IS A DIALOG PROGRAM(ACTUALLY 4 PROGRAMS IN ONE) WHICH
;ASKS THE CUSTOMER QUESTIONS ABOUT HIS CONFIGURATION.
;THE RESULTS OF THIS DIALOG ARE OUTPUT AS A FILE OF PARAMETER ASSIGNMENTS
;WHICH CAUSE CONDITIONAL ASSEMBLY IN THE DATA BASE MODULES OF THE MONITOR.
;THUS EACH CUSTOMER IS ABLE TO CUSTOM-MAKE HIS MONITOR FOR THE FEATURES
;HE WISHES DEPENDING ON HARDWARE AND SOFTWARE REQUIREMENTS.
;THESE PARAMETER ASSIGNMENTS TAKE THE FORM OF MACRO CALLS USING
; THE XP MACRO OF TWO ARGUMENTS AS DEFINED IN FILE S.MAC.  THE XP
; MACRO DEFINES THE FIRST SYMBOL TO BE EQUAL TO THE SECOND EXPRESSION
; AND DECLARES THE SYMBOL TO BE INTERNAL AND DDT OUTPUT SUPPRESSED.

;USER INSTRUCTIONS FOR RUNNING MONGEN:
;MONGEN WILL ASK YOU QUESTIONS ABOUT YOUR CONFIGURATION AND
; OUTPUT THEM IN A FILE.  TO HELP YOU ANSWER THESE QUESTIONS,
; MONGEN GIVES THREE LEVELS OF
; GUIDANCE.  SHORT MODE FOR THE VERY EXPERIENCED, PROMPT MODE
; WHERE YOU ARE GIVEN CHOICES, AND LONG MODE WHERE YOU
; ARE GIVEN THE CHOICES ALONG WITH AN EXPLANATION.  YOU MAY CHANGE
; THE MODE FOR A SINGLE QUESTION IF YOU DO NOT UNDERSTAND IT BY SIMPLY TYPING /H
; TO CHANGE THE MODE FOR THE REST OF THE QUESTIONS, TYPE /HELP:X
; WHERE X IS SHORT, PROMPT, OR LONG.  ACTUALLY MONGEN ALWAYS
; ALLOWS ABBREVIATIONS EVERYWHERE, SO S, P, AND L SUFFICE
; ALONG WITH H FOR HELP.
; QUESTIONS ASKING FOR A NUMBER(DECIMAL UNLESS SPECIFICALLY NOTED
; AS OCTAL) ALWAYS INDICATE THE RANGE INSIDE PARENS, IE (MIN-MAX).
; OTHER QUESTIONS ARE ASKING FOR ONE
; OF A LIST OF CHOICES.  THE CHOICES ARE LISTED INSIDE PARENS.
; STILL OTHER QUESTIONS ASK
; FOR Y OR N AND STILL OTHERS ASK FOR JUST A STRING.
; IN ALL QUESTIONS WHICH HAVE PROMPTING INSIDE PARENS, THE FIRST
; ITEM IN THE LIST IS CALLED THE DEFAULT AND IS ASSUMED IF YOU
; ANSWER JUST WITH CARRIAGE RETURN.  ALL THE YES/NO QUESTIONS
; HAVE PROMPTING OF (Y,N) SO CARRIAGE RETURN ALWAYS MEANS Y.
; (,ANS0,ANS1,...) MEANS NO DEFAULT ASSUMED ON JUST CR
; CALLER OF ASK ROUTINE MUST CHECK FOR N=0 IN THIS CASE AND TAKE
; APPROPRIATE ACTION.  (THIS FEATURE IS USED BY HELP ITSELF TO ALLOW
; JUST CR TO MEAN NEXT LONGER HELP MODE).


;RULE: ALL SYMBOLS ARE GENERATED ALL OF THE TIME,
; NO MATTER HOW DIALOG BRANCHES.  WHY?  SO USERS READING THE
; DATA BASE MODULES NEVER NEED TO LOOK AT MONGEN TO UNDERSTAND
; THE MONITOR.
;THE ONLY LOCAL STORAGE IN MONGEN IS USED TO STORE ANSWERS IF THE
; VALUES ARE NEEDED LATER FOR ERROR CHECKING.  MOST ANSWERS ARE OUTPUT
; IMMEDIATELY AND SO ARE NEVER STORED IN MEMORY.  BY CONVENTION THE NAMES
; OF VARIABLES WARE THE SAME AS THE ASSOCIATED SYMBOLS OUTPUT IN
; THE FILE.  OUTPUT SYMBOLS ALL START WITH THE TWO LETTERS "M."  OR "FT" THIS MAKES
; IT EASY TO RECOGNIZE SYMBOLS DEFINED BY MONGEN WHEN READING THE REST
; OF THE MONITOR.

;MONGEN IS STUPID AND SIMPLE MINDED.  IS KNOWS AS LITTLE ABOUT
; THE MONITOR AS POSSIBLE.  IT NEVER ADDS TWO ANSWERS TOGETHER, FOR EXAMPLE.
; IT ALWAYS GENERATES ALL SYMBOLS ALL THE TIME, NO MATTER
; HOW THE QUESTIONS ARE ANSWERED.  IT IS UP TO COMMON TO TAKE THE RAW DATA
; AND PERFORM COMPUTATION AND DEFINE NEW AND CONVENIENT SYMBOLS.
;THE FOLLOWING MACROS(AND SUBROUTINES BY THE SAME NAME) ARE USED TO ASK
; CUSTOMER QUESTIONS AND GET HIS ANSWERS:
;SOME ANSWERS ARE NUMERIC, WHILE OTHERS ARE CHOICES LIKE Y OR N
; OR AN ITEM OUT OF A LIST.  ALL ANSWERS ARE CHECKED FOR REASONABLENESS.
; THE GOAL IS TO PREVENT AS MANY ERRORS AS POSSIBLE, SINCE ERRORS
; ARE NOT USUALLY DISCOVERED UNTIL THE MONITOR IS LOADED AND SOMETIMES
; EVEN THEN IT IS HARD TO FIND THE PROBLEM.  ALL NUMERIC ANSWERS ARE
; CHECKED FOR MIN AND MAX AS INDICATED INSIDE PARENS WITH A -
; SEPARATING THE MIN AND MAX.  IF A NUMERIC QUESTION
; DOES NOT HAVE A RANGE SPECIFIED, MONGEN WILL PRINT
; ? INTERNAL MONGEN ERROR - ABOVE QUESTION MUST HAVE (...,MIN-MAX) -
; EDIT MONGEN.
; AND EXIT.  NOTE: (MIN-?) IS OK TO MEAN NO UPPER BOUND
;  THE PROGRAMMER MUST EDIT MONGEN TO FIX HIS BUG.
;  THE CUSTOMER SHOULD NEVER SEE THIS MESSAGE, SINCE IT IS A DEBUGGING
;  AID AND SHOULD BE CAUGHT DURING TESTING.
;EACH MACRO HAS A TEXT QUESTION AS AN ARGUMENT.  THE ANSWER IS RETURNED
; IN AC N.  IF AN ERROR IS DETECTED, THE QUESTION IS
; REASKED AT NEXT HIGHER LEVEL OF VERBOSITY.  RETURN IS ALWAYS WITH
; A SUCCESSFUL VALUE.  THE CUSTOMER MAY HAVE CHANGED LEVELS OF VERBOSITY
; USING THE /HELP: FEATURE.  LOCATION SAVLV HAS CURRENT PERMANENT LEVEL,
; WHILE LEVEL FOR CURRENT QUESTION IS KEPT IN AC LV.

;ASKYN  - ANSWER Y OR N, (Y=1, N=0) NOTE: OPPOSITE FROM ASKLST
;	  HOWEVER MORE USEFUL, SINCE CAN OUTPUT DIRECTLY IN XP MACRO
;	  WHERE XP SYMBOL,1 MEANS Y AND XP SYMBOL,0 MEANS N.
;	(Y,N) MUST APPEAR IN QUESTION AS A PROMPT.  FOR CONSISTENCY
;	THE Y MUST BE BEFORE THE N SO CR ALWAYS MEANS Y.
;ASKDEC - ANSWER DECIMAL NUMBER.  QUESTION SHOULD HAVE (DEFAULT,MIN-MAX).
;	IF NO DEFAULT IS REASONABLE(SUCH AS NUMBER OF JOBS), ONLY
;	(MIN-MAX) IS REQUIRED.
;ASKOCT - ANSWER OCTAL NUMBER.  QUESTION SHOULD HAVE (DEFAULT,MIN-MAX)
;	IF NO DEFAULT IS REASONABLE, ONLY (MIN-MAX) IS REQUIRED.
;ASKLIN - ANSWER OCTAL LINE NUMBER OR CTY
;ASKSTR - ANSWER ARBITRARY STRING.  STORED IN ASCSTR AS ASCIZ.
;	N=NO. OF CHARS IN STRING NOT COUNTING NULL OR CRLF.
;ASKLST - ANSWER ONE OF THE ITEMS IN THE PROMPTING LIST IN PARENS.
;	N=0,1,2,... IE POSITION OF ANSWER IN LIST.  IF ANSWER IS NOT
;	IN LIST OR ABBREVIATION IS NOT UNIQUE, THE QUESTION IS REASKED
;	AT HIGHER LEVEL OF VERBOSITY.  ERROR MESSAGES ARE:
;	? TYPE ENOUGH TO UNIQUELY DISTINGUISH ANSWER
;	? ANSWER WITH ONE OF THE CHOICES INSIDE ( )
;	? INTERNAL MONGEN ERROR - NO "(" IN ABOVE MESSAGE -
;	EDIT MONGEN AND ADD (ANS0,ANS1,...)
;	? INTERNAL MONGEN ERROR - TOO MANY POSSIBLE ANSWERS ABOVE -
;	EDIT MONGEN AND INCREASE MP.AMX

;TO ASK A MULTIPLE LINE QUESTION, THE FOLLOWING SPECIAL MACROS:
;ASKMN  - ANSWER M OR M,N WHERE M AND N ARE OCTAL LINE
;	NUMBERS OR JUST CTY
;ASKMNP - ANSWER M,P OR M-N,P WHERE M,N, AND P ARE OCTAL LINE NUMBERS
;
;ASKTMN - ANSWER M OR M,N OR ALL FOR 7 TRACK TAPE UNITS
;
;ASKTMN - ANSWER M OR M,N OR ALL FOR 7 TRACK TAPE UNITS
;TO OUTPUT TO TTY, FILE OR BOTH, USE THE FOLLOWING:
; USUAL FILE OUTPUT RADIX IS OCTAL, WHILE TTY OUTPUT RADIX IS DECIMAL,
; UNLESS NAME HAS OCT OR DEC IN IT, IN WHICH THE RADICES ARE THE SAME.

;BTHOUT - OUTPUT DECIMAL TO BOTH TTY AND FILE, FILE AS A COMMENT(IE ; INSERTED)
;BTHOCT - OUTPUT OCTAL TO BOTH TTY AND FILE, FILE AS A COMMENT
;FILEOUT - OUTPUT TO FIL ONLY
;FILCOM - OUTPUT TO FILE ONLY AS A MULTI-LINE COMMENT(IE ; INSERTED)
;TTYOUT - OUTPUT TO TTY ONLY(DECIMAL)(USUAL)
;TTYOCT - OUTPUT TO TTY ONLY(OCTAL)(UNUSUAL)
;FILSTR - OUTPUT STRING IN ASCSTR TO FILE
;FILDEC - OUTPUT TO FILE WITH RADIX DECIMAL INSTEAD OF OCTAL
;FILDC2 - OUTPUT TO FILE WITH RADIX DECIMAL, AT LEAST 2 CHARS
;ALL OF THE ABOVE MACROS(AND SUBROUTINES) CAN HAVE A SECOND
; ARGUMENT WHICH IS THE LOCATION OF A VALUE TO BE SUBSTITUTED FOR * IN
; THE FIRST ARGUMENT.  THE VALUE CAN BE LEFT JUSTIFIED SIXBIT OR A NUMBER.
; IF THE LOCATION OF THE VALUE IS AC N, NO EXTRA INSTRUCTION IS GENERATED
; SINCE THE MACRO USUALLY PICKS UP THE LOCATION AND PUTS IT IN N.
; HOWEVER IT IS RECOMENDED THAT N BE INCLUDED AS THE SECOND ARGUMENT
; TO INDICATE TO THE READER THAT A SUBSTITION IS GOING TO TAKE PLACE USING N.
; ELSE NEW CODE MAY BE INTRODUCED WHICH USES N BEFORE THE MACRO CALL.
; WHENEVER THE CHARACTER @ IS SEEN IT IS CONVERTED TO CRLF.  THIS
; MAKES IT NICER FOR FORMATTING THE MESSAGES INSIDE <>, SINCE
; THE <CLOSE ANGLE> CAN ALWAYS BE ON THE SAME LINE, EVEN WHEN CRLF IS WANTED.

;EXAMPLE:
;	ASKYN	<LPT(Y,N)[LINE PRINTER AT STATION *]>,OSN
;	FILOUT	<MACRLP	*@>,N

;ALL SUBROUTINES WHICH IMPLEMENT THE MACROS HAVE THE SAME CALLING
; SEQUENCE:
;CALL:	MOVE	LV,QUESTION LEVEL -1 FOR SHORT, 0 FOR PROMPT, 1 FOR LONG
;	MOVE	N,+NUMBER OR LEFT JUSTFIED SIXBIT TO BE
;				; SUBSTITUTED FOR *
;	MOVEI	T1,ADR OF ASCIZ MESSAGE
;	PUSHJ	P,ASKXXX OR FILXXX OR TTYXXX OR BTHXXX
;	ALWAYS RETURN WITH ANSWER IN N( AND STRING IN ASCSTR) OR
;	ORIGINAL CONTENTS OF N IF JUST OUTPUT ROUTINE.

;THE FGEN DIALOGUE MAKES USE OF AN AUXILIARY HELP FILE SYS:FGEN.HLP
;TO EXPLAIN THE USE OF FEATURE TEST SWITCHES AND TO INCLUDE COMMENTS
;IN THE OUTPUT FILE. THE FILE MUST BE IN THE FORM
;<TERMINATOR> <SWITCH> <TAB> <TEXT> <TERMINATOR>
;THE TERMINATOR IS DETERMINED BY SYMBOL C.TMFH AND IS CURRENTLY
;<CONTROL> A. IT MUST BE ONE CHARACTER.
;THE TEXT WILL BE COPIED FROM AFTER THE TAB TO THE NEXT TERMINATOR,
;SO IT SHOULD BE CONSTRUCTED CAREFULLY. NOTE PARTICULARLY THAT SINCE TO
;POSITION THE FILE THE CODE FIRST FINDS A TERMINATOR AND THEN READS TO
;A TERMINATOR IT WILL BE MORE EFFICIENT IF EACH SWITCH IS PRECEEDED BY
;TWO TERMINATORS.
;MACRO FHLPOS IS PROVIDED TO HELP POSITION THE HELP FILE.
; FHLPOS STRING,TAG POSITIONS THE FILE TO THE TEXT AFTER "STRING",
;AND TRANSFERS TO "TAG" IF THE STRING CANT BE FOUND. IF THE STRING
;HAS BEEN COMPUTED, IT SHOULD BE SIXBIT CHARACTERS LEFT JUSTIFIED IN
;ACCUMULATOR WD, AND THE FIRST ARGUMENT SHOULD BE *, E.G.
; FHLPOS *,ERROR

;FHLPOA IS THE SAME EXCEPT IT DOES NOT LOOK FOR A TAB AFTER THE TEXT

;SUBROUTINES HAVE BEEN PROVIDED TO COPY THE TEXT FROM THE HELP
;FILE TO THE OUTPUT FILE OR TTY.

;FHLPTT - COPIES TEXT FROM THE CURRENT POSITION OF THE HELP FILE TO
;THE NEXT TERMINATOR TO TTY

;FHLPFL - COPIES TEXT FROM THE CURRENT POSITION TO THE NEXT TERMINATOR
;TO THE OUTPUT FILE

;FHLPFC - COPIES TEXT FROM THE CURRENT POSITION TO THE NEXT TERMINATOR
;TO THE OUTPUT FILE AS A COMMENT, I.E. WITH A ; AT THE BEGINNING OF EACH LINE
;SOME CONVENTIONS:
;ALL SINGLE LINE ANSWERS ARE ANSWERED ON THE SAME LINE AS QUESTIONS.
; THIS SAVES PAPER. THE FORMAT IS QUESTION(WITHOUT QUESTION MARK)
; FOLLOWED BY COLON AND ONE SPACE.

;ONLY THE ASK MACROS ADD ANY CHARACTERS TO THE TEXT IN THE FIRST
; ARGUMENT.  THE BEGINNING OF THE MESSAGE IS INSERTED AN ";	" AS
; A COMMENT FOR THE FIL, AND ": " IS APPENDED TO THE END
; OF THE QUESTION SO THAT ALL QUESTIONS LOOK ALIKE.  NONE OF THE
; OUTPUT ONLY MACROS ADD ANY SPECIAL CHARACTERS.

;BY CONVENTION PROMPTING IN () APPEARS BEFORE LONG DIALOG IN [].
; THUS A USER CAN TYPE ^O IF THE USER GETS BORED, AND GET THE MOST USEFUL
; OUTPUT FIRST.

;IF JUST A CR IS GIVEN TO A QUESTION WHICH HAS A LIST, THE FIRST
; ITEM IS ASSUMED.  THIS IS TRUE FOR DECIMAL AND OCTAL QUESTIONS TOO.

;ALL NUMERIC QUESTIONS MUST HAVE A RANGE SUPPLIED.
; IF ONE IS NOT, THE USER GETS:
; ? INTERNAL MONGEN ERROR - NO (...,MIN-MAX) IN ABOVE QUESTION -
; EDIT MONGEN AND INCLUDE IN QUESTION.
;ALL ERRORS WHICH ARE MONGEN'S RATHER THAN THE CUSTOMER'S, ARE PRECEDED
; WITH ? INTERNAL MONGEN ERROR - FOLLOWED BY THE PROBLEM AND WHAT
; THE PROGRAMMER SHOULD DO TO FIX MONGEN.  NOTE THAT
; THE CUSTOMER SHOULD NEVER SEE THESE, SINCE THEY ARE DEBUGGING AIDS.

;ALL ERROR MESSAGES START WITH "? ". THE SPACE FOLLOWING ? MAKES THEM
; DISTINGUISHABLE FROM MONITOR ERRORS WHICH HAVE NO SPACE.

;ALL STRINGS ARE ASCIZ INCLUDING AS INPUT FROM TTY.
; ALL EOL CHARS(CR,LF,FF,VT,ESC,ALT1,ALT2,^Z,^C) ARE STRIPPED OUT
; AND ARE REPLACED BY A NULL.  THIS MAKES IT EASY TO SCAN STRINGS
; SINCE END IS ALWAYS DETECTED BY JUMPE CH,
; OUTPUT TO FILE MUST PUT CRLF BACK IN EXPLICITLY BY USING
; @ OR FCRLF ROUTINE.  THIS MAKES OUTPUT FILE MORE INDEPENDENT FROM
; USER INPUT.

;TO HELP THE READER OF MONGEN:
; ALL JUMPS ARE DOWN THE PAGE, EXCEPT LOOPS
; MOST PUSHJ ARE TO ROUTINES DOWN THE PAGE

;DEFINE THE MACROS:
; THE FOLLOWING MACROS SUFFIX ": " TO ASK QUESTION
; AND GET ANSWER ON SAME LINE
DEFINE	CAL	(XXX,A,B,%C)<
	XLIST			;;ALWAYS TURN OFF LISTING
IFNB <B>,<IFDIF <B> <N>,<MOVE	N,B>>	;;PICK UP VALUE TO BE SUBSTITUTED FOR *
	JSP	T1,%C		;;SETUP T1 WITH MESSAGE ADR AND JUMP AROUND
				;; MESSAGE WHICH MAY BE TOO BIG TO FIT
				;; IN REMOTE LITERAL.
	ASCIZ	\A: \		;;THE QUESTION WITH ": "
	INTERN	XXX		;;DECLARE INTERN SO MACRO WILL NOT THINK XXX A MACRO
%C:!	PUSHJ	P,XXX		;;CALL THE SUBROUTINE XXX
IFE RJRSTF,<LIST>		;;TURN LISTING BACK ON UNLESS INSIDE RJRST MACRO
>

DEFINE	ASKYN	(A,B)<
	CAL	ASKYN,<A>,B>

DEFINE	ASKDEC	(A,B)<
	CAL	ASKDEC,<A>,B>

DEFINE	ASKOCT	(A,B)<
	CAL	ASKOCT,<A>,B>

DEFINE	ASKLIN	(A,B)<
	CAL	ASKLIN,<A>,B>

DEFINE	ASKSTR	(A,B)<
	CAL	ASKSTR,<A>,B>

DEFINE	ASKLST	(A,B)<
	CAL	ASKLST,<A>,B>


;THE FOLLOWING MACROS DO NOT HAVE ANY CHARACTERS ADDED TO QUESTION

DEFINE	CAL2	(XXX,A,B,%C)<
	XLIST			;;ALWAYS TURN OFF LISTING
IFNB <B>,<IFDIF <B> <N>,<MOVE	N,B>>	;;PICKUP VALUE TO BE SUBSTITUTED FOR *
	JSP	T1,%C		;;SETUP T1 WITH MESSAGE ADR AND JUMP AROUND
				;; MESSAGE WHICH MAY BE TOO LONG FOR MACRO
				;; REMOTE LITERAL TABLE(14 WORDS)
	ASCIZ	\A\		;;THE QUESTION WITH NO ADDED CHARACTERS
	INTERN	XXX		;;DECLARE INTERN SO MACRO WILL NOT THINK XXX A MACRO
%C:!	PUSHJ	P,XXX		;;CALL THE SUBROUTINE TO JUST OUTPUT
IFE RJRSTF,<LIST>		;;TURN LISTING BACK ON UNLESS INSIDE RJRST MACRO
>
;OUTPUT IMMEDIATE VALUE

DEFINE	CAL3	(XXX,A,B,%C)<
	XLIST			;;ALWAYS TURN OFF LISTING
IFNB <B>,<IFDIF <B> <N>,<MOVEI	N,B>>	;;PICKUP VALUE TO BE SUBSTITUTED FOR *
	JSP	T1,%C		;;SETUP T1 WITH MESSAGE ADR AND JUMP AROUND
				;; MESSAGE WHICH MAY BE TOO LONG FOR MACRO
				;; REMOTE LITERAL TABLE(14 WORDS)
	ASCIZ	\A\		;;THE QUESTION WITH NO ADDED CHARACTERS
	INTERN	XXX		;;DECLARE INTERN SO MACRO WILL NOT THINK XXX A MACRO
%C:!	PUSHJ	P,XXX		;;CALL THE SUBROUTINE TO JUST OUTPUT
IFE RJRSTF,<LIST>		;;TURN LISTING BACK ON UNLESS INSIDE RJRST MACRO
>
DEFINE	ASKMN	(A,B)<
	CAL2	ASKMN,<A>,B>

DEFINE	ASKMNP	(A,B)<
	CAL2	ASKMNP,<A>,B>

DEFINE	ASKTMN	(A,B)<
	CAL2	ASKTMN,<A>,B>

DEFINE	BTHOUT	(A,B)<
	CAL2	BTHOUT,<A>,B>

DEFINE	BTHOCT	(A,B)<
	CAL2	BTHOCT,<A>,B>

DEFINE	FILOUT	(A,B)<
	CAL2	FILOUT,<A>,B>

DEFINE	FILCPU	(A,B)<
	CAL2	FILCPU,<A>,B>

DEFINE	FILCOM	(A,B)<
	CAL2	FILCOM,<A>,B>

DEFINE	FILOUD	(A,B)<
	CAL3	FILOUT,<A>,B>

DEFINE	TTYOUT	(A,B)<
	CAL2	TTYOUT,<A>,B
>
DEFINE	TTYOCT	(A,B)<
	CAL2	TTYOCT,<A>,B>

DEFINE	FILSTR	(A,B)<
	CAL2	FILSTR,<A>,B>

DEFINE	FILDEC	(A,B)<
	CAL2	FILDEC,<A>,B>

DEFINE	FILDC2	(A,B)<
	CAL2	FILDC2,<A>,B>

DEFINE	EREXIT	(A,B)<
	CAL2	EREXIT,<A>,B>
DEFINE	FHLPOS	(A,B)<
	XLIST
IFB <A>,<PRINTX FHLPOS MACRO MAY CLOBBER WD>
IFB <B>,<PRINTX FHLPOS MACRO MAY CLOBBER WD>
IFDIF <A>,<*>,<
	MOVE	WD,[SIXBIT \A\]
>
	INTERN	FHLPOS
	PUSHJ	P,FHLPOS
	  JRST	B
	LIST
>

DEFINE	FHLPOA	(A,B)<
	XLIST
IFB <A>,<PRINTX FHLPOA MACRO MAY CLOBBER WD>
IFB <B>,<PRINTX FHLPOA MACRO MAY CLOBBER WD>
IFDIF <A>,<*>,<
	MOVE	WD,[SIXBIT \A\]
>
	INTERN	FHLPOA
	PUSHJ	P,FHLPOA
	  JRST	B
	LIST
>
;DEFINE REMOTE MACROS WHICH ARE JUMPED TO ON UNUSUAL CASES
; INCLUDE CODE IN-LINE SO READABLE, BUT INDENT 2 TABS, JUST AS
; IF MULTI-LINE LITERAL.
;USED INSTEAD OF MULTI-LINE LITERAL BECAUSE MACRO LISTS
; SOURCE INSIDE OF MACROS INSIDE OF LITERALS
DEFINE	RJRST	(A,%B)<
	XLIST		;;TURN OFF LISTING SOURCE IN EXPANSION
RJRSTF==1		;;FLAG INSIDE OF RJRST, SO CAL MACRO
			;; WILL NOT TURN LIST BACK ON
	SKIPA		;;ALLOW MACRO IN ERROR RETURN OR AFTER TEST INSTR.
	JRST	%B	;;BY PASS UNUSUAL CODE
	A		;;THE UNUSAL CODE
RJRSTF==0		;;FLAG NO LONGER INSIDE RJRST MACRO
			;; SO FUTURE CAL MACROS WILL TURN LIST ON
%B:!	LIST		;;TURN LISTING BACK ON
>

DEFINE	RJUMPE	(AC,A,%B)<
	XLIST
RJRSTF==1		;;FLAG INSIDE OF RJRST, SO CAL MACRO
			;; WILL NOT TURN LIST BACK ON
	SKIPE	AC	;;CONDITION OF UNUSUAL CODE?
	JRST	%B	;;NO, BY PASS UNUSUAL CODE
	A		;;THE UNUSUAL CODE
RJRSTF==0		;;FLAG NO LONGER INSIDE RJRST MACRO
			;; SO FUTURE CAL MACROS WILL TURN LIST ON
%B:!	LIST		;;TURN LISTING BACK ON
>

DEFINE	RJUMPL	(AC,A,%B)<
	XLIST
RJRSTF==1		;;FLAG INSIDE OF RJRST, SO CAL MACRO
			;; WILL NOT TURN LIST BACK ON
	SKIPL	AC	;;CONDITION OF UNUSUAL CODE?
	JRST	%B	;;NO, BY PASS UNUSUAL CODE
	A		;;THE UNUSUAL CODE
RJRSTF==0		;;FLAG NO LONGER INSIDE RJRST MACRO
			;; SO FUTURE CAL MACROS WILL TURN LIST ON
%B:!	LIST
>

DEFINE	RJUMPN	(AC,A,%B)<
	XLIST
RJRSTF==1		;;FLAG INSIDE OF RJRST, SO CAL MACRO
			;; WILL NOT TURN LIST BACK ON
	SKIPN	AC	;;CONDITION OF UNUSUAL CODE?
	JRST	%B	;;NO, BY PASS UNUSUAL CODE
	A		;;THE UNUSUAL CODE
RJRSTF==0		;;FLAG NO LONGER INSIDE RJRST MACRO
			;; SO FUTURE CAL MACROS WILL TURN LIST ON
%B:!	LIST
>
DEFINE	RJUMPGE	(AC,A,%B)<
	XLIST
RJRSTF==1		;;FLAG INSIDE OF RJRST, SO CAL MACRO
			;; WILL NOT TURN LIST BACK ON
	SKIPGE	AC	;;CONDITION OF UNUSUAL CODE?
	JRST	%B	;;NO, BY PASS UNUSUAL CODE
	A		;;THE UNUSUAL CODE
RJRSTF==0		;;FLAG NO LONGER INSIDE RJRST MACRO
			;; SO FUTURE CAL MACROS WILL TURN LIST ON
%B:!	LIST
>

RJRSTF==0		;START FLAG AT 0 MEANING NOT INSIDE RJRST
;PARAMETERS:
;ACS
F=0		;FLAGS
  ;LH(DEFINED AS 36 BIT QUANTITIES):
  F.MTCH==1B0	;MATCH FOUND IN FNDASK ROUTINE
  F.OFO==1B1	;OUTPUT FILE OPEN.  FILE CALLS IGNORED IF 0
		; NEEDED SO ASK ROUTINES CAN BE USED TO ASK ABOUT FILE NAME
  F.TF==1B2	;TTY/FIL FLAG, 1 ON FIRST CHAR TO FILE
		; USED FOR DEBUG FEATURE TO PRINT <> ON TTY
		; SET BY TTYPUT ROUTINE, CLEARED BY FILPUT ROUTINE
  F.CTY==1B3	;CTY IS AN ACCEPTABLE OCTAL NUUMBER IF 1
		; SET BY ASKLIN, CLEARED BY ASKDEC,ASKOCT,ASKNUM ROUTINES
  F.FLF==1B4	;LAST CHAR ON FILE WAS LINE FEED
		; USED TO PRECEDE NEXT CHAR WITH ; TO MAKE A COMMENT IN FILE
		; IF F.COM IS ALSO ON.  SET, CLEARED AND LOOKED AT BY FILPUT ONLY
  F.COM==1B5	;MAKE ALL LINES TO FILE BE COMMENT IF THIS FLAG IS ON
		; USES F.FLF TO KNOW WHEN TO PUT ; OUT
		; SET AND CLEARED BY FILCOM AND TTYIN ROUTINES ONLY
		; LOKED AB BY FILPUT ROUTINE
  F.LPAR==1B6	;LEFT PAREN SEEN BY TTYOUT IN TTY OUTPUT STREAM.
		; USED TO SUPPRESS PROMPTING IF IN SHORT HELP MODE
		; CLEARED WHEN RIGHT PAREN SEEN.  SET, CLEARED,
		; AND USED BY TTYOUT ROUTINE ONLY.
  F.LBRK==1B7	;LEFT BRACKET SEEN BY TTYOUT IN TTY OUTPUT STREAM
		; YSED TO SUPPRESS EXPLANATION UNLESS IN LONG MODE
		; SET, CLEARED AND TESTED BY TTYOUT ROUTINE ONLY
  F.CONZ==1B8	;CONTROL Z TYPED IN ON TTY, SET BY TTYGET
  F.EXP==1B9	;IN LSTEXP, SET IF EXPLAIN, CLEARED IF LIST
  F.HOPN==1B10	;SET IF FGEN EXPLAIN FILE IS OPEN FOR READING
  F.HRRD==1B11	;SET IF READING EXPLAIN FILE A SECOND TIME
		; IF FILE WAS OPEN, MAY START SEARCHING PAST THE ENTRY DESIRED.
		; AT END OF FILE, REREAD FROM THE BEGINNING ONCE.
  F.2DEC==1B12	;SET IF WANT AT LEAST TWO CHARS IN DECIMAL OUTPUT
  F.FHLC==1B13	;SET IF LOOKING FOR TAB AFTER TEXT IN FGEN HELP FILE
  F.PER==1B14	;SET IF A PERIOD, DOLLAR SIGN  OR PERCENT CAN BE PART OF SYMBOL
		; USED TO DISTINGUISH BETWEEN FILE NAMES AND SYMBOLS
  F.INFO==1B15	;SET BY ASKMNP TO INDICATE MORE INFO WILL FOLLOW M-N OR CTY
		; RESET BY ASKMN TO INDICATE END OF STRING EXPECTED AFTER M,M-N, OR CTY
;RH BITS
  F.1FH==1B35	;1ST RC10 ON CPU
  F.1RP==1B34	;1ST RH10/RP04 ON CPU
  F.1FS==1B33	;1ST RH10/RS04 ON CPU
  F.1DP==1B32	;1ST RP10 ON CPU
  F.1TX==1B31	;1ST TX01 ON CPU
  F.1T1==1B30	;1ST TM10 ON CPU
  F.1T2==1B29	;1ST TM02 ON CPU
  F.1D2==1B28	;1ST DX20 ON CPU
  F.1RN==1B27	;1ST RH20/RP20 ON CPU
  F.KONS==F.1FH+F.1RP+F.1FS+F.1DP+F.1TX+F.1T1+F.1T2+F.1D2+F.1RN

N=1		;NUMERIC VALUE OF ASKED QUESTION.
		; ALSO USED TO SUBSTITUTE FOR * IN ALL STRINGS.
		; CAN BE LEFT JUSTIFIED SIXBIT.
		; YES ANSWERS ARE 1, NO ANSWERS ARE 0.
T1=2		;TEMPORARY AC. USUALLY ADR OF ASCIZ MESSAGE ON SUB CALL.
T2=T1+1		;FOR REMAINDER IN DIVISION
WD=4		;WORD AC ON CALLS TO GETWRD(LEFT JUSTIFIED SIXBIT)
B=5		;BYTE POINTER TO TEXT STRING
R=6		;INPUT AND OUTPUT RADIX
LV=7		;MODE OF ASKING QUESTIONS(-1=SHORT,0=PROMPT,1=LONG)
I=10		;INDEX FOR LOOP COUNTS
CH=11		;CHARACTER AC
I2=12		;SECOND INDEX FOR LOOP COUNTS
I3=13		;3RD INDEX FOR LOOP COUNTS
RH12=14		;=0 FOR RH10, =1 FOR RH20
P1=15		;"PERMANENT" ACS. THE SAVE ROUTINES DON'T EXIST,
P2=16		; USE AT GEN LEVEL FOR LOOP VARIABLES, ETC.
P=17		;PD POINTER

;SAVGET LOCATIONS

.SGDEV==11	;AC FROM RUN OR GET WHICH CONTAINS DEVICE FROM WHICH MONGEN WAS RUN
.SGPPN==7	;AC WHICH CONTAINS DIRECTORY
;SPECIAL ASCII CHARACTERS(NEVER CODE IN OCTAL SO CAN USE CREF):
C.RUB==177	;RUBOUT
C.ALT1==175	;OLD ALT MODES
C.ALT2==176	;OLD ALT MODE ON SOME TTYS
C.ESC==33	;MAP ALTS INTO ESCAPE
C.CONZ==32	;CONTROL Z
C.FF==14	;FORM FEED
C.CR==15	;CARIAGE RETURN
C.LF==12	;LINE FEED
C.CONC==3	;CONTROL C
C.TMFH==1	;CONTROL A IS TERMINATOR IN FGEN AUXILIARY HELP FILE

;STANDARD MAXIMUMS FOR QUESTIONS

SM.CPU==4	;MAXIMUM NUMBER OF CPU'S
SM.DF==^D8	;MAXIMUM NUMBER OF DF10 DATA CHANNELS
SM.RC==2	;MAXIMUM NUMBER OF RC10S PER CHANNEL
SM.RP==3	;MAXIMUM NUMBER OF RP10S PER CHANNEL
SM.KPC==10	;MAXIMUM NUMBER OF KONTROLLERS PER CHANNEL
SM.JOB==777	;MAXIMUM NUMBER OF JOBS SYSTEM MAY INCLUDE
SM.PI==7	;MAXIMUM PI CHANNEL NUMBER
SM.AC==17	;HIGHEST AC NUMBER FOR HIGHEST-AC-TO-SAVE
SM.RTD==^D77	;MAXIMUM NUMBER OF REAL TIME DEVICES
SM.HPQ==^D15	;MAXIMUM NUMBER OF HIGH PRIORITY QUEUES
SM.CDR==2	;MAXIMUM NUMBER OF CDRS
SM.DTA==2	;MAXIMUM NUMBER OF DTA CONTROLLERS
SM.LPT==3	;MAXIMUM NUMBER OF LPTS
SM.PLT==2	;MAXIMUM NUMBER OF PLOTTERS
SM.PTY==^D510	;MAXIMUM NUMBER OF PTYS
SM.DL10==2	;MAXIMUM NUMBER OF DL10'S
SM.CONN==^D512	;MAXIMUM NUMBER OF CONNECTS
SM.RMCR==^D512	;MAXIMUM NUMBER OF REMOTE TTY'S
SM.KDUP==^D2	;MAXIMUM NUMBER OF DUP-11S ON A KMC-11
SM.TTG==^D8	;MAXIMUM NUMBER OF TTY 8-LINE GROUPS
SM.68L==^D100	;MAXIMUM NUMBER OF LINES ON DC68
SM.MPI==^D512	;MAXIMUM NUMBER OF PAGES SUPPORTED ON KI10
SM.XTC==4	;MAXIMUM NUMBER OF DA28C CHANNELS
SM.D60==^D11	;MAXIMUM NUMBER OF DN60'S (IBM BSC INTERFACES)
SM.XTC==4	;MAXIMUM NUMBER OF DA28C CHANNELS
SM.DLP==2	;MAXIMUM NUMBER OF LINE PRINTER ON 1091 FRONT END
SM.DCR==1	;MAXIMUM NUMBER OF CARD READERS ON 1091 FRONT END
;DEFAULT VALUES OUTPUT BY MONGEN, MOSTLY FOR OLD SYMBOLS

IFNDEF MD.PG,<MD.P6==0>		;NO PDP 6
IFNDEF MD.2RR,<MD.2RR==1>	;ALWAYS 2 RELOCATION REGISTERS
IFNDEF MD.SEG,<MD.SEG==0>	;ALWAYS NO EXTRA SEGMENTS
IFNDEF MD.DDT,<MD.DDT==1>	;ALWAYS LOAD EDDT
IFNDEF MD.MOV,<MD.MOV==0>	;NO MOVIE
IFNDEF MD.C10,<MD.C10==1>	;CDR IS ALWAYS CR10
IFNDEF MD.DTC,<MD.DTC==0>	;NO PDP 6 DECTAPE
IFNDEF MD.TMC,<MD.TMC==0>	;NO PDP 6 MAGTAPE
IFNDEF MD.TWJ,<MD.TWJ==0>	;STANDARD VALUE FOR TMPCOR PARAMETERS
IFNDEF MD.TLJ,<MD.TLJ==0>	;...

IFNDEF FTUNSUPPORTED,<FTUNSUPPORTED==0> ;DON'T ASK QUESTIONS ABOUT UNSUPPORTED HARDWARE/SOFTWARE
IFNDEF MD.DCS,<MD.DCS==0>	;NO PDP 6 SCANNER
;BITS IN FEATURE TEST SWITCH TABLE

FS.VAL==1B0	;CURRENT VALUE MUST BE SIGN BIT

ZZ==1		;CURRENT BIT

FS.0==1B<ZZ>	;LEFT MOST BIT FOR CONFIGURATION FIELD

	DEFINE	FTSDEF(A),<
IRP A,<FS'A==1B<ZZ>	;ON IF DEFAULT ON FOR A
ZZ==ZZ+1
>>

	FTSDEF	<1070,1080,1090,1091,2020>

IFG ZZ-^D12,<PRINTX TOO MANY CONFIGURATIONS - MUST CHANGE FEATURE TEST TABLE>
;IO CHANNELS:
TTYCHN==0	;TTY INPUT AND OUTPUT CHANNEL
FILCHN==1	;FILE OUTPUT CHANNEL
FHLPCH==2	;FGEN AUXILIARY HELP FILE CHANNEL

;IO STATUS BITS:
IO.EOF==20000	;END OF FILE

;NUMBER OF I/O BUFFERS
NFILBF==2	;NUMBER OF BUFFERS FOR FILE OUTPUT
NFHLPB==2	;NUMBER OF BUFFERS FOR FGEN AUXILIARY HELP FILE

;OPDEFS:
OPDEF	PJRST	[JRST]	;EQUIVALENT TO PUSHJ POPJ PAIR
OPDEF	PJUMPE	[JUMPE]	;EQUIVALENT TO JUMPE [PJRST]
SUBTTL	INITIALIZATION, AND DISPATCH TO PROPER GEN, CLOSE FILES

BEGINA:	HLRZ	16,.JBSA##	;GET TRUE .JBFF
	CAME	16,.JBFF	;SEE IF SAME
	JRST	BEGIN-1		;NO--MUST BE ^C START
	MOVEM	.SGDEV,RUNDEV	;SAV DEVICE FROM WHICH MONGEN WAS RUN
	MOVEM	.SGPPN,RUNPPN	;AND DIRECTORY
	SETOM	FSTFLG		;INITIALIZE FSTFLG 
BEGIN:	RESET			;RESET IO DEVICES
	AOS	.JBFF		;ADVANCE .JBFF TO FLAG BEGINA THAT AC'S WERE CLOBBERED
	MOVE	P,[IOWD MP.PDL,PDLIST]	;RESET PD PTR, SINCE HERE ON IO ERRORS
				; FROM ROUTINE DEEP IN STACK
	SETZB	F,VARBEG	;CLEAR ALL FLAGS AND VARIABLE AREA
				; EXCEPT SAVLV WHERE VERBOSCITY
				; LEVEL IS SAVED AND DEBUG AND HELPF
	MOVE	LV,SAVLV	;SETUP HELP LEVEL FOR NEXT QUESTION
				; FROM LONG TERM VALUE(INITIALLY PROMPT)
				; ^C START REMEMBERS LAST PERMANENT LEVEL
				; SINCE SAVLV IS NOT CLEARED
	MOVE	T1,[XWD VARBEG,VARBEG+1]
	BLT	T1,VAREND	;CLEAR VARIABLE AREA
	INIT	TTYCHN,1	;TTY IN LINE MODE
	SIXBIT	/TTY/
	XWD	TOBUF,TIBUF	;OUTPUT,INPUT BUFFER HEADERS
	  RJRST	<EREXIT	<Cannot INIT TTY>,,>	;TYPE ? INTERNAL ERR AND EXIT
	AOS	HELPF		;ALREADY TOLD USER ABOUT HELP?
	TLZ	F,(F.CONZ)	;CLEAR CONTROL Z TYPED FLAG
	SKIPN	N+1,RUNDEV	;SKIP IF DEVICE FROM WHICH MONGEN WAS RUN
	MOVSI	N+1,'DSK'	;SPECIFIED, ELSDE START WITH DSK
	SETZB	N,N+2		;CLEAR MODE AND BUFFER HEADERS
	MOVEM	N+1,FGDEV	;STORE DEVICE IN CASE WINS
	OPEN	FILCHN,N	;OPEN DEVICE
	  JRST	FNDF1		;NO SUCH DEVICE?
	MOVE	N,FHNAME	;NAME OF FGEN HELP FILE
	HLLZ	N+1,FHNAME+1	;AND EXT
	MOVE	N+3,RUNPPN	;PPN FROM WHICH MONGEN WAS RUN
	MOVEM	N+3,FGPPN	;SAVE IN CASE WINS
	LOOKUP	FILCHN,N	;SEE IF FOUND HELP FILE
	  JRST	FNDF1		;NO, TRY SYS
	JRST	FNDFOK		;FOUND OUR HELP FILE
FNDF1:	MOVSI	N+1,'SYS'	;TRY DEVICE SYS
	MOVEM	N+1,FGDEV
	SETZB	N,N+2
	OPEN	FILCHN,N	;OPEN SYS
	  JRST	FNDF2		;NO SYS?
	MOVE	N,FHNAME	;NAME OF HELP FILE
	HLLZ	N+1,FHNAME+1	;AND EXT
	SETZB	N+3,FGPPN	;CLEAR PPN
	LOOKUP	FILCHN,N	;SEE IF FO[UND HELP FILE
	  JRST	FNDF2		;NO, GIVE UP
	JRST	FNDFOK		;OK, USE SYS VERSION
FNDF2:	SETZM	FGDEV		;CLEAR DEVICE SO ALWAYS FAILS
	TTYOUT	<%Can't find FGEN.HLP@>
FNDFOK:	MOVE	N,FSTFLG	;GET STATUS OF FSTFLG
	ADDI	N,1		;ADD ONE TO IT
	MOVEM	N,FSTFLG	;AND SAVE IT
	CAIGE	N,6		;***HAVE WE COMPLETED ALL OF THE FILES
	JRST	DOALL		;NO, GO DO NEXT FILE AUTOMATICALLY
	EXIT			;YES, EXIT TO MONITOR
DOALL:	MOVEM	N,WCHGEN	;STORE WHICH GEN(0=HDW, 1=TTY, 2=NET, 3=F)

;LOOP TO ASK FOR FILE UNTIL SUCCESSFUL ENTER CAN BE DONE.  SO INIT VARIABLES.
ASKFIL:	MOVSI	T1,(SIXBIT /DSK/) ;ASSUME DSK
	MOVEM	T1,OUTDEV	;IF USER DOES NOT SPECIFY DEVICE
	MOVE	N,WCHGEN	;THE GEN NUMBER(0-3)
	MOVE	N,FILTAB(N)	;DEFAULT FILE NAME FOR THIS GEN
				; HDWCNF,TTYCNF,NETCNF,F
	HLLZM	N,WCHNAM	;STORE NAME OF THIS GEN(TTY,NET,MON,F)
	MOVEM	N,OUTNAM	;ALSO SETUP DEFAULT FILE NAME FOR THIS GEN
	MOVE	T1,FSTFLG	;***GET GEN NUMBER
	CAIGE	T1,4		;***SYSJOB OR SYSTEM.CMD?
	JRST	MAC		;***NO, DO NEXT GEN
	CAIE	T1,4		;***SYSJOB?
	JRST	CMD		;***NO, SETUP FOR SYSTEM.CMD
	MOVSI	T1,(SIXBIT /INI/) ;***SETUP SYSJOB EXTENSION
	JRST	MAC+1		;***AND GO DO IT
CMD:	MOVSI	T1,(SIXBIT /CMD/) ;***SETUP EXTENSION FOR SYSTEM
	JRST	MAC+1		;***AND GO DO IT
MAC:	MOVSI	T1,(SIXBIT /MAC/) ;ASSUME EXTENSION OF MAC
	MOVEM	T1,OUTEXT	;FOR FILE EXTENSION
	SETZM	OUTDAT		;CLEAR DATE ARG
	SETZM	OUTPPN		;AND PROJECT,PROGRAMMER ARG
	MOVEI	CH,0		;DON'T ASK WHICH FILE TO WRITE, JUST WRITE
				;DEFAULT FILNAM.EXT
	MOVEI	WD,0		;SET WORD VALUE TO 0 AS FLAG THAT NO SPEC
	JUMPE	CH,OPNDEV	;IF CHARACTER IS 0, JUST CR TYPED
	PUSHJ	P,GETWRD	;GO GET WHAT MAY BE DEV: OR FILENAME
	CAIE	CH,":"		;IS BREAK DEVICE SEPARATOR?
	JRST	OPNDEV		;NO, SAVE FILE NAME AND GO INIT DEVICE
	MOVEM	WD,OUTDEV	;YES, STORE USER SUPPLIED DEVICE NAME
	PUSHJ	P,GETWRD	;GET NEXT WORD USER TYPED(FILE NAME)
OPNDEV:	INIT	FILCHN,1	;INIT FILE CHANNEL IN ASCII LINE MODE
OUTDEV:	SIXBIT	/DSK/		;DEVICE NAME
	XWD	FOBUF,0		;OUTPUT BUFER HEADER
	  RJRST	<TTYOUT <? Device * not available@>,OUTDEV ;TYPE ERROR
		 JRST	ASKFIL>	;GO ASK FOR FILE SPEC AGAIN
	PUSH	P,.JBFF##	;SAVE JOBFF
	MOVEI	T1,FILBUF	;ADDR OF FILE BUFFERS
	MOVEM	T1,.JBFF	;SET UP JOBFF TO ALLOCATE OUR BUFFERS
	OUTBUF	FILCHN,NFILBF	;ALLOCATE BUFFERS
	POP	P,.JBFF		;RESTORE JOBFF
	JUMPE	WD,OUTDV0	;WAS NO FILE NAME TYPED?
	MOVEM	WD,OUTNAM	;STORE CUSTOMER SUPPLIED FILE NAME
OUTDV0:	CAIE	CH,"."		;NO, WELL BETTER BE EXTENSION NEXT
	JRST	OUTDV3		;NO, GO CHECK FOR BRACKET FOR PPN
	PUSHJ	P,GETWRD	;GO GET EXTENSION
	HLLM	WD,OUTEXT	;AND STORE FOR ENTER
OUTDV3:	JUMPE	CH,OUTDV4	;END OF LINE(CR=0)?
	CAIE	CH,"["		;NO, BETTER BE LEFT BRACKET FOR PPN
OUTDV1:	JRST	FMTERR		;NO, INCREASE VERBOSITY LEVEL AND ASK AGAIN
	PUSHJ	P,GETOCT	;GET PROJ NUMBER
	CAIE	CH,","		;IS BREAK COMMA?
	JRST	FMTERR		;NO, INCREASE VERBOSITY AND ASK AGAIN
	HRLZM	N,OUTPPN	;YES, STORE PROJECT NO.
	PUSHJ	P,GETOCT	;GET PROG NUMBER
	JUMPE	CH,OUTDV2	;JUMP IF END OF LINE, END OF PPN
	CAIE	CH,"]"		;IS BREAK RIGHT BRACKET?
FMTERR:	RJRST	<TTYOUT	<? Not DEV:FILE.EXT[P,PN]@>
		AOJA	LV,ASKFIL>	;INCREASE LEV AND ASK AGAIN
OUTDV2:	HRRM	N,OUTPPN	;STORE PROG NUMBER
	JUMPE	CH,OUTDV4	;JUMP IF END OF LINE
	PUSHJ	P,GETWRD	;GET NEXT WORD
	JUMPN	WD,FMTERR	;BETTER NOT BE ANYTHING AFTER RIGHT BRACKET
	JUMPN	CH,FMTERR	;IS BREAK CR?
OUTDV4:	MOVE	N,OUTPPN	;GET PPN TYPED
	MOVEM	N,SAVPPN	;SAVE FOR LATER
	ENTER	FILCHN,OUTNAM	;TRY TO ENTER FILE ON DEVICE
	  RJRST	<HRRZ N,OUTEXT	;ENTER ERROR CODE FOR *
		 TTYOCT <? Enter error *@>,N
		 JRST ASKFIL>	;ASK FOR FILE NAME AGAIN
	MOVE	LV,SAVLV	;RESTORE PERMANENT HELP LEVEL
	TLO	F,(F.OFO!F.PER)	;FLAG THAT OUTPUT FILE IS NOW OPEN
				; SO FILPUT WONT BE A NO-OP
				; AND ALLOW PERIODS IN SYMBOLS
	MOVE	T1,WCHGEN	;ENTER OK, GET WHICH GEN THIS IS
	PUSHJ	P,@GENTAB(T1)	;DISPATCH TO PROPER GEN
				; HDWGEN, TTYGEN, NETGEN, FGEN
	MOVE	LV,SAVLV	;RESTORE PERMANENT HELP LEVEL
				; IN CASE USER TYPED /H<CR>
	MOVE	N,FSTFLG	;***GET GEN NUMBER
	CAIL	N,4		;***SYSJOB OR SYSTEM.CMD?
	JRST	CLOSE		;***YES DON'T ADD COMMENT LINES
	FILCOM	<@END OF *>,OUTNAM
	HLLZ	N,OUTEXT	;EXTENSION OF FILE WRITTEN
	FILCOM	<.*@>,N
	MOVEI	CH,C.FF		;FORM FEED
CLOSE:	PUSHJ	P,FILPUT	;TO OUTPUT FILE
	CLOSE	FILCHN,		;CLOSE OUTPUT FILE
	TLZ	F,(F.OFO)	;FLAG THAT OUTPUT FILE IS NOT OPEN
				; SO FILPUT WILL BE A NO-OP
	STATZ	FILCHN,740000	;ANY ERRORS ON LAST BUFFER
;HERE ON ANY FILE ERRORS DURING EXECUTION
FILERR:	  RJRST	<TTYOUT <? File * error>,OUTNAM
		 GETSTS	FILCHN,N ;GET FILE STATUS FROM MONITOR
		 TLZ	N,-1	;MAKE SURE NO STUFF IN LH
		 TTYOCT	<*@>;OUTPUT STATUS NUMBER AND CR
		 JRST .+1>	;CONTINUE
	RELEASE	FILCHN,		;RELEASE FILE CHANNEL
	TTYOUT	<File >
	SKIPN	N,OUTDEV	;SKIP IF DEVICE SPECIFIED
	JRST	CLTY1		;NO, DONT TYPE DEVICE
	TTYOUT	<*:>,N
CLTY1:	TTYOUT	<*>,OUTNAM
	HLLZ	N,OUTEXT	;INCLUDE EXTENSION
	TTYOUT	<.*>,N
	SKIPN	N,SAVPPN	;SKIP IF PPN SPECIFIED
	JRST	CLTY2		;NO, DONT TYPE PPN
	PUSH	P,LV		;SAVE CURRENT HELP LEVEL
	MOVEI	LV,1		;ASSUME LONG SO PPN WILL PRINT
	HLRZS	N		;N=PROJECT
	TTYOCT	<[*,>,N
	HRRZ	N,SAVPPN	;N=PROGRAMMER
	TTYOCT	<*]>,N
	POP	P,LV		;RESTORE CURRENT HELP LEVEL
CLTY2:	MOVE	N,WCHGEN	;WHICH GEN RUN
	HLLZ	N,FILTAB(N)	;PICK UP NAME OF GEN
	TTYOUT	< Closed [*GEN finished]@@>,N ;ALSO WHICH GEN
	JRST	BEGIN		;GO BACK AND ASK FOR NEXT GEN
				; KEEP SAME HELP LEVEL AND DO NOT ASK /HELP
SUBTTL	FGEN - DIALOG TO DEFINE SOFTWARE FEATURES

FGEN:	FILOUT	<UNIVERSAL	F - SOFTWARE FEATURE TEST FILE OUTPUT BY MONGEN DIALOG@@@>
	MOVEI	N,VERSION	;PUT MONGEN VERSION IN FILE FOR COMMON TO CHECK
	FILOUT	<INTERN	[email protected]==*@XLIST@>,N	;OUTPUT TO FILE

	MOVE	N,[SIXBIT/KLFULL/] ;SETUP FOR KLFULL
	MOVEM	N,ASKTAB	;SETUP ASKTAB FOR KLFULL
	SETZ	N,		;ADJUST POINTER TO TABLE
	PUSH	P,.JBFF		;SAVE JOBFF SO WILL REUSE SPACE EVERY RERUN OF FGEN
;HERE TO READ HELP FILE AND ESTABLISH SWITCHES AND THEIR BEGINNING VALUES

	MOVEM	N,FGTYPE	;SAVE N IN FGTYPE
	PUSH	P,ASKTAB(N)	;SAVE TYPE OF SYSTEM IN SIXBIT
	MOVE	T1,.JBFF	;FIRST AVAILABLE LOCATION FOR SWITCH TABLE
	HRLI	T1,T1		;ALWAYS INDEXED BY T1
	MOVEM	T1,FTTAB	;STORE POINTER TO TABLE

;HERE TO FIND NEXT SWITCH IN FILE

FSETDF:	HRRZ	T1,.JBFF	;SWITCH TABLE ADDRESS
	ADDI	T1,MP.FTA	;ADD SIZE OF SWITCH TABLE
	CAMG	T1,.JBREL##	;IN BOUNDS?
	JRST	FSETD0		;YES,PROCEED
	CORE	T1,		;NO, GET MORE CORE
	  RJRST	<EREXIT	<Insufficient user core@>,,>
FSETD0:	FHLPOA	FT,FTABEN	;POSITION FILE AT NEXT SWITCH
	MOVE	T1,[POINT 6,WD,11] ;BYTE POINTER TO BUILD SWITCH NAME
	SETZ	WD,		;START WITH FRESH AC

FSETD1:	PUSHJ	P,FHLPRC	;GET NEXT CHAR FROM FILE
	JUMPE	CH,FSETDN	;JUMP IF END OF FILE, END OF NAME
	CAIN	CH,"("		;SKIP IF NOT END OF NAME
	JRST	FSETDN		;JUMP IF FOUND BEGINNING OF SYSTEMS FOR DEFAULT ON
	CAIL	CH,"A"		;SKIP IF NOT A LETTER
	CAILE	CH,"Z"		;SKIP IF A LETTER
	SKIPA			;NOT A LETTER, SEE IF A NUMBER
	JRST	FSETD5		;A LETTER IS PART OF A SWITCH
	CAIL	CH,"0"		;SKIP IF NOT A NUMBER EITHER
	CAILE	CH,"9"		;SKIP IF A NUMBER
	SKIPA			;NOT EITHER, TRY SPECIAL CHARACTER
	JRST	FSETD5		;A NUMBER IS PART OF A SWITCH
	CAIE	CH,"$"		;SKIP IF "$"
	CAIN	CH,"%"		;SKIP IF NOT "%"
	JRST	FSETD5		;EITHER CHARACTER IS OK
	CAIE	CH,"."		;SKIP IF "."
	JRST	FSETD4		;NOT A NUMBER, LETTER OR (%,$,.), ASSUME END
				; OF SWITCH AND NO ()
FSETD5:	SUBI	CH,"0"-'0'	;CONVERT TO SIXBIT
	TLNE	T1,770000	;NO, MORE CHARS IN NAME, SKIP IF MORE THAN SIX
	IDPB	CH,T1		;STORE CHAR IN NAME
	JRST	FSETD1		;AND LOOP

FSETDN:	MOVEM	WD,@.JBFF	;STORE NAME IN SWITCH TABLE
FSETD2:	PUSHJ	P,GETWRF	;GET NEXT SYSTEM TYPE FOR WHICH SHOULD BE ON
	CAMN	WD,(P)		;SKIP IF NOT THIS TYPE OF SYSTEM
	JRST	FSETDO		;YES, TURN SWITCH ON
	CAIE	CH,")"		;SKIP IF END OF LIST OF SYSTEMS
	JRST	FSETD2		;NO, SEE IF NEXT IS OUR TYPE
	JRST	FSETD3		;YES, MUST BE OFF
;HERE IF SWITCH IS TO BE ON FOR THIS TYPE OF SYSTEM

FSETDO:	MOVSI	WD,400000	;SET SIGN BIT FOR CURRENT VALUE
	IORM	WD,@.JBFF	;STORE IN TABLE

	JRST	FSETD3		;MOVE TO NEXT SWITCH
FSETD4:	MOVEM	WD,@.JBFF	;STORE SWITCH NAME AND VALUE OFF
FSETD3:	AOS	.JBFF		;BUMP POINTER TO NEXT SWITCH
	JRST	FSETDF		;AND KEEP READING SWITCHES
;HERE WHEN NO MORE SWITCHES TO BE FOUND

FTABEN:	MOVE	T1,.JBFF	;END OF TABLE SO FAR
	HRLI	T1,N		;PLUS N FOR INDEXING TO ADD ENTRIES
	MOVEM	T1,FTADD	;STORE POINTER FOR ADDING ENTRIES
	SETZM	(T1)		;CLEAR EXTRA SPACE
	HRRZI	WD,1(T1)
	HRL	WD,T1		;MAKE BLT PTR
	BLT	WD,MP.FTA-1(T1)	;CLEAR THE SPACE
	MOVEI	T1,MP.FTA(T1)	;SAVE SOME SPACE FOR ADDING
	MOVEM	T1,.JBFF	;AND STORE THE NEW JOBFF
	HRRZ	WD,FTTAB	;LOCATION OF BEGINNING OF TABLE
	SUB	WD,T1		;MINUS LOC OF END+1=-LENGTH OF TABLE
	MOVEM	WD,FTLEN	;STORE MINUS LENGTH OF TABLE
	POP	P,(P)		;GET RID OF SYSTEM TYPE

;HERE TO ASK IF WANT STANDARD SETTING
ASKSTD:	SETZ	N,		;SETUP TO DO STANDARD SETTINGS
	JUMPE	N,FNDSTD	;JUMP IF WANT STANDARD VALUES
	TTYOUT	<@Only standard settings have been tested by DEC
all other settings may produce incorrect operation. @@>
	SOJE	N,ASKFSD	;JUMP IF SAID NO
	PUSHJ	P,LSTEXP	;LIST OR EXPLAIN FEATURE TEST SWITCHES
	JRST	ASKSTD		;NOW ASK AGAIN ABOUT STANDARD SETTING
;HERE TO ASK FOR SWITCHES
ASKFSD:	BTHOUT	<Type "switch,value"(or LIST or EXPLAIN)[
For any feature test switch to define,
type "switch,value", value=0 for off or -1 for on, or
type LIST or EXPLAIN to list or explain switches.
Type one per line, extra carriage return when through.]@@>

FSDLOP:	PUSHJ	P,TTYIN		;GET NEXT LINE
	  JRST	ASKFSD		;/HELP TYPED, ASK AT PROPER HELP LEVEL
	JUMPE	CH,FSDEND	;JUMP IF END OF LINE
	PUSH	P,B		;SAVE POSITION BEFORE SWITCH
	PUSHJ	P,GETWRD	;GET SWITCH NAME
	POP	P,T1		;POSITION BEFORE READING SWITCH
	HLRZ	N,WD		;N=BEGINNING OF WORD
	TRZ	N,77		;CLEAR OUT LOWER CHAR
	CAIN	N,'FT '		;SKIP IF NOT "FT..."
	JRST	FSDLP0		;YES, DO THIS SWITCH
	MOVE	B,T1		;RESTORE BYTE POINTER TO BEFORE KEYWORD
	MOVEI	T1,[ASCIZ .(,LIST,EXPLAIN).] ;FIRST COMMA TO MAKE N COME OUT RIGHT
	PUSHJ	P,SETASK
	PUSHJ	P,FNDASK	;SEE IF LIST OR EXPLAIN
	  JRST	ASKFSD
	PUSHJ	P,LSTEXP	;DO LIST OR EXPLAIN
	JRST	ASKFSD		;AND BEGIN ASKING AGAIN

FSDLP0:	CAIE	CH,","		;SKIP IF FOLLOWED BY COMMA
	JRST	FSDERR		;JUMP IF IMPROPER FORMAT
	TLZ	WD,777700	;CLEAR "FT"
	JUMPE	WD,FSDERR	;JUMP IF NO SWITCH NAME
	PUSHJ	P,FNDSWT	;FIND SWITCH IN TABLE, RETURN INDEX IN N
	PUSH	P,WD		;SAVE SWITCH NAME
	PUSH	P,T1		;SAVE INDEX IN TABLE, EVEN IF NEW SWITCH
	PUSHJ	P,GETDEC	;GET VALUE
	JUMPE	CH,FSDLP2	;JUMP IF END OF LINE FOUND
	CAIE	CH,"-"		;SKIP IF FOUND MINUS SIGN
	JRST	FSDERR		;NO, ILLEGAL FORMAT
	PUSHJ	P,GETDEC	;GET ACTUAL VALUE
	JUMPN	CH,FSDERR	;ERROR IF NOT END OF LINE NOW
FSDLP2:	POP	P,T1		;RESTORE INDEX IN TABLE OF SWITCH
	POP	P,WD		;RESTORE SWITCH NAME IN CASE NEW
	JUMPGE	T1,FSDNEW	;JUMP IF NEW SWITCH
	MOVSI	T2,(FS.VAL)	;BIT FOR CURRENT VALUE
	ANDCAM	T2,@FTTAB	;TURN VALUE OFF
	SKIPE	N		;SKIP IF 0 SPECIFIED
	IORM	T2,@FTTAB	;NO, TURN VALUE ON
	JRST	FSDLOP		;LOOP FOR ALL SWITCHES USER TYPES
;HERE IF USER TYPED NEW SWITCH, MAKE SURE AND IF SO OUTPUT SWITCH DIRECTLY
FSDNEW:	MOVSI	T1,(FS.0)	;LEFT MOST DEFAULT BIT FOR SWITCH ENTRY
	MOVN	T2,CNFIND	;INDEX OF CONFIGURATION IN CNF TABLES
	LSH	T1,(T2)		;POSITION BIT FOR THIS CNF
	TDO	T1,WD		;ADD IN SWITCH NAME
	SKIPE	N		;SKIP IF SWITCH IS OFF
	TLOA	T1,(FS.VAL)	;SWITCH IS ON, SET VALUE BIT
	TLZ	T1,777700	;SWITCH IS OFF, CLEAR VALUE AND DEFAULT
	MOVE	N,WD		;N=SWITCH NAME
	TLO	N,'FT '		;ADD BACK "FT"
	PUSH	P,T1		;SAVE NEW SWITCH ENTRY
	ASKYN	<%New switch *(Y,N)[if Y, keep switch, else ignore it]>
	POP	P,T1		;RESTORE NEW SWITCH TABLE ENTRY
	JUMPE	N,ASKFSD	;JUMP IF IGNORE THE SWITCH
;HERE TO ADD SWITCH TO TABLE IF POSSIBLE
	MOVSI	N,-MP.FTA	;LENGTH OF EXTENDABLE TABLE
	SKIPE	@FTADD		;SKIP IF FOUND EMPTY PLACE
	AOBJN	N,.-1		;NO, KEEP LOOKING
	JUMPGE	N,FSDFUL	;JUMP IF EXTENDABLE TABLE IS FULL
	MOVEM	T1,@FTADD	;STORE NEW SWITCH IN TABLE
	JRST	ASKFSD		;GO BACK FOR MORE
FSDFUL:	FILSTR	<XP *@>
	JRST	ASKFSD

FSDERR:	TTYOUT	<? Not "switch,value" or keyword@>
	AOJA	LV,ASKFSD	;ASK AGAIN WITH NEW HELP LEVEL

FSDEND:	MOVE	LV,SAVLV	;RESTORE PERMANENT HELP LEVEL
ASKFSA:	ASKYN	<Set each switch(Y,N)[List each switch with its current value and ask for new value]>
	JUMPE	N,FSAEND	;JUMP IF NO
	HRLZ	T1,FTLEN	;AOBJN PTR TO SWITCHES

FSALOP:	SKIPN	N,@FTTAB	;N=SWITCH ENTRY
	JRST	FSAEN2		;END OF TABLE
	LSH	N,^D12		;N=SWITCH NAME
	PUSH	P,N		;SAVE NAME OF SWITCH IN CASE LOOP
	PUSH	P,T1		;SAVE AOBJN PTR
FSALP0:	MOVE	N,-1(P)		;RESTORE NAME OF SWITCH IN CASE LOOPING
	MOVE	T1,(P)		;RESTORE AOBJN PTR IN CASE LOOPING
	SKIPL	@FTTAB		;SKIP IF SWITCH IS ON
	JRST	FSALP1		;NO, ITS OFF
	ASKLST	<FT*,-1(ON,OFF,LIST,EXPLAIN,END)>
	JRST	FSATST
FSALP1:	ASKLST	<FT*,0(ON,OFF,LIST,EXPLAIN,END)>
FSATST:	MOVE	T1,(P)		;RESTORE AOBJN PTR
	CAIN	N,4		;NO SKIP IF END TYPED
	JRST	FSAEN1		;YES, DO NO MORE
	SOJG	N,FSALEX	;JUMP IF LIST OR EXPLAIN
	MOVSI	T2,(FS.VAL)	;VALUE BIT
	ANDCAM	T2,@FTTAB	;TURN VALUE OFF
	CAIE	N,0		;SKIP IF OFF TYPED
	IORM	T2,@FTTAB	;TURN SWITCH ON
	POP	P,T1		;RESTORE AOBJN PTR
	POP	P,N		;GET RID OF NAME ON STACK
FSAEN2:	AOBJN	T1,FSALOP	;LOOP FOR ALL SWITCHES IN TABLE
	JRST	FSAEND

FSAEN1:	POP	P,T1		;RESTORE AOBJN PTR
	POP	P,N		;GET RID OF NAME ON STACK
FSAEND:	JRST	FNDSTD

FSALEX:	PUSHJ	P,LSTEXP	;DO LIST OR EXPLAIN
	JRST	FSALP0		;AND REASK ABOUT THIS SWITCH

;HERE TO CREATE FGEN OUTPUT FILE
FNDSTD:	FILOUT	<@LIST@>
	TLZ	F,(F.HOPN)	;CLEAR OPEN FLAG, HEADER IS AT BEGINNING

;HERE TO POSITION FGEN HELP FILE AT HEADER
	FHLPOS	HEADER,FNDSTE
	PUSHJ	P,FHLPFL	;COPY HEADER TO OUTPUT FILE
	JRST	FNDST1		;GO DO THE FILE

;HERE IF CANT FIND HEADER
FNDSTE:	TTYOUT	<% Can't find file header in help file@>

;HERE TO OUTPUT SWITCHES FROM TABLE
FNDST1:	HRLZ	T1,FTLEN	;AOBJN PTR TO SWITCH TABLE

STDOUT:	SKIPN	N,@FTTAB	;N=SWITCH ENTRY
	JRST	STDOUL		;IGNORE 0 ENTRIES
	PUSH	P,T1		;SAVE AOBJN PTR
	TLZ	N,777700	;CLEAR JUNK
	TLO	N,'FT '		;AND MAKE FT...
	PUSH	P,N		;SAVE NAME OF SWITCH FOR COMMENT
	MOVE	N,(P)		;REMEMBER SWITCH NAME
	FILOUT	<XP *,>
	MOVE	T1,-1(P)
	SKIPL	@FTTAB		;SKIP IF SWITCH ON
	JRST	STDOU1		;NO, ITS OFF
	FILOUT	<-1>
	JRST	STDOU2
STDOU1:	FILOUT	<0>
;HERE TO COPY TEXT FROM HELP FILE ABOUT THIS SWITCH
STDOU2:	POP	P,WD		;RESTORE NAME OF SWITCH TO SEARCH AUX FILE
	FHLPOS	*,STDOU3
	PUSHJ	P,FHLPFC	;OUTPUT TEXT AS COMMENT
STDOU3:	FILOUT	<@>
	POP	P,T1		;RESTORE AOBJN PTR
STDOUL:	AOBJN	T1,STDOUT	;LOOP FOR ALL SWITCHES IN TABLE

FEND:	FILOUT	<	IF2 <PURGE XP,XPL,XPP>@@	END>
	POP	P,.JBFF		;RESTORE ORIGINAL JOBFF
	POPJ	P,
SUBTTL	HDWGEN - DIALOG TO DEFINE HARDWARE CONFIGURATION

HDWGEN:	FILOUT	<SUBTTL HDWCNF - HARDWARE CONFIGURATION DEFINITION FILE OUTPUT BY MONGEN@@@>
	FILOUT	<DEFINE XP(A,B),<A==:B>@@@>
	MOVEI	N,VERSION	;MONGEN VERSION NO.
	FILOUT	<XP M.MON,*@>,N	;OUTPUT TO FILE


	PUSHJ	P,ASKSYS	;FIND OUT WHAT TYPE OF SYSTEM
	FILOUT	<XP M.KI10,*@>,M.P10I
	FILOUT	<XP M.KL10,*@>,M.KL10
	FILOUT	<XP M.KS10,*@>,M.KS10
	FILOUT	<XP M.1070,*@>,M.1070
	FILOUT	<XP M.1080,*@>,M.1080
	FILOUT	<XP M.1090,*@>,M.1090
	FILOUT	<XP M.1091,*@>,M.1091
	FILOUT	<XP M.2020,*@>,M.2020
	SKIPN	N,M.2020
	SKIPE	N,M.1091
	JRST	HDWGN1
	MOVEI	N,SM.CPU
	ASKDEC	<Cpu's(1,1-*)[Total number of cpu's in the system]>
HDWGN1:	MOVEM	N,M.CPU
	MOVEM	N,CPUS		;PRESERVE FOR USE IN NETGEN
	FILOUT	<XP M.CPU,*@>,M.CPU


ASKNAM:	ASKSTR	<Customer name - Type 24 characters or less>
	CAILE	N,^D24		;24 OR LESS?
	RJRST	<TTYOUT <% More than 24 characters@>
		 JRST	ASKNMA>
ASKNMA:	MOVEI	N,0		;STORE 0 TO MAKE SURE ONLY 24 CHARS OUTPUT
	DPB	N,[POINT 7,ASCSTR+4,34]
	FILSTR	<DEFINE	SYSNAM
<	ASCIZ	&*&>@>
ASKDAT:	DATE	T1,		;GET TODAYS DATE
	IDIVI	T1,^D12*^D31	;YEAR + DAYS IN THIS YEAR
	ADDI	T1,^D64		;1964 IS YEAR 0
	PUSH	P,T1		;SAVE YEAR
	MOVE	T1,T2		;NO. DAYS IN CURRENT YEAR
	IDIVI	T1,^D31		;T1=MONTH-1, T2=DAY OF MONTH-1
	PUSH	P,T2		;SAVE DAYS-1 OF MONTH
	MOVEI	N,1(T1)		;MONTH (1-12)
	FILOUT	<DEFINE	SYSDAT> ;START MACRO DEFINITION IN FILE
	PUSHJ	P,FILLAB	;OUTPUT LEFT ANGLE BRACKET TO FILE, CRLF
	FILDC2	<ASCIZ &*>,N		;OUTPUT MONTH
	MOVEM	N,M.MON		;SAVE FOR SYMBOL OUTPUT TOO
	POP	P,T1		;DAYS-1 IN MONTH
	MOVEI	N,1(T1)		;DAY OF MONTH(1-31)
	FILDC2	<-*>,N		;OUTPUT TO FILE
	MOVEM	N,M.DAY		;SAVE FOR SYMBOL OUTPUT TOO
	POP	P,N		;YEAR(64-99)
	FILDC2	<-*&>,N		;OUTPUT TO FILE
	MOVEM	N,M.YEAR	;SAVE FOR SYMBOL OUTPUT TOO
	PUSHJ	P,FILRAB	;OUTPUT RIGHT ANGLE BRACKET,CRLF
	FILOUT	<XP M.MON,*@>,M.MON
	FILOUT	<XP M.DAY,*@>,M.DAY
	FILOUT	<XP M.YEAR,*@>,M.YEAR

ASKSER:	SETZB	I,CPU		;SET LOOP COUNTER TO 0

;LOOP TO ASK FOR SERIAL NUMBERS FOR ALL CPUS IN SYSTEM
ASKSLP:	ASKDEC	<CPU* serial #(1-10000)>,I ;ASK FOR CPUN
	MOVEM	N,M.C0SN(I)	;SAVE FOR CPU1 CHECK
	SOJL	I,ASKSN1	;ANY PREVIOUS CPUS ALREADY ANSWERED?

;LOOP TO SCAN ALL PREVIOUS CPU SERIAL NUMBERS TO SEE IF THE SAME
ASKSN0:	CAMN	N,M.C0SN(I)	;SAME AS PREVIOUS SERIAL NUMBER?
	RJRST	<TTYOUT	<? Cannot be same as CPU*@>,I
		 JRST	ASKSER>	;ASK ALL CPUS OVER AGAIN
	SOJGE	I,ASKSN0	;ANY MORE PREVIOUS CPUS?
ASKSN1:	MOVE	I,CPU		;CPU NUMBER

;ASK FOR DEVICES ON THIS CPU IO BUS:

	SETZ	N,		;IN CASE THIS IS A KL10 OR KS10
	SKIPN	M.KS10		;KS10 DOES NOT HAVE DK10'S
	SKIPE	M.KL10		;KL10 DOES NOT HAVE DK10'S
	JRST	ASKSN2
	ASKDEC	<# DK10's on CPU*(1,0-2)[Real time clock]>,CPU
ASKSN2:	MOVEM	N,M.RT0(I)	;STORE ANSWER FOR THIS CPU
	SKIPN	N		;THIS CPU HAVE A DK10?
	SETOM	SCPUNR		;NO, FLAG SOME CPU AS NO REAL-TIME CLOCK
	ADDM	N,M.RTX		;ACCUM. TOTAL NO. OF DK10S FOR SYSTEM
	AOS	I,CPU		;INCREMENT CPU ITERATION COUNTER
	CAMGE	I,M.CPU		;DONE FOR ALL CPUS IN THIS SYSTEM?
	JRST	ASKSLP		;NO, GO BACK AND ASK FOR ANOTHER
	FILOUT	<XP M.C0SN,*@>,M.C0SN
	FILOUT	<XP M.C1SN,*@>,M.C1SN
	FILOUT	<XP M.C2SN,*@>,M.C2SN
	FILOUT	<XP M.C3SN,*@>,M.C3SN
	FILOUT	<XP M.C4SN,*@>,M.C4SN
	FILOUT	<XP M.C5SN,*@>,M.C5SN
	FILOUT	<XP M.RT0,*@>,M.RT0
	FILOUT	<XP M.RT1,*@>,M.RT1
	FILOUT	<XP M.RT2,*@>,M.RT2
	FILOUT	<XP M.RT3,*@>,M.RT3
	FILOUT	<XP M.RT4,*@>,M.RT4
	FILOUT	<XP M.RT5,*@>,M.RT5
	FILOUT	<XP M.RTX,*@>,M.RTX
;GIVE DEFAULTS FOR ALL ACCT SWITCHES
	MOVEI	N,1
	FILOUT	<XP M.RTCO,*@>,N
	MOVEM	N,M.EMRT	;SAVE FOR LATER
	FILOUT	<XP M.EMRT,*@>,M.EMRT
	SKIPN	M.EMRT
	JRST	NOEMR1		;NO PI EXCLUSION EITHER
	MOVEM	N,M.XPI		;SAVE
	FILOUT	<XP M.XPI,*@>,M.XPI
	JRST	ASKRTC		;NOW GO ASK ABOUT DK10'S
NOEMRT:	FILOUT	<XP M.EMRT,0@>
NOEMR1:	FILOUT	<XP M.XPI,0@>
ASKRTC:	SKIPE	M.RTX		;ANY DK10'S ON SYSTEM?
	SKIPE	M.KL10		;SKIP IF NOT A KL10 SYSTEM
	JRST	OUTRTC		;NO, SKIP BUNCH OF QUESTIONS
	SKIPE	SCPUNR		;IS SOME CPU WITHOUT A DK10?
	JRST	ASKRCS		;YES, TOO BAD SKIP HIGH PREC QUESTION
	ASKYN	<High precision time accounting(Y,N)[Use DK10 clock for 
10 micro-second time accounting]>
	MOVEM	N,M.RTCA
	JUMPN	N,OUTRC1	;IF HIGH PRECISION NEED SERVICE ROUTINE
ASKRCS:	ASKYN	<DK10 software(Y,N)[Include real time clock service routine]>
OUTRC1:	MOVEM	N,M.RTC		;NON-ZERO IF NEED RTC CLOCK SERVICE
OUTRTC:	FILOUT	<XP M.RTCA,*@>,M.RTCA
	FILOUT	<XP M.RTC,*@>,M.RTC
;	ASKYN	<Account verification(Y,N)[LOGIN and the batch system will
;verify that the user has specified a valid account]>
	SETZ	N,		;***NO ACCOUNT VERIFICATION
	FILOUT	<XP M.ACV,*@>,N
	MOVEI	N,0		;ASSUME NO MOS MEMORY SUPPORT
	SKIPE	M.KL10	;A KL10?
	SKIPE	M.1080	;YES, BUT NOT 1080'S
	JRST	MOSEND		;NO, CAN'T HAVE RECONFIGURABLE MOS
	ASKYN	<MOS memory(Y,N)[Include support for the user mode MOS memory diagnostic THGA
which collects statistics on single bit memory errors and substitutes the spare
bit when a single bit error is determined to be hard]>
MOSEND:	FILOUT	<XP M.MOS,*@>,N	;OUTPUT THE ANSWER
	ADDM	N,MOS		;***SAVE MOS FLAG FOR LATER
	SETOM	CPUN
ASKDFS:	SKIPE	M.KS10		;KS10 SYSTEM?
	JRST	ASKKSI		;YES--GO ASK ABOUT KS10 IO
	AOSN	N,CPUN
	SETOM	MKON		;MAGTAPE CONTROLLER NUMBER
	SKIPGE	MKON
	SETOM	MKONP
	CAML	N,M.CPU
	JRST	CHNEND
	SKIPE	M.1091		;IS THIS A 1091
	JRST	NODFS		;IF YES, DON'T AS FOR DF'S
	ASKYN	<DO YOU HAVE ANY DF10's, DF10C's, OR DX10's ON CPU*(Y,N)>
	MOVEM	N,DFS		;SAVE FOR LATER
	JUMPE	N,NODFS		;ONLY RH20 DIALOGUE NEEDED
	MOVE	N,CPUN	;SETUP FOR CPU #
	ASKDEC	<HOW MANY DF10s, DF10Cs, DX10s AND/OR RH20s ARE ON CPU*(2,0-?)>
	JRST	HERE		;GO DO NORMAL DIALOGUE
NODFS:	MOVE	N,CPUN	;GET CORRECT CPU NUMBER
	ASKDEC	<HOW MANY RH20'S UNDER TEST FOR CPU*(1,0-8)>
HERE:	SKIPN	CPUN		;IS THIS CPU0?
	JRST	.+3		;YES. GO CHECK FOR DUMMY TAPES
	SETZM	DMYTAP		;NO. CLEAR DUMMY TAPE FLAG, NOT NEEDED
				;FOR CPU1 ETC.
	JRST	NOTAPS		;CONTINUE WITH NORMAL DIALOGUE
	CAIE	N,1		;WAS ONLY ONE CHNL SELECTED?
	JRST	.+3		;NO, GO ASK FOR TAPES
	SETOM	DMYTAP		;YES, SET DUMMY TAPE FLAG
	AOJA	N,NOTAPS	;ADD ONE FOR DUMMY TAPE UNIT
				;AND CONTINUE NORMAL DIALOGUE
	MOVEM	N,M.CHN
	ASKYN	<DO YOU HAVE ANY TAPE UNITS ON THE SYSTEM?(Y,N)>
	JUMPE	N,.+3		;ARE THERE TAPE UNITS ON THE SYSTEM?
	MOVE	N,M.CHN		;YES. SAVE NUMBER OF CHANNELS
	JRST	NOTAPS		;AND GO TO NORMAL DIALOGUE
	AOS	N		;NO. ADJUST COUNT
	SETOM	DMYTAP		;AND SET DUMMY TAPE FLAG
	ADD	N,M.CHN		;UPDATE CHANNEL COUNT
NOTAPS:	FILCPU	<XP M.CHN,*@>,N
	JUMPE	N,NOCHNS
	MOVEM	N,M.CHN		;SAVE FOR CHANNEL LOOP
	SETZM	CCHN
	TRO	F,F.KONS	;INDICATE 1ST OF EVERYTHING
;LOOP ONCE FOR EACH CHANNEL
CHNLOP:	MOVEI	N,3		;ASSUME 1091, ONLY RH20'S
	SKIPN	DFS		;RH20 ONLY?
	JRST	CHNLP1		;YES, ONLY RH20'S
	MOVE	N,CHN		;CHANNEL ITERATION COUNTER(0,1,...)
	ASKLST	<Channel * Type (DF10,DF10C,DX10,RH20)>
CHNLP1:	CAILE	N,3		;ADJUST FOR GAP IN NUMBERS CAUSED BY
	ADDI	N,1		;RH11 CHN TYPE (SEE ASKKSI)
	MOVEM	N,CHNTYP
	FILOUT	<XP M.CH*T,>,CHN;OUTPUT CHANNEL TYPE
	FILOUT	<*@>,CHNTYP	;AND COMPLETE OUTPUT
	FILOUT	<XP M.*RH,0@>,CHN ;NO RH11'S IF WE'RE HERE
	FILCPU	<XP M.*RH,0@>,CHN ;...DITTO
	MOVE	N,CHN
	BTHOUT	<On channel # *:@>,CHN
	MOVE	N,CHNTYP	;TYPE OF CHANNEL
	CAIN	N,2		;DX10?
	JRST	DXLOOP		;YES, ASK ABOUT DX10, TX01, TU70'S
	MOVEI	RH12,0		;NO, ASSUME SOME FLAVOR FO RH10/DF10
	CAIN	N,3		;IS IT AN RH20?
	MOVEI	RH12,1		;YES
	ADDM	RH12,M.RH20	;COUNT NO OF RH20S
	ADDM	RH12,RH20CP	;COUNT RH20S ON THIS CPU
	FILOUT	<XP M.*TX,0@>,CHN ;NO TX01S ON THIS CHL
	FILCPU	<XP M.*TX,0@>,CHN ;NO TX01S ON THIS CPU
	SKIPE	N,RH12		;IF AN RH20,
	SOJA	N,NORD10	; THERE AREN'T ANY RD10S
IFN FTUNSUPPORTED,<
	ASKDEC	<  # RC10s(0-2)[Controllers for RD10 Burroughs disks and
RM10B Bryant drums on channel *]>,CHN
>
IFE FTUNSUPPORTED,<
	MOVEI	N,0		;NO RD10'S
>
NORD10:	MOVE	I,N		;SET UP ITERATION FOR THIS CONTROLLER
	FILOUT	<XP M.*FH,>,CHN ;FIRST PART OF CALL
	FILOUT	<*@>,I		;SECOND HALF
	MOVE	N,M.RC10
	TRZE	F,F.1FH		;IF 1ST KONTROLLER ON CPU
	MOVEM	N,FHCPUN	; SAVE NO ON PREVIOUS CPUS
	JUMPE	I,FHEND		;ANY CONTROLLERS AT ALL?

;LOOP FOR FH* ON THIS CHANNEL:
FHLOOP:	FILOUT	<XP M.FH*P,>,M.RC10 ;YES, DEFINE NO OF FHS ON PREVIOUS CPUS
	FILOUT	<*@>,FHCPUN
	FILOUT	<XP FH*CPU,>,M.RC10
	FILOUT	<*@>,CPUN
	AOS	N,M.RC10	;INCREMENT NO. OF RC10 IN SYSTEM
	ADDI	N,'A'-1		;MAKE SIXBIT LETTER
	ROT	N,-6		;LEFT JUSTIFIED
	ASKDEC	<  # Units on FH*(1-4)>,N
	PUSH	P,N		;SAVE NO. OF FH* UNIT ON THIS CONTROLLER
	MOVE	N,M.RC10	;MAKE SIXBIT CONTROLLER LETTER AGAIN
	ADDI	N,'A'-1
	ROT	N,-6
	FILOUT	<XP M.FH*,>,N	;FIRST HALF
	POP	P,N		;RESTORE NO OF FH* UNITS ON THIS CONTROLLER
	FILOUT	<*@>,N
	SOJG	I,FHLOOP
FHEND:	SKIPE	N,RH12		;IF AN RH20,
	SOJA	N,NORS04	; THERE AREN'T ANY RS04S
	SETOM	NUM		;SETUP TO CHECK IN[UT ON THIS CHANNEL
	ASKDEC	<  # RH10S for RS04'S(0-3)[Controllers for RS04 swapping
disks on channel *]>,CHN
NORS04:	MOVE	I,N
	FILOUT	<XP M.*FS,>,CHN
	FILOUT	<*@>,I
	TRNE	F,F.1FS		;1ST KONTROLLER ON CPU?
	SETZM	RSCPUN		;YES, CLEAR TOTAL RS04S ON CPU
	JUMPE	I,FSEND
;LOOP FOR FS* ON THIS CHANNEL:
FSLOOP:	FILOUT	<XP M.FS*F,>,M.RH1S
	SETZM	NUM		;CLEAR NUM - INPUT MADE ON THIS CHANNEL
	MOVEI	N,1
	TRZE	F,F.1FS		;IF 1ST KONTROLLER
	SETZ	N,		;SET FS*F=0
	FILOUT	<*@>,N
	FILOUT	<XP FS*CPU,>,M.RH1S
	FILOUT	<*@>,CPUN
	AOS	N,M.RH1S	;INCREMENT NO. OF RH10 IN SYSTEM
	AOS	RSCPUN
	ADDI	N,'A'-1		;MAKE SIXBIT LETTER
	ROT	N,-6		;LEFT JUSTIFIED
	ASKDEC	<  # Units on FS*(1-8)>,N
	PUSH	P,N		;SAVE NO. OF FS* UNIT ON THIS CONTROLLER
	MOVE	N,M.RH1S	;MAKE SIXBIT CONTROLLER LETTER AGAIN
	ADDI	N,'A'-1
	ROT	N,-6
	FILOUT	<XP M.FS*,>,N	;FIRST HALF
	POP	P,N		;RESTORE NO. OF FS* UNITS ON THIS CONTROLLER
	FILCPU	<*@>,N
	SOJG	I,FSLOOP
FSEND:	JUMPN	RH12,ASKRP2
	SKIPN	N,NUM		;HAS INPUT BEEN MADE ON THIS CHANNEL?
	JRST	ASKRP3		;YES, DON'T ASK NEXT QUESTION
	ASKDEC	<  # RH10S for RP04'S,RP06'S(0-3)[Controllers for RP04,RP06
disk pack units on channel *]>,CHN
	JRST	ASKRP3
ASKRP2:	SETOM	NUM
	ASKDEC	<  # RH20S for RP04'S,RP06'S(0-1)[Controllers for RP04,RP06
disk pack units on channel *]>,CHN
ASKRP3:	MOVE	I,N
	FILOUT	<XP M.*RP,>,CHN
	FILOUT	<*@>,I
	MOVE	N,M.RHP4
	TRNE	F,F.1RP
	MOVEM	N,RPCPUN		;RHP'S ON PREVIOUS CPU'S
	JUMPE	I,RPEND

;LOOP FOR RP* ON THIS CHANNEL
RPLOOP:	FILOUT	<XP M.P*F,>,M.RHP4
	SETZM	NUM
	MOVEI	N,1
	TRZE	F,F.1RP
	SETZ	N,
	FILOUT	<*@>,N
	FILOUT	<XP RP*CPU,>,M.RHP4
	FILOUT	<*@>,CPUN
	AOS	M.RH1P(RH12)		;INCR COUNT OF RH10S OR RH20S
	AOS	N,M.RHP4
	ADDI	N,'A'-1
	ROT	N,-6
	PUSH	P,N
	ASKDEC	<  # Units on RP*(1-8)>,N
	EXCH	N,(P)
	FILOUT	<XP M.RP*,>,N
	POP	P,N
	FILOUT	<*@>,N
	MOVE	I2,M.RHP4
	SUBI	I2,1
	FILOUT	<XP M.P*T,>,I2		;INDICATE TYPE
	SKIPE	N,RH12
	MOVE	N,rh20cp		;0 FOR RH10, CONTROL NUMBER FOR RH20
	FILOUT	<*@>,N
	MOVE	N,M.RHP4
	SUBI	N,1
	FILOUT	<XP M.RS*P,>,N	;NO OF RS04S PREVIOUS ON THIS CPU
	FILOUT	<*@>,RSCPUN
	SOJG	I,RPLOOP
RPEND:	SKIPN	N,RH12		;RH20?
	JRST	ASKRN1		;NO, NO RP20'S POSSIBLE
	SKIPN	N,NUM		;IS THERE A DEVICE ON THIS CRH20
	JRST	ASKRN1		;NO GO FILL IN 0,s
	ASKDEC	<  # RH20S for RP20'S(0-1)[Controllers for RP20
disk units on channel *.]>,CHN
ASKRN1:	MOVE	I2,N		;SAVE VALUE IN I2
	MOVE	N,M.RP20	;GET NUMBER OF RP20 "KONTROLLERS"
	TRZE	F,F.1RN		;FIRST ON THIS CPU?
	MOVEM	N,RNCPUN	;RP20'S ON PREVIOUS CPU'S
	JUMPE	I2,ASKRN2	;GO IF NO RP20'S
	SETZM	NUM		;IF HERE MUST HAVE SELECTED RP20
	ASKYN	<    Dual ported?(Y,N)[Does this RP20 controller
dual-port the drives on another RP20 controller?]>
	MOVNI	I,1(N)		;MAKE IT -VE
	HRLZS	I		;MAKE IT AN AOBJN POINTER
	ADDI	I2,(N)		;BUMP # OF KONTROLLERS IF DUAL-PORTED
ASKRN2:	FILOUT	<XP M.*RN,>,CHN ;OUTPUT NUMBER OF "KONTROLLERS" ON THIS
	FILOUT	<*@>,I2		;  CHANNEL
	JUMPE	I2,RNEND
	PUSH	P,I2		;SAVE 0 ON STACK IF THIS KDB IS
	SOS	0(P)		;  NOT DUAL PORTED, 1 IF IT IS

;LOOP FOR RN* ON THIS CHANNEL
RNLOOP:	FILOUT	<XP RN*CPU,>,M.RP20
	FILOUT	<*@>,CPUN
	AOS	N,M.RP20
	ADDI	N,'A'-1
	ROT	N,-6
	PUSH	P,N
	ASKDEC	<  # Units on RN*(1-8)>,N
	EXCH	N,(P)
	FILOUT	<XP M.RN*,>,N
	POP	P,N
	FILOUT	<*@>,N
	MOVE	I2,M.RP20
	SUBI	I2,1
	FILOUT	<XP M.N*D,>,I2	;M.N?D := 0 IF THIS KDB IS NOT
	MOVE	N,0(P)		;  DUAL PORTED, 1 IF
	FILOUT	<*@>,N		;  IT IS
	FILOUT	<XP M.N*A,>,I2	;M.N?A := 0 IF THIS KDB IS FIRST OF
	MOVEI	N,(I)		;  TWO DUAL PORTED KDB'S, 1 IF IT
	FILOUT	<*@>,N		;  IS THE SECOND
	FILOUT	<XP M.N*T,>,I2	;INDICATE TYPE
	MOVE	N,RH20CP	;CONTROL NUMBER FOR RH20
	FILOUT	<*@>,N
	AOBJN	I,RNLOOP
	POP	P,(P)		;BRING STACK INTO PHASE
RNEND:	SKIPE	N,RH12
	SOJA	N,NORP10		;NO RP10S IF RH20

	;REMOVE RP10 DIALOGUE - ASSUME NO MORE RP10'S IN MFG.

NORP10:	MOVE	I,N		;SETUP ITERATION COUNT FOR RP FOR THIS CHANNEL
	FILOUT	<XP M.*DP,>,CHN	;OUTPUT FIRST HALF
	FILOUT	<*@>,I		;NO. OF CONTROLLERS ON THIS CHANNEL
	MOVE	N,M.RP10
	TRZE	F,F.1DP
	MOVEM	N,DPCPUN
	JUMPE	I,DPEND		;ANY RP10S AT ALL ON THIS CHANNEL?

;LOOP FOR RP10S ON THIS CHANNEL
DPLOOP:	FILOUT	<XP M.DP*P,>,M.RP10	;NO OF RP10S ON PREVIOUS CPUS
	FILOUT	<*@>,DPCPUN
	FILOUT	<XP DP*CPU,>,M.RP10
	FILOUT	<*@>,CPUN
	AOS	N,M.RP10	;INCREMENT NO. OF RP10S ON SYSTEM
	ADDI	N,'A'-1		;FORM CONTROLER LETTER
	ROT	N,-6
	ASKDEC	<  # Units on DP*(1-8)>,N
	PUSH	P,N		;SAVE NO. UNITS ON THIS CONTROLLER
	MOVE	N,M.RP10	;NO. OF RP10S SO FAR
	ADDI	N,'A'-1		;FORM CONTROLER LETTER
	ROT	N,-6		;LEFT JUSTIFY
	FILOUT	<XP M.DP*,>,N
	POP	P,N		;RESTORE NO. UNITS ON THIS CONTROLLER
	FILOUT	<*@>,N		;AND OUTPUT
	SOJG	I,DPLOOP	;ANY MORE RP CONTROLLERS ON THIS CHANNEL?
DPEND:	SKIPE	N,RH12
	SOJA	N,NOT1B		;NO TM10B IF RH20

	;TAKE OUT TM10B DIALOGUE - ASSUME NO MORE TM10B'S IN MFG

NOT1B:	MOVE	I,N		;SET UP ITERATION COUNTER
	FILOUT	<XP M.*TB,>,CHN	;FIRST PART OF CALL
	FILOUT	<*@>,I		;SECOND PART
	MOVE	N,M.TM10	;TOTAL NO OF TM10S SO FAR
	TRZE	F,F.1T1		;IF THIS IS THE 1ST TM10 ON CPU
	MOVEM	N,T1CPUN	;SAVE AS NO OF TM10S ON PREVIOUS CPUS
	JUMPE	I,TBEND		;ANY TM10B'S AT ALL?
;LOOP FOR TB* ON THIS CHANNEL
TBLOOP:	AOS	M.TM10		;COUNT OF TM10'S ON SYSTEM
	AOS	N,MKON		;CONTROLLER #
	FILOUT	<XP M.MT*T,1@>,N ;MARK AS TM10B
	FILOUT	<XP M.T1*P,>,N
	FILOUT	<*@>,T1CPUN
	PUSHJ	P,TAPSUB	;DO TAPE CONTROLLER SUBR
	SOJG	I,TBLOOP
TBEND:	SKIPN	N,RH12		;IF NOT AN RH20,
	JRST	NODX20		;CAN'T HAVE ANY DX20'S
	SKIPN	N,NUM		;HAS A DEVICE BEEN SELECTED
	JRST	NODX20		;YES, FILL IN 0
	ASKDEC	<  # RH20's for DX20's (0-1)[Mass-bus tape controller for
DX20's on channel *]>,CHN
NODX20:	MOVE	I,N		;SAVE COUNT
	FILOUT	<XP M.*D2,>,CHN ;OUTPUT FIRST PART
	FILOUT	<*@>,I		;PLUS NUMBER OF RH20/DX20'S ON THIS CHN
	TRZE	F,F.1D2		;1ST DX20 ON THIS CPU?
	SETZM	D2RH20		;YES, CLEAR COUNT
	JUMPE	I,D2END		;GO IF NONE
	AOS	I2,MKON		;BUMP CONTROLLER NUMBER
	FILOUT	<XP M.D2*T,>,I2	;MAKE M.D2?T BE THE RH20 NUMBER
	SOSN	I2,RH20CP	;IF ON 1ST RH20 ON CPU,
	MOVEI	I2,10		;MAKE IT 10
	AOS	RH20CP		;BACK TO WHERE IT STARTED
	FILOUT	<*@>,I2		;RH20 NUMBER FOR THIS CONTROLLER
	FILOUT	<XP M.MT*T,6@>,MKON ;CONTROLLER TYPE IS RH20/DX20/TX02
	FILOUT	<XP M.MT*C,>,MKON ;OUTPUT FIRST PART
	FILOUT	<*@>,CHN	 ;  PLUS CHN # FOR THIS CONTROLLER
	FILOUT	<XP M.MT*P,>,MKON ;OUTPUT FIRST PART
	FILOUT	<*@>,CPUN	;PLUS CPU NUMBER CONTROLLER IS ON
	AOS	M.DX20		;BUMP COUNT OF DX20 "KONTROLLERS"

	MOVEI	N,1		;WE ONLY OFFICIALLY SUPPORT 1 DX20/RH20
	JRST	ONEDX2		;SO SKIP THE QUESTION FOR NOW

	MOVE	N,RH20CP	;GET NUMBER OF RH20'S
	SUBI	N,1		;MAKE IT THE RH20 NUMBER
	ASKDEC	<  # DX20's on RH20 * (1-8)[Programmed Device Adapters
driving up to 8 TU7x tape drives through a TX02 Tape Control Unit]>,N
ONEDX2:	MOVE	I2,N		;SAVE COUNT OF DX20'S ON THIS RH20
	FILOUT	<XP M.MT*U,>,MKON ;OUTPUT FIRST PART
	FILOUT	<*@>,I2		;PLUS NUMBER
	SETZB	I,I3		;I=DX20 NUMBER,I3=TOTAL DRIVES ON THIS KON
D2LOOP:	MOVE	N,D2RH20	;GET DX20 NUMBER
	SETZM	NUM		;IF HERE MUST HAVE SELECTED DX20
	ASKDEC	<  # Units on DX20 * (1-8)>,N
	ADD	I3,N		;ACCUMULATE TOTAL COUNT
	PUSH	P,N		;SAVE THE NUMBER
	FILOUT	<XP M.MT*>,MKON	;OUTPUT M.MTXY, WHERE X=KON NUMBER,
	MOVE	T2,MKON		;***GET X FOR INDEX TO TAPE TABLE
	IMULI	T2,2		;***ADJUST POINTER INTO EVEN TABLE POSITION
	SETOM	TPTAB(T2)	;***MARK TAPE TABLE ENTRY
	FILOUT	<*>,I		;  Y=DX20 NUMBER,
	POP	P,N		;  AND VALUE IS NUMBER OF DRIVES
	FILOUT	<,*@>,N		;OUTPUT VALUE
	MOVEI	T2,1		;***SETUP INDEX INTO TPTAB+1
	SKIPE	TPTAB(T2)	;***ENTRY IN TABLE?
	AOJA	T2,.-1		;***YES, BUMP INDEX AND CHECK NEXT
	MOVEM	N,TPTAB(T2)	;***MOVE NUMBER OF TAPES ON THIS CNTRL TO TPTAB
	AOS	D2RH20		;BUMP COUNT OF DX20'S ON THIS CPU
	ADDI	I,1		;BUMP DX20 NUMBER
	SOJG	I2,D2LOOP	;LOOP FOR ALL DX20'S
	FILOUT	<XP M.MT*,>,MKON;OUTPUT TOTAL NUMBER OF DRIVES ON
	FILOUT	<*@>,I3		;  THIS CONTROLLER
D2END:	JUMPN	RH12,ASKT22
	SKIPN	N,NUM		;HAVE WE INPUT DEVICE ON THIS CHANNEL
	JRST	ASKT23		;YES DON'T ASK NEXT QUESTION
	ASKDEC	<  # RH10's for TM02'S (0-2)[Mass-Bus tape controller for
TU16's and TU45's on channel *]>,CHN
	JRST	ASKT23
ASKT22:	SKIPN	N,NUM		;HAVE WE SELECTED A DEVICE
	JRST	ASKT23		;YES FILL IN 0
	SETOM	NUM		;
	ASKDEC	<  # RH20's for TM03'S (0-1)[Mass-Bus tape controller for
TU16's and TU45's on channel *]>,CHN
ASKT23:	MOVE	I,N		;CHAN
	FILOUT	<XP M.*T2,>,CHN
	FILOUT	<*@>,I		;OUTPUT NUMBER OF RH'S
	TRZe	F,F.1T2		;1ST TMO2 ON CPU?
	SETZM	T2RH10
ASKT2X:	JUMPE	I,T2END		;GO IF NONE
	SETZM	NUM		;*********
	MOVEI	N,-1(I)		;BUMP NUMBER OF "EXTRA" TAPE KONTROLLERS
	ADDM	N,TAPOFS
	MOVE	I2,MKON		;MAKE M.T2?T = 0 IF RH10
	ADDI	I2,1		; OR = RH20 # IF AN RH20
	FILOUT	<XP M.T2*T,>,I2
	JUMPN	RH12,ASKT2Y
	MOVE	I2,M.RH1S	;NO OF RS04S
	ADD	I2,M.RH1P	;+RH10/RP04S
	ADD	I2,T2RH10	;+RH10/TM02S
	SUB	I2,T2RH1P	;-NO OF RH10S ON PREVIOUS CPUS
	aos	t2rh10
	FILOUT	<-*@>,I2
	JRST	T2LOOP
ASKT2Y:	SOSN	I2,RH20CP	;IF ON 1ST RH20 ON CPU,
	MOVEI	I2,10		; MAKE IT 10
	AOS	RH20CP
	FILOUT	<*@>,I2
T2LOOP:	AOS	M.T210
	AOS	N,MKON
	FILOUT	<XP M.MT*T,4@>,N
	FILOUT	<XP M.MT*C,>,MKON
	FILOUT	<*@>,CHN
	FILOUT	<XP M.MT*N,>,MKON
	FILOUT	<*@>,I
	FILOUT	<XP M.MT*P,>,MKON ;OUTPUT CPU NUMBER
	FILOUT	<*@>,CPUN
	MOVE	N,M.T210
	SUBI	N,1
	JUMPN	RH12,T2LP1
	ASKDEC	<  How many TM02's on RH10 # * (1-8)[EACH UNIT CAN CONTROL
UP TO 8 SUB-UNITS = TAPE DRIVES]>,N
	JRST	T2LP2
T2LP1:	ASKDEC	<  How many TM03's on RH20 # * (1-8)[EACH UNIT CAN CONTROL
UP TO 8 SUB-UNITS = TAPE DRIVES]>,N
T2LP2:	MOVE	I2,N
	FILOUT	<XP M.MT*U,>,MKON
	FILOUT	<*@>,I2
	PUSH	P,I
	SETZB	I,I3
T2LP3:	ASKDEC	<How many drives on TM03 * (1-8)>,I
	ADD	I3,N
	PUSH	P,N
	FILOUT	<XP M.MT*>,MKON
	MOVE	T2,MKON		;***GET X FOR INDEX TO TAPE TABLE
	IMULI	T2,2		;***ADJUST POINTER INTO EVEN TABLE POSITION
	SETOM	TPTAB(T2)	;***MARK TAPE TABLE ENTRY
	FILOUT	<*>,I
	MOVE	N,(P)
	FILOUT	<,*@>,N
	MOVEI	T2,1		;***SETUP INDEX INTO TPTAB+1
	SKIPE	TPTAB(T2)	;***ENTRY IN TABLE?
	AOJA	T2,.-1		;***YES, BUMP INDEX AND CHECK NEXT
	MOVEM	N,TPTAB(T2)	;***MOVE NUMBER OF TAPES ON THIS CNTRL TO TPTAB
	POP	P,N
	ADDI	I,1
	SOJG	I2,T2LP3
	POP	P,I
	FILOUT	<XP M.MT*,>,MKON
	FILOUT	<*@>,I3
	SOJG	I,T2LOOP
T2END::	SKIPN	N,NUM		;*****
	JRST	NOTT78		;****
	SKIPN	N,RH12
	JRST	NOTT78
	ASKDEC	<  # RH20's for TM78'S (0-1)[Mass-Bus tape controller for
TU78's on channel *]>,CHN

NOTT78:	MOVE	I,N		;CHAN
	FILOUT	<XP M.*T7,>,CHN
	FILOUT	<*@>,I		;OUTPUT NUMBER OF RH'S
	JUMPE	I,DXEND		;GO IF NONE
	MOVEI	N,-1(I)		;BUMP NUMBER OF "EXTRA" TAPE KONTROLLERS
	ADDM	N,TAPOFS
	MOVE	I2,MKON		;MAKE M.T7?T = RH20 NUMBER
	ADDI	I2,1
	FILOUT	<XP M.T7*T,>,I2
	SOSN	I2,RH20CP	;IF ON 1ST RH20 ON CPU,
	MOVEI	I2,10		; MAKE IT 10
	AOS	RH20CP
	FILOUT	<*@>,I2
T7LOOP:	AOS	M.T78
	AOS	N,MKON
	FILOUT	<XP M.MT*T,7@>,N
	FILOUT	<XP M.MT*C,>,MKON
	FILOUT	<*@>,CHN
	FILOUT	<XP M.MT*N,>,MKON
	FILOUT	<*@>,I
	FILOUT	<XP M.MT*P,>,MKON ;OUTPUT CPU NUMBER
	FILOUT	<*@>,CPUN
	MOVE	N,M.T78
	SUBI	N,1
	ASKDEC	<  How many TM78's on RH20 # * (1-8)[EACH UNIT CAN CONTROL
UP TO 8 SUB-UNITS = TAPE DRIVES]>,N
T7LP2:	MOVE	I2,N
	FILOUT	<XP M.MT*U,>,MKON
	FILOUT	<*@>,I2
	PUSH	P,I
	SETZB	I,I3
T7LP3:	ASKDEC	<How many drives on TM78 * (1-4)>,I
	ADD	I3,N
	PUSH	P,N
	FILOUT	<XP M.MT*>,MKON
	MOVE	T2,MKON		;***GET X FOR INDEX TO TAPE TABLE
	IMULI	T2,2		;***ADJUST POINTER INTO EVEN TABLE POSITION
	SETOM	TPTAB(T2)	;***MARK TAPE TABLE ENTRY
	FILOUT	<*>,I
	MOVE	N,(P)
	FILOUT	<,*@>,N
	MOVEI	T2,1		;***SETUP INDEX INTO TPTAB+1
	SKIPE	TPTAB(T2)	;***ENTRY IN TABLE?
	AOJA	T2,.-1		;***YES, BUMP INDEX AND CHECK NEXT
	MOVEM	N,TPTAB(T2)	;***MOVE NUMBER OF TAPES ON THIS CNTRL TO TPTAB
	POP	P,N
	ADDI	I,1
	SOJG	I2,T7LP3
	POP	P,I
	FILOUT	<XP M.MT*,>,MKON
	FILOUT	<*@>,I3
	SOJG	I,T7LOOP
T7END:	JRST	DXEND
;ROUTINE TO ASK FOR # OF UNITS ON EACH KONTROLLER

TAPSUB:	FILOUT	<XP M.MT*C,>,MKON ;CHL NUMBER
	FILOUT	<*@>,CHN
TAPSB0:	FILOUT	<XP M.MT*P,>,MKON
	FILOUT	<*@>,CPUN

	MOVE	N,MKON		;GET KONROLLER #
	ADD	N,TAPOFS	;PLUS EXTRA LETTERS FOR TM02 UNITS
	ADDI	N,'A'		;MAKE INTO SIXBITCH
	ROT	N,-6
	ASKDEC	<  # Units on MT*(1-8)>,N
	PUSH	P,N		;SAVE ANSWER
	FILOUT	<XP M.MT*,>,MKON ;NUMBER OF UNITS
	MOVE	N,(P)
	FILOUT	<*@>,N		;ON EACH KONTROLLER
	POP	P,N
	POPJ	P,		;RETURN
DXLOOP:	ASKDEC	<  # Controllers(0-1)[TX01's or TX02's for TU70 Tape Drives on channel *]>,CHN
	MOVE	I,N
	FILOUT	<XP M.*FH,0@>,CHN ;NO FH,DP,FS,TB,TC
	FILOUT	<XP M.*DP,0@>,CHN
	FILOUT	<XP M.*RP,0@>,CHN
	FILOUT	<XP M.*RN,0@>,CHN
	FILOUT	<XP M.*FS,0@>,CHN
	FILOUT	<XP M.*TB,0@>,CHN
	FILOUT	<XP M.*TC,0@>,CHN
	FILOUT	<XP M.*T2,0@>,CHN
	FILOUT	<XP M.*D2,0@>,CHN
	FILOUT	<XP M.*TX,>,CHN ;OUTPUT FIRST PART OF CALL
	FILOUT	<*@>,I		;SECOND PART
	MOVE	N,M.TX01
	TRZE	F,F.1TX
	MOVEM	N,TXCPUN	;NO OF TX10S ON PREVIOUS CPUS
	JUMPE	I,DXEND

TXLOOP:	AOS	M.TX01		;INCREMENT NUMBER OF TX01'S ON SYSTEM
	AOS	N,MKON		;INCR KONTROLLER ID
	FILOUT	<XP M.MT*T,3@>,N ;MARK AS TX01
	FILOUT	<XP M.TX*P,>,N
	FILOUT	<*@>,TXCPUN
	PUSHJ	P,TAPSUB	;ASK FOR UNITS
	SOJG	I,TXLOOP

DXEND:	SKIPN	DMYTAP		;ARE THERE ANY TAPES ON SYSTEM
	JRST	.+8		;YES GO DO NORMAL CHNLOP
	MOVE	N,M.CHN		;NO. GET NUMBER OF CHANNELS
	AOS	CCHN
	AOS	CHN
	SUB	N,CCHN		;SUBTRACT NUMBER OF CHNLS COMPLETED
	CAIE	N,1		;ARE WE ON LAST CHANNEL?
	JRST	.+4		;NO CONTINUE AS NORMAL
	JRST	DUMYTP		;YES. GO INSTALL DUMMY TAPE UNIT
	AOS	N,CCHN		;INCREMENT CHANNEL LOOP COUNTER
	AOS	CHN
	CAMGE	N,M.CHN		;FINISHED WITH ALL CHANNELS?
	JRST	CHNLOP		;NO, ASK FOR CONTRLLERS ON THIS CHANNEL
	JRST	TAEND

;HERE TO INSTALL DUMMY TAPE UNIT FOR TAPELESS SYSTEMS

DUMYTP:	MOVEI	N,3		;ASSUME 1091, ONLY RH20'S
	MOVEM	N,CHNTYP
	FILOUT	<XP M.CH*T,>,CHN;OUTPUT CHANNEL TYPE
	FILOUT	<*@>,CHNTYP	;AND COMPLETE OUTPUT
	FILOUT	<XP M.*RH,0@>,CHN ;NO RH11'S IF WE'RE HERE
	FILCPU	<XP M.*RH,0@>,CHN ;...DITTO
	MOVEI	RH12,1		;YES
	ADDM	RH12,M.RH20	;COUNT NO OF RH20S
	ADDM	RH12,RH20CP	;COUNT RH20S ON THIS CPU
	FILOUT	<XP M.*TX,0@>,CHN ;NO TX01S ON THIS CHL
	FILCPU	<XP M.*TX,0@>,CHN ;NO TX01S ON THIS CPU
	SKIPE	N,RH12		;IF AN RH20,
	SOJ	N,		;***
	MOVE	I,N		;SET UP ITERATION FOR THIS CONTROLLER
	FILOUT	<XP M.*FH,>,CHN ;FIRST PART OF CALL
	FILOUT	<*@>,I		;SECOND HALF
	MOVE	N,M.RC10
	TRZE	F,F.1FH		;IF 1ST KONTROLLER ON CPU
	MOVEM	N,FHCPUN	; SAVE NO ON PREVIOUS CPUS
	FILOUT	<XP M.*FS,>,CHN
	FILOUT	<*@>,I
	TRNE	F,F.1FS		;1ST KONTROLLER ON CPU?
	SETZM	RSCPUN		;YES, CLEAR TOTAL RS04S ON CPU
	FILOUT	<XP M.*RP,>,CHN
	FILOUT	<*@>,I
	MOVE	I2,N		;SAVE VALUE IN I2
	FILOUT	<XP M.*RN,>,CHN ;OUTPUT NUMBER OF "KONTROLLERS" ON THIS
	FILOUT	<*@>,I2		;  CHANNEL
	FILOUT	<XP M.*DP,>,CHN	;OUTPUT FIRST HALF
	FILOUT	<*@>,I		;NO. OF CONTROLLERS ON THIS CHANNEL
	FILOUT	<XP M.*TB,>,CHN	;FIRST PART OF CALL
	FILOUT	<*@>,I		;SECOND PART
	MOVE	N,M.TM10	;TOTAL NO OF TM10S SO FAR
	TRZE	F,F.1T1		;IF THIS IS THE 1ST TM10 ON CPU
	MOVEM	N,T1CPUN	;SAVE AS NO OF TM10S ON PREVIOUS CPUS
	FILOUT	<XP M.*D2,>,CHN ;OUTPUT FIRST PART
	FILOUT	<*@>,I		;PLUS NUMBER OF RH20/DX20'S ON THIS CHN
	TRZE	F,F.1D2		;1ST DX20 ON THIS CPU?
	SETZM	D2RH20		;YES, CLEAR COUNT
	MOVEI	N,1		;***
	MOVE	I,N		;CHAN
	FILOUT	<XP M.*T2,>,CHN
	FILOUT	<*@>,I		;OUTPUT NUMBER OF RH'S
	TRZe	F,F.1T2		;1ST TMO2 ON CPU?
	SETZM	T2RH10
	MOVEI	N,-1(I)		;BUMP NUMBER OF "EXTRA" TAPE KONTROLLERS
	ADDM	N,TAPOFS
	MOVE	I2,MKON		;MAKE M.T2?T = 0 IF RH10
	ADDI	I2,1		; OR = RH20 # IF AN RH20
	FILOUT	<XP M.T2*T,>,I2
	JUMPN	RH12,DMYTP1	;***
	MOVE	I2,M.RH1S	;NO OF RS04S
	ADD	I2,M.RH1P	;+RH10/RP04S
	ADD	I2,T2RH10	;+RH10/TM02S
	SUB	I2,T2RH1P	;-NO OF RH10S ON PREVIOUS CPUS
	aos	t2rh10
	FILOUT	<-*@>,I2
	JRST	DMYLP		;***
DMYTP1:	SOSN	I2,RH20CP	;IF ON 1ST RH20 ON CPU,
	MOVEI	I2,10		; MAKE IT 10
	AOS	RH20CP
	FILOUT	<*@>,I2
DMYLP:	AOS	M.T210
	AOS	N,MKON
	FILOUT	<XP M.MT*T,4@>,N
	FILOUT	<XP M.MT*C,>,MKON
	FILOUT	<*@>,CHN
	FILOUT	<XP M.MT*N,>,MKON
	FILOUT	<*@>,I
	FILOUT	<XP M.MT*P,>,MKON ;OUTPUT CPU NUMBER
	FILOUT	<*@>,CPUN
	MOVE	N,M.T210
	SUBI	N,1
	MOVEI	N,1		;***
	MOVE	I2,N
	FILOUT	<XP M.MT*U,>,MKON
	FILOUT	<*@>,I2
	PUSH	P,I
	SETZB	I,I3
	MOVEI	N,1		;***
	ADD	I3,N
	PUSH	P,N
	FILOUT	<XP M.MT*>,MKON
	FILOUT	<*>,I
	MOVE	N,(P)
	FILOUT	<,*@>,N
	POP	P,N
	ADDI	I,1
	SOJ	I2,
	POP	P,I
	FILOUT	<XP M.MT*,>,MKON
	FILOUT	<*@>,I3
	MOVEI	N,0
	MOVE	I,N		;CHAN
	FILOUT	<XP M.*T7,>,CHN
	FILOUT	<*@>,I		;OUTPUT NUMBER OF RH'S
	SETOM	MACKN		;SET FLAG FOR USE IN MACK ROUTINE
	JRST	DXEND+9


;REMOVE CODE FOR TM10A. NOT SUPPORTED ON KL10

TAEND:	MOVE	N,M.RC10	;NO OF FHD'S
	SUB	N,FHCPUN	;- NO ON PREVIOUS CPU'S
	FILCPU	<XP M.FHD,*@>,N ;=NO OF FHD'S ON THIS CPU
	FILCPU	<XP M.FSD,*@>,RSCPUN ;NO OF FSD'S ON THIS CPU
	MOVE	N,M.RHP4
	SUB	N,RPCPUN
	FILCPU	<XP M.RPX,*@>,N ;NO OF RP04/6 ON THIS CPU
	MOVE	N,M.RP10
	SUB	N,DPCPUN
	FILCPU	<XP M.DPC,*@>,N ;NO OF RP10'S ON THIS CPU
	MOVE	N,M.RP20
	SUB	N,RNCPUN
	FILCPU	<XP M.RNX,*@>,N ;NO OF RP20'S ON THIS CPU
	FILCPU	<XP M.MDF,*@>,[0] ;NO MOBY DISKS
	MOVE	N,MKON		;NO. OF TAPE CONTROLS ON ALL CPUS
	SUB	N,MKONP		;NO. ON THIS CPU
	FILCPU	<XP M.TAPN,*@>,N
	MOVE	N,MKON
	MOVEM	N,MKONP
	MOVE	N,M.RH1S
	ADD	N,M.RH1P		;TOTAL # RH10S SEEN SO FAR
	MOVEM	N,T2RH1P		;SAVE
	SETZM	RH20CP
	JRST	ASKDFS

NOCHNS:	FILCPU	<XP M.FHD,0@>
	FILCPU	<XP M.FSD,0@>
	FILCPU	<XP M.RPX,0@>
	FILCPU	<XP M.RNX,0@>
	FILCPU	<XP M.DPC,0@>
	FILCPU	<XP M.MDF,0@>
	FILCPU	<XP M.TAPN,0@>
	JRST	ASKDFS
ASKKSI:	SETZM	CHN			;START AT CHANNEL 0
	AOS	CPUN			;COUNT CPU NUMBER
	SETOM	MKON			;INIT THIS GUY
	ASKDEC	<Disk drives(1,1-8)[Total number of RP06's and/or RM03's
on your system]>,N
	PUSH	P,N			;SAVE N
	FILOUT	<XP M.CH*T,4@>,CHN	;CHANNEL TYPE 4
	FILOUT	<XP M.*RH,1@>,CHN	;DISK RH11 ON FIRST CHANNEL
	FILOUT	<XP RH0CPU,*@>,CPUN	;CPU THIS RH ATTACHED TO
	FILCPU	<XP M.RHX,1@>,CHN	;NO. DISK RH11'S THIS CPU
	FILOUT	<XP M.*TR,0@>,CHN	;NOT TAPE RH11
	POP	P,N			;RESTORE N
	FILOUT	<XP M.RHA,*@>,N		;NUMBER OF DRIVES
	PUSHJ	P,KSCHNO		;OUTPUT SYMBOLS FOR NON-EXISTENT STUFF
	AOS	CHN			;NEXT CHANNEL
	ASKDEC	<Tape drives(1,1-4)[Total number of TU45's on your system]>,N
	PUSH	P,N			;SAVE N
	AOS	M.T210			;INCREMENT # TM02'S
	FILOUT	<XP M.CH*T,4@>,CHN	;CHANNEL TYPE 4
	FILOUT	<XP M.*RH,0@>,CHN	;NOT DISK RH11
	FILOUT	<XP M.*TR,1@>,CHN	;TAPE RH11 ON SECOND CHANNEL
	FILCPU	<XP M.TAPN,1@>,CHN	;NO. TAPE RH11'S THIS CPU
	FILOUT	<XP M.MT0T,5@>		;TAPE CTRL TYPE
	FILOUT	<XP M.MT0C,*@>,CHN	;CHANNEL TAPE CTRL IS ON
	FILOUT	<XP M.MT0P,*@>,CPUN	;CPU TAPE CTRL IS ON
	POP	P,N			;RESTORE N
	FILOUT	<XP M.MT0,*@>,N		;TOTAL # DRIVES
	PUSHJ	P,KSCHNO		;OUTPUT SYMBOLS FOR NON-EXISTENT STUFF
	AOS	CHN			;NEXT CHANNEL
	FILOUT	<DEFINE MACKN0 (X)>	;NO 7-TRACKS
	PUSHJ	P,FILLAB
	PUSHJ	P,FILRAB
	FILOUT	<DEFINE MACK60 (X)>	;NO 6250 BPI'S
	PUSHJ	P,FILLAB
	PUSHJ	P,FILRAB
	JRST	CHNEND			;GO TO TOTALS PROCEDURE

KSCHNO:	FILOUT	<XP M.*FH,0@>,CHN ;NO FH,DP,FS,TB,TC
	FILOUT	<XP M.*DP,0@>,CHN
	FILOUT	<XP M.*RP,0@>,CHN
	FILOUT	<XP M.*FS,0@>,CHN
	FILOUT	<XP M.*TB,0@>,CHN
	FILOUT	<XP M.*TC,0@>,CHN
	FILOUT	<XP M.*T2,0@>,CHN
	FILOUT	<XP M.*TX,0@>,CHN
	FILCPU	<XP M.FHD,0@>,CHN
	FILCPU	<XP M.FSD,0@>,CHN
	FILCPU	<XP M.RPX,0@>,CHN
	FILCPU	<XP M.RNX,0@>,CHN
	FILCPU	<XP M.DPC,0@>,CHN
	FILCPU	<XP M.MDF,0@>,CHN
	POPJ	P,		;RETURN
CHNEND:	FILOUT	<XP M.CHN,*@>,CHN
	FILOUT	<XP M.RC10,*@>,M.RC10 ;OUTPUT NO. OF RC10 IN SYSTEM
	FILOUT	<XP M.RH1S,*@>,M.RH1S	;OUTPUT NO. OF RH10/RP04'S IN SYSTEM
	FILOUT	<XP M.RH1P,*@>,M.RH1P ;OUTPUT NO. OF RH10/RP04'S IN SYSTEM
	FILOUT	<XP M.RH2P,*@>,M.RH2P	;OUTPUT NO. OF RH20/RP04'S IN SYSTEM
	FILOUT	<XP M.RH20,*@>,M.RH20	;OUTPUT NUMBER OF RH20S IN SYSTEM
	FILOUT	<XP M.RHP4,*@>,M.RHP4	;OUTPUT NO. OF RP04 CONTROLLERS IN SYSTEM
	FILOUT	<XP M.RP20,*@>,M.RP20	;OUTPUT NO. OF RP20 CONTROLLERS
	FILOUT	<XP M.RP10,*@>,M.RP10 ;OUTPUT NO. OF RP10S IN SYSTEM
	FILOUT	<XP M.TX01,*@>,M.TX01 ;OUTPUT N0. OF TX01S IN SYSTEM
	FILOUT	<XP M.TM02,*@>,M.T210	;OUTPUT NO. OF TM02'S IN SYSTEM
	FILOUT	<XP M.DX20,*@>,M.DX20	;OUTPUT NO. OF DX20'S IN SYSTEM
	FILOUT	<XP M.TM78,*@>,M.T78	;OUTPUT NO. OF TM78'S IN SYSTEM
	FILOUT	<XP M.TM10,*@>,M.TM10	;OUTPUT NO. OF TM10'S IN SYSTEM
	SKIPN	M.KS10			;KS10?
	JRST	CHNEN0			;NO--GO ON
	FILOUT	<XP M.R11D,1@>		;TOTAL # RH11'S FOR DISKS
	FILOUT	<XP M.TRH1,1@>		;TOTAL # OF RH11'S FOR TAPE
	JRST	CHNEN1			;CONTINUE
CHNEN0:	FILOUT	<XP M.R11D,0@>		;THESE ARE ZERO FOR NON-KS10
	FILOUT	<XP M.TRH1,0@>
CHNEN1:	MOVE	I,MKON		;GET # TAPE KONTROLLERS
	JUMPL	I,ASKDTE	;JUMP IF ZERO
	SKIPE	MACKN		;HAS A DUMMY TAPE BEEN INSTALLED?
	JRST	MACK		;YES. GO INSTALL MACK6N AND MACK6
	BTHOUT	<Specify which drives (M-N) are 7 track drives.
[Type one number (M) or one range(M-N) or ALL on separate lines.
Type extra carriage return when through.]@>
TAP7LP:	MOVE	N,MKON
	SUB	N,I		;START FROM ZERO
	PUSH	P,N		;SAVE NUMBER
	FILOUT	<DEFINE	MACKN* (X)>,N
	POP	P,N		;RESTORE N
	ADDI	N,'A'		;CONVERT TO SIXBIT
	ROT	N,-6
	ASKTMN	<For controller MT*@>,N
	SOJGE	I,TAP7LP	;LOOP TILL DONE
	BTHOUT	<Specify which tape drives (M-N) are capable of 6250 BPI densities.
[Type one number (M) or one range (M-N) or ALL on separate lines.
Type an extra carriage return when through.]@>
	MOVE	I,MKON		;PICK UP THE NUMBER OF CONTROLLERS
TAP6LP:	MOVE	N,MKON
	SUB	N,I		;START FROM ZERO
	PUSH	P,N		;SAVE NUMBER
	FILOUT	<DEFINE MACK6* (X)>,N
	POP	P,N		;RESTORE N
	ADDI	N,'A'		;CONVERT TO SIXBIT
	ROT	N,-6
	ASKTMN	<For controller MT*@>,N
	SOJGE	I,TAP6LP	;LOOP TILL DONE
	JRST	ASKDTE

MACK:	FILOUT	<DEFINE	MACKN0 (X)>	;SETUP FOR 7 TRK
	PUSHJ	P,FILLAB	;INSERT LFT ANG BRKT
	PUSHJ	P,FILRAB	;INSERT RGT ANG BRKT

	FILOUT	<DEFINE MACK60 (X)>	;SETUP FOR 6250 DENSITY
	PUSHJ	P,FILLAB	;INSERT LFT ANG BRKT
	PUSHJ	P,FILRAB	;INSERT RGT ANG BRKT

ASKDTE:	SKIPN	M.KL10		;IS THIS A KL10?
	JRST	ASKJOB		;NO, DON'T ASK ABOUT DTES
	SETOM	CPUN
ASKDT1:	AOS	N,CPUN
	CAML	N,M.CPU
	JRST	ASKDT2
	ASKDEC	<# DTEs on CPU*(2,1-4)[Byte transfer device used for KL10 to PDP-11 front end communications]>
	MOVEM	N,DTES		;SAVE NUMBER OF DTES FOR LATER USE
	PUSH	P,N
	FILOUT	<XP M.*DTE,>,CPUN
	FILOUT	<*@>,0(P)
	MOVE	N,M.1091
	JUMPE	N,NOTERM	;IF 1090 DON'T ASK FOR FE TERMINALS
	MOVE	N,CPUN
	ASKDEC	<  # terminals on the master front end on CPU*(16,0-128)[include
only timesharing (DH11) lines, not CTY or KLINIK]>,N
NOTERM:	POP	P,I		;RESTORE NUMBER OF DTE'S
	SKIPN	N		;ANY LINESON FCONT END
	SKIPA	N,I		;NO, NEED ONLY 1 DL11 FOR EACH
	ADDI	N,4		;ACCOUNT FOR ALL DL11 LINES (-CTY)
	ADDM	N,M.TTDN
	FILCPU	<XP M.TTDN,*@>,N
	MOVEM	N,SAVTTY	;SAVE FOR USE IN TTYGEN
	MOVE	N,M.1091
	JUMPE	N,NOPRT
	MOVE	N,CPUN
	ASKDEC	<  # line printers on the master front end on CPU*(0,0-2)>,N
NOPRT:	ADDM	N,M.DLP
	ADDM	N,LPTS		;***SAVE FOR LATER IN SYSJOB/SYSTEM.CMD
	FILCPU	<XP M.LP0N,*@>,N
	FILCPU	<XP M.LP1N,0@>
	FILCPU	<XP M.LP2N,0@>
	FILCPU	<XP M.LP3N,0@>
	JUMPE	N,ASKDT3	;DON'T ASK IF THERE AREN'T ANY PRINTERS
	MOVN	I,N		;GET -NUMBER OF PRINTERS
	HRLZ	I,I		;MAKE AN AOBJN POINTER
ASKDT4:	HRRZ	N,I		;GET LPT NUMBER
	ASKYN	<     Front end printer * lower case(Y,N)[Does printer * have lower case capability]>,N
	PUSH	P,N		;SAVE ANSWER
	HRRZ	N,I		;GET PRINTER NUMBER AGAIN
	FILCPU	<XP M.FL*L,>,N
	POP	P,N		;RESTORE ANSWER
	FILCPU	<*@>,N
	AOBJN	I,ASKDT4	;TRY FOR NEXT PRINTER
ASKDT3:	MOVE	N,M.1091
	JUMPE	N,NOCDR
	MOVE	N,CPUN
	ASKDEC	<  # card readers on the master front end on CPU*(0,0-1)>
NOCDR:	ADDM	N,M.DCR
	ADDM	N,CDRS		;***SAVE FOR LATER IN SYSJOB/SYSTEM.CMD
	FILCPU	<XP M.CR0N,*@>,N
	FILCPU	<XP M.CR1N,0@>
	FILCPU	<XP M.CR2N,0@>
	FILCPU	<XP M.CR3N,0@>
	JRST	ASKDT1
ASKDT2:	FILOUT	<XP M.TTDN,*@>,M.TTDN
	FILOUT	<XP M.DLP,*@>,M.DLP
	FILOUT	<XP M.DCR,*@>,M.DCR
ASKJOB:	MOVE	N,CPUN	;GET NUMBER OF CPUS ON SYSTEM
	SOJE	N,.+3		;IS IT MULTIPLE CPUS?
	MOVEI	N,^D100		;YES, MAKE MAXJOBS 100
	JRST	.+2		;GO OUTPUT IT
	MOVEI	N,^D75		;NO, MAKE MAXJOBS 75 AND OUTPUT IT
	FILOUT	<XP M.JOB,*@>,N


	FILOUD	<XP MD.2RR,*@>,MD.2RR
	FILOUD	<XP MD.SEG,*@>,MD.SEG
	FILOUD	<XP MD.DDT,*@>,MD.DDT

ASKCOR:	SETZ	N,		;SETUP FOR MAX P OF COR
	FILOUT	<XP M.CORE,*@>,N
	MOVEI	N,^D4096	;UP TO 4 MILLION WORDS ALLOWED




ASKNKC:	ASKDEC	<# K total system core(128-*)[ONCE-only reports if
less core at startup]>
	FILOUT	<XP M.NKC,*@>,N
ASKTPS:	ASKLST	<Clock ticks per second(60,50)[Power line frequency]>
	SKIPN	N		;SKIP IF 50
	TROA	N,^D60		;NO, 60
	MOVEI	N,^D50		;50
	FILOUT	<XP M.TPS,*@>,N
ASKRTD:	SKIPN	M.KS10		;KS10?
	JRST	ASKRT0		;NO--GO ON
	FILOUT	<XP M.RTD,0@>	;YES--NO REAL TIME
	JRST	ASKLOK		;GO ON
ASKRT0:	SETZ	N,		;ASSUME NO REAL TIME DEVS IN MFG.
	FILOUT	<XP M.RTD,*@>,N
ASKLOK:	MOVEI	N,1		;SETUP FOR LOCK JOBS IN CARE
ASKLK1:	FILOUT	<XP M.LOK,*@>,N
ASKMGC:	MOVEI	N,^D50		;SETUP FOR 50 PAGES MIN
ASKMG1:	FILOUT	<XP M.MGC,*@>,N
ASKHPQ:	MOVEI	N,5		;SETUP FOR 5 HPQ'S
	FILOUT	<XP M.HPQ,*@>,N
ASKMET:	MOVEI	N,1		;SETUP FOR DEFAULTS
	FILOUT	<XP M.METR,*@>,N ;TURN ON METER
ASKSCK:	FILOUT	<XP M.SYSC,*@>,N ;TRUN ON SYSCHK
ASKKA1:	FILOUT	<XP M.FPS,*@>,N  ;TURN ON KASER
ASKMSG:	FILOUT	<XP M.MSG,*@>,N  ;TURN ON MSGSER
ASKPSI:	FILOUT	<XP M.PSI,*@>,N  ;TURN ON PSISER
ASKIPC:	FILOUT	<XP M.IPCF,*@>,N ;TURN ON IPCSER
ASKENQ:	FILOUT	<XP M.EQDQ,*@>,N ;TURN ON ENQ/DEQ
ASKMBT:	FILOUT	<XP M.MBTS,*@>,N ;ENABLLE MONITRO RESIDENT BOOTS
	SKIPE	M.KS10		;KS10?
	JRST	KSGEN		;YES--GO DO KS10 SPECIFIC GEN
	SETOM	CPUN
ASKCDR:	AOS	N,CPUN
	CAML	N,M.CPU
	JRST	DEVEND
	MOVE	I,M.CPU
	CAIG	I,1
	JRST	ASKCD1
	BTHOUT	<on CPU*:@>,N
ASKCD1:	MOVEI	N,SM.CDR	;MAXIMUM NUMBER OF CDRS
	ASKDEC	<# CDRs(0,0-*)[Card reader on the I/O Bus]>
	ADDM	N,M.CDR
	FILCPU	<XP M.CDR,*@>,N
	ADDM	N,CDRS		;***SAVE FOR LATER IN SYSJOB.INI/SYSTEM.CMD
	SKIPE	N		;SKIP IF NO CDR
	MOVEI	N,MD.C10	;YES, GET DEFAULT VALUE FOR CR10
	FILOUT	<XP MD.C10,*@>,N
	FILCPU	<XP MD.C10,*@>,N


ASKCDP:	ASKDEC	<CDP(0,0-1)[Card punch]>
	ADDM	N,M.CDP
	FILCPU	<XP M.CDP,*@>,N
	JUMPE	N,ASKDIS
	ASKYN	<CP10D(Y,N)[Special Systems unbuffered card punch]>
	FILCPU	<XP M.CP1D,*@>,N

ASKDIS:
IFN FTUNSUPPORTED,<
	ASKYN	<DIS(Y,N)[Display device(VP10,340,30,VB10C) as distinguished from
display terminals]>
>
IFE FTUNSUPPORTED,<
	MOVEI	N,0		;NO DISPLAYS
>	JUMPE	N,ASKDS1	;ANY DISPLAYS?
	ASKLST	<Type(VP10,340,VB10C)[Answer VP10 for Type 30]>
	AOS	M.VP10(N)	;SET M.VP10, M.340 OR M.VBXC TO 1
ASKDS1:	FILOUT	<XP M.VP10,*@>,M.VP10
	FILCPU	<XP M.VP10,*@>,M.VP10
	FILOUT	<XP M.340,*@>,M.340
	FILCPU	<XP M.340,*@>,M.340
	FILOUT	<XP M.VBXC,*@>,M.VBXC
	FILCPU	<XP M.VBXC,*@>,M.VBXC
	SETZ	N,		; FOR FILOUT OF M.DIS
	SKIPN	M.VP10		;SKIP IF VP10 DISPLAY
	SKIPE	M.340		;SKIP IF NOT 340 DISPLAY
	MOVEI	N,1		;FILOUT M.DIS=1 IF EITHER 340 OR VP10
	FILOUT	<XP M.DIS,*@>,N	;
	FILCPU	<XP M.DIS,*@>,N	;

ASKDTA:	MOVEI	N,SM.DTA	;MAXIMUM NUMBER OF DTA CONTROLLERS
	ASKDEC	<# TD10s(0,0-*)[DECtape controls]>
	FILCPU	<XP M.TD10,*@>,N
	MOVE	I,N		;SETUP DTA UNIT ITERATION COUNTER
	JUMPE	I,DTEND		;ANY DTA UNIT AT ALL?
DTLOOP:	AOS	N,DTA		;YES, INCREMENT COUNT OF DT CONTROLLERS IN SYSTEM
	ADDI	N,'A'-1		;FORM SIXBIT CONTROLLER LETTER
	ROT	N,-6		;LEFT JUSTIFY
	ASKDEC	<  # Units on DT*(1-8)>,N
	PUSH	P,N		;SAVE ANSWER(NO OF UNITS ON THIS CONTROLER
	MOVE	N,DTA		;CONTROLLER NUMBER
	ADDI	N,'A'-1		;FORM SIXBIT CONTROLLER LETTER
	ROT	N,-6		;LEFT JUSTIFY
	FILOUT	<XP M.DT*,>,N	;FIRST HALF
	EXCH	N,(P)
	FILOUT	<*@>,N		;OUTPUT
	EXCH	N,(P)
	FILCPU	<XP M.DT*,>,N	;FIRST HALF
	POP	P,N		;RESTORE NO. OF UNITS ON THIS CONTROLER
	FILCPU	<*@>,N		;OUTPUT
	SOJG	I,DTLOOP	;ANY MORE CONTROLLERS?
DTEND:


ASKLPT:	MOVEI	N,SM.LPT	;MAXIMUM NUMBER OF LPTS
	ASKDEC	<LPTs(0,0-*)[Line printers on the I/O Buss]>
	FILCPU	<XP M.LPT,*@>,N
	ADDM	N,LPTS		;***SAVE FOR LATER IN SYSJOB/SYSTEM.CMD
	PUSH	P,N		;SAVE # OF LPTS
	SKIPE	N		;SKIP IF NO LPT
	MOVEI	N,MD.MOV	;GET DEFAULT VALUE FOR MOVIE
	FILOUT	<XP MD.MOV,*@>,N
	POP	P,N		;GET # OF LPTS
	JUMPE	N,NOLPT		;DON'T WORRY ABOUT LC IF NO LPTS
	MOVE	I,N		;SET UP LOOP COUNTER
MORLPT:	MOVE	N,LPTCNT	;GET CURRENT NUMBER OF  LPT
	ASKYN	<LPT* Lower case(Y,N)[Does LPT* have lower case capability]>,N
	PUSH	P,N		;SAVE ANSWER
	MOVE	N,LPTCNT	;GET NUMBER OF THIS LPT
	ADDI	N,'0'		;CONVERT TO PRINTABLE FORM
	ROT	N,-6		;LEFT-JUSTIFY IT
	FILOUT	<XP M.LP*L,>,N	;OUTPUT SYMBOL NAME
	EXCH	N,(P)
	FILOUT	<*@>,N		;OUTPUT IT AS SYMBOL VALUE
	EXCH	N,(P)
	FILCPU	<XP M.LP*L,>,N	;OUTPUT SYMBOL NAME
	POP	P,N		;GET ANSWER BACK AGAIN
	FILCPU	<*@>,N		;OUTPUT IT AS SYMBOL VALUE
	AOS	LPTCNT		;BUMP COUNT OF LPTS
	SOJG	I,MORLPT	;LOOP THRU ALL LPTS
NOLPT:


ASKPLT:	MOVEI	N,SM.PLT	;MAX NUMBER OF PLOTTERS
	ASKDEC	<PLTS(0,0-*)[Plotters]>
	ADDM	N,M.PLT
	FILCPU	<XP M.PLT,*@>,N


ASKPTP:	ASKDEC	<# PC20(0,0-1)[Paper tape punch]>
	ADDM	N,M.PTP
	FILCPU	<XP M.PTP,*@>,N
ASKPTR:	ADDM	N,M.PTR
	FILCPU	<XP M.PTR,*@>,N


ASKXTC:
IFE FTUNSUPPORTED,<
	MOVEI	N,0		;NO DA28S
>
IFN FTUNSUPPORTED,<
	MOVEI	N,SM.XTC	;MAX # OF DA28S
	ASKDEC	<# of DA28s(0,0-*)[Interprocessor channels for PDP8/11/15]>
>
	FILOUT	<XP M.XTC,*@>,N
	FILCPU	<XP M.XTC,*@>,N
IFN FTUNSUPPORTED,<
	JUMPE	N,XTCEND
	ASKDEC	<# of lines for TTY pool(8,0-512)[Lines reserved for use on DA28 channels]>
	FILOUT	<XP M.XTL,*@>,N
>
XTCEND:	FILCPU	<XP M.XTL,*@>,N
ASKD60:	MOVE	T1,[M.DN60,,M.DN60+1]
	SETZM	M.DN60
	BLT	T1,M.BD60
	SKIPN	SAVTYP		;IS THIS A 1090? 0=1090, 1=1091
	JRST	.+3		;YES GO DO NORMAL DIALOGUE
	MOVE	N,DTES		;NO, GET NUMBER OF DTE'S
	SOJE	N,ASK60A	;IF RESULT IS ZERO, THEN CAN'T HAVE DN60 ON 1091
	SETZ	N,
	SKIPE	CPUN
	JRST	ASK60A
	MOVEI	N,SM.D60	;MAXIMUM NUMBER OF DN60'S
	ASKDEC	<# DN60'S(0,0-*)[IBM BSC INTERFACES]>
ASK60A:	MOVEM	N,M.DN60	;SAVE NUMBER FOR COUNT DOWN
	FILCPU	<XP M.DN60,*@>,M.DN60
	SKIPE	CPUN
	JRST	ASK60C
	FILOUT	<XP M.DN60,*@>,M.DN60
	SKIPN	M.DN60		;SEE IF ANY DN60'S
	JRST	ASK60C		;NO DN60'S
	PUSH	P,[0]		;PUT A 0 ON THE STACK TO COUNT UP
ASK60B:	PUSHJ	P,ASK60S	;ASK ABOUT THE DN60'S
	AOS	(P)		;SET UP TO ASK ABOUT NEXT ONE
	SOSE	M.DN60		;ASKED ABOUT ALL DN60'S?
	JRST	ASK60B		;NO, ASK ABOUT ANOTHER ONE
	POP	P,(P)		;CLEAN THE STACK
ASK60C:	FILCPU	<XP M.0D60,*@>,M.0D60
	FILCPU	<XP M.1D60,*@>,M.1D60
	FILCPU	<XP M.2D60,*@>,M.2D60
	FILCPU	<XP M.3D60,*@>,M.3D60
	FILCPU	<XP M.4D60,*@>,M.4D60
	FILCPU	<XP M.5D60,*@>,M.5D60
	FILCPU	<XP M.6D60,*@>,M.6D60
	FILCPU	<XP M.7D60,*@>,M.7D60
	FILCPU	<XP M.8D60,*@>,M.8D60
	FILCPU	<XP M.9D60,*@>,M.9D60
	FILCPU	<XP M.AD60,*@>,M.AD60
	FILCPU	<XP M.BD60,*@>,M.BD60
	FILCPU	<XP M.D60L,*@>,M.D60L
	SKIPE	CPUN
	JRST	ASK60D
	FILOUT	<XP M.0D60,*@>,M.0D60
	FILOUT	<XP M.1D60,*@>,M.1D60
	FILOUT	<XP M.2D60,*@>,M.2D60
	FILOUT	<XP M.3D60,*@>,M.3D60
	FILOUT	<XP M.4D60,*@>,M.4D60
	FILOUT	<XP M.5D60,*@>,M.5D60
	FILOUT	<XP M.6D60,*@>,M.6D60
	FILOUT	<XP M.7D60,*@>,M.7D60
	FILOUT	<XP M.8D60,*@>,M.8D60
	FILOUT	<XP M.9D60,*@>,M.9D60
	FILOUT	<XP M.AD60,*@>,M.AD60
	FILOUT	<XP M.BD60,*@>,M.BD60
	FILOUT	<XP M.D60L,*@>,M.D60L
	JRST	ASK60D		;DONE DN60'S.

ASK60S:	MOVE	N,-1(P)		;GET A NUMBER FOR DN60
	TTYOCT	<@For DN60 *:@@>
	ASKOCT	<Which port is the DN60 connected to (0,0-13)[
DL10 NUMBER 1 HAS PORTS 0-3, DL10 NUMBER 2 HAS PORTS 4-7,
DTE 0-3 ARE PORTS 10-13]>
	CAIGE	N,^O11		;IS THIS DN60 ON A DTE?
	JRST	.+2		;NO GO DO NORMAL
	SOS	DTES		;YES, REDUCE DTE COUNT FOR NETGEN
	PUSH	P,N		;SAVE PORT NUMBER ON STACK
	ASKDEC	<Decimal lines on the DN60 (1-12)[
EACH DN60 CAN SUPPORT UP TO 12 IBM BSC INTERFACES]>
	ADDM	N,M.D60L	;KEEP A SUM OF THE DN60 LINES
	MOVE	T1,(P)		;GET DN60 NUMBER
	MOVEM	N,M.0D60(T1)	;SAVE LINES IN PROPER PORT LOC
	POP	P,(P)		;CLEAN STACK
	POPJ	P,		;EXIT
ASK60D:
	JRST	ASKCDR
DEVEND:	FILOUT	<XP M.CDR,*@>,M.CDR
	FILOUT	<XP M.CDP,*@>,M.CDP
	FILOUT	<XP M.TD10,*@>,DTA
	FILOUT	<XP M.LPT,*@>,LPTCNT
	FILOUT	<XP M.PLT,*@>,M.PLT
	FILOUT	<XP M.PTP,*@>,M.PTP
	FILOUT	<XP M.PTR,*@>,M.PTR
ASKPTY:	MOVE	N,CPUN	;GET FNUMBER OF CPUS ON SYSTEM
	SOJE	N,.+3		;IS IT MULTIPLE CPUS?
	MOVEI	N,^D95		;YES, MAKE MAXPTYS 95
	JRST	.+2		;GO OUTPUT IT
	MOVEI	N,^D70		;NO,MAKE MAXPTYS 70 AND OUTPUT IT
	FILOUT	<XP M.PTY,*@>,N
	JRST	ASKDSY
KSGEN:	MOVEI	N,SM.PTY	;MAXIMUM NUMBER OF PTYS
	ASKDEC	<# PTYs(20,0-*)[Pseudo-terminals - each operator
service program and Batch stream needs one]>
	FILOUT	<XP M.PTY,*@>,N
	ASKDEC	<LPT(0,0-1)[Line printer]>,N
	FILOUT	<XP M.LPT,*@>,N
	FILCPU	<XP M.LPT,*@>,N
	JUMPE	N,KSGEN0	;JUMP IF NO LPT
	FILOUT	<XP M.CH*T,5@>,CHN	;CHANNEL TYPE 5
	FILOUT	<XP M.LP0C,*@>,CHN	;LPT CHANNEL NUMBER
	FILOUT	<XP M.*RH,0@>,CHN	;NO DISK RH11 THIS CHANNEL
	FILOUT	<XP M.*TR,0@>,CHN	;NO TAPE RH11 THIS CHANNEL
	PUSHJ	P,KSCHNO		;OUTPUT OTHER SYMBOLS FOR THIS CHANNEL
	AOS	CHN			;NEXT CHANNEL
	ASKYN	<Lower case(Y,N)[Does LPT have lower case]>,N
	FILOUT	<XP M.LP0L,*@>,N
KSGEN0:	ASKDEC	<CDR(0,0-1)[CARD READER]>,N
	FILOUT	<XP M.CDR,*@>,N
	FILCPU	<XP M.CDR,*@>,N
	JUMPE	N,KSGEN1		;JUMP IF NO CDR
	FILOUT	<XP M.CH*T,6@>,CHN	;CHANNEL TYPE 6
	FILOUT	<XP M.CD0C,*@>,CHN	;CDR CHANNEL NUMBER
	FILOUT	<XP M.*RH,0@>,CHN	;NO DISK RH11 THIS CHANNEL
	FILOUT	<XP M.*TR,0@>,CHN	;NO TAPE RH11 THIS CHANNEL
	PUSHJ	P,KSCHNO		;OUTPUT OTHER SYMBOLS FOR THIS CHANNEL
	AOS	CHN			;NEXT CHANNEL
KSGEN1:	FILOUT	<XP M.CHN,*@>,CHN	;TOTAL NUMBER OF CHANNELS
	MOVEI	N,SM.KDUP		;MAXIMUM NUMBER OF DUP-11S
	ASKDEC	<# KMC/DUP Lines(0,0-*)[Number of DUP-11 synchronous
line units attached to a KMC-11 controller.]>,n
	FILOUT	<XP M.KDUP,*@>,N
	FILOUT	<XP MD.MOV,0@>	
	FILOUT	<XP MD.C10,0@>
	FILOUT	<XP M.CDP,0@>
	FILCPU	<XP M.CDP,0@>
	FILOUT	<XP M.VP10,0@>
	FILOUT	<XP M.340,0@>
	FILOUT	<XP M.VBXC,0@>
	FILOUT	<XP M.DIS,0@>
	FILOUT	<XP M.TD10,0@>
	FILCPU	<XP M.TD10,0@>
	FILOUT	<XP MD.DTC,0@>
	FILOUT	<XP M.PLT,0@>
	FILCPU	<XP M.PLT,0@>
	FILOUT	<XP M.PTP,0@>
	FILCPU	<XP M.PTP,0@>
	FILOUT	<XP M.PTR,0@>
	FILCPU	<XP M.PTR,0@>
	FILOUT	<XP M.DC44,0@>
	FILOUT	<XP M.XTC,0@>
	FILOUT	<XP M.XTL,0@>
	FILOUT	<XP M.DAS78,0@>
	FILOUT	<XP M.DN60,0@>
	FILOUT	<XP M.0D60,0@>
	FILOUT	<XP M.1D60,0@>
	FILOUT	<XP M.2D60,0@>
	FILOUT	<XP M.3D60,0@>
	FILOUT	<XP M.4D60,0@>
	FILOUT	<XP M.5D60,0@>
	FILOUT	<XP M.6D60,0@>
	FILOUT	<XP M.7D60,0@>
	FILOUT	<XP M.8D60,0@>
	FILOUT	<XP M.9D60,0@>
	FILOUT	<XP M.AD60,0@>
	FILOUT	<XP M.BD60,0@>
	JRST	ASKDSY		;CONTINUE WITH NORMAL PATH
ASKDSY:	FILOUT	<@RADIX	10@>;	;SET RADIX TO DECIMAL IN FILE
DSYEND:	FILOUT	<RADIX	8@>;	;SET RADIX BACK TO NORMAL IN FILE
ASKSP1:	FILOUT	<@DEFINE	SPCINT>
	PUSHJ	P,FILLAB	;LEFT ANGLE BRACKET,CRLF TO FILE
SP1END:	PUSHJ	P,FILRAB	;RIGHT ANGLE BRACKET,CRLF TO FILE
	MOVE	LV,SAVLV	;RESTORE PERMANENT HELP LEVEL
				; IN CASE HE TYPED /H<CR>


ASKSP2:	FILOUT	<@DEFINE	SPCDDB>	;START MACRO DEFINITION
	PUSHJ	P,FILLAB	;LEFT ANGLE BRACKET,CRLF TO FILE
SP2END:	PUSHJ	P,FILRAB	;RIGHT ANGLE BRACKET,CRLF TO FILE
	MOVE	LV,SAVLV	;RESTORE PERMANENT HELP LEVEL
				; IN CASE HE TYPED /H<CR>


ASKSP3:	FILOUT	<@DEFINE	SPCSAV>	;START MACRO DEFINITION
	PUSHJ	P,FILLAB	;LEFT ANGLE BRACKET,CRLF
SP3END:	PUSHJ	P,FILRAB	;FILL IN A RIGHT ANGLE BRACKET


ASKEDN:	FILOUT	<@DEFINE	SPCEDN>	;START MACRO DEFINITION
	PUSHJ	P,FILLAB	;ADD LEFT ANGLE BRACKET
EDNEND:	PUSHJ	P,FILRAB	;OUTPUT RIGHT ANGLE BRACKET
HDWEND:	POPJ	P,		;END OF HDWGEN, RETURN AND CLOSE FILE
SUBTTL	NETGEN - DIALOG TO DEFINE NETWORK CONFIGURATIONS

NETGEN:	FILOUT	<SUBTTL	NETCNF - NETWORK CONFIGURATION DEFINITION FILE OUTPUT BY MONGEN DIALOG@@@>
	FILOUT	<DEFINE XP(A,B),<A==:B>@@@>
	MOVEI	N,VERSION	;MONGEN PROGRAM VERSION NUMBER
	FILOUT	<XP M.NET,*@>,N ;OUTPUT TO FILE FOR COMMON TO CHECK FOR
	FILOUT	<XP M.RSS,0@>;	;OLD REMOTE STATION CODE SWITCH OFF
	FILOUT	<XP M.DS10,0@>;	;NO DS10
	FILOUT	<XP M.DP01,0@>;	;OR DP01
	MOVE	N,SAVTYP	;GET SYSTEM TYPE, 0=1090, 1=1091
	JUMPE	N,ASKNET	;IF 1090, GO ASK FOR NETWRKS
	MOVE	N,DTES		;GET NUMBER OF DTES
	SOJLE	N,NODTES	;ADJUST FOR MIN OF 1 DTE. IF RESULT
				;IS ZERO, DON'T ASK FOR NETWRKS
ASKNET:	ASKYN	<Network software(Y,N)[
Software to support remote computers: DECsystem-10's,
PDP-11's, PDP-8's (requires FTNET to be -1)]>
NODTES:	FILOUT	<XP M.NET,*@>
	JUMPE	N,NETNON
	SETZM	M.DL10		;ASSUME NO DL10'S
	MOVEI	P1,1		;COUNT FRONT ENDS STARTING AT 1
	MOVE	N,CPUS		;GET NUMBER OF CPUS FROM HDWGEN
	MOVEM	N,M.CPU
	SETOM	CPUN
ASKNT1:	AOS	N,CPUN
	CAML	N,M.CPU
	JRST	ASKCEN
	SKIPE	CPUN
	JRST	ASK85B
	SKIPE	SAVTYP		;IS THIS A 1091, 0=1090, 1=1091
	JRST	NODL		;IF 1091, DON'T ASK, N ALREADY SETUP TO
				;WRITE TO FILE
	ASKDEC	<How many DC75NP's or DN87/DL10's on CPU*(0,0-8)[Network
front-ends connected to DL10's.]>
NODL:	MOVEM	N,M.DC75	;store number of 75/87's
	FILOUT	<XP M.DC75,*@>,M.DC75
	SKIPN	M.DC75		;ask which ports if non-zero
	JRST	ASK85B		;if none, write out symbols as zeros
	SETZ	P2,		;P2=0 SAYS DL10 INTERFACE
ASK85A:	PUSHJ	P,ASK85S	;ask which port
	ADDI	P1,1		;increment counter
	SOSE	M.DC75		;are we done?
	JRST	ASK85A		;no, continue

ASK85B:	FILCPU	<XP M.0D85,*@>,M.0D85 ;OUTPUT ALL SYMBOLS

	FILCPU	<XP M.1D85,*@>,M.1D85
	FILCPU	<XP M.2D85,*@>,M.2D85
	FILCPU	<XP M.3D85,*@>,M.3D85
	FILCPU	<XP M.4D85,*@>,M.4D85
	FILCPU	<XP M.5D85,*@>,M.5D85
	FILCPU	<XP M.6D85,*@>,M.6D85
	FILCPU	<XP M.7D85,*@>,M.7D85
;
; PUT OUT SYMBOLS FOR DN87'S ON 'PORT'S 8, 9, A AND B,
;  WHICH ARE ON THE DTE20'S, EVEN THOUGH THIS IS NOT
;  SUPPORTED.  (THE DN87-S IS ON THE DTE20'S.)
;
	SETZM	M.0D85		;LET'S TIMESHARE THESE LOCATIONS
	MOVE	T1,[M.0D85,,M.1D85] ;WHICH MEANS WE HAVE TO ZERO THEM
	BLT	T1,M.BD85	;SINCE THE PREVIOUS PAGE USED THEM
ASKNT2:	MOVE	N,CPUN
	ASKDEC	<How many DN87S/DN20's on CPU*(1,0-3)[Network
front-ends connected to DTE-20's]>
	MOVEM	N,M.DC75	;store number of 75/87's
	FILOUT	<XP M.D87S,*@>,M.DC75
	FILCPU	<XP M.D87S,*@>,M.DC75
	SKIPN	M.DC75		;ask which ports if non-zero
	JRST	ASK87B		;if none, write out symbols as zeros
	MOVEI	P2,1		;SAY THIS IS DTE INTERFACED FRONT END
ASK87A:	PUSHJ	P,ASK85S	;ask which port
	ADDI	P1,1		;increment counter
	SOSE	M.DC75		;are we done?
	JRST	ASK87A		;no, continue
ASK87B:	FILCPU	<XP M.0D8S,*@>,M.0D85;OUTPUT ALL SYMBOLS
	FILCPU	<XP M.1D8S,*@>,M.1D85
	FILCPU	<XP M.2D8S,*@>,M.2D85

	FILCPU	<XP M.3D8S,*@>,M.3D85
	SETZM	M.0D85
	MOVE	T1,[M.0D85,,M.1D85]
	BLT	T1,M.3D85
	JRST	ASKNT1
ASKCEN:	MOVEI	N,^O10
	FILOUT	<XP OURNNM,*@>,N
ASKNNM:
	ASKSTR	<Name of central site[Six characters or less.]>
	CAILE	N,^D6	;CORRECT NUMBER?
	RJRST	<TTYOUT		<%More than 6 characters.@>
		JRST	ASKNNM>
	FILSTR	<@DEFINE	SYSNDE
	<SIXBIT	&*&>@>

	MOVEI	N,SM.RMCR	;MAX REMOTE TTY'S
	ASKDEC	<# of remote TTY's(1,1-*)[
Maximum number of teletypes on network nodes to be
handled at any given time.]>,N
	FILOUT	<XP M.RMCR,*@>,N

	MOVEI	N,1
	FILOUT	<XP M.RVTM,*@>,N
	MOVEI	N,0
	FILOUT	<XP M.RCDR,*@>,N
	FILOUT	<XP M.RLPT,*@>,N

REPEAT 0,<			;FOR NOW, TILL DRIVERS ARE WRITTEN
	ASKYN	<Remote paper tape punches(Y,N)[
Code to allow access to paper tape punches on remote stations.]>,N
	FILOUT	<XP M.RPTP,*@>,N

	ASKYN	<Remote paper tape readers(Y,N)[
Code to allow access to paper tape readers on remote stations.]>,N
	FILOUT	<XP M.RPTR,*@>,N

	ASKYN	<Remote plotters(Y,N)[
Code to allow access to plotters on remote stations.]>,N
	FILOUT	<XP M.RPLT,*@>,N
>				;END REPEAT 0
REPEAT 1,<			;DEFINE PTP, PTR, PLT SYMBOLS
	FILOUT	<XP M.RPTP,0@>
	FILOUT	<XP M.RPTR,0@>
	FILOUT	<XP M.RPLT,0@>
>

	FILOUT	<XP M.RDX,*@>,N
	FILOUT	<XP M.RJOB,*@>,N

	MOVEI	N,SM.CONN/2	;DEFAULT TO HALF THE MAX.
	ASKDEC	<# of connects(*,1-512)[
Maximum number of simultaneous connections.]>,N
	FILOUT	<XP M.CONN,*@>
	JRST	NETEND
NETNON:				;DEFINE ALL SYMBOLS AS ZERO
	FILOUT	<XP M.NODE,0@>
	FILOUT	<XP M.DC75,0@>
	FILCPU	<XP M.0D85,0@>
	FILCPU	<XP M.1D85,0@>
	FILCPU	<XP M.2D85,0@>
	FILCPU	<XP M.3D85,0@>
	FILCPU	<XP M.4D85,0@>
	FILCPU	<XP M.5D85,0@>
	FILCPU	<XP M.6D85,0@>
	FILCPU	<XP M.7D85,0@>
	FILCPU	<XP M.8D85,0@>
	FILCPU	<XP M.9D85,0@>
	FILCPU	<XP M.AD85,0@>
	FILCPU	<XP M.BD85,0@>
	FILOUT	<XP M.D87S,0@>
	FILCPU	<XP M.D87S,0@>
	FILCPU	<XP M.0D8S,0@>
	FILCPU	<XP M.1D8S,0@>
	FILCPU	<XP M.2D8S,0@>
	FILCPU	<XP M.3D8S,0@>
	FILOUT	<XP OURNNM,0@>
	FILSTR	<@DEFINE SYSNDE<>@>
	FILOUT	<XP M.CONN,0@>
	FILOUT	<XP M.RMCR,0@>
	FILOUT	<XP M.RVTM,0@>
	FILOUT	<XP M.RCDR,0@>
	FILOUT	<XP M.RLPT,0@>
	FILOUT	<XP M.RPTR,0@>
	FILOUT	<XP M.RPTP,0@>
	FILOUT	<XP M.RJOB,0@>
	FILOUT	<XP M.RDX,0@>
NETEND:	POPJ	P,		;END OF NETGEN, RETURN AND CLOSE FILES
ASK85S:	MOVE	N,P1		;GET FRONT END #
	TTYOCT	<For front end number *:@>;identify which PDP11
	JUMPN	P2,ASK851	;DO RIGHT MESSAGE FOR DL10/DTE-20
	ASKDEC	<To which DL10 port is the DC75 or DN87 connected (0,0-7)[]>;ask port
	JRST	ASK852		;SKIP DTE-20 QUESTION

ASK851:	ASKDEC	<To which DTE20 is the DN87S/DN20 connected (1,1-3)[]>
ASK852:	MOVE	T1,N		;use answer as index
	MOVEI	N,1		;value to set word M.nD85 to
	MOVEM	N,M.0D85(T1)	;set word to 1 indicating port in use as 85
	POPJ	P,		;return
SUBTTL	TTYGEN - DIALOG TO DEFINE TERMINAL CONFIGURATION


TTYGEN:	FILOUT	<SUBTTL	TTYCNF - TERMINAL CONFIGURATION DEFINITION FILE OUTPUT BY MONGEN@@@>
	FILOUT	<DEFINE XP(A,B),<A==:B>@@@>
	MOVEI	N,VERSION	;MONGEN VERION NO.
	FILOUT	<XP M.TTY,*@>,N	;OUTPUT TO FILE FOR COMMON TO CHECK
IFE FTUNSUPPORTED,<
	MOVEI	N,1
>
IFN FTUNSUPPORTED,<
	MOVEI	N,SM.CPU
	ASKDEC	<Cpu's(1,1-*)[Total number of cpu's in the system]>
>
	MOVEM	N,M.CPU
	SETOM	CPUN
ASKTT1:	AOS	T1,CPUN
	CAML	T1,M.CPU
	JRST	ASKOPR
	MOVE	N,CPUN
ASKHRD:
IFN FTUNSUPPORTED,<
	ASKDEC	<How many DC10s on CPU*(1,0-2)[
The DC10 is a data line scanner]>
>
IFE FTUNSUPPORTED,<
	MOVEI	N,0		;NO DC10S
>
	SKIPN	CPUN
	MOVEM	N,M.DC10
	MOVE	N,CPUN
IFN FTUNSUPPORTED,<
	ASKDEC	<How many DC68s on CPU*(1,0-2)[
The DC68 is a PDP-8 680 or 680I communications system]>
>
IFE FTUNSUPPORTED,<
	MOVEI	N,0		;NO DC68S
>
	SKIPN	CPUN
	MOVEM	N,M.DC68
	MOVE	N,CPUN
IFN FTUNSUPPORTED,<
	ASKDEC	<How many DC76s on CPU*(1,0-8)[
The DC76 is a PDP-11 communications system]>
>
IFE FTUNSUPPORTED,<
	MOVEI	N,0		;NO DC76S
>
	SKIPE	CPUN
	JRST	ASKTT1
	MOVEM	N,M.DC76
	FILOUT	<XP M.DC10,*@>,M.DC10
	FILOUT	<XP M.DC68,*@>,M.DC68
	FILOUT	<XP M.DC76,*@>,M.DC76
	FILOUD	<XP MD.DCS,*@>,MD.DCS
	SKIPN	M.DC10		;HAVE A DC10?
	JRST	ASK68		;NO--DO NOT ASK ABOUT IT
ASKDG:	SKIPN	M.DC10		;ANY DC10 HARDWARE?
	JRST	ASK68
	PUSH	P,[0]		;ASK ABOUT DC10 #0
	PUSHJ	P,ASKDCX	; ..
	AOS	(P)		;ASK ABOUT DC10 #1
	MOVE	N,M.DC10	;GET # OF DC10'S
	CAME	N,(P)		;ALL DONE
	PUSHJ	P,ASKDCX	; ..
	POP	P,(P)		;CLEAN UP THE STACK

ASK68:	SKIPN	M.DC68		;ANY DC68 HARDWARE
	JRST	ASK76		;NO--ASK ABOUT DC76
	PUSH	P,[0]		;ASK ABOUT DC68 #0
	PUSHJ	P,ASKD68	; ..
	AOS	(P)		;ASK ABOUT DC68 #1
	SOSE	M.DC68		; IF THERE ARE 2 DC10'S
	PUSHJ	P,ASKD68	; ..
	POP	P,(P)		;CLEAN UP THE STACK
ASK76:	SKIPN	M.DC76		;HAVE A DC76?
	JRST	ASKH3		;NO--DO NOT ASK DC76 QUESTIONS
	PUSH	P,[0]
	PUSHJ	P,ASKD76
	AOS	(P)
	SOSE	M.DC76
	JRST	.-3
	POP	P,(P)
	JRST	ASKH3
TKSGEN:	FILOUT	<XP M.DC10,0@>
	FILOUT	<XP M.DC68,0@>
	FILOUT	<XP M.DC76,0@>
	FILOUT	<XP MD.DCS,0@>
	ASKDEC	<TTY lines(0-32)[Total number of TTY lines]>,N
	MOVEM	N,M.DZNL
ASKH3:	FILOUT	<XP M.D70N,*@>,M.D70N
	FILOUT	<XP M.D71N,*@>,M.D71N
	FILOUT	<XP M.D72N,*@>,M.D72N
	FILOUT	<XP M.D73N,*@>,M.D73N
	FILOUT	<XP M.D74N,*@>,M.D74N
	FILOUT	<XP M.D75N,*@>,M.D75N
	FILOUT	<XP M.D76N,*@>,M.D76N
	FILOUT	<XP M.D77N,*@>,M.D77N
	FILOUT	<XP M.D78N,0@>	;DUMMY SYMBOLS SINCE DC76 ONLY ON DL10
	FILOUT	<XP M.D79N,0@>
	FILOUT	<XP M.D7AN,0@>
	FILOUT	<XP M.D7BN,0@>
	FILOUT	<XP M.TTG0,*@>,M.TTG0
	FILOUT	<XP M.TTG1,*@>,M.TTG1
	FILOUT	<XP M.DSG0,*@>,M.DSG0
	FILOUT	<XP M.DSG1,*@>,M.DSG1
	FILOUT	<XP M.68L0,*@>,M.68L0
	FILOUT	<XP M.68L1,*@>,M.68L1
	FILOUT	<XP M.DZNL,*@>,M.DZNL
	FILCPU	<XP M.DZNL,*@>,M.DZNL


	MOVE	N,M.TTG0	;NUMBER OF 8-LINE GROUPS
	ADD	N,M.TTG1	; PLUS NUMBER OF LINES ON DC10 #1
	LSH	N,3		;TIMES 8=NUMBER OF LINES
	ADD	N,M.D70N	;PLUS LINES ON DC76
	ADD	N,M.D71N
	ADD	N,M.D72N
	ADD	N,M.D73N
	ADD	N,M.D74N
	ADD	N,M.D75N
	ADD	N,M.D76N
	ADD	N,M.D77N
	ADD	N,M.DZNL
	ADD	N,M.68L0	;PLUS LINES ON DC68
	ADD	N,M.68L1	; = TOTAL NUMBER OF LINES
	FILOUT	<XP M.TLTL,* ;TOTAL LOCAL TTY LINES@@>
	JRST	ASKTT1
ASKOPR:	SKIPE	M.KL10		;KL10?
	MOVEI	N,^D512		;YES--CAN'T COMPUTE MAX LINE FOR OPR
				; AS M.TTDN DEFINED FORM HDWGEN
	SOJ	N,		;ADJUST TO GET HIGHEST LINE
	MOVE	N,[SIXBIT/CTY/]
	FILOUT	<DEFINE	OPRLIN>
	PUSHJ	P,FILLAB
	FILOUT	<@	OPRL	*@>,N
	PUSHJ	P,FILRAB
	FILOUT	<@>
ASKDSD:	FILOUT	<DEFINE	MACDSD>	;START MACRO DEFINITION
	PUSHJ	P,FILLAB
	PUSHJ	P,FILRAB
ASKTBS:	FILOUT	<DEFINE	MACTAB>	;START MACRO DEFINITION
	PUSHJ	P,FILLAB
	PUSHJ	P,FILRAB
ASKRMT:	FILOUT	<DEFINE	MACRMT>	;START MACRO DEFINITION
	PUSHJ	P,FILLAB
	PUSHJ	P,FILRAB
ASKLCP:	FILOUT	<DEFINE	MACLCP>	;START MACRO DEFINITION
	PUSHJ	P,FILLAB
	PUSHJ	P,FILRAB
ASKHLF:	FILOUT	<DEFINE	MACHLF>	;START MACRO DEFINITION
	PUSHJ	P,FILLAB
	PUSHJ	P,FILRAB
ASKSLV:	FILOUT	<DEFINE	MACSLV>
	PUSHJ	P,FILLAB
	PUSHJ	P,FILRAB
ASKFRM:	FILOUT	<DEFINE	MACFRM>
	PUSHJ	P,FILLAB
	PUSHJ	P,FILRAB
ASKINI:	FILOUT	<DEFINE	MACINI>
	PUSHJ	P,FILLAB
	FILOUT	<@L CTY@>	;ALWAYS INITIALIZE CTY
	PUSH	P,N		;SAVE STATUS OF N
	MOVE	N,SAVTYP	;GET SYSTEM TYPE
	JUMPE	N,NOTTDN	;IF 0 ASSUME 1090, DO NO MORE
	MOVE	N,SAVTTY	;GET THE SAVED NUMBER OF TTYS
	FILOUT	<@L 4,*@>,N	;INITIALIZE THESE LINES
NOTTDN:	POP	P,N		;RESTORE ORIG N
	PUSHJ	P,FILRAB
ASKFLC:	FILOUT	<DEFINE	MACFLC>
	PUSHJ	P,FILLAB
	PUSHJ	P,FILRAB
ASKBCD:	SKIPE	M.DC10		;IS THERE A DC-10 INTERFACE
	JRST	ASKBC0		;(YES) GET 2741 LINES
	FILOUT	<DEFINE MACDIS<>>
	JRST	TTYEND		;THAT'S ALL
ASKBC0:	FILOUT	<DEFINE MACDIS>
	ASKMN	<2741 lines on DC-10 interfaces[]@>
TTYEND:	POPJ	P,		;END TTYGEN,RETURN AND CLOSE FILES

;SUBROUTINE TO ASK ABOUT DC10 HARDWARE
;CALL WITH:
;	PUSHJ	P,[DC10 NUMBER]
;	PUSHJ	P,ASKDCX

ASKDCX:	MOVE	N,-1(P)		;PICK UP DC10 NUMBER
	TTYOCT	<@For DC10 *:@@>
	MOVEI	N,SM.TTG	;MAX TTY GROUPS
	ASKDEC	<# DC10B[ or 632] 8 line data groups(1-*)[
1 is TTY0-7, 2 is TTY0 - 17, ... 8 is TTY0 - 77]>
	MOVE	T1,-1(P)	;STORE FOR CORRECT DC10
	MOVEM	N,M.TTG0(T1)	; ..
	ASKDEC	<# DC10E Data set control groups(0-*)>
	MOVE	T1,-1(P)
	MOVEM	N,M.DSG0(T1)	;STORE FOR CORRECT DC10


ASKCRR:	MOVE	N,-1(P)		;WHICH DC10
	FILOUT	<DEFINE	MACCR*>
	MOVE	T1,-1(P)
	SKIPN	M.DSG0(T1)	;DATA SETS?
	JRST	ASKCR1		;NO, SKIP THIS QUESTION
	ASKMNP	<Correspondence of DC10E lines to the DC10B lines(M-N,P)[
Type M,P for one pair and M-N,P for a range of pairs
where M is octal DC10E line, M-N is octal range of DC10E
lines, and P is octal DC10B line]@>
	POPJ	P,0		;RETURN
ASKCR1:	PUSHJ	P,FILLAB	;OUTPUT NULL MACRO IF DIDNT ASK
	PJRST	FILRAB		;FINISH MACRO IF DIDNT ASK
;SUBROUTINE TO ASK ABOUT DC68 LINES
;CALL WITH:
;	PUSH	P,[DC68 NUMBER]
;	PUSHJ	P,ASKD68

ASKD68:	MOVE	N,-1(P)
	TTYOCT	<@FOR DC68 *:@@>
	MOVEI	N,SM.68L
	ASKOCT	<# Octal lines on DC68, including its console TTY(1-*)>
	MOVE	T1,-1(P)
	MOVEM	N,M.68L0(T1)
	POPJ	P,
;SUBROUTINE TO ASK ABOUT A DC76
;CALL WITH
;	PUSH	P,[DC76 NUMBER]
;	PUSHJ	P,ASKD76

ASKD76:	MOVE	N,-1(P)
	TTYOCT	<@For DC76 *:@@>
	ASKDEC	<Which DL10 port is the DC76 connected to(0,1-7)[Each PDP-11
is connected to a DL10 port. If there is only one -11 it
is always connected to port 0. If there are 2 -11's one is
connected to port 0 and the other to port 1]>
	PUSH	P,N
	ASKDEC	<Decimal lines on DC76(1-129)[
Each DC76F is 16 lines and the console teletype is
one line. A DC76 with 2 DC76Fs has 33 lines]>
	MOVE	T1,(P)
	MOVEM	N,M.D70N(T1)
	POP	P,(P)
	POPJ	P,0
SUBTTL	ASK ROUTINES - ASK QUESTION ON TTY, FILE AND GET ANSWER

;LSTEXP - ROUTINE TO DO LIST OR EXPLAIN MODE FOR FGEN
;CALL:	MOVEI	N,1 OR 2 FOR LIST OR EXPLAIN
;	PUSHJ	P,LSTEXP
;	RETURNS WHEN DONE

LSTEXP:	CAIE	N,1		;SKIP IF LIST, NOT IF EXPLAIN
	TLOA	F,(F.EXP)	;SET EXPLAIN FLAG FOR EXPLAIN
	TLZ	F,(F.EXP)	;CLEAR EXPLAIN FLAG FOR LIST
ASKLEX:	TTYOUT	<Switch(switch to list or explain)[
Type name of switch to be listed or explained or ALL or /HELP.
Type extra carriage return when through.]@@>
LEXLOP:	PUSHJ	P,TTYIN		;GET SWITCH TYPED
	  JRST	ASKLEX		;/HELP TYPED
	JUMPE	CH,LEXXIT	;EXIT IF BLANK LINE
	PUSHJ	P,GETWRD	;GET SWITCH NAME
	RJUMPN	CH,<MOVE N,WD	;;N=SWITCH NAME TYPED
		    TTYOUT <? Unknown switch *@>
		    JRST ASKLEX>
	CAMN	WD,[SIXBIT .ALL.]	;SKIP IF NOT "ALL"
	JRST	ALLLEX		;DO ALL SWITCHES IN TABLE AND EXIT
	PUSHJ	P,LEXSWT	;LIST OR EXPLAIN THIS SWITCH
	  JRST	ASKLEX		;ILLEGAL SWITCH, RETYPE PROMPT
	JRST	LEXLOP		;OK, WAIT FOR ANOTHER

LEXXIT:	MOVE	LV,SAVLV	;RESTORE PERMANENT HELP LEVEL
	POPJ	P,		;AND RETURN

;HERE IF WANT ALL SWITCHES
ALLLEX:	HRLZ	T1,FTLEN	;AOBJN PTR TO TABLE
ALLLE1:	PUSH	P,T1		;SAVE AOBJN PTR
	SKIPN	WD,@FTTAB	;SKIP IF HAVE A SWITCH HERE
	JRST	ALLLE2		;NO, IGNORE IT
	TLZ	WD,777700	;CLEAR JUNK
	TLO	WD,'FT '	;MAKE SWITCH BE FT...
	PUSHJ	P,LEXSWT	;LIST OR EXPLAIN THIS SWITCH
	  JFCL			;IGNORE ERRORS THAT SHOULDN'T HAPPEN
ALLLE2:	POP	P,T1		;RESTORE AOBJN PTR
	AOBJN	T1,ALLLE1	;LOOP FOR WHOLE TABLE
	POPJ	P,		;RETURN
;LEXSWT - ROUTINE TO LIST OR EXPLAIN ONE SWITCH
;CALL:	MOVE	WD,SWITCH NAME
;	PUSHJ	P,LEXSWT
;	RETURN HERE IF UNKNOWN SWITCH
;	RETURN HERE IF FOUND, LIST OR EXPLAIN DONE

LEXSWT:	HLRZ	N,WD		;N=FIRST THREE CHARS
	TRZ	N,77		;ONLY LOOK AT FIRST TWO
	CAIE	N,'FT '		;SKIP IF FT...
	RJRST	<MOVE N,WD
		 TTYOUT <? Unknown switch *@>
		 POPJ P,>
	TLZ	WD,777700	;CLEAR UNWANTED JUNK
	RJUMPE	WD,<TTYOUT <? Unknown switch@>
		    POPJ P,>
	PUSHJ	P,FNDSWT	;FIND SWITCH IN TABLE
	MOVE	N,WD		;N=SWITCH NAME, WT1=INDEX IN TABLE
	TLO	N,'FT '		;ADD BACK "FT"
	RJUMPGE	T1,<TTYOUT <? Unknown switch *@>
		    POPJ P,>
	PUSH	P,N		;SAVE NAME OF SWITCH IN CASE EXPLAINING
	SKIPL	@FTTAB		;SKIP IF VALUE IS ON
	JRST	LEXSW1		;NO, SWITCH IS OFF
	TTYOUT	<*,-1>
	JRST	LEXSW2
LEXSW1:	TTYOUT	<*,0>
LEXSW2:	POP	P,WD		;RESTORE NAME OF SWITCH TO LOOKUP EXPLANATION
	AOS	(P)		;OK, GIVE SKIP RETURN AND FINISH UP
	TLNE	F,(F.EXP)	;SKIP IF LIST, NOT IF EXPLAIN
	PJRST	LEXSW3		;DO EXPLAIN
	TTYOUT	<@>
	POPJ	P,

;HERE TO EXPLAIN SWITCH
;HERE TO POSITION FGEN HELP FILE AT EXPLANATION FOR THIS SWITCH, WD IS SET UP
LEXSW3:	FHLPOS	*,LEXSWE
	PUSHJ	P,FHLPTT	;COPY TO TTY
LEXSWE:	TTYOUT	<@>
	POPJ	P,		;RETURN
;FNDSWT - ROUTINE TO FIND A SWITCH IN THE TABLE
;CALL:	MOVE	WD, SWITCH NAME WITH "FT" CLEARED
;	PUSHJ	P,FNDSWT
;	RETURN	N=INDEX OF SWITCH IN TABLE, OR GE 0 IF NOT IN TABLE

FNDSWT:	HRLZ	T1,FTLEN	;AOBJN PTR TO SWITCH TABLE

FNDSW1:	HRLOI	N,77		;N=MASK FOR 4 CHARS
	AND	N,@FTTAB	;N=NEXT SWITCH NAME IN TABLE
	CAME	N,WD		;SKIP IF FOUND MATCH
	AOBJN	T1,FNDSW1	;NO, TRY NEXT IN TABLE
	POPJ	P,
;ASKSYS - ROUTINE TO FIND OUT WHAT TYPE OF SYSTEM
;CALL:	PUSHJ	P,ASKSYS
;	RETURN	N=INDEX OF TYPE OF SYSTEM

ASKSYS:	ASKYN	<DO YOU HAVE A KL10E? (Y,N)>
	MOVEM	N,SAVTYP	;SAVE TYPE OF SYSTEM FOR LATER USE
				;0=1090, 1=1091
	ADDI	N,2		;POSITION RESPONSE TO BE 1090 OR 1091
	MOVEM	N,CNFIND	;SAVE INDEX OF SYSTEM TYPE
	AOS	M.1070(N)	;SET ONE OF THE VARIABLES TO 1
				; M.1070, M.1080, M.1090, M.1091, M.2020
	CAIE	N,4		;2020?
	JRST	ASKSY1		;NO--GO ON
	AOS	M.KS10		;YES--SET RIGHT FLAG
	POPJ	P,		;RETURN
ASKSY1:	SKIPN	N
	AOSA	M.P10I
	AOS	M.KL10
	POPJ	P,		;RETURN
;ASKYN - ROUTINE TO ASK AND ACCEPT A Y OR N ANSWER
; USED WHEN ONLY CHOICE OF PRESENCE OR ABSENCE IS POSSIBLE
;CALL:	ASKYN	<...(Y,N)[...]>
;	RETURN	N=1 IF Y, N=0 IF N
; NOTE: (Y,N) MUST BE IN THIS ORDER, SO USER KNOWS DEFAULT ALWAYS IS Y

ASKYN:	PUSHJ	P,ASKLS1	;ASK QUESTION, GET ANSWER POSITION IN N
	MOVS	T1,ASKTAB+0	;IS FIRST PROMPT
	CAIE	T1,'Y  '	;Y FOR YES?
	JRST	ASKYNE		;NO, ERROR
	MOVS	T1,ASKTAB+1	;YES, IS SECOND PROMPT
	SKIPN	ASKTAB+2	;ARE THERE MORE THAN TWO CHOICES?
	CAIE	T1,'N  '	;NO, IS IT N?
ASKYNE:	RJRST	<EREXIT	<ASKYN called without (Y,N) in above message>,>
	JUMPE	N,ASKY		;FIRST ITEM IN LIST(Y)?

;HERE ON N ANSWER
	TDZA	N,N		;RETURN 0

;HERE ON Y ANSWER
ASKY:	MOVEI	N,1		;RETURN 1
	POPJ	P,
;ROUTINE TO ASK QUESTON WITH PROMPTING ANSWERS IN A LIST IN PARENS
;CALL:	ASKLST	<...(ANS0,ASN1,ANS2,...)[...]>
;	RETURN HERE WITH N=0,1,2,...
;	IF JUST CR TYPED, N=0 TO MEAN FIRST ITEM BY DEFAULT
;ABBREVIATIONS ARE ALLOWED LIKE MONITOR COMMANDS
; IF WRONG ANSWER IS GIVEN, THE FOLLOWING ERROR MESSAGE IS TYPED:
; ? ANSWER MUST BE ONE OF (ANS0,ANS1,ANS2,...)
; FOLLOWED BY A REPEAT OF QUESTION IN NEXT LONGEST MODE
;IF A LIST OF PROMPTINGS IS NOT INCLUDED IN PARENS,
; ? INTERNAL MONGEN ERROR  - NO CHOICES IN PARENS - EDIT MONGEN


ASKLST:	PUSHJ	P,ASKLS1	;ASK AND GET ANSWER
	MOVS	T1,ASKTAB+0	;IS FIRST PROMPT
	CAIE	T1,'Y  '	;Y
	CAIN	T1,'N  '	; OR N?
	JRST	ASKLSE		;YES, ERROR SHOULD USE ASKYL INSTEAD
	MOVS	T1,ASKTAB+1	;IS SECOND PROMPT
	CAIE	T1,'Y  '	;Y
	CAIN	T1,'N  '	;OR N?
ASKLSE:	RJRST	<EREXIT	<ASKLST called with (Y,N) in above question
- Edit MONGEN to call ASKYN instead of ASKLST@>,>
	POPJ	P,		;RETURN WITH N SET TO POSITION OF ANSWER

;SUBROUTINE TO DO THE WORK OF ASKING AND GETTING ANSWER.
;CALLED BY ASKLST AND ASKYN

ASKLS1:	MOVEI	R,^D10		;SET RADIX TO 10(IN CASE * SUBS.)
	PUSHJ	P,ASKBG		;STANDARD ASK ROUTINE BEGINNING
				; SAVE ADR OF QUESTION AND N ON STACK, OUTPUT CRLF
				; TO FILE, OUTPUT QUESTION AS COMMENT TO FILE

;LOOP TO ASK QUESTION OVER AGAIN AFTER ERROR OR /HELP
ASKOVR:	MOVE	N,(P)		;REESTORE ORIGINAL N INCASE THIS IS LOOP
				; SO * SUBSTITUTION WILL BE THE SAME
	HRRZ	T1,-1(P)	;ADR OF MESSAGE
	PUSHJ	P,TTROUT	;OUTPUT TO TTY
	HRRZ	T1,-1(P)	;ADR OF ASK MESSAGE
	PUSHJ	P,SETASK	;SET UP LIST OF CHOICES IN ASKTAB
				; FROM SCANNING LIST OF PROMPTINGS
	PUSHJ	P,TTYIN		;ASK FOR INPUT LINE, OUTPUT TO FILE AS COMMENT
	  JRST	ASKOVR		;/HELP TYPED, REASK IN DESIRED HELP MODE
	PUSHJ	P,FNDASK	;NO, LOOK FOR HIS ANSWER IN ASKTAB
	  AOJA	LV,ASKOVR	;NOT THERE, ASK QUESTION AGAIN WITH MORE HELP
				; BY MAKIN LEVEL ONE HIGHER
	JRST	ASKXIT		;FOUND, RESTORE LEVEL
				; TO THAT BEFORE QUESTION AND RETURN
;ROUTINE TO SCAN MESSAGE FOR PROMPTING ANSWERS
;CALL:	MOVEI	T1,ADR OF ASCIZ STRING
;	PUSHJ	P,SETLST
;	  RETURN ONLY IF ANSWERS IN PARENS FOUND
;	ELSE PRINT ? INTERNAL MONGEN ERROR - NO ( IN ABOVE MESSAGE,
; ADD (ANS0,ASN1,ASN2...) TO MONGEN BY EDITING
; B IS PRESERVED

SETASK:	HRLI	T1,440700	;FORM LH OF BYTE POINTER
	PUSH	P,B		;SAVE BYTE POINTER(NOT AN ARGUMENT)
				; CALLER MAY HAVE SOMETHING IN IT
	PUSH	P,N		;SAVE POSSIBLE SUBSTITUTION

;LOOP TO FIND LEFT PAREN
ASK0:	ILDB	CH,T1		;GET NEXT CHAR IN ASK MESSAGE
	RJUMPE	CH,<EREXIT <? No (ANS0,ASN1,...) in above question - Edit MONGEN>,>
	CAIE	CH,"("		;LEFT PAREN?
	JRST	ASK0		;NO, KEEP LOOKING
	MOVEI	N,0		;SET ANSWER INDEX TO 0
	MOVE	B,T1		;SETYUP BYTE POINTER TO PROMPTING LIST FOR GETWRD

;LOOP TO BREAK PROMPTING ANSWERS - N=0,1,... FOR EACH ANSWER
ASK2:	PUSHJ	P,GETWRD	;GET NEXT WORD INSIDE PARENS
	CAIE	CH,"*"		;SKIP IF WANT SUBSTITUTION
	JRST	ASK2A		;NO, KEEP CHECKING
	JUMPN	WD,ASK2E	;JUMP IF SOMETHING PRECEEDED *, ERROR
	MOVE	WD,(P)		;RESTORE SUBSTITUTION
ASK2A:	MOVEM	WD,ASKTAB(N)	;ANS STORE ANSWER AWAY
	CAILE	N,MP.AMX	;MORE THAN MAX. NO. OF ANSWERS FOR MONGEN?
	RJRST	<EREXIT <Too many prompts in above question - Edit MONGEN@>,>
	CAIN	CH,","		;WAS BREAK CHAR A COMMA?
	AOJA	N,ASK2		;YES, GO BACK AND GET NEXT PROMPTING WORD
	SETZM	ASKTAB+1(N)	;CLEAR LAST ARG PLUS 1 AS END FLAG
	POP	P,N		;RESTORE N
	POP	P,B		;RESTORE CALLERS BYTE POINTER
	CAIN	CH,")"		;NO, WAS BREAK RIGHT PAREN?
	POPJ	P,		;YES, RETURN
ASK3E:	EREXIT	<Special character inside () above
Edit MONGEN and remove it.>,

ASK2E:	EREXIT	<Error in above question - Edit MONGEN@>,
;ROUTINE TO FIND ONE OF A LIST OF ANSWERS IN ASKTAB USING ASCIZ STRING
;CALL:	MOVE	POSSIBLE ANSWERS TO ASKTAB+0,+1,... STORE 0 IN LAST+1
;				(SEE SETASK ROUTINE)
;	MOVE	B,BYTE POINTER TO ASCIZ STRING
;	PUSHJ	P,FNDASK(BREAK = CR) OR FNDAS1(BREAK = ANY)
;	  NOT FOUND RETURN, ERROR MESSAGE PRINTED
;	OK RETURN, N = POSITION OF ANSWER IN LIST = 0,1,2
;	N=0 IF JUST A CR TYPED
; ALLOW 0 IN ASKTAB+0 AS LEGAL ANSWER TO MEAN NO DEFAULT

FNDAS1:	PUSHJ	P,GETWRD	;GET USER SUPPLIED ANSWER
	JRST	FNDAS2		;SKIP CHECK FOR BREAK MUST BE EOL

FNDASK:	PUSHJ	P,GETWRD	;GET USER SUPPLIED ANSWER
	RJUMPN	CH,<TTYOUT <? Type one answer followed by carriage return@>
		popj p,>	;error return, so ask question again
FNDAS2:	TLZ	F,(F.MTCH)	;CLEAR MATCH FOUND FLAG
	SETZB	N,SAVN		;SET ANSWER INDEX TO 0
	JUMPE	WD,ASK8		;JUST A CR TYPED?
	MOVEI	T1,0		;NO, FORM MASK FOR ABBREVIATION
ASK5:	ROT	T1,6		;MOVE MASK LEFT 1 CHAR POSITION
	IORI	T1,77		;SET LOW ORDER CHAR MASK
	TDNN	WD,T1		;ANY CHARS IN THESE LOW ORDER POSITIONS?
	JRST	ASK5		;NO, LOOK AT NEXT CHAR TO LEFT
	LSH	T1,-6		;YES, MOVE MASK SO ONLY COVERS CHARS NOT TYPED
	MOVE	T2,ASKTAB(N)	;GET FIRST POSSIBLE ANSWER. MAYBE 0 IF
				; NO DEFAULT ALLOWED, IE (,ANS0,ANS1,...)

;LOOP TO SCAN FOR MATCH WITH PROMPTING ANSWERS STORED IN ASKTAB
ASK6:	CAMN	T2,WD		;SKIP IF NOT EXACT MATCH
	JRST	ASK9		;YES, TAKE THIS IMMEDIATELY
	TDZ	T2,T1		;CLEAR OUT CHARS USER DID NOT TYPE
	CAME	T2,WD		;MATCH THE CHARS HE DID TYPE?
	JRST	ASK7		;NO, GO GET NEXT ANSWER
	MOVEM	N,SAVN		;YES, SAVE ANSWER INDEX
	TLOE	F,(F.MTCH)	;ALREADY FOUND A MATCH?
	RJRST	<TTYOUT	<? Type enough to uniquely distinguish answer@>
		 POPJ	P,>	;ERROR RETURN
ASK7:	SKIPE	T2,ASKTAB+1(N)	;GET NEXT PROMPT, IS THERE ONE?
	AOJA	N,ASK6		;YES, BUMP ANSWER INDEX
	TLNN	F,(F.MTCH)	;NO, WAS A MATCH FOUND?
	RJRST	<TTYOUT	<? Answer with one of the choices inside parens@>
		 POPJ	P,>	;ERROR RETURN
ASK8:	MOVE	N,SAVN		;YES, RETURN THE MATCH INDEX
ASK9:	SKIPN	ASKTAB(N)	;SKIP IF DEFAULT ALLOWED
	RJRST	<TTYOUT <? No default allowed@>
		POPJ P,>
	JRST	CPOPJ1		;GIVE OK RETURN
;ROUTINE TO ASK QUESTION AND GET DECIMAL ANSWER AND CHECK FOR LIMITS
;CALL:	ASKDEC	<QUESTION(DEFAULT,MIN-MAX)[...]>
;	RETURN HERE WITH N AS VALUE OF ANSWER, CR ASSUMES DEFAULT

ASKDEC:	MOVEI	R,12		;SET RADIX TO DECIMAL
	JRST	ASKNUM		;GO ASK QUESTION AND CHECK ANSWER

;ROUTINE TO ASK QUESTION AND GET OCTAL LINE NUMBER OR CTY
;CALL:	ASKLIN	<QUESTION(DEFAULT,MIN-MAX)[...]>
;	RETURN HERE WITH N AS VALUE OR 'CTY', CR ASSUMES DEFAULT

ASKLIN:	MOVEI	R,10		;SET RADIX TO OCTAL
	TLO	F,(F.CTY)	;FLAG THAT CTY IS OK OCTAL NUMBER
	JRST	ASKNM1		;ASK QUESTION, ETC

;ROUTINE TO ASK QUESTION AND GET OCTAL ANSWER AND CHECK FOR LIMITS
;CALL:	SAME AS ASKDEC, EXCEPT ANSWER CONVERTED AS OCTAL

ASKOCT:	MOVEI	R,10		;SET RADIX TO OCTAL
ASKNUM:	TLZ	F,(F.CTY)	;FLAG THAT CTY IS NOT ACCEPTABLE NUMBER
ASKNM1:	PUSHJ	P,ASKBG		;STANDARD ASK ROUTINE BEGINNING
				; SAVE ADR OF QUESTION AND N ON STACK, OUTPUT CRLF
				; TO FILE, OUTPUT QUESTION AS COMMENT TO FILE

;LOOP TO ASK QUESTON AGAIN IF SYNTAX ERROR OR OUT OF RANGE OR /HELP
ASKAGN:	MOVE	N,(P)		;REESTORE ORIGINAL N IN CASE THIS IS LOOP
				; SO * SUBSTITUTION WILL BE THE SAME
	HRRZ	T1,-1(P)	;ADR OF MESSAGE
	PUSHJ	P,TTROUT	;ASK USER ON TTY
	SETOM	DFAULT		;SET DEFAULT TO NONE FOUND YET
				; USER CANNOT TYPE IN -1
	SETZM	MINLIM		;SET MIN LIMIT TO 0
	MOVSI	T1,'?  '	;SET MAX LIMIT TO BIG POS. NO.
				; WHICH WILL ALSO PRINT IF BELOW MIN
	MOVEM	T1,MAXLIM	;TO VERY BIG NUMBER
	HRRZ	B,-1(P)		;ADR OF QUESTION
	HRLI	B,440700	;FORM BYTE POINTER TO IT

;LOOP TO FIND FIRST PAREN
ASKN0:	ILDB	CH,B		;GET NEXT CHAR
	JUMPE	CH,ASKN2	;ERROR IF END OF STRING FOUND
	CAIE	CH,"("		;LEFT PAREN?
	JRST	ASKN0		;NO, KEEP LOOKING
;LOOP TO LOOK FOR DEFAULT, MIN AND MAX INSIDE PARENS
ASKN1:	PUSHJ	P,GETNUM	;GET NUMERIC FIELD
ASKN1B:	CAIE	CH,"*"		;SKIP IF * FOUND
	JRST	ASKN1C		;NO, PROCEED
	JUMPN	N,ASKN2		;JUMP IF SOMETHING BEFORE THE *
	MOVE	N,(P)		;PICK UP VALUE FOR SUBSTITUTION
	PUSHJ	P,SKBLNK	;SKIP TO NEXT TERMINATOR
	JRST	ASKN1B		;AND LOOP
ASKN1C:	CAIN	CH,"-"		;DASH TO SEPARATE MIN-MAX
	JRST	ASKN3		;YES, FOUND MIN
	CAIN	CH,"C"+40	;IS IT LOWER CASE C?
	TRC	CH,40		;YES, CONVERT IT
	CAIE	CH,"C"		;YES, AND IS BREAK A C?
	JRST	ASKN1A		;NO, GO CHECK OTHER BREAK CHARS
	JUMPN	N,ASKN2		;JUMP IF SOMETHING BEFORE THE *
	PUSHJ	P,GETWRD	;YES, GET REST OF WORD
	MOVEI	N,'CR '		;GET READY IF CR TO STORE CR AS DEFAULT
	CAME	WD,[SIXBIT /R/]	;IS IT R AFTER C?
				;YES,  STORE DEFAULT CR
	TLNN	F,(F.CTY)	;NOT CR, IS CTY A LEGAL ANSWER?
	JRST	ASKN1A		;NO, GO CHECK OTHER BREAKS
	CAME	WD,[SIXBIT /TY/] ;IS REST OF WORD "TY"?
	JRST	ASKN2		;NO, PRINT ERROR
	MOVEI	N,'CTY'		;STORE ARG AS TYPED
ASKN1A:	SKIPGE	DFAULT		;ALREADY STORED DEFAULT?
	MOVEM	N,DFAULT	;NO, STORE DEFAULT, IN CASE JUST TYPES CR
	CAIN	CH,")"		;IS THIS THE ONLY NUMBER
	JRST	ASKN4		;YES, GO GET USER ANSWER
	CAIN	CH,","		;IS BREAK A COMMA?
	JRST	ASKN1		;YES, GO GET NEXT NUMBER IN LIST
ASKN2:	EREXIT	<Above question must have(...,min-max) - Edit MONGEN>,
;HERE WHEN MIN FOUND
ASKN3:	MOVEM	N,MINLIM	;STORE MINIMUM LIMIT
	PUSHJ	P,GETNUM	;GET NEXT NUMBER
	CAIN	CH,"?"		;NO MAX SPECIFIED?
	JRST	ASKN3A		;YES, SET TO INFINITY
	CAIE	CH,"*"		;NO, IS MAX. SUBSTITUTABLE ARG?
	JRST	ASKN3B		;NO, GO CHECK FOR RIGHT PAREN
	SKIPA	N,(P)		;YES, USE VALUE WHICH WAS SUBSTITUTED
ASKN3A:	MOVSI	N,'?  '		;SET MAX TO PLUS INFINITY
	PUSHJ	P,SKBLNK	;SKIP TO NEXT NON-BLANK
ASKN3B:	CAIE	CH,")"		;BETTER BE RIGHT PAREN
	JRST	ASKN2		;NO, ERROR
	MOVEM	N,MAXLIM	;STORE MAX LIMIT

;HERE WHEN FIRST () ALL SCANNED FOR DEFAULT, MIN AND MAX
ASKN4:	PUSHJ	P,TTYIN		;GET USER ANSWER FROM TTY, OUTPUT TO FILE
				; AS COMMENT
	  JRST	ASKAGN		;/HELP TYPED, ASK AGAIN
	JUMPE	CH,ASKN5	;JRST CR TYPED?(GO USE DEFAULT IF YES)
	PUSHJ	P,GETNUM	;NO, GET NUMBER USER TYPED
	JUMPE	CH,ASKN5A	;END OF STRING?
	TLNN	F,(F.CTY)	;NO, IS CTY A POSSIBLE OCTAL NUMBER?
	RJRST	<TTYOUT	<? Type single number followed by carriage return@>
		 AOJA	LV,ASKAGN>  ;ASK AGAIN AT HIGHER LEVEL
	CAIN	CH,"C"+40	;IS IT LOWER CASE C?
	TRC	CH,40		;YES, CONVERT IT
	CAIE	CH,"C"		;YES, WAS BREAK C?
	JRST	ASKN4A		;NO, PRINT ERROR
	JUMPN	N,ASKN4A	;ERROR IF SOMETHING PRECEDED C
	PUSHJ	P,GETWRD	;YES, GET REST OF WORD
	CAMN	WD,[SIXBIT /TY/] ;IS WORD REST OF CTY?
	JRST	ASKN4B		;YES, ALLOW IT
ASKN4A:	RJRST	<TTYOCT	<? Type octal line number or CTY followed by carriage return@>
		 AOJA	LV,ASKAGN> ;ASK AGAIN AT HIGHER LEVEL
ASKN4B:	MOVSI	N,'CTY'		;RETURN LEFT JUSTFIED CTY AS OCTAL NO.
	JRST	ASKN6		;SKIP RANGE CHECK


;HERE IF JUST CR TYPED AS ANSWER, USE DEFAULT IF THERE IS ONE
ASKN5:	MOVS	N,DFAULT	;GET DEFAULT IF ONE SPECIFIED
	CAME	N,[SIXBIT /CR/]	;WAS DEFAULT CR?
	CAMN	N,[SIXBIT /CTY/] ;WAS DEFAULT CTY?
	JRST	ASKN6		;YES, BY PASS RANGE CHECK
	MOVSS	N		;RESTORE TO UNSWAPPED STATE
	RJUMPL	N,<TTYOUT <? No default allowed, type a number@>
		 AOJA	LV,ASKAGN> ;ASK AGAIN AT HIGHER LEVEL
;HERE TO CHECK RANGE OF ANSWER
ASKN5A:	CAMN	N,DFAULT	;SKIP IF NOT DEFAULT VALUE
	JRST	ASKN6		;IF DEFAULT NOT IN RANGE, MUST BE SPECIAL TERMINATOR
	CAML	N,MINLIM	;LESS THAN MIN?
	CAMLE	N,MAXLIM	;NO, EXCEED MAX?
	RJRST	<TTYOUT	<? Must be in range *>,MINLIM
	 	TTYOUT	<-*@>,MAXLIM
	 	AOJA	LV,ASKAGN>  ;ASK AGAIN AT NEXT LONGER MODE
ASKN6:	JRST	ASKXIT		;STANDARD ASK EXIT - RESTORE ORIGINAL
				; HELP LEVEL, POP QUESTION ADR, AND RETURN
;ROUTINE TO ASK QUESTION AND GET STRING FOR ANSWER
;CALL:	ASKSTR	<QUESTION*>,X

ASKSTR:	PUSHJ	P,ASKBG		;STANDARD ASK ROUTINE BEGINNING
				; SAVE ADR OF QUESTION AND N ON STACK, OUTPUT CRLF
				; TO FILE, OUTPUT QUESTION AS COMMENT TO FILE

;LOOP TO ASK QUESTION OVER AGAIN AFTER REQUEST FOR HELP
ASKST1:	MOVE	N,(P)		;RESTORE ORIGINAL N IN CASE THIS IS LOOP
				; SO * SUBSTITUTION WILL BE THE SAME
	HRRZ	T1,-1(P)	;ADDRESS OF MESSAGE
	PUSHJ	P,TTROUT	;TYPE IT ON TTY
	PUSHJ	P,TTYIN		;WAIT FOR INPUT, OUTPUT TO FILE
				; AS COMMENT
	  JRST	ASKST1		;/HELP TYPED, REASK AT DESIRED HELP MODE
	JRST	ASKXIT		;COMMON EXIT FROM ASK ROUTINES
				; POP OLD N AND QUESTION ADR, RESTORE HELP LEVEL
;ROUTINE TO ASK FOR M-N<EOL> OR M<EOL> ON REPEATED LINES UNTIL BLANK LINE
; SYNTAX AND OUTPUT TO FILE
;CALL:	FILOUT	<DEFINE	MAC???>	;START MACRO DEFINITION IN FILE
;	ASKMN	<ASK MESSAGE@>
;	RETURN WHEN ALL ANSWERS HAVE BEEN CHECKED AND OUTPUT

ASKMN:	MOVEI	R,^D8		;ASSUME OCTAL RADIX FOR IO
	PUSHJ	P,FILLAB	;OUTPUT LEFT ANGLE BRACKET, CRLF TO FILE
				; AS BEG OF MACRO DEFINITION
	PUSHJ	P,ASKBG		;STANDARD ASK ROUTINE BEGINNING
				; SAVE ADR OF QUESTION AND N ON STACK, OUTPUT CRLF
				; TO FILE, OUTPUT QUESTION AS COMMENT TO FILE

;LOOP TO ASK QUESTION IN CASE OF ERROR OR /HELP
ASKM0:	MOVE	N,(P)		;RESTORE ORIGINAL N IN CASE THIS IS LOOP
				; SO * SUBSTITUTION WILL BE THE SAME
	HRRZ	T1,-1(P)	;ADR OF MESSAGE
	PUSHJ	P,TTROUT	;OUTPUT TO TTY

;LOOP TO GET NEXT LINE OF INPUT
ASKMLP:	PUSHJ	P,TTYIN		;GET TTY LINE
	  JRST	ASKM0		;/HELP TYPED, ASK AGAIN
	JUMPE	CH,ASKPXT	;NO, DID HE TYPE A BLANK LINE MEANING ALL DONE?
	TLZ	F,(F.INFO);
	PUSHJ	P,GETMN		;NO, SCAN FOR M OR M-N AND STOP ON NON-BREAK
	RJUMPN	CH,<TTYOCT <? Type octal M-N or M@>
		AOJA	LV,ASKM0>  ;RAISE LEVEL OF VERBOSCITY AND ASK AGAIN
	FILSTR	<L *@>;	;OUTPUT SAME STRING HE TYPED IN WITH MACRO
				; NAME PRECEDING IT SO COMMON CAN
				; REDEFINE AS IT PLEASES.
	JRST	ASKMLP		;AND GO GET NEXT LINE OF INPUT


;ROUTINE TO ASK FOR M-N,P<EOL>, GET REPEATED LINES OF INPUT
; UNTIL BLANK LINE, ANS OUTPUT TO FILE
;CALL:	FILOUT	<DEFINE	MAC???>	;START MACRO DEFINITON IN FILE
;	ASKMNP	<ASK MESSAGE@>
;	RETURN WHEN ALL ANSWERS HAVE BEEN CHECKED AND OUTPUT

ASKMNP:	MOVEI	R,^D8		;ASSUME OCTAL RADIX FOR IO
	PUSHJ	P,FILLAB	;OUTPUT LEFT ANGLE BRACKET, CRLF TO FILE
				; AS BEG OF MACRO DEFINITION
	PUSHJ	P,ASKBG		;STANDARD ASK ROUTINE BEGINNING
				; SAVE ADR OF QUESTION AND N ON STACK, OUTPUT CRLF
				; TO FILE, OUTPUT QUESTION AS COMMENT TO FILE

;LOOP TO ASK FOR MULTI LINE INPUT AGAIN IN CASE OF ERROR
ASKP0:	MOVE	N,(P)		;RESTORE ORIGINAL N IN CASE THIS IS LOOP
				; SO * SUBSTITUTION WILL BE THE SAME
	HRRZ	T1,-1(P)	;ADR OF MESSAGE
	PUSHJ	P,TTROUT	;OUTPUT TO  TTY

;LOOP TO GET NEXT LINE OF INPUT
ASKPLP:	PUSHJ	P,TTYIN		;GET NEXT LINE FROM TTY
	  JRST	ASKP0		;/HELP TYPED, ASK AGAIN
	JUMPE	CH,ASKPXT	;NO, BLANK LINE MEANING END
	TLO	F,(F.INFO)
	PUSHJ	P,GETMN		;NO, GET M OR M-N
	CAIE	CH,","		;IS BREAK A COMMA?
	JRST	ASKPE		;NO, ERROR, PRINT MESAGE AND ASK AGAIN
	PUSHJ	P,GETOCT	;GET OCTAL P
	JUMPE	CH,ASKP1	;IS THIS END OF STRING?
ASKPE:	TTYOUT	<? Type octal M-N,P or M,P@>
	AOJA	LV,ASKP0	;RAISE LEVEL AND ASK AGAIN

ASKP1:	FILSTR	<L *@>;	;OUTPUT TO FILE ENTIRE ANSWER WITH MACRO
				; NAME PRECEDING IT WHICH COMMON WILL DEFINE
				; AS IT PLEASES.
	JRST	ASKPLP		;AND GO GET ANOTHER LINE OF INTPUT
;ROUTINE TO ASK FOR M-N OR ALL, GET REPEATED LINES OF INPUT
;UNTIL BLANK LINE, AND OUTPUT TO FILE
;CALL: - SEE ASKMN

ASKTMN:	MOVEI	R,^D8		;RADIX 8
	PUSHJ	P,FILLAB	;PUT OUT RIGHT BRACKET
	PUSHJ	P,ASKBG		;STD BEGINNING

ASKTM0:	MOVE	N,(P)		;RESTORE N
	HRRZ	T1,-1(P)	;ADDR OF MSG
	PUSHJ	P,TTROUT	;OUTPUT TO TTY

ASKTLP:	PUSHJ	P,TTYIN		;GET LINE OF INPUT
	  JRST	ASKTM0		;/HELP WAS TYPED
	JUMPE	CH,ASKPXT	;EXIT IF NULL LINE
	PUSHJ	P,GETTMN	;GET ANSWERS
	RJUMPN	CH,<TTYOCT <? Type octal M-N or M@>
		     AOJA LV,ASKTM0>	;GIVE HIM HELP
	FILSTR	<KN X,*@>
	JRST	ASKTLP		;ASK AGAIN

;ROUTINE TO GET M-N OR "ALL"

GETTMN:	PUSHJ	P,GETOCT	;GET OCTAL NUMBER
	CAIN	CH,"A"		;SEE IF START OF ALL
	JRST	GETTM1
	CAIE	CH,"-"		;CHECK DASH
	POPJ	P,		;NO - ERROR RETURN
	MOVEI	CH,","		;CONVERT TO MAKE MACRO HAPPY
	DPB	CH,B		;PUT IN STRING
	PJRST	GETOCT		;GET 2ND AND RETURN

GETTM1:	PUSHJ	P,GETWRD	;GET REST OF WORD
	MOVSI	N,'ALL'		;CORRECT ANSWER
	CAME	WD,[SIXBIT "LL"] ;REMAINDER CORRECT?
	MOVEI	CH,"A"		;NO - GIVER ERROR
	POPJ	P,		;RETURN
;ROUTINE TO SETUP ALL ASK ROUTINES
; OUTPUTS CRLF TO FILE, OUTPUT QUESTION AS COMMENT, PUT ADR OF QUESTION ON STACK
; PUT ARG FOR * SUBSTITUTION (N) ON STACK SO QUESTION CAN BE REASKED.
;CALL:	MOVEI	T1,ADR OF QUESTION
;	PUSHJ	P,ASKBG
;	RETURN HERE WITH T1 ON END OF LIST

ASKBG:	EXCH	T1,(P)		;SAVE ADR OF MESSAGE ON STACK
	PUSH	P,N		;SAVE ARG FOR * SUBSTITUTION IN CASE
				; OF ERROR AND QUESTION MUST BE REASKED
				; COMMON ASK EXIT(ASKXIT) WILL POP THESE OFF
	PUSH	P,T1		;SAVE RETURN ON END
	PUSHJ	P,FCRLF		;OUTPUT CRLF TO FILE
	HRRZ	T1,-2(P)	;ADR OF QUESTION
	PJRST	FILCOM		;OUTPUT AS A COMMENT, PUTTING ; IN FRONT
				; OF EVERY LINE IN QUESTION

;HERE TO EXIT ASKMN AND ASKMNP
ASKPXT:	PUSHJ	P,FILRAB	;OUTPUT RIGHT ANGLE BRACKET,CRLF TO FILE

;HERE TO EXIT FROM ALL ASK ROUTINES
ASKXIT:	MOVE	LV,SAVLV	;RESTORE VERBOSCITY LEVEL BEFORE QUESTION ASKED
				; OR AS SET BY /HELP:XXX
	POP	P,T1		;THROW AWAY * SUBSTITUTION ARG( AC N)
				; N HAS ANSWER IN IT NOW
	POP	P,T1		;POP OFF T1
	JRST	FILOT2		;CLEAR LF FLAG SO FOLLOWING OUTPUT WONT
				; ACCIDENTALLY GET ; IN FRONT. THEN RETURN.
SUBTTL	GET ROUTINES - SCAN AND CHECK IN CORE STRINGS

;ROUTINE TO GET OCTAL LINE NUMBER OR "CTY"
;CALL:	MOVE	B,BYTE POINTER
;	PUSHJ	P,GETLIN
;	ALWAYS RETURN, N=VALUE OR SIXBIT CTY
;	STOP IN FIRST NON-OCTAL CHAR OR NON-CTY
;	CALLER MUST CHECK FOR LEGAL BREAK CHARACTER

GETLIN:	PUSHJ	P,GETOCT	;GET OCTAL NUMBER
	JUMPN	N,CPOPJ		;RETURN IF GOT SOME VALUE
	CAIN	CH,"C"+40	;IS IT LOWER CASE C?
	TRC	CH,40		;YES, CONVERT IT
	CAIE	CH,"C"		;IS BREAK "C"?
	POPJ	P,		;NO, MAYBE 0 OR CR, LET CALLER CHECK
	PJRST	GETMN1		;SEE IF REST IS CTY

;ROUTINE TO SYNTAX CHECK M-N OR M FOLLOWED BY ANY BREAK
;CALL:	MOVE	B,BYTE POINTER
;	PUSHJ	P,GETMN
;	ALWAYS RETURN HERE, BREAK IN CH

GETMN:	PUSHJ	P,GETOCT	;GET OCTAL LINE NUMBER
	CAIN	CH,"C"+40	;IS IT LOWER CASE C?
	TRC	CH,40		;YES, CONVERT IT
	CAIN	CH,"C"		;SKIP IF NOT START OF CTY
	JRST	GETMN1		;YES, SEE IF IS CTY
	CAIE	CH,"-"		;IS BREAK -?
	POPJ	P,		;NO, LET CALLER CHECK FURTHER
	MOVEI	CH,","		;YES, CHANGE TO , SO MACRO WILL ACCEPT
	DPB	CH,B		;IN OUTPUT FILE
	PJRST	GETOCT		;GET SECOND OCTAL DIGIT

GETMN1:	PUSHJ	P,GETWRD	;YES, GET REST OF WORD
	MOVSI	N,'CTY'		;ASSUME CTY
	CAMN	WD,[SIXBIT /TY/]  ;IS IT REST OF CTY?
	JRST	NULL		;INSERT A NULL
	MOVEI	CH,"C"		;NO, RETURN ORIGINAL BREAK FOR CALLER
				; TO GET ERROR WHEN CHECKS IT
	POPJ	P,		;RETURN, CALLER CHECK FOR BREAK
NULL:	TLNN	F,(F.INFO)	;ARE WE EXPECTING MORE INFO TO FOLLOW "CTY"?
	MOVEI	CH,0		;PUT A NULL IN THE BUFFER
	DPB	CH,B		; TO BE AN EOL
	POPJ	P,		;RETURN

;ROUTINE TO GET DECIMAL FROM STRING
;CALL:	MOVE	B,BYTE POINTER
;	PUSHJ	P,GETDEC
;	ALWAYS RETURN HERE, BREAK IN CR, VALUE IN N
;CALLER MUST CHECK FOR PROPER BREAK

GETDEC:	MOVEI	R,12		;SET RADIX TO DECIMAL
	PJRST	GETNUM		;GET NUMBER


;ROUTINE TO GET OCTAL NUMBER FROM STRING
;SAME CALL AS GETDEC

GETOCT:	MOVEI	R,10		;SET RADIX TO OCTAL
				; FALL INTO GETNUM

;ROUTINE TO GET NUMBER FROM STRING
;CALL:	MOVE	R,RADIX
;	MOVE	B,BYTE POINTER
;	PUSHJ	P,GETNUM
;	ALWAYS RETURN HERE, BREAK IN CH, VALUE IN N
;CALLER MUST CHECK FOR PROPER BREAK, GETNUM STOPS ON FIRST NON-NUMERIC

GETNUM:	MOVEI	N,0		;SET VALUE TO 0
	PUSHJ	P,SKBLNK	;SKIP LEADING BLANKS(SPACES AND TABS)
GETN0:	JUMPE	CH,CPOPJ	;IS THIS END OF STRING
	CAIL	CH,"0"		;LESS THAN 0?
	CAIL	CH,"0"(R)	;LESS THAN RADIX
	PJRST	SKBLK1		;YES, RETURN - SKIP TO FIRST NON-BLANK
	IMUL	N,R		;MULTIPLY OLD NUMBER BY RADIX
	ADDI	N,-"0"(CH)	;ADD IN VALUE OF THIS CHAR
	ILDB	CH,B		;GET NEXT CHAR IN STRING
	JRST	GETN0		;GET ANOTHER CHAR
;ROUTINE TO GET A WORD FROM AN ASCIZ STRING.  FILTERS OUT TAB, SPACE
; STOPS ON ANY NON-ALPHA NUMERIC, EXCEPT DOT, CALLER MUST CHECK FOR LEGAL BREAK
;CALL:	MOVE	B,BYTE POINTER
;	PUSHJ	P,GETWRD
;	RETURN WITH SIXBIT WD LEFT JUSTIFIED, BREAK IN CH

GETWRF:	PUSH	P,[PUSHJ P,FHLPRC] ;INSTRUCTION TO GET NEXT CHAR
	JRST	GETWR1		;READ ASCIZ STRING FOR SIXBIT

GETWRD:	PUSH	P,[ILDB CH,B]	;INSTRUCTION TO GET NEXT CHAR
GETWR1:	PUSHJ	P,GETSKB	;SKIP LEADING BLANKS(SPACES, TABS)
	MOVEI	WD,0		;SET WORD TO 0 FOR RETURN
	MOVE	T1,[XWD	440600,WD] ;SET SIX BIT BYTE POINTER TO WD

;LOOP TO ACCUMULATE AFTER LEADING SPACES AND TABS
GETWLP:	JUMPE	CH,GETWX1	;END OF STRING?
	TLNN	F,(F.PER)	;ARE SYMBOL CHARACTERS ALLOWED IN NAMES?
	JRST	GETWD1		;NO, (MUST BE SCANNING FILE NAMES)
	CAIN	CH,"."		;PERIOD(CAN BE PART OF SYMBOL)
	JRST	GETWD3		;YES, ACCEPT AS PART OF SYMBOL
	CAIE	CH,"%"		;CHECK FOR PERCENT SIGN
	CAIN	CH,"$"		;CHECK FOR DOLLAR SIGN
	JRST	GETWD3		;YES, ACCEPT AS PART OF SYMBOL
GETWD1:	CAIL	CH,"0"		;LESS THAN 0?
	CAILE	CH,"9"		;LESS THAN OR EQUAL TO 9?
	JRST	GETWD2		;YES, SEE IF LETTER?
	JRST	GETWD3		;NO, NUMBER, STORE

;HERE IF NOT NUMBER
GETWD2:	CAIL	CH,"A"+40	;LOWER CASE?
	TRC	CH,40		;YES, CONVERT TO UPPER CASE
	CAIL	CH,"A"		;LESS THAN A
	CAILE	CH,"Z"		;LESS THAN OR EQUAL TO Z?
	PJRST	GETWRX		;SKIP TRAILING BLANKS TO FIRST NON-BLANK
				; AND RETURN TO CALLER
;HERE IF A LETTER OR NUMBER - CONVERT TO SIXBIT AND STORE
GETWD3:	SUBI	CH,40		;CONVERT TO SIXBIT
	TLNE	T1,770000	;OVERFLOWED WD YET?
	IDPB	CH,T1		;NO, STORE NEXT SIXBIT CHAR
	XCT	(P)		;GET NEXT CHAR
	JRST	GETWLP		;AND CHECK IT

GETWRX:	PUSHJ	P,SKBLK1	;RETURN FIRST NON-BLANK AFTER TRAILING SPACES
GETWX1:	POP	P,(P)
	POPJ	P,
GETSKB:	XCT	-1(P)		;GET NEXT CHAR
GETSK1:	CAIE	CH," "		;SPACE?
	CAIN	CH,"	"	;TAB?
	JRST	GETSKB		;YES, GET NEXT CHAR
	POPJ	P,		;NO, FOUND NON-BLANK
;ROUTINE TO GET TTY LINE, AND SCAN FOR DEV:PI
; WHERE DEV IS 3 CHAR OR LESS AND PI IS # FOR 0-7
;CALL:	PUSHJ	P,GETDPI
;	  ERROR RETURN, /HELP , DEV TOO LONG, OR PI TOO BIG
;	OK RETURN, BREAK IN CH, WD=0 IF JUST CR TYPED

GETDPI:	PUSHJ	P,TTYIN		;GET NEXT LINE
	  POPJ	P,		;/HELP TYPED, REASK IN DESIRED HELP MODE
	MOVEI	WD,0		;SET JUST CR TYPED INDICATION
	JUMPE	CH,CPOPJ1	;JUST A BLANK LINE?
	PUSHJ	P,GETWRD	;NO, GET FIRST WORD
	JUMPE	WD,ASKDPE	;ARE THERE ANY CHAR IN DEVICE NAME?
	CAIE	CH,","		;IS BREAK CHAR COMMA?
	POPJ	P,		;NO, ERROR
	TRNE	WD,777777	;IS DEVICE 3 CHAR OR LESS?
ASKDPE:	RJRST	<TTYOUT	<? Device-mnemonic must be 3 char or less@>
		 POPJ	P,>	;GO TRY AGAIN
	PUSHJ	P,GETDEC	;GET PI NO.
	CAILE	N,SM.PI		;LEGAL PI?
	RJRST	<MOVEI N,SM.PI	;GET MAXIMUM LEGAL PI
		 TTYOUT	<? PI-channel must be * or less@>
		 POPJ	P,>	;GO TRY AGAIN
	JRST	CPOPJ1		;YES, GIVE LEGAL RETURN


;ROUTINE TO SKIP LEADING BLANKS(SPACES AND TABS)
;CALL:	MOVE	B,BYTE POINTER
;	PUSHJ	P,SKBLNK	OR SKBLK1 IF FIRST CHAR ALREADY IN CH
;	FIRST NON-BLANK RETURNED IN CH

SKBLNK:	ILDB	CH,B		;GET NEXT CHAR
SKBLK1:	CAIE	CH," "		;SPACE?
	CAIN	CH,"	"	;TAB?
	JRST	SKBLNK		;YES, GET NEXT CHAR
	POPJ	P,		;NO, RETURN WITH FIRST NON-BLANK IN CH
SUBTTL	FGEN AUXILIARY HELP FILE ROUTINES

;ROUTINE TO OUTPUT FROM THE AUXILIARY FILE TO TTY

FHLPTT:	PUSH	P,[PUSHJ P,FHLPRC] ;INSTRUCTION TO GET NEXT CHAR TO OUTPUT
	MOVSI	N,'*  '		;EASY WAY TO MAKE SURE * COMES OUT RIGHT
	JRST	TTYOLP		;TYPE OUT STRING

;ROUTINE TO OUTPUT FROM THE AUXILIARY FILE TO THE OUTPUT FILE
;CALL:	PUSHJ	P,FHLPFC TO OUTPUT AS A COMMENT
;	PUSHJ	P,FHLPFL TO OUTPUT AS TEXT

FHLPFC:	TLO	F,(F.COM)	;NOTE OUTPUT AS A COMMENT
FHLPFL:	PUSH	P,[PUSHJ P,FHLPRC] ;INSTRUCTION TO GET NEXT CHAR TO OUTPUT
	MOVSI	N,'*  '		;EASY WAY TO MAKE SURE * COMES OUT RIGHT
	JRST	FILOLP		;OUTPUT TO FILE

;ROUTINE TO POSITION THE AUXILIARY FILE
;CALL:	MOVE	WD,SIXBIT TEXT TO FIND
;	PUSHJ	P,FHLPOS
;	ERROR RETURN - CANT FIND IT
;	OK RETURN - FILE POSITIONED AFTER TAB
;
;	NOTE LOOKS FOR TERMINATOR FIRST, TO BE FOLLOWED IMMEDIATELY BY TEXT IN WD

FHLPOA:	TLZA	F,(F.FHLC)	;NOTE DONT WANT TAB AFTER TEXT
FHLPOS:	TLO	F,(F.FHLC)	;NOTE LOOKING FOR A TAB AFTER TEXT
	TLZ	F,(F.HRRD)	;CLEAR REREADING FLAG
FHLPS0:	PUSHJ	P,FHLPRD	;READ NEXT CHAR FROM AUX FILE
FHLPS3:	JUMPL	CH,FHLPEF	;JUMP IF END OF AUX FILE
	JUMPN	CH,FHLPS0	;LOOK FOR TERMINATOR
FHLPS1:	MOVE	T1,[POINT 6,WD]	;BYTE PTR FOR DESIRED STRING
FHLPS2:	TLNN	T1,770000	;SKIP IF NEED MORE CHARS TO MATCH
	JRST	FHLPFN		;FOUND WHAT WAS DESIRED
	ILDB	N,T1		;N=NEXT CHAR NEEDED (IN SIXBIT)
	JUMPE	N,FHLPFN	;JUMP IF THAT'S ALL THATS NEEDED
	PUSHJ	P,FHLPRD	;GET NEXT CHAR FROM AUX FILE
	JUMPL	CH,FHLPEF	;JUMP IF END OF FILE
	JUMPE	CH,FHLPS1	;IF TERMINATOR, START LOOKING AGAIN
	CAIL	CH,140		;SKIP IF NOT LOWER CASE
	SUBI	CH,40		;MAKE UPPER CASE FOR COMPARISON
	CAIE	N,' '-" "(CH)	;SKIP IF THIS CHAR MATCHES
	JRST	FHLPS0		;NO, MOVE TO NEXT TERMINATOR
	JRST	FHLPS2		;YES, KEEP ON
;HERE IF FOUND END OF AUX FILE
FHLPEF:	TLNE	F,(F.FHLC)	;SKIP IF NOT LOOKING FOR TAB AFTER TEXT
	TLOE	F,(F.HRRD)	;SKIP IF NOT ALREADY REREADING THE FILE
	POPJ	P,		;CANT FIND DESIRED STRING
	TLZ	F,(F.HOPN)	;CLEAR OPEN FLAG TO RESTART AT BEGINNING OF FILE
	JRST	FHLPS0		;NO, MAY HAVE STARTED PAST THE PLACE
;HERE WHEN FILE POSITIONED AS REQUESTED
FHLPFN:	TLNN	F,(F.FHLC)	;SKIP IF LOOKING FOR TAB AFTER STRING
	JRST	CPOPJ1		;NO, ALL SET
FHLPF1:	PUSHJ	P,FHLPRD	;SKIP TO TAB
	JUMPLE	CH,FHLPS3	;JUMP IF TERMINATOR FOUND
	CAIE	CH,"	"	;SKIP IF FOUND TAB
	JRST	FHLPF1		;KEEP ON
	JRST	CPOPJ1		;GIVE GOOD RETURN

;THIS ROUTINE READS A CHAR FROM THE AUXILIARY HELP FILE FOR MESSAGES
FHLPRC:	PUSHJ	P,FHLPRD	;GET NEXT CHAR
	JUMPGE	CH,CPOPJ	;OK IF REAL CHAR
	SETZ	CH,		;TURN EOF INTO END OF STRING
	POPJ	P,
;ROUTINE TO READ NEXT CHAR FROM FGEN AUXILIARY HELP FILE

FHLPRD:	TLNE	F,(F.HOPN)	;SKIP IF HELP FILE IS NOT YET OPEN
	JRST	FHLPR1		;ALREADY OPEN, GO AHEAD
	INIT	FHLPCH,0
FGDEV:	SIXBIT	.SYS.
	XWD	0,FHIBUF
	  JRST	FHLPE1		;CANT INIT SYS?
	MOVE	CH,FGPPN	;PPN FOR HELP FILE
	MOVEM	CH,FHNAME+3	;STORE FOR LOOKUP
	LOOKUP	FHLPCH,FHNAME	;LOOKUP FILE
	  JRST	FHLPE1		;CANT FIND FILE
	TLO	F,(F.HOPN!F.HRRD) ;NOTE OPEN AND ON SECOND PASS
	PUSH	P,.JBFF##	;SAVE JOBFF
	MOVEI	CH,FHLPBF	;ADDR OF FHELP FILE BUFFERS
	MOVEM	CH,.JBFF	;SET UP TO ALLOCATE BUFFERS
	INBUF	FHLPCH,NFHLPB	;ALLOCATE INPUT BUFFERS
	POP	P,.JBFF		;RESTORE JOBFF
FHLPR1:	SETZ	CH,		;CLEAR CH IN CASE ERROR IN IN SUBROUTINE
	SOSG	FHIBUF+2
	PUSHJ	P,[IN FHLPCH,
		   POPJ P,
		   JRST	FHLPER]
	JUMPL	CH,CPOPJ	;GIVE UP IF ERROR READING
	ILDB	CH,FHIBUF+1	;GET NEXT CHAR
	JUMPE	CH,FHLPR1	;IGNORE NULLS
	CAIN	CH,C.RUB	;AND RUBOUTS
	JRST	FHLPR1
	CAIL	CH,175		;DO THE ALTMODE THING
	MOVEI	CH,C.ESC
	CAIN	CH,C.TMFH	;SKIP IF NOT OUR TERMINATOR
	SETZ	CH,		;RETURN 0 FOR TERMINATOR FOR CONVENIENCE
	POPJ	P,
FHLPER:	TLZ	F,(F.HOPN)	;CLEAR OPEN FLAG
	RELEASE	FHLPCH,
FHLPE1:	SETO	CH,
	POPJ	P,
SUBTTL	TTY INPUT ROUTINES

;ROUTINE TO ACCEPT 1 LINE FROM TTY, MOVE IT TO ASCSTR
;REMOVE EOLS, AND COMMENTS, AND ADD A NULL TO MAKE IT ASCIZ
; LOOK FOR /H AND HANDLE IT
;OUTPUT LINE WITH PRECEDING ; TO FILE
;CALL:	PUSHJ	P,TTYIN
;	  NON SKIP RETURN IF USER TYPES /HELP, CALLER MUST REASK QUESTION
;	    LEVEL SET AS USER WISHES IN LV FOR THIS QUESTION,
;	    AND IN SAVLV FOR FUTURE
;	SKIP RETURN WITH B SETUP AS BYTE POINTER TO BEG OF STRING
;	CH = 0 IF JUST A BLANK LINE TYPED
;	N = NUMBER OF CHARACTERS NOT COUNTING EOLS OR NULLS
;	B = BYTE POINTER TO STRING JUST READ IN


TTYIN:	TLO	F,(F.COM)	;FLAG OUTPUT TO FILE AS COMMENTS SO ALL
				; CALLS TO FILOUT WILL PUT PRECEDING ;
	PUSHJ	P,TTYGET	;GET NEXT CHAR, OUTPUT TO FILE, SKIP COMMENTS, EOL=0
	MOVEI	N,0		;SETUP LENGTH OF STRING TO 0
	MOVE	B,[XWD 440700,ASCSTR] ;BYTE POINTER

;LOOP TO COPY CHARS FROM TTY TO CORE BUFFER(ASCSTR)
TTYINB:	IDPB	CH,B		;STORE AWAY
	JUMPE	CH,TTYINC	;IF EOL CHAR, RETURN
	PUSHJ	P,TTYGET	;GET NEXT CHAR
	CAIGE	N,MP.LMX	;LESS THAN MAX LINE LENGTH?
				; ASCSTR ALWAYS HAS ROOM FOR NULL
	TLZ	F,(F.COM)	;CLEAR FLAG FOR FILE COMMENTS
	AOJA	N,TTYINB	;YES, OK TO STORE NEXT CHAR
	TTYOUT	<? Line too long@>
	AOJA	LV,FILOT2	;INCREASE LEVEL BY 1 FOR THIS QUESTION
				; AND PRETEND /HELP TYPED BY GIVING NO-SKIP
				; RETURN SO CALLER WILL REASK QUESTION

;HERE WHEN STRING ALL STORED IN CORE BUFFFER
TTYINC:	TLZ	F,(F.COM)	;CLEAR FLAG FOR FILE COMMENTS
	MOVE	B,[XWD 440700,ASCSTR] ;BYTE POINTER TO CORE BUFFER
	PUSHJ	P,SKBLNK	;SKIP BLANKS(SPACE, TAB)
	CAIN	CH,"/"		;IS FIRST NON-BLANK A SLASH?
	JRST	TTYINH		;YES, GO DO /HELP
	MOVE	B,[XWD 440700,ASCSTR] ;SETUP BYTE POINTER TO
				; BEG OF CORE BUFFER FOR CALLER
	TLZ	F,(F.COM)	;CLEAR COMMENT FLAG
	JRST	CPOPJ1		;GIVE NON-HELP RETURN
;HERE ON LEADING / FROM TTYIN ROUTINE - SEE IF /HELP
; REST OF INPUT LINE ALEADY COPIED TO FILE AND CORE BUFFER(ASCSTR)
; OK TO DESTROY ASKTAB+0,... SINCE GOING TO GIVE NON-SKIP RETURN
TTYINH:	PUSH	P,N		;SAVE CCALLERS N IN CASE * SUBSTITUTION
				; WHEN QUESTION REASKED
	MOVEI	T1,[ASCIZ /(HELP)/] ;SETUP ONLY CHOICE AS IF PROMPT
	PUSHJ	P,SETASK	;IN CHOICES TABLE(ASKTAB)
	PUSHJ	P,FNDAS1	;SCAN CHARS AFTER / TO SEE IF HELP
				; OR ABBREV(ALLOW ANY BREAK)
	AOJA	LV,TTYIH1	;NO, GIVE HIM HELP WITH HELP
				; AT NEXT LONGER HELP LEVEL
	PJUMPE	CH,RAISE1	;IS BREAK EOL?(IF YES, JUST INCREASE
				; LEVEL OF VERBOSCITY BY 1 FOR THIS QUESTION
				; BY ADDING TO LV BUT NOT TO SAVLV
	CAIE	CH,":"		;IS BREAK COLON?
	AOJA	LV,TTYIH1	;NO, ASK HELP QUESTION
				; AT NEXT LONGER MODE
	MOVEI	T1,[ASCIZ /(,SHORT,PROMPT,LONG)/] ;SETUP UP CHOICES TO /HELP:
				; N=0 MEANS JUST CR TYPED
	PUSHJ	P,SETASK	;IN ASKTAB+0,1,...
	PUSHJ	P,FNDASK	;FIND THE ONE HE TYPED
	  AOJA	LV,TTYIH1	;NOT FOUND, INCREASE HELP LEVEL
	JUMPE	N,RAISE1	;DID HE TYPE JUST CR?
				; IF YES, JUST INCREASE LEVEL FOR THIS QUESTION
	SUBI	N,2		;NO, FORM -1,0,1 FOR SHORT,PROMPT,LONG
	TLZ	F,(F.COM)	;CLEAR COMMENT FLAG
	JRST	HELP0		;GO STORE NEW PERMANENT HELP LEVEL

;HERE TO RAISE LEVEL 1 FOR THIS QUESTION ONLY
RAISE1:	TLZ	F,(F.COM)	;CLEAR COMMENT FLAG
	AOJA	LV,HELP1	;INCREMENT LEVEL BY ONE, BUT DO NOT
				; REMEMBER IN MEMORY(SAVLV)
				; AND RETURN
TTYIH1:	TLZA	F,(F.COM)	;CLEAR COMMENT FLAG AND GO TO TTYHP1

;ROUTINE TO TYPE HELP QUESTION
; CALLED AT BEGINNING ONCE ONLY AND WHENEVER /HELP:XXX MISTYPED
;CALL:	PUSHJ	P,TTYHLP

TTYHLP:	PUSH	P,N		;SAVE CALLER N INCASE * SUBSTITUTION
				; WHEN QUESTION REASKED
TTYHP1:	MOVEI	N,MP.MVN	;MONITOR VERSION NUMBER FOR THIS MONGEN
				; TELL USER SO HE GETS PROPER MONGEN
	ASKLST	<MONGEN for * monitors
/HELP(PROMPT,SHORT,LONG)[
All # are decimal unless stated otherwise
Unique abbrivation allowed everywhere to all questions
/HELP reasks a question in next longer mode
/HELP:xxx sets mode permanently.  Modes are:
SHORT is short
PROMPT has choices in ()
LONG has choices in () and explanation in []]>
	CAIN	N,1		;ANSWER 1(SHORT)
	SETOM	N		;YES, SET LEVEL TO SHORT
	CAIN	N,2		;ANSWER 2(LONG)?
	MOVEI	N,1		;YES, SET LEVEL TO LONG

;HERE TO STORE NEW PERMANENT HELP LEVEL
HELP0:	MOVEM	N,SAVLV		;SET PERMANENT LEVEL OF HELP
	MOVE	LV,N		;SET CURRENT LEVEL TO THE SAME
HELP1:	POP	P,N		;RESTORE ORIGINAL N(IN CASE THIS
				; IS HELP IN MIDDLE OF A QUESTION)
	POPJ	P,		;GIVE NON-SKIP RETURN SO QUESTION
				; WILL BE REASKED

;ROUTINE TO GET ONE CHAR FROM TTY, CHECK FOR EOLS, PUT CHAR IN  FILE
; AND SKIP OVER COMMENTS. ALSO CHECK FOR /HELP

TTYGET:	PUSHJ	P,TTYGT1	;GET NEXT CHAR FROM TTY AND PUT IN FILE
	  POPJ	P,		;IT WAS AN EOL, RETURN, F.COM CLEARED
	CAIE	CH,";"		;NO, WAS IT ";" FOR A COMMENT?
	CAIN	CH,"!"		;"!" IS ALSO A COMMENT
	JRST	TTYGT0		;READ COMMENT
	POPJ	P,		;NO, RETURN

;LOOP TO THROW AWAY COMMENTS USER TYPED IN AFTER ANSWER
TTYGT0:	PUSHJ	P,TTYGT1	;YES, GET NEXT CHAR
	  POPJ	P,		;IT WAS AN EOL, RETURN WITH F.COM CLEARED
	JRST	TTYGT0		;NOT AN EOL, THROW IT AWAY AND GET NEXT CHAR

;ROUTINE TO GET ONE CHAR FROM TTY, CHECK FOR EOL, PUT CHAR IN FILE
;CALL:	PUSHJ	P,TTYGT1
;	  EOL RETURN CH=0, F.COM CLEARED(MAKE FILE OUTPUT NO LONGER BE COMMENTS)
;	NOT AN EOL RETURN, CH IS CHAR

TTYGT1:	SOSG	TIBUF+2		;DECREMENT INPUT TTY BUFFER COUNT
	RJRST	<IN	TTYCHN,	;GET NEXT BUFFER FROM MONITOR
		 JRST	TTYGT2	;NO ERRORS
		 STATO	TTYCHN,IO.EOF ;END OF FILE ON TTY?
		 JRST	TTYGT2	;NO, IGNORE ERROR
		 JRST	TTYZ>	;YES, SET CONTROL Z FLAG
TTYGT2:	ILDB	CH,TIBUF+1	;GET NEXT CHAR FROM BUFFER
	JUMPE	CH,TTYGT1	;IS IT NULL?
	CAIE	CH,C.RUB	;IGNORE RUBOUTS
	CAIN	CH,C.CR		;IS IT CR?
	JRST	TTYGT1		;YES, SKIP
	CAIL	CH,C.LF		;LESS THAN LINE FEED?
	CAILE	CH,C.CR		;NO, LESS THAN CARRIAGE RETURN?
	SKIPA			;NO, NOT AN EOL
	JRST	TTYEOL		;YES, CONSIDER AS EOL
	CAIE	CH,C.ESC	;ESCAPE?
	CAIL	CH,C.ALT1	;OLD ALTMODE?
	JRST	TTYEOL		;YES, TREAT AS EOL
	CAIE	CH,C.CONC	;CONTROL C?
	CAIN	CH,C.CONZ	;CONTROL Z?
	JRST	TTYZ		;YES, SET FLAG(OLDER MONITORS STORE ^Z IN BUFFER)
	PUSHJ	P,FILPUT	;STORE CHAR IN FILE
	JRST	CPOPJ1		;AND SKIP RETURN

;HERE WHEN CONTROL Z SEEN OF END OF FILE SET ON TTY
TTYZ:	CLOSE	TTYCHN,		;TURN OFF EOF FOR TTY
				; CLEAR EOF SO CAN DO MORE INPUTS
	TLO	F,(F.CONZ)	;FLAG CONTROL Z SEEN
TTYEOL:	PUSHJ	P,FCRLF		;OUTPUT CRLF TO FILE
	MOVEI	CH,0		;RETURN 0 AS EOL CHAR
	POPJ	P,		;GIVE EOL RETURN
SUBTTL	OUTPUT ROUTINES - TTY AND FILE

;ROUTINE TO TYPE INTERNAL MONGEN ERROR ON TTY AND FILE, THEN EXIT TO MONITOR
;USE TTCALL IN CASE TTY COULD NOT BE INITED
;CALL:	EREXIT	<MESSAGE>,

EREXIT:	PUSH	P,T1		;SAVE ADR OF MESSAGE
	OUTSTR	[ASCIZ /
? Internal MONGEN error - /]
	OUTSTR	(T1)		;THE CALLERS MESSAGE
	FILOUT	<@? Internal MONGEN error - >
	POP	P,T1		;RESTORE MESSAGE ADR
	PUSHJ	P,FILOUT	;OUTPUT TO FILE
	EXIT			;EXIT TO MONITOR


;ROUTINE TO OUTPUT TO FILE IN DECIMAL AND SUBSTITUTE FOR *
;CALL:	MOVEI	T1,ADR OF MESSAGE
;	PUSHJ	P,FILDEC
;	ALWAYS RETURN HERE, N PRESERVED

FILDC2:	TLO	F,(F.2DEC)	;ASK FOR AT LEAST TWO CHARS OUTPUT
FILDEC:	MOVEI	R,12		;SET RADIX TO DECIMAL
	PJRST	FILOT1		;DO OUTPUT AND SUBSTITUTION

;ROUTINE TO OUTPUT TO FILE AND SUBSTITUTE FOR *
; VALUE OR SIXBIT IN N
;CALL:	MOVEI	T1,ADR OF ASCIZ STRING TO OUTPUT
;	MOVE	N,NUMBER OR LEFT JUSTIFIED SIXBIT
;	PUSHJ	P,FILOUT
;	ALWAYS	RETURN HERE, N PRESERVED

FILCOM:	TLOA	F,(F.COM)	;SET FLAG TO PRECEDE ALL LINE WITH ;
				; AS A COMMENT IN FILE
FILOUT:	MOVEI	R,10		;SET OUTPUT RADIX TO OCTAL FOR MACRO
FILOT1:	HRLI	T1,440700	;FORM LH OF BYTE POINTER
	PUSH	P,[ILDB CH,T1]	;INSTRUCTION TO GET NEXT CHAR
FILOLP:	XCT	(P)		;GET NEXT CHAR IN OUTPUT MESSAGE
	PJUMPE	CH,FILT2A	;RETURN IF END OF STRING
	CAIN	CH,"*"		;NOT EOS, IS IT ASTERISK?
	PUSHJ	P,EITAST	;YES, SUBSTITUTE N FOR IT
	  PUSHJ	P,FILPUT	;ARG TO EITAST OR OUTPUT CHAR
	JRST	FILOLP		;LOOP AND GET NEXT CHAR


;ROUTINE TO REPLACE A "DOT" IN A SYMBOL WITH THE VALUE OF CPUN

FILCPU:	MOVEI	R,10		;OUTPUT RADIX
FILCP0:	HRLI	T1,440700	;FORM A BYTE POINTER
	PUSH	P,T1		;SAVE IT
FILCP1:	ILDB	CH,(P)		;GET NEXT CHARACTER IN OUTPUT
	PJUMPE	CH,FILT2A	;JUMP IF LAST
	PUSH	P,N		;SAVE ARGUMENT
	CAIN	CH,"*"		;SUBSTITUTE N?
	JRST	FILCP2		;YES
	MOVE	N,CPUN		;CURRENT CPU NUMBER
	CAIN	CH,"."		;A DOT?
FILCP2:	PUSHJ	P,EITAST	;YES, CONVERT CPU NUMBER
	  PUSHJ	P,FILPUT	;OUTPUT CHARACTER OR CPU NUMBER
	POP	P,N		;RESTORE ARGUMENT
	JRST	FILCP1		;LOOP OVER ENTIRE STRING

;HERE ON END OF STRING
FILT2A:	POP	P,(P)		;REMOVE INSTRUCTION FROM STACK
FILOT2:	TLZ	F,(F.COM!F.2DEC) ;NOW CLEAR FLAG SO NEXT CALLER CAN USE
				; FILOUT OR FILCOM WITHOUT HAVING TO SET OR CLEAR
				; TO INDICATE COMMENT OR NOT
	POPJ	P,		;RETURN


;ROUTINE TO OUTPUT TO BOTH FILE AND TTY
; SUBSTITUTE FOR * VALUE OR SIXBIT IN N, PRECEDE EACH
; LINE IN FILE WITH ; SO A COMMENT
;CALL:	MOVEI	T1,ADR OF ASCIZ STRING
;	PUSHJ	P,BTHOUT	FOR DECIMAL OR BTHOCT FOR OCTAL
;	ALWAYS RETURN HERE, N PRESERVED

BTHOCT:	SKIPA	R,[EXP 10]	;OCTAL RADIX
BTHOUT:	MOVEI	R,12		;OCTAL OUTPUT FOR FILE
	PUSH	P,T1		;SAVE ADR OF ASCIZ MESSAGE
	PUSHJ	P,FILCOM	;OUTPUT TO FILE AS A COMMENT
	POP	P,T1		;RESTORE ADR OF MESSAGE AND
	JRST	TTROUT		;REPEAT OUTPUT, BUT TO TTY: THIS TIME


;ROUTINE TO OUTPUT TO TTY IN DECIMAL
; SUBSTITUTE FOR * VALUE OR SIXBIT IN N
; OUTPUT INSIDE PARENS AND BRACKETS DEPENDING ON HELP LEVEL
;CALL:	MOVEI	T1,ADR OF ASCIZ STRING
;	PUSHJ	P,TTYOUT
;	ALWAYS RETURN HERE, N PRESERVED

TTYOCT:	MOVEI	R,10		;OCTAL RADIX(RARE) FOR TTY
	JRST	TTROUT		;GO DO REST OF TTYOUT

TTYOUT:	MOVEI	R,12		;SET RADIX TO DECIMAL FOR PEOPLE
TTROUT:	HRLI	T1,440700	;FORM LH OF BYTE POINTER
	PUSH	P,[ILDB CH,T1]	;INSTRUCTION TO GET NEXT CHAR
TTYOLP:	XCT	(P)		;GET NEXT CHAR INTO CH
	PJUMPE	CH,TTYNOW	;IF EOL, FORCE OUT TTY NOW
	CAIN	CH,"["		;LEFT BRACKET?
	TLO	F,(F.LBRK)	;YES, FLAG INSIDE EXPLANATION
	TLNE	F,(F.LBRK)	;ARE WE INSIDE AN EXPLANATION?
	JUMPLE	LV,TTYSBK	;YES, IS HELP LEVEL SHOR OR PROMPT?
	CAIN	CH,"("		;NO, LONG MODE, IS THIS CHAR LEFT PAREN?
	TLO	F,(F.LPAR)	;YES, FLAG INSIDE PROMPTING
	TLNE	F,(F.LPAR)	;ARE WE INSIDE PROMPTING?
	JUMPL	LV,TTYSPR	;YES, IS HELP LEVEL SHORT?

;HERE IF HELP LEVEL PERMITS THESE CHARS TO BE OUTPUT
	CAIN	CH,"*"		;NO, IS IT ASTRISCK?
	PUSHJ	P,EITAST	;YES, SUBSTITUTE N FOR IT
	  PUSHJ	P,TTYPUT	;ARG TO EITAST OR OUTPUT CHAR ROUTINE

;HERE TO SUPPRESS PROMPTING INSIDE PARENS(SHORT MODE ONLY)
TTYSPR:	CAIN	CH,")"		;WAS CHAR JUST OUTPUT RIGHT PAREN?
	TLZ	F,(F.LPAR)	;YES, CLEAR INSIDE PROMPTING FLAG

;HERE TO SUPPRESS EXPLANATION INSIDE BRACKETS(SHORT AND PROMPT MODES)
TTYSBK:	CAIN	CH,"]"		;WAS CHAR JUST OUTPUT RIGHT BRACKET?
	TLZ	F,(F.LBRK)	;YES, CLEAR INSIDE EXPLANATION
	JRST	TTYOLP		;LOOP AND GET NEXT CHAR
;ROUTINE TO SUBSTITUTE FOR * IN OUTPUT TO FIL OR TTY USING N
;CALL:	MOVE	N,[SIXBIT / /] OR DECIMAL NUMBER
;	MOVEI	R,RADIX
;	MOVE	T1,BYTE POINTER
;	CAIN	CH,"*"
;	PUSHJ	P,EITAST
;	  PUSHJ	P,FILPUT OR TTYPUT
;	RETURN	HERE WITH T1 AND N PRESERVED

EITAST:	PUSH	P,T1		;SAVE BYTE POINTER TO STRING
	TLNN	N,770000	;DOES N HAVE A SIXBIT ARG?
	JRST	EITAS2		;NO, OUTPUT AS A NUMBER

;HERE TO OUTPUT N AS SIXBIT FOR *
	MOVE	WD,[XWD 440600,N] ;SETUP BYTE POINTER TO SIXBIT ARG
EITAS1:	ILDB	CH,WD		;GET NEXT SIXBIT CHAR
	JUMPE	CH,TPOPJ1	;IS IT END OF SIXBIT?
	ADDI	CH,40		;CONVERT TO ASCII
	XCT	@-1(P)		;OUTPUT CHAR TO TTY OR FIL ACCORDING
				; TO ARG IN CALLING SEQUENCE
	TLNE	WD,770000	;BYTE POINTER EXHAUSTED WD?
	JRST	EITAS1		;NO, KEEP GETTING SIXBIT CHARS
	JRST	TPOPJ1		;YES, RETURN

;HERE TO CONVERT N AND OUTPUT ACCORDING TO CURRENT RADIX
EITAS2:	MOVE	WD,@-1(P)	;GET ADR OF CHAR PUT ROUTINE FOR TTY OR FILE
				; (TTYPUT OR FILPUT)
	MOVE	T1,N		;MOVE NO. TO DOUBLE AC
	CAIG	N,^D9		;SKIP IF GREATER THAN TWO CHARS
	TLNN	F,(F.2DEC)	;ONE CHAR, SKIP IF WANT AT LEAST TWO
	JRST	EITAS3		;GO AHEAD AS PLANNED
	MOVEI	CH,"0"		;OUTPUT LEADING ZERO
	PUSHJ	P,(WD)		;OUTPUT IT
EITAS3:	PUSHJ	P,EITSUB	;CALL RECURSIVE OUTPUT ROUTINE
TPOPJ1:	POP	P,T1		;RSTORE BYTE POINTER
CPOPJ1:	AOS	(P)		;SET FOR SKIP RETURN
CPOPJ:	POPJ	P,		;RETURN

EITSUB:	IDIVI	T1,(R)		;DIVIDE REMAINING NUMBER BY RADIX
	HRLM	T2,(P)		;SAVE REMAINDER ON STACK
	JUMPE	T1,EITSB1	;REMAINING NUMBER ALL GONE?
	PUSHJ	P,EITSUB	;NO, DIVIDE REMAINING NUMBER BY RADIX AGAIN
EITSB1:	HLRZ	CH,(P)		;GET MOST RECENT CHAR CONVERTED
	ADDI	CH,"0"		;CONVERT TO ASCII
	PJRST	(WD)		;OUTPUT CHAR TO TTY OR FIL AS SPECIFIED
				; IN CALLING SEQUENCE
				; RETURN TO EITSB1 UNTIL ALL CHAR OUTPUT
;ROUTINE TO OUTPUT JUST A STRING AND SUBSTITUTE ASCSTR FOR *
;CALL:	FILSTR	<MESSAGE*MESSAGE@>

FILSTR:	HRLI	T1,440700	;FORM LH OF BYTE POINTER
STRLOP:	ILDB	CH,T1		;GET NEXT CHAR
	JUMPE	CH,CPOPJ	;END OF STRING?
	CAIN	CH,"*"		;IS THIS ASTERISK?
	JRST	STRSUB		;YES, SUBSTITUTE STRING IN ASCSTR
	PUSHJ	P,FILPUT	;NO, STORE THIS CHAR IN FILE OUTPUT BUFFER
	JRST	STRLOP		;GO GET NEXT CHAR

STRSUB:	PUSH	P,T1		;SAVE BYTE POINTER SO FAR
	MOVEI	T1,ASCSTR	;SETUP TO OUTPUT FROM WHERE USER TYPED IN
	PUSHJ	P,FILOUT	;OUTPUT STRING TO FILE
	POP	P,T1		;RESTORE BYTE POINTER TO WHERE LEFT OFF
	JRST	STRLOP		;GO GET NEXT CHAR(SKIP OVER * ITSELF)

;ROUTINE TO OUTPUT LEFT ANGLE BRACKET CRLF TO FILE
;CALL:	PUSHJ	P,FILLAB

FILLAB:	MOVEI	CH,"<"		;LEFT ANGLE BRACKET
	PUSHJ	P,FILPUT	;PUT IN OUTPUT FILE
	PJRST	FCRLF		;OUTPUT CRLF TO FILE

;ROUTINE TO OUTPUT RIGHT ANGLE BRACKET CRLF TO FILE
;CALL:	PUSHJ	P,FILRAB

FILRAB:	MOVEI	CH,">"		;RIGHT ANGLE BRACKET
	PUSHJ	P,FILPUT	;PUT IN OUTPUT FILE
				; FALL INTO FCRLF

;ROUTINE TO OUTPUT CRLF TO FILE
;CALL:	PUSHJ	P,FCRLF

FCRLF:	MOVEI	CH,C.CR		;OUTPUT CR
	PUSHJ	P,FILPUT	;TO FILE
	MOVEI	CH,C.LF		;THEN LINE FEED
				; FALL INTO FILPUT
;ROUTINE TO OUTPUT 1 CHAR TO OUTPUT FILE, IF @ SUBSTITUTE CRLF
; OUTPUT TO TTY TOO IF DEBUGGING FLAG IS SET(DEBUG)
;INSERT PRECEDING ; IF FIRST CHAR ON A LINE AND F.COM SET
;CALL:	MOVEI	CH,CHAR
;	PUSHJ	P,FILPUT
;	RETURN CH PRESERVED

FILPUT:	TLNN	F,(F.OFO)	;OUTPUT FILE OUTPUT YET?
	POPJ	P,		;NO, MUST BE ASKING QUESTION ABOUT OUTPUT FILE
	CAIN	CH,"@"		;YES, IS THIS CHAR THE CRLF CHAR?
	PJRST	FCRLF		;YES, OUTPUT CRLF TO FILE AND RETURN
	SKIPE	DEBUG		;NO, ARE WE DEBUGGING?
	TLOE	F,(F.TF)	;YES, IS THIS THE FIRST CHAR TO FIL
				; AFTER TTY OUTPUT?
	JRST	FILPU1		;NO, LEFT ANGLE ALREADY OUTPUT
	PUSH	P,CH		;YES, SAVE CHAR
	MOVEI	CH,"<"		;FLAG START OF OUTPUT WITH LEFT ANGLE
	PUSHJ	P,TTYPU1	;ON TTY
	POP	P,CH		;RESTORE REAL FIRST CHAR TO FILE
FILPU1:	TLZE	F,(F.FLF)	;WAS LAST CHAR OUTPUT TO FILE A LF?
	TLNN	F,(F.COM)	;YES, SHOULD THIS LINEN BE A COMMENT IN FILE?
	JRST	FILPU2		;NO, SO OUTPUT IT
	PUSH	P,CH		;YES, SAVE FIRST CHAR OF LINE
	MOVEI	CH,";"		;INSTEAD PUT OUT SEMI-COLON AS COMMENT CHAR
	PUSHJ	P,FILPU3	; AS FIRST CHAR ON LINE
	MOVEI	CH,";"		;OUTPUT 2 ; IN CASE COMMENT IS IN MACRO
	PUSHJ	P,FILPU3	;SO WONT SAVE COMMENT IN MACRO EXPANSION
	MOVEI	CH,"	"	;TAB
	PUSHJ	P,FILPU3	;OUTPUT TAB
	POP	P,CH		;RESTORE FIRST CHAR OF COMMENT
FILPU2:	CAIN	CH,C.LF		;IS THIS CHAR A LINE FEED?
	TLO	F,(F.FLF)	;YES, FLAG LAST CHAR OUTPUT WAS A LINE FEED
				; FOR NEXT CALL TO FILPUT
FILPU3:	SKIPE	DEBUG		;DEBUGGING SO WANT TO SEE FILE OUTPUT
	PUSHJ	P,TTYPU1	;YES, OUTPUT TO TTY TOO
	SOSG	FOBUF+2		;DECREMENT BUFFER COUNTER
	PUSHJ	P,[OUT	FILCHN,	;BUFFER FULL, GIVE TO MONITOR
		   POPJ	P,	;NO ERRORS
		   JRST FILERR]	;FILE ERROR, COMPLAIN AND START OVER
	IDPB	CH,FOBUF+1	;STORE CHAR IN BUFFER
	POPJ	P,		;RETURN
;ROUTINE TO OUTPUT CRLF TO TTY
;CALL:	PUSHJ	P,TCRLF

TCRLF:	MOVEI	CH,C.CR		;CR CHAR
	PUSHJ	P,TTYPUT	;OUTPUT TO TTY
	MOVEI	CH,C.LF		;LINE FEED CHAR
				; FALL INTO TTYPUT ROUTINE

;ROUTINE TO OUTPUT 1 CHAR TO TTY, IF @ SUBSTITUTE CRLF
;CALL:	MOVEI	CH,CHAR
;	PUSHJ	P,TTYPUT
;	RETURN CH PRESERVED

TTYPUT:	CAIN	CH,"@"		;IS THIS THE CRLF CHAR?
	PJRST	TCRLF		;YES, OUTPUT CRLF ON TTY AND RETURN
	SKIPE	DEBUG		;NO, ARE WE DEBUGGING?
	TLZN	F,(F.TF)	;YES, IS THIS FIRST CHAR ON TTY AFTER FIL?
	JRST	TTYPU1		;NO, OK TO OUTPUT
	PUSH	P,CH		;YES, SAVE REAL FIRST CHAR
	MOVEI	CH,">"		;AND INDICATE TERMINATION OF FILE OUTPUT
	PUSHJ	P,TTYPU1	;OUTPUT TO TTY
	POP	P,CH		;RESTORE REAL FIRST TTY CHAR

;SUBROUTINE TO REALLY OUTPUT 1 CHAR TO TTY
TTYPU1:	SOSG	TOBUF+2		;ROOM IN THIS OUTPUT BUFFER?
	OUTPUT	TTYCHN,		;NO, SO OUTPUT 
	IDPB	CH,TOBUF+1	;THEN STORE THIS CHAR IN BUFFER
	POPJ	P,		;RETURN

;SUBOURINTE TO FORCE OUT CURRENT BUFFER NOW
;CALL:	PUSHJ	P,TTYNOW

TTYNOW:	OUTPUT	TTYCHN,		;GIVE BUFFER TO MONITOR
	POP	P,(P)		;REMOVE INSTRUCTION FROM STACK
	POPJ	P,		;RETURN


;***SUBROUTINE TO BUILD SYSJOB.INI

SYSINI:	FILOUT	<LOGIN@>
	FILOUT	<DAEMON@>
	FILOUT	<LOGIN@>
	FILOUT	<FILDAE@>
	FILOUT	<LOGIN@>
	FILOUT	<QUASAR@>
	FILOUT	<LOGIN@>
	FILOUT	<ORION@>
	FILOUT	<LOGIN@>
	FILOUT	<PULSAR@>
	FILOUT	<LOGIN@>
	FILOUT	<BATCON@>
;	SKIPN	LPTS		;***LPT ON SYSTEM?
;	JRST	CARD		;NO GO TO CARD READER
PRNTR:	MOVE	N,LPTS		;GET NUMBER OF PRINTERS ON THE SYSTEM
	SOJL	N,CARD		;GOT ANY
	FILOUT	<LOGIN@>	;YES, PUT IN SPOOLER
	FILOUT	<LPTSPL@>
	JRST	PRNTR+1		;AND LOOP BACK
CARD:	;SKIPN	CDRS		;***CDR ON SYSTEM?
;	JRST	TGH		;NO GO TO TGHA
	MOVE	N,CDRS		;GET NUMBER OF CARD READERS ON THE SYSTEM
	SOJL	N,TGH		;GOT ANY?
	FILOUT	<LOGIN@>	;YES, PUT IN SPRINT
	FILOUT	<SPRINT@>
	JRST	CARD+1		;AND LOOP BACK
TGH:	SKIPN	MOS		;***MOS MEMORY?
	JRST	MIC		;NO GO DO MIC
	FILOUT	<LOGIN@>
	FILOUT	<TGHA@>
MIC:	FILOUT	<LOGIN@>
	FILOUT	<R MIC@>
	POPJ	P,

;***SUBROUTINE TO BUILD SYSTEM.CMD

SYSCMD:	FILOUT	<START BATCH-STREAM 0:14@>	;SETUP SYSTEM.CMD FOR
						;NORMAL COMMANDS
	FILOUT	<DISABLE OUTPUT-DISPLAY ALL-MESSAGES /JOB@>
	FILOUT	<DISABLE VOLUME-RECOGNITION TAPE-DRIVES@>
	SKIPN	TPTAB			;ANY TAPES INSTALLED?
	JRST	SYSNTP			;NO GO DO SINGLE INTRY
	SETZ	T1,			;CLEAR T1 AND T2
STPLP:	SKIPN	TPTAB(T1)		;DONE LOOP?
	JRST	SYSLPT-1		;YES, GO DO LINEPRINTERS
	PUSH	P,T1			;SAV INDEX
	FILOUT	<SET TAPE-DRIVE >	;OUTPUT PART OF LINE TO FILE
	POP	P,T1			;GET INDEX
	PUSH	P,T1			;PUT IT BACK ON STACK FOR NOW
	PUSHJ	P,TPNAM			;GO OUTPUT NAME
	POP	P,T1			;GET INDEX
	MOVE	N,TPTAB+1(T1)		;GET NUMBER OF XPORTS
	SUBI	N,1			;ADJUST XPORT NUMBER
	MOVEM	N,TPTAB+1(T1)		;RESTORE NEW COUNT OF TAPES
	PUSH	P,T1			;SAVE INDEX
	FILOUT	<*: UNAVAILABLE ^Z@>,N	;OUTPUT XPORT NUMBER
	POP	P,T1			;RETRIVE INDEX
	SKIPE	N			;IF N = 0 DO NEXT LOOP
	JRST	STPLP			;LOOP FOR NEXT ENTRY
NXTLP:	ADDI	T1,2			;BUMP INDEX
	JRST	STPLP			;LOOP BACK
SYSNTP:	FILOUT	<SET TAPE-DRIVE MTA0: UNAVAILABLE ^Z@>
	MOVE	N,LPTS			;GET NUMBER OF LINE PRINTERS
SYSLPT:	SOJL	N,SYSCDR		;ANY ON SYSTEM?
	FILOUT	<SET PRINTER * PAGE-LIMIT 2000@>,N	;YES, OUTPUT COMMAND
	FILOUT	<START PRINTER *@>,N	;TO SYSTEM.CMD
	JRST	SYSLPT			;AND LOOP BACK
SYSCDR:	MOVE	N,CDRS			;GET NUMBER OF CARD READERS
	SOJL	N,SYSTAP		;ANY ON SYSTEM
	FILOUT	<START READER *@>,N	;YES, OUPUT COMMAND TO SYSTEM.CMD
	JRST	SYSCDR+1		;AND LOOP BACK
SYSTAP:	POPJ	P,

;SUBROUTINE TO OUTPUT MTX TO SYSTEM.CMD FILE 

TPNAM:	MOVE	N,T1		;GET INDEX INTO TPTAB
	JRST	TPJMP(N)
TPJMP:	JSR	TPNMA		;GO OUTPUT MTA
	POPJ	P,		;RETURN
	JSR	TPNMB		;GO OUTPUT MTB
	POPJ	P,		;RETURN
	JSR	TPNMC		;GO OUTPUT MTC
	POPJ	P,		;RETURN
	JSR	TPNMD		;GO OUTPUT MTD
	POPJ	P,		;RETURN
	JSR	TPNME		;GO OUTPUT MTE
	POPJ	P,		;RETURN

TPNMA:	0			;RETURN ADDR
	FILOUT	<MTA>		;OUTPUT NAME OF XPORT
	JRST	@TPNMA		;RETURN
TPNMB:	0			;RETURN ADDR
	FILOUT	<MTB>		;OUTPUT NAME OF XPORT
	JRST	@TPNMB		;RETURN
TPNMC:	0			;RETURN ADDR
	FILOUT	<MTC>		;OUTPUT NAME OF XPORT
	JRST	@TPNMC		;RETURN
TPNMD:	0			;RETURN ADDR
	FILOUT	<MTD>		;OUTPUT NAME OF XPORT
	JRST	@TPNMD		;RETURN
TPNME:	0			;RETURN ADDR
	FILOUT	<MTE>		;OUTPUT NAME OF XPORT
	JRST	@TPNME		;RETURN

SUBTTL	DATA STORAGE

;CONSTANTS:

;DEFAULT FILE NAMES:
FILTAB:	SIXBIT	/HDWCNF/	;HDWCNF
	SIXBIT	/TTYCNF/	;TTYGEN
	SIXBIT	/NETCNF/	;NETGEN
	SIXBIT	/F/		;FGEN
	SIXBIT	/SYSJOB/	;***SYSJOB
	SIXBIT	/SYSTEM/	;***SYSTEM

;DISPATCH TABLE:
GENTAB:	EXP	HDWGEN		;HDWGEN
	EXP	TTYGEN		;TTYGEN
	EXP	NETGEN		;NETGEN
	EXP	FGEN		;FGEN
	EXP	SYSINI		;***SYSJOB
	EXP	SYSCMD		;***SYSTEM.CMD


LSTD44:	I,,PAR			;INDEX BY DC44 NUMBER
	I,,PAP			;PA611R AND PA611P
	I,,LPC			;END LPC11
	I,,PCR			;END PC11 READERS
	I,,PCP			;AND PC11 PUNCHES
TYPDEV=.-LSTD44-1
;VARIABLES:
; THESE ARE STRICTLY INTERNAL TO MONGEN AND ARE NEVER OUTPUT IN FILE
;ONES NOT CLEARED IN MAIN LOOP, INSTEAD SET TO INITIAL VALUES ONLY ON GET.
; THUS ^C START DOES NOT INITIALIZE:


FGTYPE:	0		;TYPE OF SYSTEM FOR FGEN
HELPF:	-1		;FLAG TO TYPE /HELP ONLY ONCE THRU LOOP OR START
DEBUG:	0		;PATCH NON-ZERO TO DEBUG BY HAVING FIL OUTPUT TO TTY TOO
			; COME OUT ON TTY INSIDE <>
SAVLV:	0		;CURRENT PERMANENT VERBOSICITY LEVEL FOR ASKING QUESTIONS
			; AC LV MAY BE DIFFERENT IF USER HAS CHANGED
			; LEVEL FOR THIS QUESTION ONLY
			; LEVELS ARE -1 FOR SHORT, 0 FOR PROMPT,
			; AND 1 OR GREATER FOR LONG
			; INITIALLY SET TO PROMPT ON A GET
FHNAME:	SIXBIT	.FGEN.	;LOOKUP BLOCK FOR FGEN AUXILIARY HELP FILE
	SIXBIT	.HLP.
	0
	0

RUNDEV:	BLOCK	1	;DEVICE FROM RUN OR GET
RUNPPN:	BLOCK	1	;DIRECTORY FROM RUN OR GET
FGPPN:	BLOCK	1	;DIRECTORY TO USE FOR HELP FILE
;VARIABLES CLEARED EACH TIME THROUGH MAIN LOOP FOR A NEW GEN:

VARBEG:			;FIRST LOC CLEARED ON MAIN LOOP
PDLIST:	BLOCK	MP.PDL+1	;PD LIST
ASKTAB:	BLOCK	MP.AMX+1	;TABLE TO STOR POSSIBLE ANSWERS
				; SETUP BY ASKLST WITH PROMPTING INSIDE ()
				; LAST ENTRY MUST BE ZERO AS FLAG OF END
				; FIRST ENTRY MAYBE 0 TO MEAN NO DEFAULT
				; IE (,ANS0,ANS1,...)
ASCSTR:	BLOCK	<MP.LMX+4+1>/5	;STRING FOR TTY INPUT LINE(SEE TTYIN)
			; ENOUGH ROOM FOR MP.LMX CHAR, PLUS NULL
SAVN:	BLOCK	1	;PLACE TO SAVE MATCH INDEX IN ASKLST SUB
CNFIND:	BLOCK	1	;INDEX OF SYSTEM TYPE
MINLIM:	BLOCK	1	;MIN VALUE FOR ASK QUESTION.  SET BY NOS. INSIDE ()
			; WHICH PRECED A DASH.
MAXLIM:	BLOCK	1	;MAX VALUE FOR ASK QUESTION.  SET BY NOS. INSIDE
			; WHICH FOLLOW A DASH.
DFAULT:	BLOCK	1	;DEFAULT FOUND FIRST INSIDE () IN ASK QUESTION
			; BY SETLST ROUTINE
WCHGEN:	BLOCK	1	;WHICH GEN, 0=HDW, 1=TTY, 2=NET, 3=F
WCHNAM:	BLOCK	1	;WHICH GEN NAME, LH=SIXBIT HDW, TTY, NET, OR F
CPU:	BLOCK	1	;LOOP COUNTER FOR CPU LOOP
SCPUNR:	BLOCK	1	;NON-ZERO IF SOME CPU HAS NO REAL-TIME CLOCK
CHNTYP:	BLOCK	1	;CHANNEL TYPE 0=DF10,1=DF10C,2=DX10
CHN:	BLOCK	1	;LOOP COUNTER FOR CHANNEL LOOP
CCHN:	BLOCK	1	;LOOP COUNTER FOR CHANNELS ON A CPU
CPUN:	BLOCK	1	;LOOP COUNTER FOR DEVICES ON CPU'S OTHER THAN 0
DTA:	BLOCK	1	;LOOP COUNTER FOR DTA LOOP
MKON:	BLOCK	1	;COUNTER FOR MAG-TAPE KON ID
MKONP:	BLOCK	1	;NUMBER OF TAPE CONTROLS ON PREVIOUS CPUS
TAPOFS:	BLOCK	1	;NUMBER OF "EXTRA" TM02 UNITS
OSN:	BLOCK	1	;OCTAL STATION NO. CURRENTLY BEING DEFINED
LPTCNT:	BLOCK	1	;# OF LPTS
T2RH10:	BLOCK	1	;# OF RH10/TM02S ON CPU
T2RH1P:	BLOCK	1	;# OF RH10S ON PREVIOUS CPUS
D2RH20:	BLOCK	1	;# OF DX20S ON RH20S ON THIS CPU
TXCPUN:	BLOCK	1	;# TX10S
T1CPUN:	BLOCK	1	;# TM10S
RSCPUN:	BLOCK	1	;# OF RS04S ON THIS CPU
RPCPUN:	BLOCK	1	;# OF RP04S ON PREVIOUS CPUS
RNCPUN:	BLOCK	1	;# OF RP20S ON PREVIOUS CPUS
DPCPUN:	BLOCK	1
FHCPUN:	BLOCK	1
rh20cp:	block	1	;#of rh20s on this cpu

;FILE 4 WORD ENTER BLOCK:
OUTNAM:	BLOCK	1	;FILE NAME
OUTEXT:	BLOCK	1	;FILE EXTENSION
OUTDAT:	BLOCK	1	;FILE DATE
OUTPPN:	BLOCK	1	;FILE PROJECT, PROGRAMMER NUMBER
SAVPPN:	BLOCK	1	;SAVE PPN FOR MESSAGE AFTER ENTER
;BUFFER HEADERS:
TIBUF:	BLOCK	3	;TTY INPUT BUFFER HEADER
TOBUF:	BLOCK	3	;TTY OUTPUT BUFFER HEADER
FOBUF:	BLOCK	3	;FILE OUTPUT BUFFER HEADER
FHIBUF:	BLOCK	3	;FGEN AUXILIARY HELP FILE INPUT BUFFER HEADER

;BUFFERS
FILBUF:	BLOCK	NFILBF*203	;BUFFERS FOR OUTPUT FILE
FHLPBF:	BLOCK	NFHLPBF*203	;BUFFERS FOR FHELP FILE

;POINTERS TO FGEN SWITCH TABLE
FTTAB:	BLOCK	1	;POINTER TO TABLE READ FROM FILE
FTADD:	BLOCK	1	;POINTER TO TABLE OF USER ADDED SWITCHES
FTLEN:	BLOCK	1	;MINUS LENGTH OF WHOLE TABLE
;VARIABLES WHICH ARE ALSO OUTPUT IN FILE AS SYMBOLS

;***************************************************************
;NOTE:	MACRO REQUIRES A ; AFTER ANGLE BRACKET IN CALL, ELSE TAB
; SNEAKS IN BETWEEN SYMBOL AND ;
;***************************************************************

;MACRO TO DEFINE CONSECUTIVE VARIABLES USED BY AOS(N) TRICK
;ORDER MUST BE THE SAME AS IN PROMPTING ANSWERS INSIDE PARENS

DEFINE	V (A)<
IRP (A) <M.'A:	BLOCK	1
>>

V <1070,1080,1090,1091,2020>;	;WHICH TYPE OF DECSYSTEM10
V <RT0,RT1,RT2,RT3,RT4,RT5>;	;NO OF DK-10S ON CPU'N
V <RTX>;			;TOTAL DK-10S ON SYSTEM
V <RTCA>;			;HIGH PRECISION TIME ACCOUNTING
V <RTCO>;			;INCLUDE MONITOR OVERHEAD IN RUNTIME
V <RTC>;			;INCLUDE DK10 SERVICE ROUTINE
V <EMRT>;			;EBOX/MBOX RUNTIME ACCOUNTING
V <XPI>;			;EXCLUDE PI TIME FROM USER RUNTIME
V <CPU>;			;NO. OF CPUS
V <P10>;			;PDP-10
V <P10I>;			;PDP-10I
V <KL10>;			;KL10 CPU
V <KS10>;			;KS10 CPU
V <C0SN,C1SN,C2SN,C3SN,C4SN,C5SN>;  ;CPU SERIAL NOS.
V <MON,DAY,YEAR>;		;MONTH, DAY, YEAR SYMBOLS
V <CHN>;			;NO. OF DISK CHANNELS
V <RC10>;			;NO. OF RC10 CONTROLLERS
V <RH1S>;			;NO OF RH10/RS04 CONTROLLERS
V <RH1P>;			;NO OF RH10/RP04 CONTROLLERS
V <RH2P>;			;NO. OF RH20/RP04 CONTROLLERS
				;MUST IMMEDIATELY FOLLOW RH1P
V <RHP4>;			;TOTAL NO OF RHP04'S (RH10 AND RH20)
V <RP20>;			;TOTAL NO OF RP20'S (RH20)
V <RH20>;			;NO. OF RH20S (RP04, TM02)
V <RP10>;			;NO. OF RP10 CONTROLLERS
V <TX01>;			;NO. OF TX01 CONTROLLERS
V <TM10>;			;NO. OF TM10 CONTROLLERS
V <T210>;			;NO. OF TM02 CONTROLLERS
V <DX20>;			;NO. OF DX20 CONTROLLERS
V <T78>;			;NO OF TM78 CONTROLLERS

V <HRSN>;			;HIGHEST REMOTE STATION NUMBER
V <TTDN>;			;TOTAL NUMBER OF RSX20-F TERMINALS
V <DLP>;			;TOTAL NUMBER OF RSX20-F LPTS
V <DCR>;			;TOTAL NUMBER OF RSX20-F CDRS

;HDWGEN:
V <VP10,340,VBXC>;		;TYPE OF DISPLAY
V <DN60,D60L,0D60,1D60,2D60,3D60,4D60,5D60,6D60,7D60,8D60,9D60,AD60,BD60>;	;DN60

;TTYGEN:
V <DC10,DC68,DC76>;		;TYPE OF TERMINAL COMMUNICATIONS EQUIPMENT
V <TTG0,TTG1,DSG0,DSG1,68L0,68L1,D70N,D71N,D72N,D73N,D74N,D75N,D76N,D77N>
V <DZNL>;
	DEFINE	BLOK4(PREFIX,POSTFX)
<	IRP	PREFIX
<
PREFIX:
ZZZ=0
	REPEAT	8,<
	WORD	(PREFIX,\ZZZ,POSTFX)
ZZZ=ZZZ+1
>	;;END OF REPEAT 4
	WORD	(PREFIX,8,POSTFX)
	WORD	(PREFIX,9,POSTFX)
	WORD	(PREFIX,A,POSTFX)
	WORD	(PREFIX,B,POSTFX)
>	;;END OF IRP PREFIX
>	;;END OF DEFINE BLOK4

	DEFINE	WORD(A,B,C)
<A'B'C:	EXP	0
>

;NOTE THE POSTFIX IS A NOOP FOR PREFIXES OF 5 CHARACTERS E.G. TYPNU


M.DC44:	EXP	0	;NUMBER OF DC44'S
TYPNUM:	EXP	0	;TOTAL NUMBER OF DC44 FRONT END DEVICES
	BLOK4	<TYPNU,PAR,PAP,LPC,PCR,PCP>,N

M.DC75:	EXP	0	;NUMBER OF DC75'S OF DAS85'S
M.DL10:	EXP	0
M.0D85:	EXP	0	;SYMBOL INDICATING PORT PRESENT
M.1D85:	EXP	0
M.2D85:	EXP	0
M.3D85:	EXP	0
M.4D85:	EXP	0
M.5D85:	EXP	0
M.6D85:	EXP	0
M.7D85:	EXP	0
M.8D85:	EXP	0	;DUMMY SINCE DN87'S ONLY GO ON DL10'S
M.9D85:	EXP	0
M.AD85:	EXP	0
M.BD85:	EXP	0
M.CONN:	EXP	0	;ACCUMULATES DEFAULT # OF CONNECTS
M.CDR:	EXP	0
M.CDP:	EXP	0
M.PLT:	EXP	0
M.PTP:	EXP	0
M.PTR:	EXP	0


DFS:	BLOCK	1	;FLAG TO INDICATE EXISTANCE OF DF10S ON 1090 SYSTEM
NUM:	BLOCK	1	;FLAG TO INDICATE THAT A CHANNEL HAS BEEN SELECTED
DMYTAP:	BLOCK	1	;DUMMY TAPE FLAG USED TO INSERT DUMMY
			;TU45 IN HDWGEN FOR TAPELESS SYSTEMS
MACKN:	BLOCK	1	;FLAG TO INDICATE DUMMY TAPE INSTALLED 
			;USED IN MACK ROUTINE
VAREND==.-1		;LAST LOC TO CLEAR IN MAIN LOOP FOR NEW GEN

FSTFLG:	BLOCK	1	;FLAG USED TO INDEX WHICH GEN HAS BEEN DONE
DTES:	BLOCK	1	;NUMBER OF DTES SELECTED IN HDWGEN
SAVTTY:	BLOCK	1	;NUMBER OF TTYS SELECTED IN HDWGEN, USED IN TTYGEN
SAVTYP:	BLOCK	1	;TYPE OF SYSTEM. 1=1091, 0=1090
CPUS:	BLOCK	1	;NUMBER OF CPUS ON SYSTEM. GENERATED IN HDWGEN, USED IN
			;NETGEN
MOS:	BLOCK	1	;***FLAG TO INDICATE MOS FOR SYSJOB
LPTS:	BLOCK	1	;***FLAG TO INDICATE LPT FOR SYSJOB
CDRS:	BLOCK	1	;***FLAG TO INDICATE CDR FOR SYSJOB
TPTAB:	BLOCK	20	;***TAPE COUNT TABLE EVEN ADDR = -1 ODD ADDRESS =
			;EQUALS NUMBER OF TAPES ON THAT UNIT

	END	BEGINA