/50 OS/8 TECO VERSION 7
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/
/THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO CHANGE WITHOUT NOTICE
/AND SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT
/CORPORATION.  DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/FOR ANY ERRORS THAT MAY APPEAR IN THIS DOCUMENT.
/
/
/
/
/
/
/
/
/
/
/
/BROUGHT TO YOU BY: RUSS HAMM, O.M.S.I., AND RICHARD LARY (IN THAT ORDER)
/WITH ASSISTANCE FROM MARIO DENOBILI OF THE P?S
/PATCHES INCORPORATED BY S.R. ON 5-AUGUST-75 FOR OS/8 V3C:

/1.	UPDATED VERSION # TO V4
/2.	INCORPORATED PATCHES #S 1 & 2 (V302 AND V303)
/	PREVENTS \ FROM GOING OUTSIDE OF BUFFER
/	RESETS CFLAG TO PREVENT ARGUMENT ERROR EVERY 4096 TIMES IN LOOP

/	CHANGES FOR V5: -STANLEY RABINOWITZ-

/3.	ADDED OVERLAYS
/4.	EXPANDED ERROR MESSAGES
/5.	DOCUMENTED CORE LAYOUT
/6.	ADDED "T, "S, "F, "U, AND "R
/7.	FIXED EG BUG
/8.	MADE DEFAULT ITERATION COUNT TRULY INFINITE
/9.	ADDED N^T
/10.	ADDED :=
/11.	ADDED SOME SAFETY ERROR MESSAGES
/	(I)	ERROR IF Y HAS A NUMERIC ARGUMENT
/	(II)	ERROR IF TWO ARGUMENTS ARE SPECIFIED TO D
/12.	REMOVE ^R (OBSOLETE COMMAND)
/13.	REMOVE "A AND "B (AFTER AND BEFORE)
/14.	ADDED 13-BIT ARITHMETIC
/15.	MADE = AND \ GIVE SIGNED RESULTS (DECIMAL ONLY)
/16.	ALLOW 13-BIT NUMERIC Q-REGISTERS.
/	THIS IS ACCOMPLISHED BY RESERVING THE HIGH ORDER BIT
/	OF THE LENGTH WORD.  STRING PORTION OF Q-REGISTER
/	NOW RESTRICTED TO 2047 CHARACTERS.  IT GETS CHECKED BY
/	^U AND X.  BELL RINGS WITHIN 12 CHARACTERS OF FILLING
/	UP COMMAND STRING Q-REGISTER.
/17.	STORED LINK AS LOW ORDER BIT IN NLINK IN CASE WE EVER
/	WANT TO GO TO 24-BIT ARITHMETIC.
/18.	ERROR ON A,B,C
/19.	P DOESN'T CREATE FORM FEEDS
/20.	ALLOW @ MODIFIER WITH ER, EW, EB.
/21.	EK
/22.	^S FREEZE
/23.	EGTEXT$
/24.	GOT RID OF F_
/25.	F IS ILLEGAL IF NOT FOLLOWED BY S OR N
/26.	W IS NOW AN ILLEGAL COMMAND (EXCEPT ON -12)
/27.	ADDED :G
/28.	Y AND _ GIVE ERRORS IF DATA IS GOING TO BE LOST
/	(IF OUTPUT FILE IS OPEN AND BUFFER IS NOT EMPTY)
/29.	CASE FLAGGING IMPLEMENTED
/30.	"< AND "> ARE SYNONYMOUS WITH "L AND "G
/31.	^G<SPACE> AND ^G*
/32.	SCOPE RUBOUTS
/33.	== NOW PRINTS NUMBER IN OCTAL
/34.	EUFLAG AND ETFLAG IMPLEMENTED
/35.	CASE FLAGGING WORKS
/36.	IMAGE MODE (ET BIT 11) APPLIES TO T, ^A, AND N^T
/	IT DOES NOT APPLY TO :G
/37.	ERROR IF TRY TO DO AN EB TO A .BK FILE (IT DOES AN ER)
/38.	VT AND FF ARE NOW LINE TERMINATORS
/39.	BELL ECHOES AS ^G AS WELL AS RINGING BELL
/40.	^K IS AN ERROR
/41.	REMOVED ^Z COMMAND
/42.	CHANGED ^V TO EO
/43.	CHANGED ^W TO W
/44.	MEMORY RESIDENT OVERLAYS IF MORE THAN 12K
/45.	LONG FORM ERROR MESSAGES ON 1EH
/46.	ET FLAG 8'S BIT AFFECTS ECHOING OF ^T
/47.	NEGATIVE OR 0 ITERATION SKIPS
/48.	CTRL/N
/49.	CTRL/C TRAP

/KNOWN BUGS
/1.	LARGE T OR X AND ONLY 1 BLOCK LEFT IN OUT DEV
/2.	^S DOESN'T KEEP SCREEN ON (ON PDP-12)
/3.	FIX BATCH INTERRACTION
/4.	MAKE VT AND FF SIMULATION INDEPENDENT OF TAB
/5.	^T COMMAND (WITH ECHO ON) READS DOLLAR SIGN FOR TYPED ALTMODE

VERSN=	7.	/ VERSION NUMBER - CHANGE WITH EVERY EDIT 
/CHANGES FOR V6: (STAN RABINOWITZ)

/50.	ADDED SYMBIONT SUPPORT
/51.	CONVERTED TO MACREL
/52.	ADDED VT52 SUPPORT (JIM ROTH)
/53.	AY PATCH (501)
/54.	CONDITIONAL PATCH (502)
/55.	BELL ON 12 CHARACTERS (503)
/56.	^U, *, ^G<SPACE>, ETC. (504)
/57.	N*0 PATCH (505)
/58.	8K PATCH (506)
/59.	SKIPPING W (507)
/60.	NO ERROR ON ^S AFTER ^S
/61.	REDUCED EXTRA BLOCK WRITE OF OVERLAYS
/62.	REMOVED ^P CMD AND EXECUTION TIME ^P COMMAND
/63.	IMPLEMENTED IMMEDIATE MODE CMDS LF AND BS
/64.	:ER AND :EB
/65.	ERFILE/S$ FOR SUPERTECO
/66.	PUT F_ BACK IN
/67.	^L COMMAND
/68.	ALLOW @^A
/69.	2'S BIT IN ED FLAG
/70.	ALLOW CHAIN ARG TO BE LARGE
/71.	EXTRA 7 CHARS IN SEARCH BUFFER IF NOT ON PDP-12 OR VT52
/72.	REMOVED MQ DISPLAY
/73.	ABORT ON ERROR BIT
/74.	PATCH FOR UNSPECIFIED ITERATION AFTER INSERT (508)
/75.	VT05 SUPPORT
/76.	^R (LITERALLY) IN SEARCH STRINGS
/77.	FORTIFIED ?POP ERROR MESSAGE
/78.	"= SYNONOMOUS WITH "E
/79.	FIXED NUMBER FLAG AFTER A 0<>
/80.	FIXED H$T BUG
/81.	ADDED ^C TRAP BIT (IF VT52 SUPPORT IN)
/82.	ADDED TECO.INI CODE
/83.	<TAB> PRINTS RATHER THAN <HT>
/84.	SET SCOPE BIT IF SCOPE
/85.	ADDED ED BIT 1, ALLOW ^ IN SEARCH STRINGS
/86.	SOME ERROR MESSAGE CODES CHANGED

/VERSION 602 CHANGES:

/87.	3EH CODE
/88.	4EH BIT IN
/89.	EX WITH TEXT AND NO OUT FILE GIVES ?NFO
/90.	FIXED BUG IN 1ED

/VERSION 604 CHANGES:

/91.	TECO.TEC
/92.	* CLEARS ?
/93.	AID * IDENTICAL TO AID ^S
/94.	^_
/95.	V
/96.	"D AND "A
/97.	EY
/98.	?NAS BECAME ?ISA
/99.	1024 BIT IN ET SET ON PDP-12
/100.	PRINT SEARCH STRING ON ?SRH
/101.	?UEC ETC.
/102.	/
/103.	READ WITH NO WAIT
/104.	LF AND BS
/105.	^B
/106.	?NPA --> ?IPA

/VERSION 605 CHANGES:

/107.	FIXED 16K BUG
/108.	<NOT>,<ANY>,<SEP>
/109.	N<A> RETURNS -1 IF POINTER REFERENCE IS OFF PAGE
/110.	F_ BACK IN
/111.	-1EJ
/112.	M,N<FLAG>

/VERSION 606 CHANGES:

/113.	ADDED IF-THEN-ELSE

/VERSION 7 CHANGES:

/114.	PUT AID ^S BACK IN (SAME AS *)
	.ENABLE 7BIT

	.GLOBAL CHR.W,C.W,SCHLST,CIL2,CFSI
	.GLOBAL	CHKCTC,TPUTX,STABLE
	.GLOBAL TSFWT,OUTDNE,CHKCTC,TYI
	.GLOBAL CTLWR,TSTA,SCHSRT
	.GLOBAL VT05B,VBAR
	.GLOBAL CAHT,CHRL1,NAME,NUMLNS,R
	.GLOBAL ASR33,BLSP1,BLSP2,BLSP3,BLSP4,BUFIN,CACR,CHTECO
	.GLOBAL COLCT,EUFLAG,EU1,EU2,GETQX,IC,INCTLW,INHNDL
	.GLOBAL INPCNT,INRSIZ,INXR,I2,J12K1,J12K2,L12K1,L12K2,KSFWT,L16K
	.GLOBAL MQMAX,NWRUSR,OUTSIZ,POUTHT,QLIMIT
	.GLOBAL QPUTS,Q12MAX,RUBY,SCAPE,SCOPY
	.GLOBAL SCPBIT,TECOS,TECO1,TEMPT,TYI1,T0A
	.GLOBAL CHKCTR,TYIRET
	.GLOBAL VT52B
	.GLOBAL ETFLAG,MEMSIZ
	.GLOBAL IOVRLC,QOVRLC,XOVRLC,FOVRLC
	.GLOBAL QPNTR,ERRXX,EHFLAG,ETFLAG
	.GLOBAL MEMLOC,CTL.C,LASTC,OVREAD,ERRRET
	.GLOBAL ERROR,T0,QLENGTH
	.GLOBAL ECDISM,ERR,GETUSR,NNEW13,OCMDLN
	.GLOBAL TCTLS,IREST
	.GLOBAL ZROSPN,EDFLAG,ET8,POKE,TPUT,CHR.T
	.GLOBAL NCOM14,NORMAL,OCNT
	.GLOBAL SORTA1
	.GLOBAL EH4,KTYPE,TQMK
	.GLOBAL OCRCNT,OUNAM,OUTR,OMAXLN,OSETP,IBLK,DECPUT
	.GLOBAL STECO1,STECO2
	.GLOBAL QBASE,ZRON,CHREY
	.GLOBAL ET1,SCHU,UPOC,ERR01,ERR07,SCHCTE
	.GLOBAL YSKP,EOVRLC
	.GLOBAL CHR.A,CHR.B,CHR.C,CHR.D,CHR.E,CHR.G,CHR.H,CHR.I,CHR.J,CHR.K
	.GLOBAL CHR.L,CHR.M,CHR.P,CHR.Q,CHR.R,CHR.T,CHR.U,CHR.X,CHR.Y,CHR.Z
	.GLOBAL SERR,POPK,ZRON,CPCS,CCMA
	.GLOBAL CATS,CEXP,INRCNT
	.GLOBAL ICRCNT,QPTR,UPPERC,GETN,CHR.UA
	.GLOBAL CTL.A,CTL.H,CTL.I,CTL.T

	.EXTERNAL TSAV,NRET,ESCAPE,NCOM,CMIN,TSTD
	.EXTERNAL DSPLAY,TCINIT,ERR30
	.EXTERNAL JTECO,ERRYY,XH,QMK
	.EXTERNAL DRAD,SETSKP,VBARE
	.EXTERNAL CDSP,PDLBEG,PDLEND,CSEM,ELIST,ALTLST

IN=	6200		/INPUT BUFFER AT 06200
OUT=	5200		/OUTPUT BUFFER AT 05200
ZMAX=	7640		/MAX 4000[10] CHARACTERS IN TEXT BUFFER
QMAX=	3720		/MAX 2000[10] Q-REGISTER CHARS IN 8K
Q12MAX=	5600		/MAX 2944[10] Q-REGISTER CHARS IN 12K

MTWO=	CLA CLL CMA RAL
MTHREE=	CLA CLL CMA RTL
AC3777=	CLL STA RAR
SCPBIT=	7726
	.MACRO	.ERROR	ERNUM
	.GLOBAL ERR'ERNUM
ERR'ERNUM:	ERR
	.ENDM

	.MACRO	.SORT	ARG1,ARG2
	SORT;	ARG1;	ARG2-ARG1
	.ENDM

	.MACRO	.OVRLAY	LAY,ADDR
	OVRLAY;	LAY'OVRLY;	ADDR
	.ENDM
/THINGS WE WOULD LIKE TO ADD:

