Google
 

Trailing-Edge - PDP-10 Archives - de-10-omona-v-mc9 - mongen.mac
There are 17 other files named mongen.mac in the archive. Click here to see a list.
TITLE	MONGEN - PROGRAM TO DEFINE MONITOR, TTY AND REMOTE CONFIGURATIONS - V1050
SUBTTL	T. HASTINGS/TH/EP/DAL	22 AUG 78
EDITNO==136		;EDIT NO.
VERSION==050		;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) 1970,1974,1978 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

;SYMBOLS WHICH ARE PARAMETERS OF MONGEN ITSELF(PREFIX MP)
IFNDEF MP.MVN,<MP.MVN==^D603>	;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==^D7>	;MAX SYSTEM SUPPORTED IN 6.03
		; 1040=0, 1050=1,1055=2,1070=3,1077=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 > 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	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 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

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.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.ONNM==77	;MAXIMUM STATION NUMBER WHICH MAY BE CENTRAL SITE
SM.NODES==77	;MAXIMUM NUMBER OF NODES
		;THE CONNECTS MESSAGE HAS THE ABS VALUE
SM.CONN==^D512	;MAXIMUM NUMBER OF CONNECTS
SM.RTTY==^D512	;MAXIMUM NUMBER OF REMOTE TTY'S
SM.RCDR==77	;MAXIMUM NUMBER OF REMOTE CDR'S
SM.RLPT==77	;MAXIMUM NUMBER OF REMOTE LPT'S
SM.RPR==0	;MAXIMUM NUMBER OF PAPER TAPE READERS
SM.RPP==77	;MAXIMUM NUMBER OF PAPER TAPE PUNCHES
SM.RMTA==0	;MAXIMUM NUMBER OF REMOTE MAGNETIC TAPE DRIVES
SM.RJOB==^D128	;MAXIMUM NUMBER OF REMOTE PROCESSES
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.DLP==2	;MAXIMUM NUMBER OF LINE PRINTERS ON 1091 FRONT END
SM.DCR==1	;MAXIMUM NUMBER OF CARD READERS ON 1091 FRONT END
SM.D78==^D8	;MAXIMUM NUMBER OF DAS78'S (IBM 360,370,2780 SUPPORT)
SM.XTC==4	;MAXIMUM NUMBER OF DA28C CHANNELS
SM.D78==^D8	;MAXIMUM NUMBER OF DAS78'S (IBM 360,370,2780 SUPPORT)
;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 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	<1040,1050,1055,1070,1077>

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		;NO--MUST BE ^C START
	MOVEM	.SGDEV,RUNDEV	;SAV DEVICE FROM WHICH MONGEN WAS RUN
	MOVEM	.SGPPN,RUNPPN	;AND DIRECTORY
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
	AOSG	HELPF		;ALREADY TOLD USER ABOUT HELP?
	PUSHJ	P,TTYHLP	;NO, ASK USER FOR LEVEL OF VERBOSITY WITH /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:	ASKLST	<Which GEN(HDW,TTY,NET,F)[
HDW to define hardware configuration
TTY to define terminal configuration
NET to define network configuration
F to define software features]>
	TLNE	F,(F.CONZ)	;DID USER TYPE CONTROL Z?
	EXIT			;YES, EXIT TO MONITOR
	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
	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
	ASKSTR	<Output(DSK:*.MAC)>,OUTNAM ;ASK FOR FILE SPEC
	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>
	FILCOM	<@END OF *>,OUTNAM
	HLLZ	N,OUTEXT	;EXTENSION OF FILE WRITTEN
	FILCOM	<.*@>,N
	MOVEI	CH,C.FF		;FORM FEED
	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

;HERE TO FIND OUT WHAT TYPE OF SYSTEM
	ASKLST	<Feature set(TINY,KALUG,KILUG,KAFULL,KIFULL,KLFULL)[
TINY   Is minimum subset of features for KA10 timesharing
KALUG  Is medium size KA10 monitor with enough features for  batch
KILUG  Same as KALUG but for KI10 cpu
KAFULL Includes all features of DECsystem10 monitor such
	as real-time and extended file system for KA10 cpu
KIFULL Same as KAFUL but for KI10 cpu
KLFULL	Same as KIFULL but for KL10 cpu]>
	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
	JRST	.+2		;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
	JRST	FSETD4		;NOT A NUMBER OR LETTER, 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:	ASKLST	<Standard setting(YES,NO,LIST,EXPLAIN)[
Standard values for all feature test switches for your configuration]>
	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	T2,FGTYPE
	CAMN	N,[SIXBIT 'FTVM']	;VIRTUAL MEMORY?
	CAIG	T2,3
	JRST	STDOU0		;NO V-M
	ASKLST	<Do you want the virtual memory facility(YES,NO)[VMSER must
be on your distribution tape]>
	MOVE	T1,-1(P)
	MOVSI	T2,(FS.VAL)
	ANDCAM	T2,@FTTAB
	JUMPN	N,STDOU0
	IORM	T2,@FTTAB
STDOU0:	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	<	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.KA10,*@>,M.P10
	FILOUT	<XP M.KI10,*@>,M.P10I
	FILOUT	<XP M.KL10,*@>,M.KL10
	FILOUT	<XP M.1040,*@>,M.1040
	FILOUT	<XP M.1050,*@>,M.1050
	FILOUT	<XP M.1055,*@>,M.1055
	FILOUT	<XP M.1070,*@>,M.1070
	FILOUT	<XP M.1077,*@>,M.1077
	FILOUT	<XP M.1080,*@>,M.1080
	FILOUT	<XP M.1088,*@>,M.1088
	FILOUT	<XP M.1091,*@>,M.1091
	FILOUD	<XP MD.P6,*@>,MD.P6
	AOS	M.CPU		;INDICATE AT LEAST 1 CPU
	SKIPE	M.1088		;DUAL KL10?
	AOS	M.CPU		;YES, INDICATE TWO CPUS
	SKIPN	M.1055		;DUAL PDP10?
	SKIPE	M.1077		;DUAL PDP10I?
	AOS	M.CPU		;YES, INDICATE TWO CPUS
	FILOUT	<XP M.CPU,*@>,M.CPU


ASKNAM:	ASKSTR	<System name[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
	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
	ASKYN	<Exclude Monitor overhead from user run time(Y,N)[
Overhead is CPU time spent clock queue processing, command
decoding, core shuffling, swapping, and scheduling.
User run time always includes UUO execution and
unless EBOX/MBOX runtime accounting is selected
(KL10 systems only) includes IO interrupt service time.
On KA or KI systems, each CPU must have a DK10]>
	FILOUT	<XP M.RTCO,*@>,N
ASKEMT:	SKIPN	M.KL10		;KL10 SYSTEM?
	JRST	NOEMRT		;NO, NO EBOX/MBOX TIME ACCOUNTING
	ASKYN	<EBOX/MBOX runtime accounting?(y,n)[
If EBOX/MBOX runtime accounting is selected in a KL10
based system, user runtime is computed using the KL10
internal accounting clocks]>
	MOVEM	N,M.EMRT	;SAVE FOR LATER
	FILOUT	<XP M.EMRT,*@>,M.EMRT
	SKIPN	M.EMRT
	JRST	NOEMR1		;NO PI EXCLUSION EITHER
	ASKYN	<Exclude PI time from user runtime?(y,n)[
An answer of "yes" to this question will cause the monitor
to set up the KL10 accounting meters in such a manner that
users will not be charged for cpu time used during interrupts]>
	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
ASKDFS:	MOVEI	N,SM.DF		;MAXIMUM NUMBER OF DF10S
	ASKDEC	<# Data Channels(2,1-*)[DF10s, DF10Cs, DX10s OR RH20'S  for disk and tape]>
	FILOUT	<XP M.CHN,*@>,N
	MOVEM	N,M.CHN		;SAVE FOR CHANNEL LOOP
	SETOM	MKON		;MAGTAPE CONTROLLER #

;LOOP ONCE FOR EACH CHANNEL
CHNLOP:	MOVE	N,CHN		;CHANNEL ITERATION COUNTER(0,1,...)
	ASKLST	<Channel * Type (DF10,DF10C,DX10,RH20)>
	MOVEM	N,CHNTYP
	MOVE	N,CHN
	FILOUT	<XP M.CH*T,>,N	;OUTPUT CHANNEL TYPE
	MOVE	N,CHNTYP	;GET BACK ANSWER
	FILOUT	<*@>,N		;AND COMPLETE OUTPUT
	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
	FILOUT	<XP M.C*TX,0@>,CHN ;NO TX01S ON THIS CHL
	SKIPE	N,RH12		;IF AN RH20,
	SOJA	N,NORD10	; THERE AREN'T ANY RD10S
	ASKDEC	<  # RC10s(0-2)[Controllers for RD10 Burroughs disks and
RM10B Bryant drums on channel *]>,CHN
NORD10:	MOVE	I,N		;SET UP ITERATION FOR THIS CONTROLLER
	FILOUT	<XP M.C*FH,>,CHN ;FIRST PART OF CALL
	FILOUT	<*@>,I		;SECOND HALF
	JUMPE	I,FHEND		;ANY CONTROLLERS AT ALL?

;LOOP FOR FH* ON THIS CHANNEL:
FHLOOP:	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
	ASKDEC	<  # RH10S for RS04'S(0-3)[Controllers for RS04 swapping
disks on channel *]>,CHN
NORS04:	MOVE	I,N
	FILOUT	<XP M.C*FS,>,CHN
	FILOUT	<*@>,I
	JUMPE	I,FSEND
;LOOP FOR FS* ON THIS CHANNEL:
FSLOOP:	AOS	N,M.RH1S	;INCREMENT NO. OF RH10 IN SYSTEM
	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
	FILOUT	<*@>,N
	SOJG	I,FSLOOP
FSEND:	JUMPN	RH12,ASKRP2
	ASKDEC	<  # RH10S for RP04'S, RP06'S(0-3)[Controllers for RP04, RP06 disk pack
units on channel *]>,CHN
	JRST	ASKRP3
ASKRP2:	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.C*RP,>,CHN
	FILOUT	<*@>,I
	JUMPE	I,RPEND

;LOOP FOR RP* ON THIS CHANNEL
RPLOOP:	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	N,M.RHP4
	SUBI	N,1
	FILOUT	<XP M.RP*T,>,N		;INDICATE TYPE
	SKIPE	N,RH12
	MOVE	N,M.RH20		;0 FOR RH10, CONTROL NUMBER FOR RH20
	FILOUT	<*@>,N
	SOJG	I,RPLOOP

RPEND:	SKIPE	N,RH12
	SOJA	N,NORP10		;NO RP10S IF RH20
	ASKDEC	<  # RP10s(0-3)[Controllers for Memorex and ISS RP02 and RP03 
disk pack units on channel *]>,CHN
NORP10:	MOVE	I,N		;SETUP ITERATION COUNT FOR RP FOR THIS CHANNEL
	FILOUT	<XP M.C*DP,>,CHN	;OUTPUT FIRST HALF
	FILOUT	<*@>,I		;NO. OF CONTROLLERS ON THIS CHANNEL
	JUMPE	I,DPEND		;ANY RP10S AT ALL ON THIS CHANNEL?

;LOOP FOR RP10S ON THIS CHANNEL
DPLOOP:	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
	ASKDEC	<  # TM10Bs(0-2)[Tape Controller for NRZI only drives
on channel  *]>,CHN
NOT1B:	MOVE	I,N		;SET UP ITERATION COUNTER
	FILOUT	<XP M.C*TB,>,CHN	;FIRST PART OF CALL
	FILOUT	<*@>,I		;SECOND PART
	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
	PUSHJ	P,TAPSUB	;DO TAPE CONTROLLER SUBR
	SOJG	I,TBLOOP
TBEND:	SKIPE	N,RH12
	SOJA	N,NOTC10	;NO TC10 IF RH20
	ASKDEC	<  # TC10Cs(0-1)[Special Systems Tape Controller for
TU42's and TU43's on channel *]>,CHN
NOTC10:	MOVE	I,N
	FILOUT	<XP M.C*TC,>,CHN
	FILOUT	<*@>,I
	JUMPE	I,TCEND

TCLOOP:	AOS	M.TC10		;COUNT OF TC10'S ON SYSTEM
	AOS	N,MKON		;CONTROLLER #
	FILOUT	<XP M.MT*T,2@>,N ;MARK AS TC10
	PUSHJ	P,TAPSUB	;DO SUBR
	SOJG	I,TCLOOP	;LOOP TILL DONE

TCEND:	JUMPN	RH12,ASKT22
	ASKDEC	<  # RH10's for TM02'S (0-2)[Mass-Bus tape controller for
TU16's and TU45's on channel *]>,CHN
	JRST	ASKT23
ASKT22:	ASKDEC	<  # RH20's for TM02'S (0-1)[Mass-Bus tape controller for
TU16's and TU45's on channel *]>,CHN
ASKT23:	MOVE	I,N		;CHAN
	FILOUT	<XP M.C*T2,>,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	N,MKON		;MAKE M.T2?T = 0 IF RH10
	ADDI	N,1		; OR = RH20 # IF AN RH20
	FILOUT	<XP M.T2*T,>,N
	SKIPE	N,RH12
	MOVE	N,M.RH20
	FILOUT	<*@>,N

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
	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 TM02'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 TM02 * (1-8)>,I
	ADD	I3,N
	PUSH	P,N
	FILOUT	<XP M.MT*>,MKON
	FILOUT	<*>,I
	POP	P,N
	FILOUT	<,*@>,N
	ADDI	I,1
	SOJG	I2,T2LP3
	POP	P,I
	FILOUT	<XP M.MT*,>,MKON
	FILOUT	<*@>,I3
	SOJG	I,T2LOOP