/FR
/-S
/::S
/^EQ
/M,NS
/[Q
/]Q
/NON-EXACT SEARCH MODE
/*N
/CHECK FOR $ ON NI$
/NV=(1-N)TNT
/:X
/"V
/"W
/:^U
/^X
/ES
/EV
/M,ND
/E?HELP$  COMMAND
/:C,:J, ETC.
/^Q REMOVED FROM INPUT RING BUFFER (OR IMMED ACTION ^Q CMD)
/^V AND ^W MATCH CONTROL
/BS SHOULD NOT STICK AT TOP
/MEMSIZ SHOULD BE ADJUSTED
/SEARCH STRING TOO LONG NEEDS A 0
/TEST FOR ILLEG CHAR IN FILE  SELECT
/?MEE, ETC. ERROR MESSAGES
/| SHOULD GO INTO ROOT
/*****************************************
/	TECO ERROR MESSAGES:
/*****************************************

/	TECO ERROR MESSAGES CONSIST OF A QUESTION MARK AND THREE LETTERS
/	TYPING "?" IMMEDIATELY AFTER AN ERROR MESSAGE PRINTOUT PRINTS
/	THE CURRENT COMMAND LINE UP TO THE ERROR CHARACTER.

/1	?ILL	ILLEGAL COMMAND
/2	?UTC	INCOMPLETE COMMAND (PDL NOT EMPTY AT END OF COMMAND STRING)
/3	?IQN	NON-ALPHANUMERIC Q-REGISTER NAME
/4	?PDO	PUSHDOWN OVERFLOW (MACROS & ITERATIONS NESTED TOO DEEPLY)
/5	?MEM	TEXT BUFFER OVERFLOW
/6	?STL	SEARCH STRING TOO LARGE ( >31 CHARS)
/7	?ARG	NUMBER MISSING BEFORE COMMA
/		OR TWO ARGUMENTS SPECIFIED TO D
/		OR 3 NUMERIC ARGUMENTS
/8	?IFN	ILLEGAL FILE NAME IN "ER","EW" OR "EB" COMMAND
/9	?SNI	SEMICOLON ON COMMAND LEVEL
/10	?BNI	ITERATION CLOSE (>) WITHOUT MATCHING OPEN (<)
/11	?POP	ATTEMPT TO MOVE POINTER OUTSIDE OF TEXT BUFFER
/12	?QMO	Q-REGISTER STORAGE OVERFLOW
/13	?UTM	INCOMPLETE COMMAND (PDL NOT EMPTY AT END OF MACRO)
/14	?OUT	OUTPUT FILE TOO BIG OR OUTPUT PARITY ERROR
/15	?INP	PARITY ERROR ON INPUT FILE
/16	?FER	FILE ERROR: CAN MEAN EITHER
/		A)	INPUT FILE NOT FOUND ON "ER" COMMAND
/		B)	CANNOT ENTER OUTPUT FILE ON "EW" OR "EB" COMMAND
/		C)	DEVICE SPECIFIED FOR FILE DOES NOT EXIST
/		D)	"EB" COMMAND GIVEN ON NON-FILE-STRUCTURED DEVICE
/17	?FUL	OUTPUT COMMAND WOULD HAVE OVERFLOWED OUTPUT FILE
/		[PANIC MODE]
/18	?NYA	NUMERIC ARGUMENT SPECIFIED WITH Y COMMAND
/19	?IEC	E FOLLOWED BY AN ILLEGAL CHARACTER
/20	?IQC	" FOLLOWED BY AN ILLEGAL CHARACTER
/21	?NAE	NO NUMERIC ARGUMENT TO THE LEFT OF AN =
/22	?NAU	NO NUMERIC ARGUMENT TO THE LEFT OF A U
/23	?NAQ	NO NUMERIC ARGUMENT TO THE LEFT OF A "
/24	?SRH	FAILING SEARCH AT COMMAND LEVEL
/25	?NPA	NEGATIVE OR ZERO ARGUMENT TO P
/26	?NCA	NEGATIVE ARGUMENT TO COMMA
/27	?NYI	CASE SUPPORT NOT IMPL (USE W FOR WATCH)
/28	?UIS	UNDEFINED I/O SWITCH
/29	?ISA	NEGATIVE OR ZERO ARGUMENT WITH A SEARCH
/30	?WLO	WRITE LOCKED SYSTEM DEVICE
/31	?IFC	F FOLLOWED BY AN ILLEGAL CHARACTER
/32	?YCA	Y (OR _) COMMAND ABORTED BECAUSE DATA WOULD BE LOST
/33	?CCL	CCL NOT FOUND OR EG ARGUMENT TOO LONG
/34	?XAB	EXECUTION ABORTED BY ^C
/35	?NYI	CASE SUPPORT NOT IMPL (USE EO FOR VERSION)
/36	?UEC	UNIMPLEMENTED E COMMAND
/37	?DTB	DELETE TOO BIG
/38	?POP	REFERENCE TO POINTER OFF PAGE
/39	?ICE	ILLEGAL CONTROL-E
/40	?NAB	NO ARGUMENT BEFORE ^_
/41	?NYI	PUSH AND POP NOT YET IMPLEMENTED
/42	?NFO	ATTEMPT TO OUTPUT WITHOUT OPENING AN OUTPUT FILE
/	CORE LAYOUT AND OVERLAY STRUCTURE

/	BUFFER STRUCTURE:

/BUFFER		8K VERSION	12K VERSION

/INPUT  BUFFER	06200-07200	25600-27600
/OUTPUT BUFFER	05200-06200	05200-07200
/Q-REG STORAGE	OVER TEXT BFR	20000-25600

/	HANDLER LOCATIONS:

/HANDLER	PDP-8 VERSION	PDP-12 VERSION

/INPUT  HANDLER	7200-7600	7200-7400
/OUTPUT HANDLER	4000-4400	7400-7600
/SIZE OF HNDLR	2-PAGES		1-PAGE
/DISPLAY CODE	NONE		4000-4400

/	OVERLAY STRUCTURE

/ALL OVERLAYS ARE TWO PAGES LONG AND RESIDE IN CORE
/AT LOCATIONS 3200-3600 WHEN RUNNING.  THE I-OVERLAY
/INITIALLY RESIDES IN THESE LOCATIONS.

/OVERLAY	BLOCK	INITIAL LOCATION	CONTENTS

/  I-OVERLAY	40	3200-3600	ER,EW,EB
/  Q-OVERLAY	41	5600-6200	", O, SKPSET
/  E-OVERLAY	42	6200-6600	ERROR MESSAGE PROCESSOR
/  X-OVERLAY	43	6600-7200	EX,EC,EG,EK,EF (EA,EI,EN,EP)
/  F-OVERLAY	44	7200-7600	ED,EH,EO,ES,ET,EU (EV)

	IOVRLC=40
	QOVRLC=41
	EOVRLC=42
	XOVRLC=43
	FOVRLC=44

	IOVRLY=3200
	QOVRLY=3201
	EOVRLY=3202
	XOVRLY=3203
	FOVRLY=3204

/EACH OVERLAY IS ASSIGNED A LOCATION AT THE BEGINNING OF PAGE 3200.
/IF THIS LOCATION IS 0 (AS IT ALWAYS IS), THEN THAT OVERLAY IS
/IN CORE.  IF IT IS NOT 0, THEN THIS LOCATION CONTAINS THE
/BLOCK NUMBER TO READ IN THAT OVERLAY.
/THUS EACH OVERLAY HAS POINTERS TO ALL THE OTHER OVERLAYS.
	MEMLOC=2000

/IN 16K MACHINES, FIELD 3 IS USED TO HOLD OVERLAYS
/IN 20K MACHINES, FIELD 4 SERVES THIS PURPOSE INSTEAD

/NAME	BLOCK	MEMORY

/I	40	2000
/Q	41	2400
/E	42	3000
/X	43	3400
/F	44	4000


/INITIAL MEMORY LAYOUT

/0000-3177	TECO
/3200-3577	OVERLAY AREA (INITIALLY I-OVERLAY)
/3600-3777	TECO
/4000-4377	PDP-12 DISPLAY ROUTINE
/4400-5177	TECO
/5200-5577	INITIALIZATION CODE
/5600-6177	Q-OVERLAY CODE
/6200-6577	E-OVERLAY CODE
/6600-7177	X-OVERLAY CODE
/7200-7577	F-OVERLAY CODE

/FIELD 1:

/0000-3177	VT52 SUPPORT CODE INITIALLY RESIDES HERE
/3200-3377	INITIAL COPY OF EXTENDED MATCH CONTROL CODE
/3400-3777	MORE INITIALIZATION CODE
/4000-4377	RESERVED FOR TECO.INI STUFF
/4400-7377	EXTENDED ERROR MESSAGES
/		MOVES TO FIELD 3 OR 4
/7400-7577	FREE. AVAILABLE TO USER FOR EXTENDED CHAIN ARGUMENT
/	EXECUTION-TIME MEMORY LAYOUT

/	FIELD 0					NOTES

/0000-3177	TECO
/3200-3577	OVERLAY AREA
/3600-3777	TECO
/4000-4377	OUTPUT HANDLER		(VR12 CODE ON PDP-12)
/4400-5137	TECO
/5140-5177	PUSHDOWN STACK
/5200-6177	OUTPUT BUFFER
/6200-7177	INPUT BUFFER		(ADDITIONAL OUTPUT BUFFER IF .GT. 8K)
/7200-7377	INPUT HANDLER		(EXTENDED MATCH CONTROL MAY BE HERE)
/7400-7577	MORE INPUT HANDLER	(OUTPUT HANDLER ON PDP-12)

/	FIELD 1

/0000-7637	TEXT BUFFER	     (IN 8K, Q-REGISTERS MULTIPLEX THIS AREA)

/	FIELD 2

/0000-5577	Q-REGISTER STORAGE
/5600-7577	INPUT BUFFER

/	FIELD 3

/0000-7577	VT SUPPORT

/	FIELD 4	(FIELD 3 IF NO VT SUPPORT)

/0000-1777	HELP BUFFER
/2000-2377	RESIDENT I-OVERLAY
/2400-2777	RESIDENT Q-OVERLAY
/3000-3377	RESIDENT E-OVERLAY
/3400-3777	RESIDENT X-OVERLAY
/4000-4377	RESIDENT F-OVERLAY
/4400-7377	EXTENDED ERROR MESSAGE CODE

/**  TECO KLUDGES **		/7/27/73
/ONE OF THE REASONS WHY TECO GETS SO MANY OPERATIONS
/INTO SUCH A SMALL AMOUNT OF CORE IS THAT IT
/IS FULL OF *K*L*U*D*G*E*S*.  THESE SHOULD BE KEPT IN MIND WHEN
/MODIFYING THE PROGRAM.  SOME OF THEM ARE:

/	THE "SORT" ROUTINE COMPARE LIST MUST END WITH A NEGATIVE NUMBER.
/	USUALLY A FORTITUOUS JMS OR OPR INSTRUCTION IS USED

/	THE "SORT" JUMP LIST ENTRIES ARE TREATED AS JUMP ADDRESSES
/	IF THEY ARE POSITIVE AND SUBSTITUTE VALUES IF THEY ARE
/	NEGATIVE - THEREFORE ALL LOCS JUMPED TO MUST BE BELOW 4000
/	ANOTHER CONSEQUENCE IS THAT "QUOTST" CANNOT BE CALLED FROM
/	ABOVE 4000

/	THE MASTER DISPATCH TABLE HAS ENTRIES THAT ARE POSITIVE
/	TO MEAN BRANCH TO THIS CODE, AND NEGATIVE TO MEAN THAT THE COMMAND
/	IS HANDLED IN AN OVERLAY.  THUS, ALL CODE FOR COMMANDS MUST START
/	AT A POSITIVE ADDRESS.

/	THERE ARE OTHER LOCALIZED KLUDGES - THEY CAN GENERALLY
/	BE IDENTIFIED BY THE APPEARANCE OF A DOUBLE-ASTERISK IN THE
/	COMMENTS FIELD ALONG WITH A TERSE DESCRIPTIVE COMMENT
	.JSW	0
	.VERSION VERSN

	.ASECT	TECO.0

	*0
	0		/RESERVED FOR USE BY
	CIF 30		/  OS/78 SYMBIONT SUPPORT
	JMP .-1
NAME,	ZBLOCK	4	/NAME BUILD BUFFER - MUST BE AT LOCATION 3 (USED TO BE 0)
			/SEE 'NAMEC' ROUTINE
			/LOCS 4,5&6 ARE NO LONGER RESERVED SO WE CAN USE OS/8 ODT
	DM=NAME+3
	*10	/CONSTANTS & NON-INDIRECT TEMPS STORED IN AUTO-XRS!
QUOTE,	33	/QUOTE CHAR - SINGLE WORD SORT LIST
SERR,	.ERROR 01	/END OF LIST
INRSIZ,	2	/4 IF 12K MACHINE
NUMLNS,	3	/NUMBER OF LINES (+ AND -) TO DISPLAY ON VR12 SCOPE

	.ASECT TEC.16

	*16

INXR,	0	/XR USED TO UNPACK INPUT BUFFER
XR,	0	/WORK XR

NMT,	0	/USED  AS NUMBER TEMP AND SEARCH FAIL FLAG
CFLG,	0	/COMMA FLAG
CLNF,	0	/COLON FLAG
TFLG,	0	/TRACE FLAG
NFLG,	0	/NUMBER FLAG
QFLG,	0	/QUOTED STRING FLAG
M,	0	/NUMBER ARGS
N,	0
NLINK,	0	/LINK AFTER ARITH OPERATIONS
CHAR,	0	/CHARACTER BUFFER
ITRST,	0	/ITERATION FLAG
ITRCNT,	0	/ITERATION COUNT
MPDL,	0	/MACRO FLAG
SCHAR,	0	/LAST CHAR SORTED
FFFLAG,	0	/FORM FEED FLAG - 7777 IF FORM FEED SEEN ON THIS READ
REND,	0	/INPUT END-OF-FILE FLAG
SCANP,	0	/COMMAND LINE EXECUTION POINTER
OSCANP,	0	/BACKUP FOR SCANP
PDLP,	PDLBEG	/PUSH-DOWN-LIST POINTER
QCMND,	0	/COMM LINE OR MACRO POINTER
P,	0	/CURRENT PNTR TO TEXT BUFFER
ZZ,	0	/END OF TEXT BUFFER POINTER
Q,	0	/EXTRA BUFFER POINTERS
	IFNZRO .-47 <_ERROR_>
R,	0
QP,	0	/Q REGISTER POINTER
QZ,	0	/END OF Q-REG POINTER (MUST BE INITIALLY 0)
Z7,
CTLBEL,	7
CACR,	15	/CR
Z11,
CAHT,	11	/HT
Z33,
CAAM,	33	/ALT MODE
Z14,
CAFF,	14	/FF: END OF PAGE
	13	/VT
Z12,
CALF,	12	/LF
NERR,	.ERROR 07	/END OF LIST
RADIX,	DRAD	/RADIX TABLE POINTER - DRAD OR ORAD
MQ,	0
DVT1,	0
ODEV,	0	/OUTPUT DEVICE NUMBER
OUTHND,	0
INHND,	0
EBFLG,	0	/EDIT BACKUP FLAG
QNMBR,	0	/LAST Q-REG REFERENCED
QBASE,	0	/BASE OF CURRENT COMMAND LINE
QLENGT,	0	/LENGTH OF CURRENT COMMAND LINE
QPTR,	0	/POINTER TO Q-REGISTER CONTROL BLOCK
ICRCNT,	0	/INPUT DOUBLEWORD COUNTER
OCRCNT,	0	/OUTPUT "
OPTR2,	0	/OUTPUT BUFFER POINTER
INRCNT,	0	/NUMBER OF INPUT RECORDS LEFT
OCMDLN,	0	/LENGTH OF OLD COMMAND LINE
CDT,	0
KTYPE,	TYPE		/*ET SET TO PUTT IF NO CONVERSION
TEMPT,	0		/TEMP.  GET RID OF WHEN FIND ROOM ON PAGE
MEMSIZ,	0		/HIGHEST MEMORY FIELD IN BITS 9-11
LASTC,	0		/LAST CHARACTER GOTTEN OUT OF COMMAND LINE
/ZCHAR,	0

/NFLG:	0'ED BY COMMANDS WHICH EAT ARGUMENTS OR DON'T RETURN
/	VALUES; SUCH AS C,R,J,L,^A,X,$,',>,^U,G,O AND
/	NON-COLON MODIFIED SEARCHES
/	SET TO -1 TO INDICATE THAT WE'VE SEEN A NUMBER
	/TECO PSEUDO-OPERATIONS

PUSH=	JMS I	.;	PUSHXX
POP=	JMS I	.;	POPXX	/** MUST BE ONE MORE THAN "PUSH"
PUSHJ==	JMS I	.;	PUSHJY
POPJ==	JMP I	.;	POPJXX
PUSHL==	JMS I	.;	PUSHLX
POPL==	PUSHL			/** POPL CALLED WITH POSITIVE AC

ERR=	JMS I	.;ERROR,ERRXX
SORT==	JMS I	.;	SORTB
RESORT==	JMP I	.;	SORTA2
SCAN==	JMS I	.;	SGET
LISTEN=	JMS I	.;	TYI
TYPE==	JMS I	.;	TYPCTV
OUTPUT==	JMS I	.;OUTR,	ERRXX	/** MUST BE ONE MORE THAN "TYPE"
				/PROBABLY NOT ANY MORE (19-JUN-77)
CRLF==	JMS I	.;	TYCRLF
GETQ==	JMS I	.;	GETQX
SKPSET==	JMS I	.;	SETSKP
NCHK==	ISZ	NFLG		/USED TO BE A SUBROUTINE CALL
CTCCHK=	JMS I	.;	CHKCTC
BZCHK=	JMS I	.;	CHKBZ
QCHK==	JMS I	.;	CHKQF
QSKP==	JMS I	.;	QOVER
QREF==	JMS I	.;	QREFER
QSUM=		JMS I	.;	QSUMR
QPUT==		JMS I	.;	QPUTS
QUOTST==	JMS I	.;	QTST
SETCMD=		JMS I	.;	CMDSET
GETN=		JMS I	.;	NGET
ADJQ==		JMS I	.;	QADJ
MQLDVI==	JMS I	.;	DVIMQL
UPPERC=		JMS I	.;	CUPPER
SCANUP==	JMS I	.;	SCUPPR
TSTSEP==	JMS I	.;	SCHSRT
DISPLY==	JMS I	.;	DSPLAY
NOTRCE==	JMS I	.;	SAVTRA
ENTRCE==	JMS I	.;	RESTRA
OVRLAY=		JMS I	.;	OVERLY
GETNUM==	JMS I	.;	NUMGET	/GET 13 BIT NUMBER INTO L,AC
PUTT==		JMS I	.;	TPUT
TESTA==		JMS I	.;	TSTA
TESTD==		JMS I	.;	TSTD
/	PAGE 0 LITERALS (THAT LINKER COULDN'T SHARE)

Z7400,	7400
Z4,	4
Z40,	40
Z200,	200
ZM12,	-12
ZM60,	-60
Z7740,
ZM40,	-40
Z7700,
ZM100,	-100
ZM10,
Z7770,	-10
Z377,	377
Z177,	177
Z77,	77
ZIREST,	IREST
ZNXTBUF,NXTBUF
ZQPNTR,	QPNTR
Z52,	"*
Z100,	100
Z137,	137
Z6,	6
	.ASECT	TECO

/ENTER HERE TO USE AN ASR33 AS THE TELETYPE

TECOS,	ISZ I	SPUT	/IF CALLED BY "R" OR "RUN" - CHANGED TO TLS
TECO1,	JMP I	COMPAR	/IF CALLED VIA "CHAIN" - CHANGED TO "JMP T0A"
TBEL,	JMS	COMPAR	/HERE ON ^G - 2 ^G'S KILL ENTIRE COMMAND

T0,	CRLF
T0A,	TAD	PDL..B
	DCA	PDLP	/INITIALIZE PUSHDOWN LIST
T1,	TAD	PDLP
	CIA
	TAD	PDL..B
	SZA CLA
	.ERROR	02	/ERROR - PUSHDOWN LIST DID NOT BALANCE
	TAD	(45
	QREF		/SET UP POINTERS TO COMMAND LINE
	TAD I	ZQPNTR
	DCA	OCMDLN	/SAVE OLD COMMAND LINE LENGTH
			/** SAVE ONLY IF < 20?
	ADJQ		/REDUCE COMMAND LINE LENGTH TO 0
	CLL
	PUSHJ
		NRET	/CLEAR NUMBER AND LAST OPERATOR
	DCA	MPDL	/DELETE MACRO FLAG
	DCA	ITRST	/ALSO ITERATION FLAG,
	DCA	CLNF	/AND COLON FLAG
	PUSHJ		/KILL QUOTE FLAG
		ZROSPN	/KILL QUOTE AND NUMBER FLAGS AND SCAN POINTER
	KCC		/KILL ^O IF IN KEYBOARD BUFFER
	TAD I	(ETFLAG
	AND	(3537	/KILL FATAL ERROR RETURN AND ^C TRAP AND READ W NO WAIT
	DCA I	(ETFLAG
	DCA	TFLG	/PROMPT SHOULD CLEAR TRACE FLAG
	TAD	(AIDLST
	DCA	SRT+1	/FIRST CHARACTER AFTER PROMPT IS SPECIAL
	TAD	Z52
	SKP
ROCMND,	JMS I	(BACKUP	/BACK UP AND GET LAST CHAR
	TYPE
T2M1,	DCA	CHAR	/KILL CHAR TO PREVENT SPURIOUS DOUBLE CHARACTERS
T2,	LISTEN		/BUILD COMMAND LINE
SRT,	.SORT	AIDLST,AIDTAB	/CHECK FOR SPECIAL FIRST CHARACTERS
	.SORT	COMLST,COMTAB	/CHECK FOR IMMEDIATE MODE COMMANDS
T2A,	DCA	CHAR
	TAD	Z11	/GUARANTEED NEGATIVE NUMBER INDICATES NULL LIST (11 CONTAINS SERR)
	DCA	SRT+1	/NOT AT FIRST CHARACTER ANY MORE
	JMS	SPUT	/PUT INTO C.L. BUFFER
	JMP	T2	/GO GET ANOTHER

PDL..B,	PDLBEG
TCRLF,	TAD	CACR	/CR IN COMM LINE
	DCA	CHAR
	JMS	SPUT	/PUT INTO COMM LINE
	TAD	CALF	/THEN PUT IN A LF
	JMP	T2A	/AND GET SOME MORE
	.SBTTL	.	Command Execution Loop

TALTM,	JMS	COMPAR	/2ND ALTM STARTS EXECUTION
	CRLF		/START COMM EXECUTION
	DCA I	ERROR	/CLEAR ERROR JUST OCCURRED FLAG
CHTECO,	TAD	(45	/NUMBER OF INPUT COMMAND Q-REGISTER
	SETCMD		/SET UP THE INPUT LINE AS THE CURRENT COMMAND LINE
6$:	SCANUP
T6A:	DCA	CHAR	/SAVE COMMAND CHAR
	TAD	CHAR
	TAD	(CDSP	/ADD BASE OF DISPATCH TABLE
	DCA	8$	/LOOK UP ENTRY IN
	TAD	(OVBRAN	/PREPARE TO DISPATCH TO OVERLAY
	DCA	7$
	TAD I	8$	/COMMAND DISPATCH TABLE
	SMA		/IS AN OVERLAY NECESSARY?
	DCA	7$	/NO, CALL RECURSIVELY
/	CLL		/YES
	PUSHJ
7$:		0	/CALL TO ROUTINE
	CTCCHK		/CHECK FOR ^C - ** AC MAY NOT BE 0 HERE **
	CLA		/CTCCHK LEAVES AC NON-ZERO
	TAD	NFLG
	SPA CLA
	JMP	6$
	DCA	N	/IF WE ARE NOT ENTERING A NUMBER
	DCA	NLINK	/SET 13-BIT N TO 0
	JMP	6$	/KEEP INTERPRETING

8$:	0

TQMK,	.OVRLAY E,QMK

TSLASH,	.OVRLAY E,XH

VBAR,	.OVRLAY Q,VBARE
COMPAR,	TCINIT		/LOOK FOR DOUBLED COMM LINE CHARS
	TAD	SCHAR	/MOST RECENT
	CIA
	TAD	CHAR	/PREVIOUS
	SZA CLA
	RESORT		/NOT THE SAME
	JMS	SPUT	/PUT THE CHAR INTO THE COMMAND LINE AND ECHO IT
	JMP I	COMPAR	/SAME-SPECIAL HANDLING

SPUT,	JTECO		/PUT CHAR INTO COMM LINE
	TAD	QZ
	DCA	QP
	TAD	CHAR
	QPUT		/STORE CHARACTER AWAY
	TAD I	ZQPNTR
	IAC
	ADJQ		/ADJUST COMMAND LINE REGISTER LENGTH
	TAD	CHAR
	TYPE		/TYPE THE INSERTED CHARACTER
	TAD I	ZQPNTR
	TAD	Z12
	SPA CLA
	JMP	1$	/TYPE BELL IF WITHIN 12 CHARACTERS OF 2048
	CLL
	TAD	QZ
	TAD	QLIMIT
	SNL CLA		/TYPE A BELL IF THE LINE IS
	JMP I	SPUT	/ WITHIN 12 CHARS OF OVERFLOW
1$:	TAD	Z7	/EMERGENCY!
	PUTT
	JMP I	SPUT
QLIMIT,	12-QMAX
	PAGE
	.SBTTL	.	Q-register pack and unpack

	/THE Q-REGISTERS ARE STORED IN THE UPPER 4 BITS OF THE WORDS
	/WHICH HAVE THE TEXT BUFFER CHARACTERS IN THEIR LOWER 8 BITS.
	/THEREFORE EACH Q-REGISTER CHARACTER TAKES 2 WORDS.

QPUTS,	0		/STORE THROUGH POINTER "QP" AND BUMP POINTER
	CLL RTL
	RTL
	DCA	GETQX	/SAVE CHARACTER
	TAD	QP
	CLL RAL
	DCA	CHKCTC	/COMPUTE CORE POINTER = 2*QP
	CDF 10
	TAD	GETQX
	JMS	ST4BTS	/STORE HIGH ORDER 4 BITS
	ISZ	CHKCTC
	TAD	GETQX
	CLL RTL
	RTL
	JMS	ST4BTS	/STORE LOW ORDER 4 BITS
	CDF 0
	ISZ	QP	/BUMP POINTER
	JMP I	QPUTS

GETQX,	0
	CLL RAL
	DCA	CHKCTC	/COMPUTE CORE POINTER = 2*AC
	CDF 10
	TAD I	CHKCTC
	AND	Z7400	/FETCH HIGH ORDER
	ISZ	CHKCTC
	DCA	QPUTS
	TAD I	CHKCTC
	AND	Z7400	/FETCH LOW ORDER
	CLL RTR
	RTR
	TAD	QPUTS	/COMBINE TO FORM CHARACTER
	RTR
	RTR
	CDF 0
	JMP I	GETQX

ST4BTS,	0
	AND	Z7400
	DCA	POPXX
	TAD I	CHKCTC
	AND	Z377
	TAD	POPXX
	DCA I	CHKCTC	/STORE HIGH ORDER
	JMP I	ST4BTS

/MANY LOCATIONS ABOVE ARE FREE IN 12K
CHKCTC,	0		/SUBROUTINE TO CHECK FOR ^C IN KEYBOARD
			/** AC MAY NOT BE 0 ON ENTRY
C7600,	7600		/JUST IN CASE THERE IS NO MQ
VT52B,	KSF		/*VT52
	JMP I	CHKCTC	/*VT52 NO CHAR IN KEYBOARD BUFFER - EXIT
	KRS		/*VT52
	AND	Z177	/KILL PARITY BIT
	TAD	(-3
	SZA		/^C?
CHKCTR,	JMP I	CHKCTC	/NO - RESUME WITH NON-ZERO AC
	.ERROR	34	/^C, EXECUTION ABORTED

	.SBTTL	Cmd ^C

CTL.C,	TSF
	JMP	CTL.C	/WAIT FOR TELETYPE TO DIE DOWN
	JMP I	C7600	/RETURN TO OS/8


POPJXX,	DCA	GETQX	/POPJ ROUTINE
	POP
POPJXY,	DCA	POPXX
	TAD	GETQX
	JMP I	POPXX

	.SBTTL	Cmd ^

CHR.UA,	POP		/^ COMMAND - POP OFF RETURN ADDRESS
	SCANUP		/GET THE NEXT CHARACTER IN UPPER CASE
	AND	Z77	/MAKE IT A CONTROL CHARACTER
	JMP I	(T6A	/USE IT INSTEAD OF THE ^
	.SBTTL	.	Push down list routines

POPXX,	0		/POP ROUTINE
	STA
	TAD	PDLP
	DCA	PDLP
	TAD I	PDLP
	JMP I	POPXX

PUSHXX,	0		/PUSH ROUTINE (DOESN'T AFFECT LINK)
	DCA I	PDLP
	ISZ	PDLP	/BUMP PUSHDOWN POINTER
	TAD	PDLP	/CHECK FOR EXACTLY FULL - THIS ALLOWS THE
	TAD	PDL..E
	SNA CLA		/** ERROR ROUTINE TO DO A PUSHJ
	.ERROR	04	/FULL - REPORT IT
	JMP I	PUSHXX

PDL..E,	-PDLEND

PUSHJY,	0		/PUSHJ ROUTINE (DOESN'T AFFECT LINK)
	DCA	GETQX
	IAC		/** LINK SHOULD BE PRESERVED ON EXIT
	TAD	PUSHJY
	PUSH
	TAD I	PUSHJY
	JMP	POPJXY

PUSHLX,	0		/PUSH AND CLEAR A LIST
	CLL
	SMA		/PUSH LIST IF AC<0, POP IT IF >=0
	CMA STL
	DCA	PUSHJY	/SET COUNTER
	RAL		/** DEPENDS ON FACT THAT POP=PUSH+1 **
	TAD	3$
	DCA	2$	/STORE EITHER A "PUSH" OR A "POP"
	POP		/SAVE RETURN POINTER
	DCA	CHKCTC
1$:	TAD I	PUSHLX
	DCA	GETQX
	TAD I	GETQX
2$:	PUSH		/PUSH OR POP
	DCA I	GETQX	/IF PUSHYX=PUSH, THIS ZEROES THE PUSHED LOCATION
	ISZ	PUSHLX
	ISZ	PUSHJY
	JMP	1$
	TAD	CHKCTC	/RESTORE RETURN POINTER
3$:	PUSH
	JMP I	PUSHLX
TPUT,	0		/TELETYPE OUTPUT
	DCA	TEMPT
TPUTX,	CTCCHK		/CHECK FOR ^C
	TAD	(3-17	/INHIBIT PRINTING AS LONG AS THERE
	SNA		/IS A ^O IN THE KEYBOARD BUFFER.
	JMP I	TPUT
	TAD	(17-23	/CHECK FOR ^S
	SNA CLA
	JMP	TPUTX
	TSF		/WAIT FOR TELETYPE FLAG
TSFWT,	JMP	.-1	/WHILE WAITING, DISPLAY TEXT ON SCOPE
	TAD	TEMPT
	TLS
	DCA	OUTDNE
	JMP I	TPUT
OUTDNE,	0
	PAGE
	.SBTTL	Cmd J

CHR.J,	DCA	NFLG	/COMMAND J
	GETNUM		/CAUSE NEG ARGUMENT TO GIVE A POP
	JMP	CLOQ

	.SBTTL	Cmd R

CHR.R,	GETN		/GET LAST NUMBER, DEFAULT=(+ OR -)1
CHR1,	CML CIA		/NEGATE 13-BIT NUMBER
	SKP

	.SBTTL	Cmd C

CHR.C,	GETN		/GET LAST NUMBER, DEFAULT=(+ OR -)1
	TAD	P	/OFFSET RELATIVE TO .
/
/	*** LINK NOT ALWAYS SET RIGHT
/
CLOQ,	BZCHK		/SEE IF IN RANGE B,Z
	.ERROR	11	/?POP
	DCA	P	/IN RANGE
	POPJ
	.SBTTL	Cmd L

CHR.L,	GETN		/GET LAST NUMBER, DEFAULT=(+ OR -)1
CHRL1,	CDF 10
	SZL SNA
	JMP	2$
	CIA
	DCA	CDT
L$:	TAD	P
	CIA
	TAD	ZZ
	SNA CLA		/IF WE ARE AT THE END OF THE BUFFER,
	JMP	DNN3	/RETURN
	JMS I	(CHLCMP	/COMPARE CHARACTER AGAINST LINE FEED
	ISZ	P
	JMP	L$	/KEEP GOING UNTIL WE GET THERE OR OVERFLOW BUFFER
2$:	TAD	(-1
	DCA	CDT
1$:	CLA CMA CLL
	TAD	P
	DCA	P	/MOVE POINTER BACKWARD 1
	SNL
	JMP I	(CHRLI	/OOPS - PAST THE BEGINNING OF THE BUFFER - RETURN
	JMS I	(CHLCMP	/COMPARE CHARACTER AGAINST LINE FEED
	JMP	1$	/NOT SATISFIED YET - KEEP LOOPING

NUMGET,	0		/PUT 13-BIT NUMBER IN L,AC
	TAD	NLINK
	CLL RAR
	TAD	N
	JMP I	NUMGET
	.SBTTL	Cmd D

CHR.D,	ISZ	CFLG	/WAS THERE A COMMA?
	SKP		/NO
	JMP	NERR	/YES, 2 ARGS TO D
	GETN		/GET LAST NUMBER, DEFAULT=(+ OR -)1
	SNL		/SIGN BIT OF 13-BIT NUMBER IS IN LINK
	JMP	PLUSND	/+ND
	CLL CIA
	DCA	CDT	/-ND
	TAD	CDT
	PUSHJ		/DO (-)NC(+)ND
		CHR1
	TAD	CDT
	JMP	PLUSND

ADJ,	SNA		/ADJUST BUFFER + OR - N CHARS
			/TEST FOR NOTHING
	POPJ		/GO AWAY
	STL		/MOVE UP N CHARACTERS
	TAD	ZZ	/ADD TO MAX CHARACTER
	DCA	R	/NEW HIGHEST
	TAD	R	/SEE IF TOO HIGH
	TAD	(-ZMAX
	SNL SZA CLA	/TWO PLACES FOR OVERFLOW THERE
	.ERROR	05
	TAD	ZZ
	DCA	Q
	TAD	R
	DCA	ZZ
	CDF 10
UPNL,	TAD	Q
	CIA
	TAD	P
	SNA CLA		/FINISHED?
	JMP	DNN3	/YES
	CMA
	TAD	Q
	DCA	Q
	CMA
	TAD	R
	DCA	R
	TAD I	Q	/GET A CHAR
L12K1,	AND	Z377	/JMP .+5  IF 12K
	DCA	CHLTMP
	TAD I	R	/BE CAREFUL NOT TO
	AND	Z7400	/DESTROY THE HIGH-
	TAD	CHLTMP	/ORDER 4 BITS
J12K1=	JMP	.
	DCA I	R	/AND PUT IT IN THE LOW PART OF THE TARGET WORD
	JMP	UPNL
	.SBTTL	Cmd K

CHR.K,	JMS I	(NLINES	/CONVERT LINES TO CHARS
	DCA	CDT
	TAD	M	/SET POINTER
	DCA	P	/LOWER ARG
	TAD	CDT
PLUSND,	SNA
	POPJ		/IGNORE 0D
ADJ2,	CLL
	TAD	P	/MOVE DOWN N CHARACTERS
	BZCHK
	.ERROR	37	/DELETE TOO BIG
	DCA	Q	/N IN AC
	TAD	P
	DCA	R
	CDF 10
DNN1,	TAD	ZZ
	CIA
	TAD	Q
	SNA CLA		/FINISHED?
	JMP	DNN2
	TAD I	Q	/GET A CHAR
L12K2,	AND	Z377	/JMP .+5  IF 12K
	DCA	CHLTMP
	TAD I	R	/BE CAREFUL NOT TO
	AND	Z7400	/DESTROY THE HIGH-
	TAD	CHLTMP	/ORDER 4 BITS
J12K2=	JMP	.
	DCA I	R	/AND PUT IT IN THE LOW PART OF THE TARGET WORD
	ISZ	Q
	ISZ	R
	JMP	DNN1
DNN2,	TAD	R
	DCA	ZZ
DNN3,	CDF	0
	POPJ

CHLTMP,	0

/GO TO ADJ TO MOVE UP TEXT
/GOTO ADJ2 TO MOVE DOWN TEXT
/IN EITHER CASE, AC CONTAINS NUMBER OF CHARS TO MOVE (0-4095)
C.W,	JMP I	(CHR.W	/THIS MUST BE BELOW 4000
	PAGE
	.SBTTL	.	Scope subroutines

	.ASECT TEC0B

	*1400

/CURSOR RIGHT IS $C
/CURSOR UP IS $A
/ERASE LINE IS $K

BUGFLG,	0		/-1 MEANS MUST RETYPE LINE ON NEXT RUBOUT

BSP,	0
	TAD	TTY10
	PUTT		/TYPE BS, SPACE, BS
	TAD	TTY40
	PUTT
	TAD	TTY10
	PUTT
	STA
	TAD I	(COLCT	/FIX UP COLUMN COUNTER
	DCA I	(COLCT
	JMP I	BSP
SCOPY,	JMS I	(BACKUP	/BACK UP ONE CHAR IN CMD LINE
	TAD	ZM40	/LOOK AT CHAR WE BACKED OVER
	SMA
	JMP	SCP.RO	/IT'S EASY TO RUB THIS ONE OUT
	TAD	Z40	/RESTORE CHARACTER
	.SORT	CTLBEL,SCPTAB
SCP.BEL,CLA
	JMS	BSP	/^X NEEDS TWO RUB OUTS
SCP.RO,	CLA
	ISZ	BUGFLG	/MAYBE WE REALLY SHOULD REPRINT LINE
TTY10,	SKP		/NOT NECESSARY
	JMP	SCP.CR	/NECESSARY (PREVIOUS VERTICAL MOTION MAY
			/HAVE SCROLLED OFF TOP OF SCREEN)
	JMS	BSP	/RUB IT OUT
SCOPGO,	DCA	BUGFLG
	JMP I	(T2M1

SCP.LF,	TAD	CTLBEL	/CURSOR UP 1
SCP.FF,	TAD	(-4	/CURSOR UP 8
SCP.VT,	TAD	(-4	/CURSOR UP 4
	DCA	BSP
	JMS I	(ESCAPE
VT05B,	101		/CURSOR UP
	ISZ	BSP
	JMP	.-3
TTY40,	STA
	JMP	SCOPGO
	.SBTTL	Imm ^G<space>
	.SBTTL	Imm ^G*

TSPACE,	TAD	ZM12
TSTAR,	DCA	BCHAR
	TAD	CHAR	/LOOK AT PREVIOUS CHARACTER
	TAD	(-7
	SZA CLA		/WAS IT ^G ?
	RESORT		/NO
	STA		/YES
	TAD I	ZQPNTR	/REDUCE CMD LINE BY 1 CHAR
	ADJQ		/I.E. GET RID OF ^G
	JMP	BLSP1

SCP.CR,	TAD	ZM12
	DCA	BCHAR
BLSP1,	CRLF		/TAD	CACR
BLSP2,	NOP		/TYPE
	TAD	MQ
	DCA	SAVMQ
	DCA	MQ
	TAD	QZ	/START FROM END OF COMMAND LINE
L$:	DCA	QP	/AND SEARCH FOR LF
	STA
	TAD	MQ	/COUNT HOW MANY
	DCA	MQ
	TAD	QBASE
	CMA
	TAD	QP
	SPA
	JMP	2$
	TAD	QBASE
	GETQ
	TAD	BCHAR	/LOOK FOR LF
	SNA CLA		/IS IT LF?
	JMP	3$	/YES
	STA		/NO
	TAD	QP	/BUMP BACK ONE MORE CHAR
	JMP	L$

2$:	CLA
	TAD	Z52	/PRINT ANOTHER *
	TYPE
3$:	PUSHJ
		COLG4	/REPRINT LINE TO END OF CMD LINE
	TAD	SAVMQ	/RESTORE MQ
	DCA	MQ
BLSP3,	NOP		/JMS I	SCAPE
BLSP4,	NOP		/113
	KCC
	JMP I	(T2M1

SAVMQ,	0
BCHAR,	-12		/CHAR WE'RE SEARCHING BACKWARDS FOR
SCAPE,	ESCAPE
	.SBTTL	.	Sort and branch

SORTB,	0		/SORT AND BRANCH ROUTINE
	DCA	SCHAR	/SAVE SORT CHAR
	STA
	TAD I	SORTB	/GET POINTER TO LIST
	ISZ	SORTB
	DCA	XR
SORTA1,	TAD I	XR	/GET ITEM IN TEST LIST
	SPA		/END MARKED BY NEG VALUE
	JMP	SORTA2	/FELL OUT BOTTOM
	CIA STL
	TAD	SCHAR
	SZA CLA		/COMPARE SORT CHAR
	JMP	SORTA1	/NOT IT.
	TAD	XR	/GOT IT. NOW MAKE INDEX
	TAD I	SORTB	/TO JUMP TABLE
	DCA	COUNT$	/THIS IS TABLE POINTER
	TAD I	COUNT$	/GET JUMP ADDRESS FROM TABLE
	SPA		/IF IT IS NEGATIVE,
	JMP	3$	/IT'S NOT A JUMP ADDRESS - IT'S A VALUE
	DCA	COUNT$
	CLA CLL
	JMP I	COUNT$
SORTA2:	CLA CLL		/FELL OUT BOTTOM
	TAD	SCHAR	/CARRY CHARACTER BACK TO
3$:	ISZ	SORTB
	JMP I	SORTB	/DO SOMETHING ELSE

COUNT$:	0
SCPTAB,	SCP.BEL		/BELL
	SCP.CR		/CR
	SCP.CR		/TAB
	SCP.RO		/ALT
	SCP.FF		/FF
	SCP.VT		/VT
	SCP.LF		/LF
	PAGE
	.SBTTL	Cmd P

CHR.P,	JMS	POKE	/LOOK AHEAD ONE CHARACTER
	UPPERC		/BUT IN UPPERCASE
	TAD	(-"W	/SEE IF IT'S "W"
	DCA	TEMPT	/SAVE KNOWLEDGE AS FLAG
	TAD	TEMPT
	SNA CLA
	SCAN		/PASS UP W
	CLA		/CLEAR W FROM AC
	TAD	CFLG
	SPA CLA		/IS THIS COMMAND  M,NP?
	JMP	CHRW	/YES - TREAT LIKE M,NPW
	GETN		/COMMAND P - GET # OF PAGES
	SZL SNA
	.ERROR	25	/NEG OR 0 ARG TO P
	CIA
	DCA	CPCT
CPOA,	PUSHJ
		CPOC	/DO N<HPY>
	TAD	TEMPT	/IS NEXT CHARACTER W?
	SNA CLA
	JMP	NOYANK	/YES
/	TAD	REND	/IF WANT P TO CREATE FF'S
/	SZA CLA		/WHEN NO MORE INPUT FILE
	ISZ	FFFLAG	/NO, SAW FF?
	JMP	2$	/NO
	TAD	CAFF	/YES
	OUTPUT		/OUTPUT FF
2$:	PUSHJ
		CHREY	/WHOEVER THOUGHT OF THE PW COMMAND SHOULD BE SHOT
YANKY,	ISZ	CPCT
	JMP	CPOA
	POPJ
CPCT,	0

POKE,	0		/RETURN NEXT CHARACTER (BY LOOKING AHEAD)
	TAD	QLENGT
	CIA CLL
	TAD	SCANP
	SZL CLA		/MAKE SURE WE HAVEN'T RUN OFF END OF COMMAND LINE
	JMP I	POKE	/RETURN 0 IF NO CHAR
	TAD	SCANP
	TAD	QBASE
	GETQ
	JMP I	POKE	/LEAVE CHAR IN AC

NOYANK,	TAD	CAFF	/NPW OUTPUTS FFS
	OUTPUT
	JMP	YANKY
	.SBTTL	Cmd T

CHR.T,	TAD	KTYPE
	JMP	CHRT2

CPOC,	PUSHJ
		CHR.H
CHRW,	TAD	(OUTPUT
CHRT2,	DCA	CWOUT	/P AND T COMMANDS - SAME THING, DIFFERENT DEVICES
	JMS	NLINES	/CONVERT LINES TO CHARS
CWOA,	CMA
	DCA	NLINES	/SET CHARACTER COUNT
	TAD	NLINES
	CIA
	MQLDVI		/COMPUTE HOW MANY WORDS THIS OUTPUT WILL USE
	6		/(BY TAKING 2/3 OF THE NUMBER OF CHARACTERS,
	CLL CML RTL	/ BUT THAT'S SLOW SO WE TAKE 4/6 AND ROUND)
	JMS I	(FITS	/DETERMINE WHETHER THE OUTPUT WILL FIT
	.ERROR	17	/NO - TELL THE USER
	CLA		/CLEAR CRAP FROM AC
	JMP	CWOC
CWOB,	CDF 10
	TAD I	M
	AND	Z177
	CDF 0
CWOUT,	0		/TYPE, OUTPUT, OR QPUT
	ISZ	M
CWOC,	ISZ	NLINES	/DONE?
	JMP	CWOB	/NO
	POPJ
	.SBTTL	Cmd X

CHR.X,	QREF		/COMMAND X
	JMS	NLINES	/CONVERT LINES TO CHARS
	ADJQ		/ADJUST Q-REGISTERS AND SET UP NEW LENGTH.
	TAD	(QPUT
	DCA	CWOUT	/SET OUTPUT ROUTINE TO STORE INTO Q REG
	TAD	MQ	/LOAD THE CHARACTER COUNT
	JMP	CWOA	/GO TO TEXT OUTPUTTER

NLINES,	0		/CONVERT + OR - N LINES AROUND . TO CHARS M,N
	ISZ	CFLG	/WAS THERE A COMMA?
	SKP		/NO
	JMP	1$	/YES - DON'T CONVERT LINES TO CHARS
	TAD	P
	DCA	M
	DCA	CFLG	/V3C
	PUSHJ		/CHR.L DOES A "GETN"
		CHR.L	/TO GET THE DEFAULT VALUES OF N
	TAD	P
	DCA	N
	TAD	M
	DCA	P
1$:	DCA	NFLG	/CLEAR NFLG IN CASE COMMA FLAG WAS ON
	CLL		/M AND N ARE KNOWN TO BE 12-BITS LONG
			/AND POSITIVE
	TAD	N
	BZCHK		/IS N OK?
	.ERROR	38	/?POP REFERENCE OFF PAGE
	CMA CLL		/YES - COMPUTE N-M
	TAD	M	/BY COMPUTING M-N-1
	CMA		/AND COMPLEMENTING IT
	SNL		/IS M>N?
	JMP I	NLINES	/NO - RETURN N-M
	TAD	M	/N-M+M=N NOW IN AC.
	DCA	CPCT	/INTERCHANGE M AND N
	TAD	M
	DCA	N
	TAD	CPCT
	DCA	M
	JMP	1$
	.SBTTL	Cmd ;

CFSI,	TAD	ITRST
	SNA CLA
	.ERROR	24	/FAILING SEARCH NOT IN ITERATION
	.OVRLAY	Q,CSEM
	.SBTTL	Cmd ^A

CTL.A,	TAD	KTYPE
CEXP,	DCA	TO$
	TAD	CHAR
	DCA	QUOTE	/TERMINATING CHAR SAME AS COMMAND CHAR
	QCHK		/ALLOW @ ON ^A OR !
	DCA	NFLG	/KILL NUMBER IF PRESENT
L$:	QUOTST
	JMP I	ZIREST
TO$:	0		/TYPE OR IGNORE THE CHARACTER
	JMP	L$	/* TECHNICALLY WE CAN CALL QUOTST WITH NON-ZERO AC
	PAGE
	.SBTTL	Cmd A

CHR.A,	NCHK		/COMMAND A
	JMP	CHAA
	GETNUM
	TAD	P
	DCA	R
	TAD	R
	SNL		/MAKE SURE CATCH -1
	IAC
	BZCHK
	JMP	APOP
	CLA
	CDF 10
	TAD I	R
	CDF	0
	AND	Z377
NCOM14,	CLL
	JMP I	(NCOM

APOP,	STL STA
	JMP I	(NCOM	/RETURN -1 IF POINTER REFERENCE OFF PAGE
	.SBTTL	Cmd Y

CHR.Y,	NCHK
	SKP CLA
	.ERROR	18	/NUMERIC ARGUMENT TO Y
	TAD	OUTR
	CIA
	TAD	ERROR
	SZA CLA
	TAD	ZZ
YSKP,	SZA CLA		/*ED CHANGED TO SKP CLA TO NEVER ABORT Y COMMAND
	.ERROR	32	/Y COMMAND ABORTED
CHREY,	DCA	ZZ
	DCA	P	/WIPE OUT THE BUFFER
CHAA,	TAD	(ZMAX-1
	AND	REND
	CIA CLL
	TAD	ZZ	/IF WE HAVE ALREADY SEEN THE INPUT EOF,
	SZL CLA		/OR IF WE'RE ALREADY FULL (OR NEARLY SO)
	JMP	APLF	/GET OUT
DECGET,	ISZ	ICRCNT
	JMP	I2	/NO NEED TO READ
	CLL
	TAD	INRSIZ
	TAD	INRCNT
STECO1,	SNL		/"SKP!CLA" FOR SUPERTECO
	DCA	INRCNT	/UPDATE RECORD COUNT
LFTAB,	CLL CML CMA RTR	/IF WE OVERFLOWED THE END OF THE FILE,	!
	RTR		/5 ENTRY TABLE: MUST BE - - - + +	!
	RTR		/SHORTEN THE READ BY THE CORRECT AMOUNT	!
	TAD	INCTLW	/					!
	DCA	INCTRL	/SO THAT WE WILL NOT READ TOO FAR	!
	JMS I	INHND
I3,
INCTRL,	0400
BUFIN,	IN		/6200 IF 8K, 5600 IF 12K
IBLK,	0
	SMA CLA
	SKP
	JMP	INER	/IGNORE END-OF-FILE ERRORS, WE'LL SEE THE ^Z.
	TAD	IBLK
	TAD	INRSIZ	/BUMP RECORD NUMBER BY THE MAXIMUM NUMBER
	DCA	IBLK	/(IF WE READ SHORT ITS THE LAST ONE ANYWAY)
	CLA CMA
	TAD	BUFIN
	DCA	INXR	/SET UP INPUT XR
	TAD	INPCNT
	DCA	ICRCNT
	MTHREE
	DCA	I3
I2,	NOP		/CDF 20 IF 12K
	ISZ	I3
	JMP	1$	/NORMAL CHARACTER
	MTHREE		/WEIRD CHARACTER-RESET SWITCH
	DCA	I3
	MTWO
	TAD	INXR
	DCA	INXR	/MOVE INPUT XR BACK TO BEGINNING OF DBLWORD
	TAD I	INXR
	AND	Z7400
	DCA	FFFLAG	/TEMP
	TAD I	INXR
	AND	Z7400
	CLL RTR
	RTR
	TAD	FFFLAG
	CLL RTR
	RTR
	SKP
1$:	TAD I	INXR
IC,	NOP		/CDF 0  IF 12K
	AND	Z177	/MASK OFF GARBAGE
	/INPUT CHARACTER IN AC
	SZA
	TAD	(-177
	SNA		/IGNORE BLANK TAPE AND RUBOUTS
	JMP	DECGET
	TAD	(177-32
STECO2,	SNA		/"SKP" FOR SUPERTECO
	JMP	5$	/IT'S A ^Z
	TAD	(16
	SNA
	JMP	6$	/ITS A FORM FEED
	TAD	CAFF	/RESTORE CHAR
	CDF 10
	DCA	MQ	/SAVE CHAR
	TAD I	ZZ	/PROTECT HIGH-
	AND	Z7400	/ORDER BITS
	TAD	MQ	/OF TARGET
	DCA I	ZZ	/STORE CHAR IN BUFFER
	TAD	MQ
	CDF 0
	ISZ	ZZ
	TAD	ZM12
	SNA CLA		/IF THE CHAR IS A LINE FEED,
	TAD	(-310	/CHECK THAT THE BUFFER IS NOT NEARLY FULL
	JMP	CHAA
5$:	DCA	REND	/SIGNAL END OF FILE
	SKP
6$:	STA
APLF,	DCA	FFFLAG	/SET FORM FEED FLAG
	POPJ
INER,	DCA	REND	/INHIBIT FUTURE INPUTS
	.ERROR	15

INCTLW,	401		/1021 IF 12K MACHINE
INPCNT,	6400		/5000 IF 12K MACHINE
	PAGE
	.SBTTL	.	Teletype routines

TYPCTV,	0		/TELETYPE STUFFER
	.SORT	CTLBEL,CTLTAB
	DCA	SCHAR	/STORE (POSSIBLY TRANSLATED) CHAR
OUTCC,	TAD	SCHAR
	ISZ	COLCT	/BUMP COLUMN COUNTER
	AND	Z7740
	SZA CLA		/IS THE CHAR A CONTROL CHARACTER?
	JMP	NOCON	/NO
	TAD	(136
	PUTT		/OUTPUT "^"
OUTLF2,	ISZ	COLCT
	TAD	Z100
OUT.LF,	TAD	SCHAR
OUTLF1,	PUTT
	JMP I	TYPCTV
COLCT,	0

OUT.CR,	DCA	COLCT	/RESET CHAR COUNT
	JMP	OUT.LF
OUT.VT,	TAD	Z4
OUT.FF,	TAD	Z7770	/FORM FEED IS 8 LINE FEEDS, VERT TAB IS 4
	DCA	COLCT	/*** BUG
ASR33,	TAD	CALF	/SIMULATE FORMFEEDS AND VERT TABS WITH LINEFEEDS
	JMP	OUTCOM	/*K* 8 LOCS AT ASR33 OVERLAYED BY ASR35 CODE

OUT.HT,	TAD	COLCT	/COLUMN COUNTER, MOD 8
	AND	L7
	TAD	Z7770	/SIMULATE TABS WITH SPACES
	DCA	COLCT
L7,	7		/TAKE UP SPACE SO ASR-35 ROUTINE WILL JUST FIT
	TAD	Z40	/USE SPACES FOR TABS
OUTCOM,	PUTT		/PUT ONE OUT THE
	ISZ	COLCT	/WINDOW
	JMP I	(TPUTX	/STILL MORE INSIDE
	JMP I	TYPCTV

NOCON,	TAD	SCHAR
	AND	Z100
EU1,	SNA CLA		/*EU SET TO CLA IF EUFLAG < 0 (NO CASE FLAGGING)
	JMP	OUT.LF	/NOT ALPHANUMERIC
EU2,	NOP		/*EU SET TO TAD Z40 IF EUFLAG>0 (FLAG UPPER CASE)
	TAD	SCHAR
	AND	Z40
	SNA CLA
	JMP	OUT.LF
	TAD	SQUO
	PUTT
	ISZ	COLCT
	TAD	SCHAR
	AND	Z137
	JMP	OUTLF1	/OUTPUT UPPER CASE VERSION

OUT.BEL,TAD	SCHAR
	PUTT
	JMP	OUTCC
	.SBTTL	.	Q-register manipulation

	/ROUTINE TO MANIPULATE Q-REGISTER STORAGE

/*** ALLOW : TO MEAN APPEND TO Q-REGISTER
/APPLIES TO X AND ^U COMMANDS
/MAKE SURE CMD LINE AND ^S ZERO CLNF

QADJ,	0
	SPA
	JMP	ERR12	/STRING TOO LONG FOR Q-REGISTER
	DCA	MQ	/SAVE NEW LENGTH OF Q-REGISTER
	QSUM		/COMPUTE POINTER TO CURRENT Q-REGISTER
	AC3777
	AND I	QPTR
	TAD	QP
SQUO,	DCA	R
	AC3777
	AND I	QPTR	/GET ITS CURRENT LENGTH
	CIA CLL
	TAD	MQ	/COMPUTE DIFFERENCE
	SNL		/ADJUST Q-REGS
	JMP	QDNN	/TO HOLD NEW STRING
	SNA		/CHECK FOR ZERO
	JMP	QADJDN	/NOTHING TO DO
	TAD	QZ	/MOVE Q-REGISTERS UP TO INSERT CHARS
	DCA	QP	/(LINK IS 1 FROM PREVIOUS SNL)
	TAD	QP
	TAD	MQMAX	/SEE IF OUT OF BOUNDS
	SNL CLA		/TWO PLACES TO TOGGLE LINK THERE
	.ERROR	12	/GETTING TOO FULL
	TAD	QZ
	DCA	Q
	TAD	QP
	DCA	QZ
	ISZ	QP
L$:	TAD	Q
	CIA
	TAD	R	/DOUBLES AS ASCII FOR '
	SNA CLA
	JMP	QADJDN
	CMA
	TAD	Q
	DCA	Q
	MTWO
	TAD	QP
	DCA	QP
	TAD	Q
	GETQ
	QPUT
	JMP	L$
QDNN,	TAD	R	/MOVE Q-REGS DOWN TO ABSORB CHARACTERS
	DCA	QP
1$:	TAD	QZ
	CIA
	TAD	R	/-NUMBER OF CHARS TO MOVE
	SNA CLA		/DONE?
	JMP	2$	/YES
	TAD	R
	GETQ
	QPUT
	ISZ	R
	JMP	1$	/LOOP AGAIN
2$:	TAD	QP	/SET NEW VALUE
	DCA	QZ	/OF HIGHEST CHAR
QADJDN,	STL CLA RAR	/4000
	AND I	QPTR	/SAVE HIGH ORDER PART
	TAD	MQ
	DCA I	QPTR	/SAVE NEW LENGTH OF Q-REGISTER IN Q-REG TABLE
	TAD	QCMND	/SET UP COMMAND LINE AGAIN
	SETCMD		/AS IT MAY HAVE BEEN SHUFFLED.
	QSUM		/RECOMPUTE POINTER TO BEGINNING OF NEW Q-REG
	JMP I	QADJ

MQMAX,	-QMAX

QOVER,	0		/SUBROUTINE TO SKIP TO END OF STRING
	QCHK		/GET THE QUOTE CHARACTER (IF ANY)
	TAD	SCANP
	DCA	OSCANP	/SAVE BACKUP SCAN POINTER
L$:	QUOTST
	JMP I	QOVER	/FOUND AN ALTM OR EQUIVALENT - RETURN
	JMP	L$	/NOT END - SKIP ANOTHER CHAR

/COULD MOVE ABOVE TO Q-OVERLAY
	PAGE
	.SBTTL	.	Q-register subroutines


QSUMR,	0		/COMPUTE POINTER TO Q-REG
	SNA
	TAD	QNMBR	/NORMALLY USES QNMBR, BUT CAN BE OVERRIDDEN BY AC
	CIA
	DCA	KNT$
	DCA	QP
	TAD	(QARRAY	/BASE ADDR OF Q-REG POINTERS
	DCA	QPTR
	JMP	2$
L$:	AC3777
	AND I	QPTR	/ADD # OF CHARS IN LOWER REG
	TAD	QP
	DCA	QP
	ISZ	QPTR	/SKIP VALUE WORD
	ISZ	QPTR	/POINT TO NEXT Q-REG
2$:	ISZ	KNT$	/REACHED OUR Q-REGISTER YET?
	JMP	L$	/NO - ADD IN ANOTHER
	JMP I	QSUMR
KNT$:	0
SGET,	0		/SCAN COMMAND LINE OR MACRO
1$:	CLA		/** CALLED WITH AC NON-ZERO **
	TAD	QLENGT
	CIA CLL
	TAD	SCANP
	SZL CLA		/CHECK THAT WE ARE STILL INSIDE THE COMMAND LINE
	JMP	2$	/NO - COMMAND DONE
	TAD	SCANP	/GET CHARACTER POSITION IN LINE
	TAD	QBASE	/ADD IT TO THE ADDRESS OF THE LINE
	GETQ		/AND GET THAT CHARACTER.
	DCA	LASTC
	TAD	TFLG
	AND	LASTC	/IF THE TRACE FLAG IS ON,
	SZA
	TYPE		/PRINT THE CHAR
	TAD	LASTC
	ISZ	SCANP	/INCREMENT CHARACTER POINTER AFTER FETCH
	JMP I	SGET	/RETURN
2$:	TAD	MPDL	/"MPDL" IS THE PUSHDOWN POINTER ON ENTRY TO THIS
	SNA		/MACRO. IF IT IS 0, WE ARE NOT IN A MACRO
	JMP I	(T1	/SO RETURN TO THE USER
	TAD	PDLP	/CHECK THAT THE ENDING POINTER IS THE SAME
	IAC
	SZA CLA		/AS THE ENTRY ONE - OTHERWISE WE HAVE
	.ERROR	13	/SCREWED UP SOMEHOW (EG WE ARE
	POP		/ IN THE MIDDLE OF A COMMAND)
	DCA	SCANP
	POP
	DCA	ITRST
	POP		/RESTORE THE PREVIOUS VALUES OF
	DCA	MPDL	/MPDL, THE SCAN POINTER AND THE COMMAND LINE
	POP		/POINTER FROM THE PUSHDOWN LIST
	SETCMD
	JMP	1$	/AND FETCH A CHARACTER FROM THE UPPER LEVEL.
CMDSET,	0		/SUBROUTINE TO SET UP COMMAND LINE POINTERS
	DCA	QCMND	/STORE IN COMMAND LINE NUMBER
	TAD	QCMND
	QSUM
	TAD	QP	/GET FIRST LOCATION IN COMMAND LINE
	DCA	QBASE	/AND STORE IN "QBASE"
	AC3777
	AND I	QPTR
	DCA	QLENGT	/STORE THE LINE LENGTH IN "QLENGT"
	JMP I	CMDSET	/RETURN

QREFER,	0		/SET UP POINTERS FOR Q-REG REFERENCE
	SZA
	JMP	2$	/AHA - WE ALREADY HAVE THE Q-REGISTER
	SCANUP		/GET Q-REGISTER IDENTIFIER
	DCA	QNMBR
	TAD	QNMBR
	TSTSEP		/TEST FOR ALPHANUMERIC (LOWER CASE LEGAL)
	.ERROR	03	/OOPS - BAD Q-REGISTER REFERENCE
	TAD	QNMBR
	TAD	Z7700
	SPA		/NUMERIC?
	TAD	Z7	/YES - FORCE NUMBERS UP TO ABUT LETTERS
	TAD	Z12	/FORCE IDENTIFIER INTO THE RANGE 1-44 (OCTAL)
2$:	DCA	QNMBR	/STORE AWAY NUMBER FOR FURTHER REFERENCE
	QSUM		/COMPUTE QP AND QPTR
	JMP I	QREFER	/RETURN

CHR.U,	JMP I	(CHRUU
	.SBTTL	Cmd ^T

CTL.T,	NCHK
	JMP	CTLT2	/NO ARG
	TAD	N
ET1,	TYPE		/TYPE CHAR REPRESENTED BY ARGUMENT
	POPJ
CTLT2,	LISTEN		/^T COMMAND - VALUE OF NEXT CHAR FROM TTY
ET8,	TYPE		/*ET	ECHO THE CHARACTER
	TAD	SCHAR	/GET THE CHARACTER
NNEW13,	CLL
	SPA
	STL		/EXTEND SIGN BIT TO LINK
	JMP I	(NCOM	/RETURN -1 IF F.F., 0 OTHERWISE
	.SBTTL	.	Overlay handler

OVERLY,	0
	TAD I	OVERLY	/GET LOCATION TO CHECK
	ISZ	OVERLY
	DCA	TMP
	TAD I 	OVERLY
	DCA	OVERLY	/SET RETURN ADDRESS
	TAD I	TMP	/IS OUR OVERLAY IN CORE?
	SNA
	JMP I	OVERLY	/YES, BRANCH INTO IT
	DCA	TMP	/NO, SET BLOCK TO READ IN
/**	THE NEXT 5 WORDS ARE MODIFIED IF WE HAVE MORE THAN 12K
OVREAD,	JMS I	(7607	/CALL SYSTEM HANDLER
	0200		/READ 2 PAGES
	3200		/INTO 3200
TMP,	0		/FROM THIS BLOCK
	HLT		/ERROR READING OVERLAY
	JMP I	OVERLY	/GO TO NEXT SPOT

ALTTAB,	4033
	4033		/ALTMODE WITH SIGN BIT ON

CATS,	STA		/@ COMMAND - FAKE OUT "IREST"
IREST,	DCA	QFLG	/RESET QUOTED STRING FLAG
	TAD	CAAM
	DCA	QUOTE	/RESET QUOTE CHAR TO ALTMODE
POPK,	POPJ		/RETURN

QTST,	0		/SUBROUTINE TO GET A CHAR AND TEST FOR ALTMODE
	SCAN
	.SORT	QUOTE,QTST	/RETURN IF QUOTE FOUND
	ISZ	QTST
	JMP I	QTST	/SKIP-RETURN WITH AC INTACT IF NOT FOUND

SCHCTE,	.ERROR 39	/ILLEGAL CTRL/E
	PAGE
ERRXX,	ERR30+1		/ENTRY POINT ALSO SERVES AS A FLAG FOR "TQMK"
	KCC		/CLEARS AC
	CDF 0		/JUST IN CASE
	.OVRLAY	E,ERRYY

ERRRET,	JMP I	EH4	/CONTINUE AS NORMAL UNLESS USER TYPES "?"
EH4,	T0		/*EH

	.SBTTL	Cmd E

CHR.E,	SCANUP		/GET CHARACTER AFTER E
	TESTA		/CHECK FOR ALPHABETIC
	.ERROR	19	/BAD CHARACTER AFTER E
	TAD	(ELIST-"A
	DCA	TYI
	TAD I	TYI	/GET ENTRY FROM DISPATCH TABLE
OVBRAN,	DCA	2$	/BRANCH TO OVERLAY
	TAD	2$
	AND	Z377
	TAD	(3200	/BASE OF OVERLAY AREA
	DCA	1$	/ADDRESS
	TAD	2$
	RAL
	RTL
	RTL
	AND	Z7
	TAD	(3200
	DCA	2$	/KEY
	OVRLAY
2$:	0
1$:	0

/FORMAT OF CALL TO OVBRAN:

/	TAD	(OVERLAY CODE
/	JMP	OVBRAN

/OVERLAY CODE HAS THE FOLLOWING FORMAT:

/BIT	MEANING
/0	WILL BE IGNORED (USUALLY NEGATIVE)
/1-3	OVERLAY NUMBER
/4-11	RELATIVE ADDRESS WITHIN OVERLAY
	.SBTTL	Cmd I

CHR.I,	NCHK		/I COMMAND
	JMP	CIL1
	TAD	N	/INSERT CHAR WHOSE VALUE IS N
	JMS	UPOC
/*** CHECK FOR $
	POPJ

	.SBTTL	Cmd <TAB>

	.SBTTL	Cmd ^I

CTL.I,	DCA	QFLG	/CANNOT BE QUOTED
	TAD	CAHT	/TAB
	JMS	UPOC
CIL1,	QSKP		/COUNT LENGTH OF INSERTION
	DCA	DVT1	/ZERO FUDGE USED BY FS COMMAND
CIL2,	TAD	OSCANP
	TAD	QBASE
	DCA	QP	/SET UP POINTER TO INSERTION STRING
	TAD	SCANP
	CIA CLL
	TAD	OSCANP
	DCA	MQ	/STORE CHAR COUNT TO INSERT (-1)
	TAD	MQ
	TAD	DVT1	/ADD FS FUDGE
	CMA
	SNL		/DID WE INSERT MORE THAN WE DELETED?
	JMP	EXPAND	/YES - IGNORE SIGN BIT OF COUNT
	CIA
	PUSHJ
		ADJ2	/COMPRESS OUT EXCESS DELETED STUFF
	JMP	CIL4
CIL3,	TAD	QP
	GETQ		/GET A CHAR
	DCA	TYI
	JMS	STOREC	/STORE A CHARACTER
	ISZ	QP
CIL4,	ISZ	MQ
	JMP	CIL3	/OF INSERTION
	JMP I	(ZRON

STOREC,	0		/STORE CHAR IN "TYI" INTO TEXT BUFFER AT P
	CDF 10
	TAD I	P
	AND	Z7400
	TAD	TYI
	DCA I	P
	CDF 0
	ISZ	P
	JMP I	STOREC
	.SBTTL	Cmd G

CHR.G,	QREF		/G COMMAND - GET Q-REGISTER NUMBER
	DCA	NFLG
	AC3777
	AND I	QPTR	/GET COUNT OF CHARS IN REGISTER
	CMA
	DCA	MQ	/SAVE AS TRANSFER COUNT
	ISZ	CLNF
	SKP
	JMP	COLG4
	DCA	CLNF
	AC3777
	AND I	QPTR
EXPAND,	PUSHJ		/COME HERE FROM INSERT LOGIC
		ADJ	/INCREASE TEXT BUFFER SIZE ( Q-REG LENGTH MAY
	JMP	CIL4	/BE NEGATIVE) AND GO TRANSFER THE CHARS

TYI,	0		/TELETYPE INPUT
TYI1,	KSF		/*VT52 WAIT FOR THE KEYBOARD FLAG
KSFWT,	JMP	.-1	/*VT52 WHILE WAITING, DISPLAY TEXT ON SCOPE
	CTCCHK		/*VT52 CHECK FOR ^C
	KRB		/*VT52 WATCH OUT - AC MAY NOT BE 0!
TYIRET,	SPA
	JMP I	TYI	/ALLOW READ WITH NO WAIT TO RETURN -1
	AND	Z177
/	SNA
/	JMP	TYI1	/IGNORE NULL CHARS AND LEADER
	.SORT	ALTLST,ALTTAB	/LOOK FOR NON-STANDARD ALTMODES
	AND	Z177	/MUST GET RID OF HIGH-ORDER BIT
	JMP I	TYI

UPOC,	0		/MOVE TEXT BUFFER UP ONE CHAR
	AND	Z177
	DCA	TYI
	CLA IAC
	PUSHJ
		ADJ
	JMS	STOREC	/STORE CHAR IN THE HOLE WE MADE
	JMP I	UPOC

CUPPER,	0		/FORCE CHARACTER TO UPPER CASE
	TAD	ZM100
	SMA		/IF ITS >100
	AND	Z137	/REDUCE IT TO BE <140
	TAD	Z100	/ABOVE LITERAL COULD HAVE BEEN (37
	JMP I	CUPPER	/RETURN
COLG3,	TAD	QP
	GETQ		/GET A CHAR
	TYPE
	ISZ	QP
COLG4,	ISZ	MQ
	JMP	COLG3
	POPJ

	.SBTTL	Imm ^S
	.SBTTL	Imm *

TSAVE,	.OVRLAY X,TSAV
	PAGE
TBS,	PUSHJ
		CMIN
TLF,	PUSHJ
		CHR.L
	CRLF
	PUSHJ
		CHR.T
	JMP I	(T0A
	.SBTTL	Cmd Q

CHR.Q,	QREF		/COMMAND Q
	CLL
	JMP	CQOA

CPCS,	QREF		/COMMAND %
	GETN
CQOA,	ISZ	QPTR	/POINT TO VALUE WORD
	TAD I	QPTR	/INCREMENT VALUE BY ARGUMENT
	DCA I	QPTR
/ADD LINKS
	STA
	TAD	QPTR	/GO BACK ONE
	DCA	QPTR2	/ALSO COMPL LINK
	CML RAR
	TAD I	QPTR2
	DCA I	QPTR2
	TAD I	QPTR2
	RAL
	CLA
	TAD I	QPTR
	JMP I	(NCOM	/MAKE A NUMBER

QPTR2,
TYCRLF,	0		/TYPE A CR AND LF
	TAD	CACR	/CR
	TYPE
	TAD	CALF	/LF
	TYPE
	JMP I	TYCRLF	/RETURN
	.SBTTL	Cmd ,

CCMA,	NCHK		/COMMAND ,
	JMP	NERR	/NUMBER FLAG NOT SET (COULD GIVE ?NAC HERE)
	TAD	NLINK
	SZA CLA
	.ERROR	26	/NEG ARGUMENT TO ,
	ISZ	CFLG
	SKP
	JMP	NERR	/3 NUMERIC ARGUMENTS
	TAD	N	/MOVE N TO M
CCMA3,	DCA	M	/ENTERED HERE BY "H" COMMAND
	DCA	N	/AND CLEAR N
	STA
	DCA	CFLG	/SET COMMA FLAG
	POPJ
	.SBTTL	.	Number routines

/RETURNS 13-BIT RESULT IN AC,LINK

NGET,	0		/SUBROUTINE TO GET LAST NUMBER, WITH
NGET1,	NCHK		/DEFAULT VALUES OF +1 (NO NUMBER),
	JMP	NGET2	/OR -1 (JUST A MINUS SIGN)
	GETNUM
	JMP I	NGET	/DIGITS SEEN - RETURN THEM
NGET2,	CLA CLL IAC	/NO DIGITS SEEN
	PUSHJ		/MAKE BELIEVE WE SAW THE DIGIT "1"
		NCOM	/AND CREATE A NUMBER FROM IT (TAKING ANY
	JMP	NGET1	/OPERATORS INTO ACCOUNT) AND USE IT

BACKUP,	0
	TAD I	ZQPNTR	/SEE IF ANYTHING TO ERASE
	SNA CLA
	JMP I	(T0	/NO, START ALL OVER
	STA
	TAD I	ZQPNTR	/THEN THE CHARACTER COUNT
	ADJQ		/REDUCE THE LENGTH OF THE COMMAND REGISTER BY 1
	TAD	QZ
	GETQ		/GET THE CHARACTER WE RUBBED OUT
	JMP I	BACKUP

CHLCMP,	0		/COMPARISON SUBROUTINE
	TAD I	P	/DATA FIELD IS 10
	AND	Z377
	CDF	0
	.SORT	CAFF,LFTAB
	SPA CLA		/LINE TERMINATORS ARE CHANGED TO NEGATIVE NOS.
	ISZ	CDT	/IS COUNT EXHAUSTED?
	JMP	CHLRET	/NO
CHRLI,	ISZ	P
	NOP
	CDF	0
	POPJ
	.SBTTL	Cmd H

CHR.H,	PUSHJ		/COMMAND H
		CCMA3	/SET M=0 AND COMMA FLAG ON AND FALL INTO "Z"
			/** COULD CAUSE ERROR ON B AND H IF NFLG SET
	.SBTTL	Cmd Z

CHR.Z,	TAD	ZZ	/COMMAND Z

	.SBTTL	Cmd ^H

CTL.H,			/^H COMMAND - TIME OF DAY - NOT IMPLEMENTED

	.SBTTL	Cmd B

CHR.B,	JMP I	(NCOM14	/COMMAND B

CHLRET,	CDF	10
	JMP I	CHLCMP
ZROSPN,	DCA	SCANP	/RESET TO BEGINNING OF ITERATION
ZRON,	DCA	NFLG	/KILL NUMBER FLAG
	DCA	CFLG	/KILL COMMA FLAG
	JMP I	ZIREST
	.SBTTL	Cmd M

CHR.M,	QREF		/COMMAND M
	TAD	(-4	/4 ITEMS PUSHED TO
	PUSHL		/SAVE CURRENT MACRO STATE
		QCMND
		MPDL
		ITRST	/SO THE "O" COMMAND WILL WORK IN MACROS
		SCANP	/ZEROED BY "PUSHL"
	TAD	PDLP	/MUST CHECK PDL AT END OF MACRO
	CIA
	DCA	MPDL
	TAD	QNMBR	/Q-REGISTER TO EXECUTE
	SETCMD		/SET COMMAND LINE TO THIS Q-REG
	POPJ		/LEAVE NUMBER FLAG ALONE AND EXIT
TCTLU,	TAD	SCHAR
	TYPE		/PRINT "^U"
TCTLS,	JMS I	(BACKUP
	TAD	ZM12	/CHECK FOR LF
	SZA CLA
	JMP	TCTLS	/LOOP UNTIL LF
	IAC
	TAD I	ZQPNTR
	ADJQ
	JMP I	(SCP.CR
/COULD REPLACE 4044 BY OUTESC
/OUTESC,TAD (44-33-100
/	JMP OUTLF2	/TO FIX ^T INPUT OF <ESC> BUG

CTLTAB,	OUT.BEL	/BELL
	OUT.CR
POUTHT,	OUT.HT
	4044		/$ WITH SIGN BIT ON
	OUT.FF
	OUT.VT
	OUT.LF
	PAGE
	.SBTTL

	.ASECT TEC0C

	*3600

NORMAL,	TAD	ODEV	/CLOSE FILE
	CIF 10
	JMS I	Z200
	4
	OUNAM
OCNT,	0		/NUMBER OF BLOCKS
	HLT
	TAD	ERROR	/RESET OUTPUT SUBROUTINE POINTER
	DCA	OUTR	/TO ERROR
ECDISM,	CIF 10		/DISMISS OS/8 USR ROUTINE
	JMS I	Z200
	11		/KICK USR OUT
	JMP I	ZIREST
/	SKIP IF LETTER OR DIGIT

SCHSRT,	0
	TESTA		/TEST FOR LETTER
	SKP		/NOT ALPHABETIC
	ISZ	SCHSRT	/YES IT'S ALPHABETIC
	TESTD		/TEST FOR DIGIT
	JMP I	SCHSRT	/NOT A DIGIT
	ISZ	SCHSRT	/YES, IT'S A DIGIT
	JMP I	SCHSRT	/RETURN

RT,	0		/ROUTINE TO PACK THIRD CHAR INTO OUTPUT BUFFER
	CLL RTL
	RTL
	DCA	DM	/CALLED TWICE - FIRST TIME WITH CHAR IN AC,
	TAD	DM	/SECOND TIME WITH "DM" IN AC
	AND	Z7400
	TAD I	OPTR2
	DCA I	OPTR2
	ISZ	OPTR2
	JMP I	RT
DVIMQL,	0		/FAKE MQL DVI
	DCA	DVT1	/STORE DIVIDEND
	DCA	MQ	/INITIALIZE QUOTIENT
1$:	TAD I	DVIMQL	/GET DIVISOR
	CIA
	CLL		/SET UP TO TAKE IMMEDIATE EXIT ON ZERODIVIDE
	TAD	DVT1	/SUBTRACT DIVISOR FROM DIVIDEND
	SNL		/OVERFLOWED YET?
	JMP	2$	/YES
	DCA	DVT1	/NO - STORE IT BACK
	ISZ	MQ	/BUMP QUOTIENT
	JMP	1$	/AND LOOP
2$:	CLA
	TAD	MQ
	ISZ	DVIMQL	/SKIP PAST DIVISOR
	JMP I	DVIMQL	/RETURN WITH QUOTIENT IN AC

CHKQF,	0		/CHECK FOR EXPLICIT QUOTES
	ISZ	QFLG	/QUOTE FLAG SET?
	JMP	.+3	/NO
	SCAN		/GET QUOTING CHAR
	DCA	QUOTE	/PUT INTO SEARCH TABLE
	DCA	QFLG	/ZAP QUOTE FLAG
	JMP I	CHKQF	/RETURN
/******************
/
/	THE FOLLOWING COULD MOVE TO OVERLAY
/
/******************

SAVTRA,	0		/SAVE TRACE MODE
	TAD	TFLG
	DCA	TFGTMP
	DCA	TFLG
	JMP I	SAVTRA	/EXIT WITH TRACE OFF

RESTRA,	0		/RESTORE TRACE MODE
	TAD	TFGTMP
	DCA	TFLG
	JMP I	RESTRA
TFGTMP,	0
DECPUT,	0		/DEVICE INDEPENDENT I/O
	TAD	Z200	/ADD ON PARITY BIT
	ISZ	O3	/3RD CHAR OF 3?
	JMP	O2	/NO
	JMS	RT	/YES, SPECIAL HANDLING
	TAD	DM	/TEMP STORAGE
	JMS	RT
SETO3,	MTHREE		/RESET SWITCH
	DCA	O3
	ISZ	OCRCNT	/END OF BUFFER?
	JMP I	DECPUT	/NO
	JMS	FITS	/CHECK FOR OUTPUT OVERFLOW
	JMP	OERR	/YUP
	DCA	OCNT	/NO - UPDATE OUTPUT COUNT
	JMS I	OUTHND	/OUTPUT THE BUFFER
OUCTRL,	4400
BUFOUT,	OUT
OBLK,	0
	JMP	OERR
	TAD	OBLK
	TAD	INRSIZ	/BUMP THE OUTPUT RECORD NUMBER BY THE MAXIMUM
OSETP,	DCA	OBLK	/SINCE ALL WRITES EXCEPT THE LAST ARE MAXIMAL
	TAD	BUFOUT	/BUFFER POINTERS
	DCA	OPTR1
	TAD	BUFOUT
	DCA	OPTR2
	TAD	OUTSIZ
	DCA	OCRCNT	/DOUBLEWORD COUNT (7377 IF 8K, 6777 IF 12K)
	JMP	SETO3	/SET BYTE COUNTER AND RETURN
OERR,	CLA
	TAD	ERROR
	DCA	OUTR	/INHIBIT FUTURE OUTPUT
	.ERROR	14
O2,	DCA I	OPTR1	/NORMAL HANDLING
	ISZ	OPTR1	/BUMP POINTER
	JMP I	DECPUT
OPTR1,	0
OMAXLN,	0		/SIZE OF HOLE FOR OUTPUT
OUTSIZ,	7377		/6777
O3,	0
FITS,	0		/SUBROUTINE TO CHECK FOR OUTPUT OVERFLOW
	TAD	OPTR1	/** AC MAY CONTAIN FUDGE ON INPUT **
	CIA
	TAD	BUFOUT	/COMPUTE NUMBER OF WORDS IN BUFFER
	AND	Z7400	/ROUND "UP" TO NEXT BUFFERLOAD
	CIA		/MAKE POSITIVE
	CLL CML RAR
	DCA	OUCTRL	/AND SAVE IT AS A BUFFER CONTROL WORD
	TAD	OUCTRL
	CLL RAL
	CLL RTL		/ISOLATE THE BLOCK COUNT OF THE CONTROL WORD
	RTL		/IN THE LOW ORDER PART OF THE AC
	RAL
	TAD	OCNT	/ADD IT TO THE CURRENT OUTPUT COUNT
	CLL CML
	TAD	OMAXLN	/SEE THAT WE DIDN'T OVERFLOW
	SNL SZA		/THE ASSIGNED OUTPUT AREA
	JMP I	FITS	/OOPS - WE DID - ERROR RETURN
	CIA
	TAD	OMAXLN	/SUBTRACT OFF THE LIMIT
	CIA		/TO ARRIVE AT THE UPDATED BLOCK COUNT
	ISZ	FITS
	JMP I	FITS	/AND SKIP RETURN
	PAGE
	.ASECT	TECO2

	*4400

	.SBTTL

STABLE,	ZBLOCK	40	/SEARCH BUFFER

/MUST KEEP THIS CODE IMMEDIATELY AFTER STABLE
	.SBTTL	Cmd W

CHR.W,	NCHK		/*VT52 W COMMAND - IF THERE WAS A NUMBER BEFORE
	JMP	2$	/*VT52 THE W, SET THE NUMBER OF LINES TO DISPLAY
	TAD	N	/*VT52 EQUAL TO THAT NUMBER.
	DCA	NUMLNS	/*VT52
			/DON'T WORRY ABOUT NEGATIVE N
2$:	ISZ	R	/FAKE OUT! (MUST BE BEFORE CALL TO DISPLY)
	DISPLY		/IN ANY CASE, GO THROUGH ONE DISPLAY CYCLE
CTLWR,	POPJ		/THEN RETURN

AIDTAB,	ROCMND		/RUBOUT
	TCTLU		/^U		(COULD BE T2M1)
	TQMK		/?
	TSAVE		/^S
/	T2M1		/^Q
	TSAVE		/*
	TLF		/LF
	TBS		/BS
	TSLASH		/SLASH
NXTBUF,	0
	SZA CLA
	JMP	1$	/READ-ONLY IF AC NOT 0 ON ENTRY
	PUSHJ
		CPOC	/HP
	DCA	ZZ	/FORCE Y TO WORK
	ISZ	FFFLAG	/IF WE DIDN'T SEE A FORM FEED ON INPUT
	JMP	1$	/DON'T OUTPUT ONE
	TAD	CAFF
	OUTPUT
1$:	PUSHJ
		CHR.Y	/READ NEW BUFFER
	CTCCHK		/CHECK FOR ^C
	CLA		/*K* CTCCHK LEAVES AC NON-ZERO!
	JMP I	NXTBUF

GETUSR,	0		/ROUTINE TO LOCK THE USR INTO CORE
	CDF 0
	TAD	ZZ	/IF THE TEXT BUFFER IS EMPTY AND
	SNA CLA		/WE HAVE 12K, SO Q-REGS ARE IN FIELD 2,
NWRUSR,	NOP		/(CHANGED BY INIT CODE TO "TAD Z4" IF 12K)
	STL RTR		/THEN WE SHOULD NOT SAVE CORE ON A USR CALL.
/	DCA I	(JSBITS	/THIS STORES A 2000 OR A 2001
	DCA I	M32	/"
	CIF 10
	JMS I	Z7700	/OK - NOW LOAD THE USR IN
	10
	JMP I	GETUSR
AIDLST,	177		/RUBOUT
	^"U		/^U
	"?		/?
	^"S		/^S
/	^"Q		/^Q
	"*		/* = ^S
	12		/LF
	10		/BS
L16K,	"/		/SLASH	(MUST BE LAST) -1 IF NO EXTENDED ERRS

	.SBTTL	Cmd U

CHRUU,	QREF		/COMMAND U
	NCHK
	.ERROR	22	/U MUST BE PRECEDED BY A NUMBER
	TAD	NLINK
	CLL RTR
	DCA	NLINK
	AC3777
	AND I	QPTR
	TAD	NLINK
	DCA I	QPTR
	ISZ	QPTR
	TAD	N
	DCA I	QPTR
	POPJ
/SKIP IF LETTER (LEAVES U.C. OF CHAR IN AC)

TSTA,	0
	UPPERC		/MAKE LIFE EASIER FOR US
	TAD	M101
	CLL
	TAD	M32
	SNL
	ISZ 	TSTA
	TAD	(101+26.
	JMP I	TSTA

EDFLAG,	1		/MUST BE KEPT TOGETHER
EHFLAG,	2
EOFLAG,	VERSN
ESFLAG,	0
ETFLAG,	200+4		/INITIALLY ABORT ON ERROR AND READ LOWER CASE
EUFLAG,	0
/EVFLAG,	0
/CXFLAG,	0

COMLST,	7		/^G, COMMAND LINE EDIT LIST
	15		/CR, INSERT CR & LF
	177		/RUBOUT
	25		/^U - RUB OUT LINE
	33		/ALT MODE
	52		/*
	40		/SPACE
M101,	-101
/SEARCH STRING MODIFIERS:

SCHLST,	^"N	/^N - ANYTHING BUT
	^"Q	/^Q - LITERALLY
	^"S	/^S - ANY SEPARATOR
	^"X	/^X - ANYTHING
	^"R	/^R - LITERALLY
	^"E	/^E - RESERVED FOR EXTENSIONS
SCHU,	-1	/^  - USE NEXT CHAR AS CONTROL CHARACTER	*ED	"^
		/SCHU MUST BE LAST AND MUST BE FOLLOWED BY A NEGATIVE NUMBER
M32,	-32
	PAGE
/DISPATCH TABLE FOR COMMAND INPUT

COMTAB,	TBEL		/^G
	TCRLF		/CR
RUBY,	ROCMND		/RUBOUT
	TCTLU		/^U
	TALTM		/ALTMODE
	TSTAR		/*
	TSPACE		/SPACE

CHKBZ,	0		/SEE THAT B .LE. C(AC) .LE. ZZ
	SZL
	JMP I	CHKBZ	/POP
	CIA		/ENTERED WITH LINK SET CORRECTLY
	TAD	ZZ
	SNL		/13-BIT ARITHMETIC
	JMP I	CHKBZ	/C(AC)>ZZ
	CIA
	TAD	ZZ	/RESTORE ORIGINAL AC
	ISZ	CHKBZ
	JMP I	CHKBZ

SCUPPR,	0		/SCAN AND CONVERT TO UPPER CASE
	SCAN
	UPPERC
	JMP I	SCUPPR	/THAT'S ALL?

/Q-REGISTER STORAGE - EACH Q-REGISTER TAKES 2 WORDS.
/WD 1 CONTAINS THE LENGTH OF THE CHARACTER PART OF THE REGISTER (IF ANY)
/WD 2 CONTAINS THE VALUE  OF THE NUMERIC PART OF THE REGISTER (IF ANY)

QARRAY,	ZBLOCK	110	/36 Q-REGISTERS * 2 WORDS/REGISTER = 72 WORDS
QPNTR,	0		/FAKE Q-REGISTER FOR INPUT LINE - LENGTH ONLY.

OUNAM,	ZBLOCK	4	/NAME OF OPEN OUTPUT FILE GOES HERE