T2END:	JRST	DXEND

;ROUTINE TO ASK FOR # OF UNITS ON EACH KONTROLLER

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

TAPSB0:	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
	POP	P,N		;RESTORE
	FILOUT	<*@>,N		;ON EACH KONTROLLER
	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.C*FH,0@>,CHN ;NO FH,DP,FS,TB,TC
	FILOUT	<XP M.C*DP,0@>,CHN
	FILOUT	<XP M.C*RP,0@>,CHN
	FILOUT	<XP M.C*FS,0@>,CHN
	FILOUT	<XP M.C*TB,0@>,CHN
	FILOUT	<XP M.C*TC,0@>,CHN
	FILOUT	<XP M.C*T2,0@>,CHN
	FILOUT	<XP M.C*TX,>,CHN ;OUTPUT FIRST PART OF CALL
	FILOUT	<*@>,I		;SECOND PART
	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
	PUSHJ	P,TAPSUB	;ASK FOR UNITS
	SOJG	I,TXLOOP

DXEND:	AOS	N,CHN		;INCREMENT CHANNEL LOOP COUNTER
	CAMGE	N,M.CHN		;FINISHED WITH ALL CHANNELS?
	JRST	CHNLOP		;NO, ASK FOR CONTRLLERS ON THIS CHANNEL
CHNEND:	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.RP10,*@>,M.RP10 ;OUTPUT NO. OF RP10S IN SYSTEM
	FILOUT	<XP M.TC10,*@>,M.TC10 ;OUTPUT NO. 0F TC10S 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

ASKTMA:	ASKDEC	< # TM10As(0,0-2)[I/O Bus type Controller for NRZI only drives]>,N
	MOVE	I,N		;SET UP ITERATION COUNTER
	JUMPE	I,TAEND		;ANY TM10A'S AT ALL?

TALOOP:	AOS	M.TM10		;COUNT OF TM10'S ON SYSTEM
	AOS	N,MKON		;INCR KONTROLLER ID
	FILOUT	<XP M.MT*T,0@>,N ;MARK AS TM10A
	PUSHJ	P,TAPSB0	;GET UNIT INFO
	SOJG	I,TALOOP
TAEND:	FILOUT	<XP M.TM10,*@>,M.TM10	;OUTPUT NO. OF TM10'S IN SYSTEM
	MOVE	I,MKON		;GET # TAPE KONTROLLERS
	JUMPL	I,ASKDTE	;JUMP IF ZERO
	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 an 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
ASKDTE:	SKIPN	M.KL10		;IS THIS A KL10?
	JRST	ASKJOB		;NO, DON'T ASK ABOUT DTES
	ASKDEC	<# DTEs on CPU0(2,1-4)[BYTE TRANSFER DEVICE USED FOR KL10 to PDP-11 front end communications]>
	FILOUT	<XP M.0DTE,*@>,N
	FILOUT	<XP M.1DTE,0@>

ASKJOB:	MOVEI	N,SM.JOB	;MAXIMUM NUMBER OF JOBS
	ASKDEC	<# Jobs(1-*)[Maximum number attached and detached, not
counting null job]>
	FILOUT	<XP M.JOB,*@>,N


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

ASKCOR:	MOVSI	N,(SIXBIT /K/)	;ASSUME PDP-10
	SKIPN	M.P10		;IS IT A KA10
	MOVE	N,[SIXBIT /pages/] ;NO--ASK PAGES INSTEAD OF K
	BTHOUT	<Max. * of core>,N
	MOVEI	N,^D256		;MAX K OF CORE(ASSUME KA10)
	SKIPN	M.P10		;IS IT AK KA?
	MOVEI	N,SM.MPI	;NO, MAX NO. OF PAGES ON KI10
	ASKDEC	< For each job(0,0-*)[0 means all of core]>,N
	FILOUT	<XP M.CORE,*@>,N
	MOVEI	N,^D256		;ASSUME KA10
	SKIPN	M.P10		;IS IT A KA10?
	MOVEI	N,^D4096	;YES, UP TO 4 MILLION WORDS ALLOWED




ASKNKC:	ASKDEC	<# K total system core(32-*)[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:	MOVEI	N,SM.RTD	;MAXIMUM NUMBER OF REAL TIME DEVICES
	ASKDEC	<# Real-time devices(0,0-*)[Max. # which can be put
on PI channels simultaneously]>
	FILOUT	<XP M.RTD,*@>,N
	JUMPN	N,ASKLK1	;DO NOT ASK ABOUT LOCKING IF REAL TIME
				; SINCE MUST HAVE LOCKING FOR REAL TIME

ASKLOK:	ASKYN	<Allow jobs to be locked in core(Y,N)>
ASKLK1:	FILOUT	<XP M.LOK,*@>,N
	JUMPE	N,ASKMG1
ASKMGC:	SKIPE	M.P10		;KA10 OR KI10?
	JRST	ASKLKA
	MOVEI	N,SM.MPI	;MAXIMUM NUMBER OF PAGES ON KI10
	ASKDEC	<# PAGES min guaranteed among jobs not locked in core(0,0-*)[
minimum free core pool for unlocked jobs, 0 assumes all of core]>
	JRST	ASKMG1
ASKLKA:	MOVEI	N,^D256		;256 K IS MAXIMUM ON KA10
	ASKDEC	<# K min guaranteed among jobs not locked in core(0,0-*)[
minimum free core pool for unlocked jobs, 0 assumes all of core]>
ASKMG1:	FILOUT	<XP M.MGC,*@>,N


ASKHPQ:	MOVEI	N,SM.HPQ	;MAXIMUM NUMBER OF HIGH PRIORITY QUEUES
	ASKDEC	<# High priority queues(0,0-*)>
	FILOUT	<XP M.HPQ,*@>,N
ASKTMP:	ASKYN	<CCL commands to stay in core(Y,N)[System programs pass
commands to each other via core(TMPCOR UUO) rather than disk]>
	FILOUT	<XP M.TMP,*@>,N
	JUMPE	N,ASKMET	;JUMP IF NO TMPCOR
	FILOUD	<XP MD.TWJ,*@>,MD.TWJ
	FILOUD	<XP MD.TLJ,*@>,MD.TLJ

ASKMET:	ASKYN	<Meter(Y,N)[Performance analysis metering(METER UUO)]>
	FILOUT	<XP M.METR,*@>,N


ASKSCK:	ASKYN	<SYSCHK(Y,N)[Initial Hardware integrity check at ONCE-only time]>
	FILOUT	<XP M.SYSC,*@>,N

ASKMSG:	ASKYN	<MSGSER(Y,N)[Support for device MPX. (more than one device
on an I/O channel). This feature is required for TYPSET-10
and MCS-10]>
	FILOUT	<XP M.MSG,*@>,N
ASKPSI:	ASKYN	<PSISER(Y,N)[Advanced programmed software interrupt service -
Support for the PISYS. UUO. This provides an easy
and powerful interrupt method for program to trap asynchronous
events. Required by MCS-10]>
	FILOUT	<XP M.PSI,*@>,N

ASKIPC:	ASKYN	<IPCF(Y,N)[Inter process communition facility]>
	FILOUT	<XP M.IPCF,*@>,N

ASKENQ:	ASKYN	<ENQ/DEQ(Y,N)[Sychronization Primitives To-allow
simultaneous file update by multiple co-operating processes]>
	FILOUT	<XP M.EQDQ,*@>,N

ASKCDR:	MOVEI	N,SM.CDR	;MAXIMUM NUMBER OF CDRS
	ASKDEC	<# I/O Bus CDRs(1,0-*)[Card reader]>
	FILOUT	<XP M.CDR,*@>,N
	SKIPE	N		;SKIP IF NO CDR
	MOVEI	N,MD.C10	;YES, GET DEFAULT VALUE FOR CR10
	FILOUT	<XP MD.C10,*@>,N


ASKCDP:	ASKYN	<CDP(Y,N)[Card punch]>
	FILOUT	<XP M.CDP,*@>,N
	JUMPE	N,ASKDIS
	ASKYN	<CP10D(Y,N)[Special Systems unbuffered Card Punch]>
	FILOUT	<XP M.CP1D,*@>,N



ASKDIS:	ASKYN	<DIS(Y,N)[Display device(VP10,340,30,VB10C) as distinguished from
display terminals]>
	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
	FILOUT	<XP M.340,*@>,M.340
	FILOUT	<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	;

ASKDTA:	MOVEI	N,SM.DTA	;MAXIMUM NUMBER OF DTA CONTROLLERS
	ASKDEC	<# TD10s(1,0-*)[DECtape controls]>
	FILOUT	<XP M.TD10,*@>,N
	MOVE	I,N		;SETUP DTA UNIT ITERATION COUNTER
	SKIPE	N		;SKIP IF NO DECTAPES
	MOVEI	N,MD.DTC	;YES, GET DEFAULT VALUE FOR PDP 6 DTA
	FILOUT	<XP MD.DTC,*@>,N
	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
	POP	P,N		;RESTORE NO. OF UNITS ON THIS CONTROLER
	FILOUT	<*@>,N		;OUTPUT
	SOJG	I,DTLOOP	;ANY MORE CONTROLLERS?
DTEND:


ASKLPT:	MOVEI	N,SM.LPT	;MAXIMUM NUMBER OF LPTS
	ASKDEC	<I/O Bus LPTs(1,0-*)[Line printers]>
	FILOUT	<XP M.LPT,*@>,N
	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
	SETZM	LPTCNT		;INIT TEMP COUNTER OF LPTS
	JUMPE	N,CFELPT	;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
	POP	P,N		;GET ANSWER BACK AGAIN
	FILOUT	<*@>,N		;OUTPUT IT AS SYMBOL VALUE
	AOS	LPTCNT		;BUMP COUNT OF LPTS
	SOJG	I,MORLPT	;LOOP THRU ALL LPTS
CFELPT:	SKIPN	N,M.1091	;THIS A 1091?
	JRST	NOFEL1		;NO, DON'T ASK THE QUESTION
	ASKDEC	<# line printers on the master front end on CPU0(0,0-2)>
NOFEL1:	ADDM	N,M.DLPT
	FILOUT	<XP M.LP01,*@>,N
	FILOUT	<XP M.LP02,0@>
	FILOUT	<XP M.LP03,0@>
	FILOUT	<XP M.LP04,0@>
	FILOUT	<XP M.LP11,0@>
	JUMPE	N,NOCFEL	;DON'T ASK ABOUT PRINTERS THAT AREN'T THERE
	MOVE	I,N		;SET UP LOOP COUNTER
CFELL:	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
	POP	P,N		;GET ANSWER BACK AGAIN
	FILOUT	<*@>,N		;OUTPUT IT AS SYMBOL VALUE
	AOS	LPTCNT		;BUMP COUNT OF LPTS
	SOJG	I,CFELL		;LOOP THRU THIS DTE

NOCFEL:	SKIPN	N,M.1091	;THIS A 1091?
	JRST	NOFEC1		;NO, DON'T ASK ABOUT FE CDRS
	ASKDEC	<# card readers on the master front end on CPU0(0,0-1)>
NOFEC1:	ADDM	N,M.DCDR
	FILOUT	<XP M.CR01,*@>,N
	FILOUT	<XP M.CR02,0@>
	FILOUT	<XP M.CR03,0@>
	FILOUT	<XP M.CR04,0@>
	FILOUT	<XP M.CR11,0@>

	FILOUT	<XP M.DLPT,*@>,M.DLPT
	FILOUT	<XP M.DCDR,*@>,M.DCDR
NOCFE:


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


ASKPTP:	ASKYN	<PTP(Y,N)[Paper tape punch]>
	FILOUT	<XP M.PTP,*@>,N


ASKPTR:	ASKYN	<PTR(Y,N)[Paper tape reader]>
	FILOUT	<XP M.PTR,*@>,N


ASKPTY:	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


;CODE ASSEMBLED ONLY WHEN DC44 SUPPORT IS WISHED
;THE ONLY ADDITION OUTSIDE THIS CONDITIONAL HAS BEEN THE DEFINITION
;OF A SECOND LOOP CONTROL REGISTER I2

	DEFINE	FILLST	(FILLER,PREFIX,POSTFX)
<	IRP	PREFIX
<	FILVAL	<PREFIX'FILLER'POSTFX>
>	;;END OF IRP PREFIX
>	;;END OF FILLST MACRO
	DEFINE	FILVAL(SYMBOL)
<	FILOUT	<XP SYMBOL,*@>,SYMBOL
>
	ASKYN	<DC44(Y,N)[
The DC44 is a TYPESET-10 front end which supports
the following devices:
PA611R	High speed paper tape reader
PA611P	High speed paper tape punch
LPC11	Online photocomposition machine]>
	JUMPE	N,LOOP47	;NO FINISH THE CONFIGURATION
	MOVEM	N,M.DC44	;NUMBER OF DCC44 PORTS
	ASKDEC	<DL10 Port number for DC44(0,0-7)[]>
	MOVEI	I,1(N)	;+1 FOR ADDRESSING
	ASKDEC	<# of PA611Rs(0,0-32)[
High speed paper tape readers]>
	MOVEM	N,PAR-1(I)	;SET PARXN
	ASKDEC	<# of PA611Ps(0,0-32)[
High speed paper tape punches for driving "hot metal" machines]>
	MOVEM	N,PAP-1(I)	;SET PAXN
	ASKDEC	<# of LPC11s(0,0-6)[
Online photocomposition machines]>
	MOVEM	N,LPC-1(I)	;SET LPCXN
	ASKYN	<PC11(Y,N)[
Paper tape reader/punch on the PDP-11]>
	MOVEM	N,PCR-1(I)	;SET PCRXN
	MOVEM	N,PCP-1(I)	;SET PCPXN
	SETZB	I,TYPNUM	;DC44  NUMBER
LOOP45:	SETZB	N,I2		;ZERO RESULT AND DEVICE COUNTER
LOOP46:	ADD	N,@LSTD44(I2)	;GET THE DEVICE CONTRIBUTION
	CAIE	I2,TYPDEV	;TO THE TOTAL NUMBER OF DEVICES
	AOJA	I2,LOOP46	;FOR THIS DC44
	MOVEM	N,TYPNU(I)	;SET NUMBER FOT THIS ONE
	ADDM	N,TYPNUM	;TOTAL NUMBER OF TYPESET DEVICES
	ADDI	I,1		;NEXT DC44
	CAIE	I,10		;ALL DONE
	JRST	LOOP45		;AND THERE IS
LOOP47:	FILOUT	<XP M.DC44,*@>,M.DC44
	FILOUT	<XP TYPNUM,*@>,TYPNUM
ZZZ=0
	REPEAT	8,<
	FILLST	(\ZZZ,<TYPNU,PAR,PAP,LPC,PCR,PCP>,N)
ZZZ=ZZZ+1
>	;;END OF REPEAT 4 
ASKXTC:	MOVEI	N,SM.XTC	;MAX # OF DA28S
	ASKDEC	<# of DA28s(0,0-*)[Interprocessor channels for PDP8/11/15]>
	FILOUT	<XP M.XTC,*@>,N
	JUMPE	N,XTCEND
	ASKDEC	<# of lines for TTY pool(8,0-512)[Lines reserved for use on DA28 channels]>
XTCEND:	FILOUT	<XP M.XTL,*@>,N
ASKD78:	MOVEI	N,SM.D78	;MAXIMUM NUMBER OF DAS78'S
	ASKDEC	<# DAS78'S(0,0-*)[IBM 360, 370, and/or 2780 support]>
	MOVEM	N,M.DAS78	;SAVE NUMBER FOR COUNT DOWN
	FILOUT	<XP M.DAS78,*@>,M.DAS78
	SKIPN	,M.DAS78		;SEE IF ANY DAS78'S
	JRST	ASK78B		;NO DAS78'S
	PUSH	P,[0]		;PUT A 0 ON THE STACK TO COUNT UP
ASK78A:	PUSHJ	P,ASK78S	;ASK ABOUT THE DAS78'S
	AOS	(P)		;SET UP TO ASK ABOUT NEXT ONE
	SOSE	M.DAS78		;ASKED ABOUT ALL DAS78'S?
	JRST	ASK78A		;NO, ASK ABOUT ANOTHER ONE
	POP	P,(P)		;CLEAN THE STACK
ASK78B:	FILOUT	<XP M.0D78,*@>,M.0D78
	FILOUT	<XP M.1D78,*@>,M.1D78
	FILOUT	<XP M.2D78,*@>,M.2D78
	FILOUT	<XP M.3D78,*@>,M.3D78
	FILOUT	<XP M.4D78,*@>,M.4D78
	FILOUT	<XP M.5D78,*@>,M.5D78
	FILOUT	<XP M.6D78,*@>,M.6D78
	FILOUT	<XP M.7D78,*@>,M.7D78
	FILOUT	<XP M.D78L,*@>,M.D78L
	FILOUT	<XP M.XXI,*@>,M.D78L
	FILOUT	<XP M.XXO,*@>,M.D78L
	JRST	ASK78C		;DONE DAS78'S.

ASK78S:	MOVE	N,-1(P)		;GET A NUMBER FOR DAS78
	TTYOCT	<@For DAS78 *:@@>
	ASKDEC	<Which DL10 port is the DAS78 connected to (0,0-7)]
Each DAS78 PDP11 is connected to a DL10 port]>
	PUSH	P,N		;SAVE PORT NUMBER ON STACK
	ASKDEC	<Decimal lines on the DAS78 (1-16)[
Each DAS78 can support up to 16 IBM 360s, 370s, and or 2780s]>
	ADDM	N,M.D78L	;KEEP A SUM OF THE DAS78 LINES
	MOVE	T1,(P)		;GET DAS78 NUMBER
	MOVEM	N,M.0D78(T1)	;SAVE LINES IN PROPER PORT LOC
	POP	P,(P)		;CLEAN STACK
	POPJ	P,		;EXIT
ASK78C:
ASKDSY:	FILOUT	<@RADIX	10@>;	;SET RADIX TO DECIMAL IN FILE
	BTHOUT	<Decimal "symbol,value"[
For any symbols to be defined.
Type one per line, extra carriage return when through]@>
DSYLOP:	PUSHJ	P,TTYIN		;GET NEXT LINE
	  JRST	ASKDSY		;/HELP TYPED, ASK AT PROPER HELP MODE
	JUMPE	CH,DSYEND	;JUST A CR?
	PUSHJ	P,GETWRD	;GET FIRST WORD
	CAIE	CH,","		;IS IT FOLLOWED BY ,
	JRST	DSYERR		;NO, ERROR
	PUSHJ	P,GETDEC	;GET SECOND WORD AS DECIMAL
	JUMPN	CH,DSYERR	;IS IT LAST WORD ON LINE?
	FILSTR	<XP *@>;	;YES, WRITE IT OUT
	JRST	DSYLOP		;LOOP BACK FOR NEXT LINE

DSYERR:	TTYOUT	<? Not symbol,value@>
	AOJA	LV,ASKDSY	;TRY AGAIN

DSYEND:	FILOUT	<RADIX	8@>;	;SET RADIX BACK TO NORMAL IN FILE
	MOVE	LV,SAVLV	;RESTORE PERMANENT HELP LEVEL
				; IN CASE HE TYPED /H<CR>


ASKOSY:	BTHOUT	<@Octal "symbol,value"[
For any symbol to be defined.
Type one per line, extra carriage return when through]@>
OSYLOP:	PUSHJ	P,TTYIN		;GET NEXT LINE FOR USER
	  JRST	ASKOSY		;/HELP TYPED, ASK IN DESIRED HELP MODE
	JUMPE	CH,OSYEND	;JUST A BLANK LINE?
	PUSHJ	P,GETWRD	;NO, GET FIRST WORD
	CAIE	CH,","		;IS BREAK A COMMA?
	JRST	OSYERR		;NO, ERROR
	PUSHJ	P,GETOCT	;YES, GET VALUE IN OCTAL
	JUMPN	CH,OSYERR	;IS THIS END OF LINE?
	FILSTR	<XP *@>;	;YES, WRITE IT OUT
	JRST	OSYLOP		;LOOP BACK FOR MORE

OSYERR:	TTYOUT	<? Not symbol,value@>
	AOJA	LV,ASKOSY	;GO TRY AGAIN
OSYEND:	MOVE	LV,SAVLV	;RESTORE PERMANENT HELP LEVEL
				; IN CASE HE TYPED /H<CR>
ASKSSY:	BTHOUT	<@SIXBIT "symbol,value"[
For any sixbit symbol to be defined.
Type one per line, extra carriage return when through]@>
SSYLOP:	PUSHJ	P,TTYIN		;GET NEXT LINE
	  JRST	ASKSSY		;/HELP TYPED, ASK IN PROPER MODE
	JUMPE	CH,SSYEND	;CARRIAGE RETURN?
	PUSH	P,B		;SAVE BYTE POINTER TO STRING
	PUSHJ	P,GETWRD	;GET FIRST WORD
	CAIE	CH,","		;IS BREAK A COMMA?
	JRST	SSYERR		;NO, ERROR
	PUSHJ	P,GETWRD	;GET SECOND WORD
	JUMPN	CH,SSYERR	;ERROR IF MORE TYPE-IN
	POP	P,B		;RESTORE BYTE POINTER
	PUSHJ	P,GETWRD	;GET FIRST WORD AGAIN
	FILOUT	<XP *>,WD	;OUTPUT FIRST WORD
	PUSHJ	P,GETWRD	;GET SECOND WORD
	FILOUT	<,<SIXBIT/*/>@>,WD	;OUTPUT SIXBIT VALUE
	JRST	SSYLOP		;AND LOOK FOR MORE

SSYERR:	POP	P,B		;RESTORE PDL
	TTYOUT	<? Not symbol,value@>
	AOJA	LV,ASKSSY	;GO TRY AGAIN

SSYEND:	MOVE	LV,SAVLV	;RESTORE PERMANENT HELP LEVEL
				; IN CASE USER TYPED /H<CR>
ASKSP1:	FILOUT	<@DEFINE	SPCINT>
	PUSHJ	P,FILLAB	;LEFT ANGLE BRACKET,CRLF TO FILE
ASKS1A:	BTHOUT	<Type "device-mnemonic,PI-channel" for special devices[
With neither channel AC save routine nor device data block,
the "device-mnemonic" must be 3 characters or less.
Type extra carriage return when through.]@>
SP1LOP:	PUSHJ	P,GETDPI	;GET NEXT LINE AND SCAN FOR DEV:PI
	  AOJA	LV,ASKS1A	;ERROR OR /HELP
	JUMPE	WD,SP1END	;JUST CR TYPED?
	RJUMPN	CH,<TTYOUT <? Not device-mnemonic,PI-channel@>
		AOJA	LV,ASKS1A>  ;GO ASK FOR MORE
	FILSTR	<SPASGINT *@>;	;OUTPUT ANSWER TO FILE
	JRST SP1LOP		;GO GET ANOTHER LINE
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
ASKS2A:	BTHOUT	<Type "device-mnemonic,PI-channel,no.-of-devices"[
For special devices with device data blocks.
the "device-mnemonic" must be 3 characters or less.
Type extra carriage return when through.]@>
SP2LOP:	PUSHJ	P,GETDPI	;GET NEXT LINE, AND SCAN FOR DEV:PI
	  AOJA	LV,ASKS2A	;/HELP OR ERROR, REASK QUESTION
	JUMPE	WD,SP2END	;JUST CR TYPED?
	CAIE	CH,","		;IS BREAK A COMMA?
	JRST	SP2ERR		;END OF LINE TOO SOON?
	PUSHJ	P,GETDEC	;GET NO. OF DEVICES
	JUMPN	CH,SP2ERR	;IS THIS LAST WORD ON LINE?
	FILSTR	<SPASGDDB *@>;	;YES, OUTPUT TRIPLE
	JRST	SP2LOP		;GO GET ANOTHER LINE

SP2ERR:	TTYOUT	<? Not device-mnemonic,PI-channel, no.-of-devices@>
	AOJA	LV,ASKS2A	;GO GET MORE

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
ASKS3A:	BTHOUT	<Type "device-mnemonic,PI-channel,highest-ac-to-save"[
For special devices with channel save routines to save acs up to
the "highest-ac-to-save".  "Device" must be 3 char or less.
Type extra carriage return when through.]@>
SP3LOP:	PUSHJ	P,GETDPI	;GET NEXT LINE AND SCAN FOR DSK:PI
	  AOJA	LV,ASKS3A	;/HELP OR ERROR, REASK QUESTION
	JUMPE	WD,SP3END	;JUST CR TYPED?
	CAIE	CH,","		;IS BREAK AFTER PI A COMMA?
	JRST	SP3ERR		;NO, ERROR
	PUSHJ	P,GETOCT	;GET HIGHEST AC TO SAVE
	JUMPN	CH,SP3ERR	;IS THIS LAST ITEM ON LINE?
	CAILE	N,SM.AC		;SKIP IF LEGAL AC
	RJRST	<MOVEI	N,SM.AC
		TTYOCT	<? Highest-ac-to-save must be * or less@>
		AOJA	LV,ASKS3A>
	FILSTR	<SPASGSAV *@>;	;OUTPUT TRIPLE TO FILE
	JRST	SP3LOP		;GO GET NEXT LINE
SP3ERR:	TTYOUT	<? Not device-mnemonic,PI-channel,highest-ac-to-save@>
	AOJA	LV,ASKS3A	;GO ASK  FOR MORE

SP3END:	PUSHJ	P,FILRAB	;FILL IN A 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
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)]>
	FILOUT	<XP M.NET,*@>
	JUMPE	N,NETNON
	MOVEI	N,SM.NODES	;MAX NODES
	ASKDEC	<How many nodes do you wish to support(3,0-*)[Maximum]>,N
	FILOUT	<XP M.NODE,*@>,N;NUMBER OF NODES
	JUMPE	N,NETEND	;IF NONE, SKIP TO END
	SETZM	M.DL10		;ASSUME NO DL10'S
	MOVEI	P1,1		;COUNT FRONT ENDS STARTING AT 1
	ASKDEC	<How many DC75NP's or DN87's on the system(1,0-8)[Network
front-ends connected to DL10's.]>
	MOVEM	N,M.DC75	;store number of 75/87's
	FILOUT	<XP M.DC75,*@>,N
	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:	FILOUT	<XP M.0D85,*@>,M.0D85;output all symbols
	FILOUT	<XP M.1D85,*@>,M.1D85
	FILOUT	<XP M.2D85,*@>,M.2D85
	FILOUT	<XP M.3D85,*@>,M.3D85
	FILOUT	<XP M.4D85,*@>,M.4D85
	FILOUT	<XP M.5D85,*@>,M.5D85
	FILOUT	<XP M.6D85,*@>,M.6D85
	FILOUT	<XP M.7D85,*@>,M.7D85
	SETZM	M.0D85		;LET'S TIMESHARE THESE LOCATIONS
	MOVE	T1,[M.0D85,,M.1D85] ;WHICH MEANS WE HAVE TO ZERO THEM
	BLT	T1,M.7D85	;SINCE THE PREVIOUS PAGE USED THEM
	ASKDEC	<How many DN87S's on the system(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,*@>,N
	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:	FILOUT	<XP M.0D8S,*@>,M.0D85;output all symbols
	FILOUT	<XP M.1D8S,*@>,M.1D85;NOTE: ASK87S SHOULD ENSURE PRIMARY DTE IS
	FILOUT	<XP M.2D8S,*@>,M.2D85; RESERVED FOR RSX-20F

	FILOUT	<XP M.3D8S,*@>,M.3D85
ASKCEN:	MOVEI	N,SM.ONNM	;HIGHEST ALLOWED NODE NUMBER
	ASKOCT	<Node number of central site(1-*)[
Unique number identifying DECsystem-10 to network.]>,n
	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.RTTY	;MAX REMOTE TTY'S
	ASKDEC	<# of remote TTY's(0,0-*)[
Maximum number of teletypes on network nodes to be
handled at any given time.]>,N
	MOVEM	N,M.CONN	;START COUNT OF DEFAULT # OF CONNECTIONS
	FILOUT	<XP M.RTTY,*@>,N
	MOVEI	N,SM.RCDR	;MAX REMOTE CDR'S
	ASKDEC	<# of remote CDR's(0,0-*)[
Maximum number of card readers on network nodes to be
handled at any given time.]>,N
	ADDM	N,M.CONN
	FILOUT	<XP M.RCDR,*@>,N
	MOVEI	N,SM.RLPT	;MAX REMOTE LPT'S
	ASKDEC	<# of remote LPT's(0,0-*)[
Maximum number of line printers on network nodes to be
handled at any given time.]>,N
	ADDM	N,M.CONN
	FILOUT	<XP M.RLPT,*@>,N
	MOVEI	N,SM.RPR	;MAX REMOTE PTR'S
	ASKDEC	<# of remote PTR's(0,0-*)[
Maximum number of paper tape readers on network nodes to be
handled at any given time.]>,N
	ADDM	N,M.CONN
	FILOUT	<XP M.RPTR,*@>,N
	MOVEI	N,SM.RPP	;MAX REMOTE PTP'S
	ASKDEC	<# of remote PTP's(0,0-*)[
Maximum number of paper tape punches on network nodes to be
handled at any given time.]>,N
	ADDM	N,M.CONN
	FILOUT	<XP M.RPTP,*@>,N
	MOVEI	N,SM.RMTA	;MAX REMOTE MTA'S
	ASKDEC	<# of remote MTA's(0,0-*)[
Maximum number of magnetic tape drives on network nodes to be
handled at any given time.]>,N
	ADDM	N,M.CONN
	FILOUT	<XP M.RMTA,*@>,N
	MOVEI	N,SM.RJOB
	ASKDEC	<# of remote processes(0,0-*)[
Maximum number of remote processes that can be connected to at
any given time (requires FTTSK to be -1).]>,N
	ADDM	N,M.CONN
	FILOUT	<XP M.RJOB,*@>,N
	ASKYN	<Remote data entry software(Y,N)[
Software to support remote data entry terminals for MCS-10 applications
(requires FTRDX to be -1)]>
	FILOUT	<XP M.RDX,*@>
	MOVE	N,M.CONN	;GET # CONNECTS NEEDED
	CAILE	N,SM.CONN	;MORE THAN WE CAN HANDLE?
	MOVEI	N,SM.CONN	;YES, USE 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@>
	FILOUT	<XP M.0D85,0@>
	FILOUT	<XP M.1D85,0@>
	FILOUT	<XP M.2D85,0@>
	FILOUT	<XP M.3D85,0@>
	FILOUT	<XP M.4D85,0@>
	FILOUT	<XP M.5D85,0@>
	FILOUT	<XP M.6D85,0@>
	FILOUT	<XP M.7D85,0@>
	FILOUT	<XP M.D87S,0@>
	FILOUT	<XP M.0D8S,0@>
	FILOUT	<XP M.1D8S,0@>
	FILOUT	<XP M.2D8S,0@>
	FILOUT	<XP M.3D8S,0@>
	FILOUT	<XP OURNNM,0@>
	FILSTR	<@DEFINE SYSNDE<>@>
	FILOUT	<XP M.CONN,0@>
	FILOUT	<XP M.RTTY,0@>
	FILOUT	<XP M.RCDR,0@>
	FILOUT	<XP M.RLPT,0@>
	FILOUT	<XP M.RPTR,0@>
	FILOUT	<XP M.RPTP,0@>
	FILOUT	<XP M.RMTA,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 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

	PUSHJ	P,ASKSYS		;FIND TYPE OF PROCESSOR

ASKHRD: ASKDEC	<How many DC10s(1,0-2)[
The DC10 is a data line scanner]>
	MOVEM	N,M.DC10
	ASKDEC	<How many DC68s(1,0-2)[
The DC68 is a PDP-8 680 or 680I communications system]>
	MOVEM	N,M.DC68
	ASKDEC	<How many DC76s(1,0-8)[
The DC76 is a PDP-11 communications system]>
	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)
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.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
	SKIPN	N,M.KL10	;ON A KL10 SYSTEM?
	JRST	NOTKL		;NO, SET M.AT01 TO 0
	SKIPN	N,M.1091	;ON A 1091?
	JRST	NOT191		;NO, DON'T ASK ABOUT FE TTY'S

	ASKDEC	<# terminals on the master front end on CPU0(1,1-132)[
include only timesharing (DH11) lines, not CTY or KLINIK]>
NOT191:	ADDI	N,4		;ACCOUNT FOR DL11 LINES
NOTKL:	ADDM	N,M.TTDN
	FILOUT	<XP M.AT01,*@>,N
	FILOUT	<XP M.AT11,0@>
	FILOUT	<XP M.TTDN,*@>,M.TTDN

	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.TTDN	;PLUS LINES ON RSX20F
	ADD	N,M.68L0	;PLUS LINES ON DC68
	ADD	N,M.68L1	; = TOTAL NUMBER OF LINES
	FILOUT	<XP M.TLTL,* ;TOTAL LOCAL TTY LINES@@>
ASKOPR:	SOJ	N,		;ADJUST TO GET HIGHEST LINE
	ASKLIN	<OPR octal line #(CTY,0-*)[OPR is privileged operator terminal]>
	FILOUT	<DEFINE	OPRLIN>
	PUSHJ	P,FILLAB
	FILOUT	<@	OPRL	*@>,N
	PUSHJ	P,FILRAB
	FILOUT	<@>
ASKTTY:	BTHOUT	<Answer the following questions about your TTY lines(M-N).
[Type one octal line #(M) or one range(M-N) or CTY on separate
lines.  Type extra carriage return when through.]@>


ASKDSD:	FILOUT	<DEFINE	MACDSD>	;START MACRO DEFINITION
	ASKMN	<Data set lines[Class of terminal for LOGIN, LOGIN resets line
to computer echoing and no hardware tabs]@>


ASKTBS:	FILOUT	<DEFINE	MACTAB>	;START MACRO DEFINITION
	ASKMN	<Lines with hardware tabs[Monitor simulates rest with spaces]@>


ASKRMT:	FILOUT	<DEFINE	MACRMT>	;START MACRO DEFINITION
	ASKMN	<Remote lines[Class of terminal for LOGIN, do not confuse
with remote station TTYs]@>


ASKLCP:	FILOUT	<DEFINE	MACLCP>	;START MACRO DEFINITION
	ASKMN	<Local copy lines[Echoing provided by terminal rather than
by computer.  Often (incorrectly) called half duplex]@>


ASKHLF:	FILOUT	<DEFINE	MACHLF>	;START MACRO DEFINITION
	ASKMN	<Half duplex lines[TWX or half duplex wired scanner(DC10C)]@>


ASKSLV:	FILOUT	<DEFINE	MACSLV>
	ASKMN	<Slaves[No commands may be typed]@>


ASKFRM:	FILOUT	<DEFINE	MACFRM>
	ASKMN	<Lines with hardware form feed[Leave out if users
would rather not get form feeds until they do TTY FORM commands]@>


ASKINI:	FILOUT	<DEFINE	MACINI>
	ASKMN	<Lines which run INITIA at startup@>

ASKFLC:	FILOUT	<DEFINE	MACFLC>
	ASKMNP	<Filler class codes(M-N,P)[
Type M,P for one line M with filler class code P or
M-N,P for a range of lines with filler class code P]@>

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:	ASKLST	<DECsystem10(1040,1050,1055,1070,1077,1080,1088,1091)[
1040 is small disk system with KA10 cpu
1050 is large disk system with KA10 cpu
1055 is disk system with 2 KA10 cpu's
1070 is disk system with KI10 cpu
1077 is disk system with 2 KI10 cpu's
1080 is disk system with KL10 cpu
1088 is disk system with 2 KL10 cpu's
1091 is disk system with KL10 cpu, internal memory, and
devices on the front end]>
	CAILE	N,MP.SMX	;IS THIS A PDP10I SYSTEM?
	RJRST	<MOVEI	N,MP.MVN  ;MONITOR VERSION NUMBER
		TTYOUT <? Not available in * monitor@>,N
		 JRST	ASKSYS>
	MOVEM	N,CNFIND	;SAVE INDEX OF SYSTEM TYPE
	AOS	M.1040(N)	;SET ONE OF THE VARIABLES TO 1
				; M.1040, M.1050, M.1055, M.1070, M.1077
	CAIG	N,2		;IS THIS A PDP10I SYSTEM?
	AOSA	M.P10		;NO, SET PDP10 FLAG TO 1
	AOS	M.P10I		;YES, SET PDP10I FLAG TO 1
	CAIE	N,6		;A 1088?
	CAIN	N,5		;IS THIS A 1080?
	JRST	ASKSY1		;YES
	CAIE	N,7		;A 1091?
	POPJ	P,		;NO, RETURN
ASKSY1:	AOS	M.KL10		;SET KL10 FLAG
	SETZM	M.P10		;AND CLEAR OTHERS
	SETZM	M.P10I
	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
	CAMN	N,[SIXBIT /TY1/];NO, IS REST OF WORD CTY1?
	JRST	ASKN4C		;YES, ALLOW IT
ASKN4A:	RJRST	<TTYOCT	<? Type octal line number or CTY or CTY1 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

ASKN4C:	MOVE	N,[SIXBIT /CTY1/]  ;RETURN LEFT JUSTIFIED CTY1 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
	CAMN	N,[SIXBIT /TY1/];WAS DEFAULT CTY1?
	JRST	ASKN6		;YES, BY PASS RANGE CHECK
	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
	MOVE	N,[SIXBIT /CTY1/]  ;ASSUME CTY1
	CAMN	WD,[SIXBIT /TY1/] ;IS IT REST OF CTY1?
	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 PERIODS 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
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?
	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


;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
				; FALL INTO TTYOUT


;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
SUBTTL	DATA STORAGE

;CONSTANTS:

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

;DISPATCH TABLE:
GENTAB:	EXP	HDWGEN		;HDWGEN
	EXP	TTYGEN		;TTYGEN
	EXP	NETGEN		;NETGEN
	EXP	FGEN		;FGEN


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
DTA:	BLOCK	1	;LOOP COUNTER FOR DTA LOOP
MKON:	BLOCK	1	;COUNTER FOR MAG-TAPE KON ID
TAPOFS:	BLOCK	1	;NUMBER OF "EXTRA" TM02 UNITS
OSN:	BLOCK	1	;OCTAL STATION NO. CURRENTLY BEING DEFINED
LPTCNT:	BLOCK	1	;# OF LPTS

;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 <1040,1050,1055,1070,1077,1080,1088,1091>;	;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 <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 <RH20>;			;NO. OF RH20S (RP04, TM02)
V <RP10>;			;NO. OF RP10 CONTROLLERS
V <TC10>;			;NO. OF TC10 CONTROLLERS
V <TX01>;			;NO. OF TX01 CONTROLLERS
V <TM10>;			;NO. OF TM10 CONTROLLERS
V <T210>;			;NO. OF TM02 CONTROLLERS

V <HRSN>;			;HIGHEST REMOTE STATION NUMBER

V <TTDN>;			;TOTAL NUMBER OF RSX20-F TERMINALS
V <DLPT>;			;TOTAL NUMBER OF RSX20-F LPTS
V <DCDR>;			;TOTAL NUMBER OF RSX20-F CDRS

;HDWGEN:
V <VP10,340,VBXC>;		;TYPE OF DISPLAY
V <DAS78,D78L,0D78,1D78,2D78,3D78,4D78,5D78,6D78,7D78>;	;DAS78

;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>
	DEFINE	BLOK4(PREFIX,POSTFX)
<	IRP	PREFIX
<
PREFIX:
ZZZ=0
	REPEAT	8,<
	WORD	(PREFIX,\ZZZ,POSTFX)
ZZZ=ZZZ+1
>	;;END OF REPEAT 4
>	;;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.CONN:	EXP	0	;ACCUMULATES DEFAULT # OF CONNECTS
VAREND==.-1		;LAST LOC TO CLEAR IN MAIN LOOP FOR NEW GEN
	END	BEGINA