Google
 

Trailing-Edge - PDP-10 Archives - BB-BT99S-BB_1990 - 10,7/ddt/ddt.mac
There are 55 other files named ddt.mac in the archive. Click here to see a list.
SUBTTL	DDT	/TW/PFC/TWE/EJW/JNG/RDH/DIB/DLM/JBS/PTR/JM/RCB 18-Sep-89


	COMMENT	\

DDT  --  "Dynamic Debugging Technique" for TOPS-10/TOPS-20

;COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION 1970,1980,1983,1984,1987,1988,1989.
;ALL RIGHTS RESERVED.
;
;
;THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
;ONLY  IN  ACCORDANCE  WITH  THE  TERMS  OF  SUCH LICENSE AND WITH THE
;INCLUSION OF THE ABOVE COPYRIGHT NOTICE.  THIS SOFTWARE OR ANY  OTHER
;COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
;OTHER PERSON.  NO TITLE TO AND OWNERSHIP OF THE  SOFTWARE  IS  HEREBY
;TRANSFERRED.
;
;THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT  NOTICE
;AND  SHOULD  NOT  BE  CONSTRUED  AS A COMMITMENT BY DIGITAL EQUIPMENT
;CORPORATION.
;
;DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY  OF  ITS
;SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY DIGITAL.

\


;DDT VERSION IDENTIFICATION

MAJVER==45	;MAJOR VERSION LEVEL
MINVER==1	;MINOR (MAINTENANCE RELEASE) LEVEL
CSTVER==0	;CUSTOMER VERSION (WHO LAST . . .)
EDTVER==715	;EDIT LEVEL

%%DDT==:<BYTE (3)CSTVER(9)MAJVER(6)MINVER(18)EDTVER>

	IF2	<PURGE MAJVER,MINVER,CSTVER,EDTVER>
;               TABLE OF CONTENTS FOR DDT
;
;
;                        SECTION                                   PAGE
;    1. REVISION HISTORY..........................................   5
;    2. DDT ASSEMBLY SWITCHES.....................................  10
;    3. TITLE AND VERSION SETTING.................................  11
;    4. OPDEFS, MACROS, ETC.......................................  12
;    5. DDT SYMBOLS...............................................  16
;    6. GLOBAL SYMBOLS FOR USE BY THE OUTSIDE WORLD...............  17
;    7. MEMORY ALLOCATION PARAMETERS..............................  18
;    8. MISCELLANEOUS DDT SYMBOLS.................................  20
;    9. FILDDT
;         9.1   COMMAND SCANNER...................................  25
;         9.2   SETUP PAGE BUFFERS AND SYMBOLS....................  53
;   10. START DDT.................................................  59
;   11. DDT COMMAND PARSER........................................  60
;   12. COMMAND DISPATCH TABLE....................................  65
;   13. COMMAND ROUTINES
;        13.1   CLASS 1...........................................  66
;        13.2   CLASS 2...........................................  84
;        13.3   CLASS 3...........................................  85
;        13.4   CLASS 4...........................................  86
;        13.5   CLASS 5...........................................  87
;        13.6   CLASS 6...........................................  89
;        13.7   REGISTER DEPOSIT AND OPEN.........................  89
;        13.8   RETYPE LAST QUANTITY..............................  97
;        13.9   TYPEOUT MODE CONTROL..............................  98
;        13.10  LIMITS AND PATCHING............................... 100
;        13.11  MEMORY AND PAGING CONTROL......................... 105
;        13.12  BREAKPOINT FACILITY............................... 111
;        13.13  EXECUTE AND SINGLE STEP........................... 118
;        13.14  PUNCH PAPER TAPE.................................. 144
;        13.15  SEARCHING......................................... 148
;        13.16  COMMAND FILE INPUT................................ 150
;        13.17  MISCELLANEOUS COMMANDS............................ 153
;   14. FILE SPECIFICATION PARSING AND ERROR ROUTINES............. 159
;                        SECTION                                   PAGE
;   15. ENTER AND LEAVE DDT
;        15.1   SAVE.............................................. 169
;        15.2   RESTOR............................................ 174
;        15.3   SWAP.............................................. 176
;        15.4   BCOM.............................................. 177
;   16. WORD TYPEOUT AND FORMATTING ROUTINES...................... 180
;   17. OUTPUT SUBROUTINES........................................ 187
;   18. SYMBOL TABLE ROUTINES
;        18.1   CHECK POINTERS.................................... 192
;        18.2   CONVERT SYMBOL TO VALUE........................... 194
;        18.3   CONVERT VALUE TO SYMBOL........................... 196
;        18.4   HARDWARE OPCODE PROCESSING........................ 199
;        18.5   FIND PROGRAM NAME................................. 209
;        18.6   REMOVE AN UNDEFINED SYMBOL........................ 210
;        18.7   SYMSET, USYSET, AND ADVSYM........................ 211
;   19. MEMORY MANAGEMENT ROUTINES
;        19.1   FETCH............................................. 218
;        19.2   DEPOSIT........................................... 226
;        19.3   ADDRESS MAPPING................................... 238
;        19.4   PHYSICAL MEMORY................................... 243
;        19.5   FILDDT I/O........................................ 246
;        19.6   SYMBOL TABLE ACCESS............................... 252
;        19.7   ADDRESS CHECKING.................................. 259
;        19.8   MISCELLANEOUS..................................... 270
;   20. PRESERVATION ROUTINES..................................... 286
;   21. TELETYPE IO LOGIC
;        21.1   DEFINITIONS....................................... 288
;        21.2   INPUT ROUTINES.................................... 291
;        21.3   LINE BUFFERING ROUTINES........................... 295
;        21.4   UTILITY ROUTINES.................................. 312
;        21.5   OUTPUT SUBROUTINES................................ 319
;        21.6   SAVE/RESTORE...................................... 324
;   22. STORAGE
;        22.1   LITERALS AND END OF CODE.......................... 336
;        22.2   ALLOCATION MACROS................................. 337
;        22.3   MISCELLANEOUS..................................... 339
;        22.4   $X LOGIC AND PATCH COMMAND........................ 341
;        22.5   BREAKPOINTS....................................... 342
;        22.6   SYMBOL TABLE LOGIC................................ 344
;        22.7   ADDRESSING DATA................................... 346
;        22.8   SAVE AREAS FOR PREVIOUS CONTEXT................... 347
;        22.9   STATE VARIABLES................................... 349
;        22.10  FILDDT............................................ 350
;        22.11  PUSH DOWN LIST.................................... 353
SUBTTL	REVISION HISTORY

;THE REVISION HISTORY STARTS SUDDENLY AT EDIT 200
;
;	DDT %37(200)   RDH   14-NOV-76

;200	RDH	14-NOV-76	SPR 10-17714
;	VALIDITY-CHECK THE SYMBOL POINTER FOR THE HIGH-SEG SYMBOL
;	TABLE (.JBHSM) RATHER THAN ARBITRARILY BELIEVING IT (AND
;	SUBSEQUENTLY ILL MEM REF'ING, ETC.).

;201	RDH	14-NOV-76	SPR 10-18806
;	MORE OF EDIT 200, AT DEF1:

;202	RDH	14-NOV-76	SPR 10-19661
;	TREAT THE MAP INSTRUCTION "E" FIELD AS AN IMMEDIATE QUANTITY
;	RATHER THAN AS A MEMORY REFERENCE.

;203	RDH	14-NOV-76
;	EXPAND FILDDT TO HANDLE FULL 22-BIT ADDRESSING IN EXE-FORMAT
;	FILES (SPECIFICALLY CRASH.EXE).

;204	RDH	14-NOV-76	SPR 10-20165
;	IMPLEMENT SPECIAL BYTE-FORMAT TYPEOUT FOR THE VARIOUS
;	BYTE MANIPULATION INSTRUCTIONS. CODE COURTESY OF THE
;	UNIVERSITY OF ARIZONA.

;205	RDH	15-NOV-76
;	PUT TAG PTDFLG: UNDER FTYANK RATHER THAN FTEXEC!FTFILE FOR
;	THOSE SITES THAT WISH TO TAKE THEIR CHANCES WITH $Y IN EITHER
;	UDDT OR VMDDT (NOTE: $Y USES I/O CHANNEL 17 - BE WARNED)

;206	RDH	4-DEC-76
;	REWRITTEN CODE IN CHKADR (TO BETTER HANDLE KL'S) FORGOT HOW
;	KA'S WORKED AND LOST THE APR PI ASSIGNMENT.

;207	RDH	4-DEC-76
;	IMPLEMENT "/D" FOR FILDDT  --  TREAT FILE SPECIFIED AS PURE
;	DATA FILE - DON'T CRUMP ON FIRST 20 LOCATIONS (THE "ACS"),
;	DON'T LOOK FOR SYMBOL TABLE. IF NOT .EXE FORMAT AND NOT .XPN
;	FORMAT THEN "/D" IS ASSUMED.

;210	RDH	6-DEC-76
;	EXTEND THE $M COMMAND  --  <M>$<N>M  --  WHERE <N> IS THE
;	MASK NUMBER AND <M> IS THE ASSOCIATED MASK.
;
;	<N> =  0 OR NOT-SPECIFIED THEN <M> IS THE SEARCH MASK
;	<N> = 1 THEN <M> IS TTY CONTROL MASK:
;		1B35 = 1 THEN "ECHO" <DEL>'S AS <BS><SP><BS>
;211	RDH	6-DEC-76
;	NEW ASSEMBLY PARAMETER "SKPMAX" TO SET MAXIMUM NUMBER OF
;	LOCATIONS SKIPPED FOR $X LOGIC. IF <INSTR>$X THEN TYPE
;	<SKP> FOR EACH LOCATION SKIPPED. IF $$X THEN DO INDEFINITE
;	$X UNTIL OLD-PC .LT. NEW-PC .LE. OLD-PC+SKPMAX

;212	RDH	7-DEC-76
;	MATCH ANGLE BRACKETTS  --  <<
;	WHEN PATCHING ($>) DON'T INSERT A 0 WORD UNLESS USER EXPLICITLY
;	TYPED IT - I.E., ALLOW THE $> TO APPEAR BY ITSELF - THE WAY MOST
;	PEOPLE TEND TO USE IT.

;213	RDH	9-DEC-76
;	CHANGE SKIPN'S TO SKIPE'S IN [207] AND CAILE TO CAIL IN [210]

;214	RDH	18-DEC-76
;	MATCH ANGLE BRACKETTS IN EDIT [212] COMMENTS TO KEEP VARIOUS
;	AND SUNDRY PEOPLE HAPPY.

;215	RDH	19-DEC-76
;	IF SPYSEG THEN NO HISEG SYMBOL TABLE.

;216	RDH	19-DEC-76
;	CHKHSM ROUTINE ([200],[201]) IS TOO RESTRICTIVE, WON'T ALLOW
;	.JBHSM TO POINT TO LOW SEG; CHKADR ROUTINE WON'T ALLOW RANDOM
;	NON-CONTIGUOUS PAGES.

;217	RDH	19-DEC-76
;	NAMSET ROUTINE (TO HANDLE MODULE$:) ASSUMES HIGH SEGMENT ALWAYS
;	STARTS AT 400000, LEADING TO SUBSEQUENT ILL MEM REF'S.

;220	JNG	28-JAN-77
;	PREVENT ILL MEM REF ON PATCH CLOSE WHEN USING A WRITE-LOCKED
;	(E.G. HISEG) SYMBOL TABLE.

;DDT %40(220) MARCH, 1977

;221	TAH	13-MAR-77
;	ADD COMMAND FRONT END TO INTERFACE FILDDT TO TOPS-20 SYSTEM.
;	ADD KL PAGING CODE TO CVTADR, ALL UNDER FTFD20 CONDITIONAL
;	(FTFILE MUST STILL BE ON ALSO).

;222	ASM	13-MAR-77
;	IN EXEC DDT DETERMINE EXEC VIRTUAL ADDRESS OF EPT BY SCANNING
;	EXEC VIRT ADR SPACE IF PAGING IS ON.

;223	TAH	13-MAR-77
;	MAKE LPDL LARGER FOR TOPS-20 MDDT
;224	RDH	13-MAR-77
;	MAKE SEARCHES HANDLE NON-CONTIGUOUS CORE/FILE IMAGES, ADD
;	TWO NEW ASSEMBLY PARAMETERS:
;
;	    INDPTH	;MAX INDIRECT NESTING FOR $E SEARCHES
;	    LISCNT	;NUM OF <PUSHJ P,LISTEN>'S TWEEN INCHRS'S

;225	RDH	13-MAR-77
;	HANDLE TYPEOUT RADIX .GE. 10 (E.G., HEX) MORE GRACEFULLY

;226	RDH	13-MAR-77
;	EDIT 215 IS WRONG, .GTSGN == 14

;227	JNG	13-MAR-77
;	ADD CODE TO DDT TO WRITE-ENABLE PAGES ON TOPS-20 BEFORE
;	ATTEMPTING TO WRITE THEM - E.G., FOR BREAKPOINTS, PATCHS,
;	AND SO FORTH. IF PAGE NOT WRITE-ENABLED, SET COPY-ON-WRITE
;	SO AS NOT TO ZAP OTHER USERS "SHARING" THE PAGE.

;230	RDH	13-MAR-77
;	WHEN IN A COMMAND FILE ($Y) THEN DO NOT CHECK THE COMMAND
;	FILE FOR INPUT ON CALLS TO LISTEN - ONLY ACCEPT PHYSICAL
;	TTY INPUT.

;231	RDH	14-MAR-77
;	CLEAR $U POINTERS IN FILDDT ON ^Z, START SEQUENCE

;232	RDH	14-MAR-77
;	UPDATE LH(.JBSA) ON PATCH END IF .JBFF WAS DEFAULTED TO
;	ON PATCH BEGIN. THIS WAY THE PATCH IS AT LEAST SAVED ON
;	SAVE'S, RESET'S, AD NAUSEUM.

;233	RDH	14-MAR-77
;	REVAMP PATCH LOGIC ($< AND $>) TO DISPLAY LOCATION BEFORE
;	MODIFYING SAME LOCATION SO THAT FILDDT CAN PATCH RUNNING
;	MONITOR (ALSO LOOKS NEATER).

;234	RDH	23-MAR-77
;	ADD NEW "MASK" COMMAND <N>$2M TO SET THE SYMBOL OFFSET RANGE
;	(I.E. THE RANGE IN WHICH VALUES WILL BE TYPED IN THE FORM
;	SYMBOL+<OFFSET>) TO <N>. ADD ASSEMBLY PARAMETER "ADRNGE"
;	AS THE DEFAULT VALUE. ALSO MAKE $1M/ ETC. WORK.

;235	RDH	24-MAR-77
;	REVAMP BYTE TYPEOUT LOGIC: ADD <N>$3M AS BYTE TYPEOUT MASK
;	(EACH "1" BIT IN THE MASK MARKS THE END OF A BYTE, BIT 35
;	IS ALWAYS CONSIDERED THE END OF A BYTE). FOR VALUES OF <N>
;	SUCH THAT 1 .LE. <N> .LE. 36(10) THE COMMANDS $<N>O & $$<N>O
;	WORK AS USUAL BY SETTING AN INTERNAL BYTE MASK. FOR <N> = 0
;	THE $3M BYTE MASK WILL BE USED. FOR <N> = <NULL> (I.E. THE
;	$O COMMAND) THE CURRENTLY PREVAILING $O OR $$O MASK WILL
;	BE USED IF NON-BLANK, ELSE THE $3M MASK WILL BE USED.
;	$$O MAKES PERMANENT THE CURRENTLY PREVAILING $O (OR $$O)
;	BYTE MASK.
;236	RDH	14-APR-77
;	ADD IFN FTYANK CONDITIONALS SO THAT FILDDT CAN BE ASSEMBLED
;	WITH FTYANK TURNED OFF.

;237	RDH	17-APR-77
;	GENERAL CLEANUP AND REARRANGEMENT. MAKE TOPS-10 DDT SEARCH
;	THE "C" UNIVERSAL FILE. TYPE OUT "DDT" WHEN USER MODE DDT
;	IS ENTERED. PUT TOPS-10-SPECIFIC CODE UNDER "IFN FTDEC10"
;	RATHER THAN "IFE FTDEC20".

;240	RDH	15-JUN-77
;	ADD CODE TO TYPE OUT SYMBOLIC WORDS WITH USER-DEFINED SYMBOLS
;	SUCH AS THE CALLI OR JSYS MNEMONICS. ORDER OF SEARCH IS:
;	   1)	OPCODE & AC & I & X & Y FIELDS
;	   2)	OPCODE & I & X & Y FIELDS (E.G. CALLI OR JSYS)
;	   3)	OPCODE & AC FIELDS (E.G. TTCALLS)
;	   4)	OPCODE ONLY
;	   5)	HARDWARE-KNOWN OPCODE (JRST, ETC.)
;	PUT CODE UNDER FTOPX .NE. 0 CONDITIONAL SINCE UNTIL SORTED
;	SYMBOL TABLES AVAILABLE THIS CODE TAKES MUCH RUN TIME.
;	ALSO MAKE TRXX AND TLXX TYPE OUT ADDRESS AS OCTAL RATHER
;	THAN SYMBOL+OFFSET.

;241	RDH	15-SEP-77	SPR # 10-22011
;	"777777" COULD GET TYPED OUT AS "-1" WHEN $X'ING IF THE
;	AC BEING TYPED OUT WAS TYPED OUT IN XWD FORMAT.

;242	RDH	16-SEP-77	SPR # 10-22616
;	"AOS UND#(AC)" LOST BOTH THE UND SYMBOL AND THE AC IN
;	THE WORD BEING BUILT (I.E., LEFT ONLY THE AOS).

;243	RDH	16-SEP-77	SPR # 10-22788
;	PATCHING WITH FILDDT WRONG IF NONE OF THE USUAL PATCHING
;	SYMBOLS (PAT.., PAT, PATCH) ARE PRESENT AND THUS PATCHING
;	DEFAULTS TO C(.JBFF) - THE .JBFF USED WAS FILDDT'S, NOT
;	THE FILE'S.

;244	RDH	16-SEP-77	SPR # 10-22894
;	SOME RUBOUT'S STILL GET TYPED OUT.

;245	RDH	17-SEP-77	SPR # 10-23013
;	AFTER REFERENCING AN UNDEFINED SYMBOL, THE UNDEFINED SYMBOL
;	IS LEFT IN THE SYMBOL CACHE WITH ITS BOGUS VALUE (E.G., THE
;	ADDRESS TO FIX UP).

;246	RDH	25-SEP-77
;	BE MORE CHOOSEY ABOUT TYPE-IN INVOLVING UNDEFINEDS - CATCH ERRORS
;	SUCH AS "PUSHJ UND#,FOO" OR "MOVE 4,(UND#)"
;247	RDH/JNG	16-OCT-77 TO 28-JUN-78
;	MASSIVE DEVELOPMENT AND REVAMPING: EXTENDED ADDRESSING; JSYSIZE FILDDT;
;	REMOVE SYMBOL CACHE; ADD $0W AND $1W; DISK SUPER I/O (FILDDT);
;	PHYSICAL MEMORY ADDRESSING; KS-10 SUPPORT; KI/KL PAGING SUPPORT;
;	$Z; $8T AND $9T; $.; $U ENHANCEMENTS; $B ENHANCEMENTS; $X EN-
;	HANCEMENTS; DECOMMIT EXEC PAPER TAPE STUFF; SYMBOLIC TYPEOUT
;	ENHANCEMENTS; $Y ENHANCEMENTS (TOPS-10 ONLY); NUMEROUS RANDOM
;	BUG FIXES. CALL VERSION 41.

;250	JNG	15-AUG-78
;	SEARCH UUOSYM, MACTEN INSTEAD OF C.

;DDT %40A(250)	OCTOBER, 1978

;251	JNG/RDH	15-AUG-78 TO 26-JAN-79
;	CONTINUING AND FIXING BUGS IN 247: IMPLEMENT HISEG SYMBOL TABLES
;	IN FILDDT; ALLOW THE SYMBOL TABLE TO BE IN ANOTHER ADDRESS SPACE
;	FOR EDDT AND MDDT; ADD $: WITH NO ARGUMENT; ADD "M" ERROR.

;252	JNG	4-FEB-79
;	CHANGE HIDDEN SYMBOL LOGIC TO DO EXEC VIRTUAL BLT'S INSTEAD
;	OF SWITCHING THE EPT BASE ADDRESS.

;253	DIB	8-MAR-79
;	INSERT A NEW SYMBOL TABLE CACHE FOR OUTPUT ONLY.  ALSO MOVE
;	DATA PAGES BELOW CODE PAGES SO SYMBOL CACHE WILL FIT IN UDDT.

;254	JNG/RDH	8-MAR-79
;	GET FAKEAC LOGIC RIGHT IN $U COMMANDS.  BROKEN BY 251. ONLY
;	SETUP .JBVER IF FILDDT. ADD /A (ABORT ON COMMAND ERROR) FOR
;	$Y. MAKE ^W WORK MORE REASONABLY ON -10. MAKE FANCY RUBOUT
;	HANDLING AUTOMATIC ON -10 (7.01 ONLY). ADD $$. AS PREVIOUS
;	$. (USEFUL FOR $$.<$$X ETC.).
;	(MATCH ANGLE BRACKETS:>)

;255	RDH	31-MAR-79
;	LOST INSTRUCTION IN EDDT FOR KI-10'S. SUPPRESS ADDRESS BREAKS
;	IN FETCH AND STORE LOGIC. IF $$X'ING (OR $W'ING (SEARCHING)
;	OR $Z'ING (DEPOSITING)) AND USER TYPES A ? THEN GIVE A QUICKIE
;	TYPEOUT STATUS. SECOND FIELD TEST FOR TOPS-10 7.00.

;256	RDH	17-APR-79
;	RANDOM VERSION 41 BUGS (IN PARTICULAR $P OF A BREAKPOINT CAUSED
;	BY XCT'ING A BREAKPOINT LOCATION FAILED). HANDLE ERCAL/JMP ON
;	$P. HANDLE INIT UUO.

;257	JNG	21-APR-79
;	CONVERT $U COMMAND TO FUNCTION CODES.
;260	RDH	13-MAY-79
;	ADD ADR$V COMMAND TO "WATCH" A LOCATION AND REPORT ANY CHANGE IN
;	ITS CONTENTS (ADR DEFAULTS TO LAST LOCATION OPENED).

;261	RDH	22-MAY-79
;	STUPID LITTLE BUGS.

;262	RDH	8-JUL-79
;	XJRSTF AND FRIENDS WANT ALL 36 BITS OF PC FLAGS, NOT JUST THE
;	LEFT-MOST 18 BITS. $I+3 IS 36-BIT PC FLAGS, $I+4 IS 36-BIT PC.

;263	RDH	16-JUL-79
;	MORE STUPID LITTLE BUGGIES. IN PARTICULAR, N$P BROKE.

;264	DZN	25-OCT-79
;	REPLACE SUB IN LOOKDN WITH EQUIVALENT CODE THAT DOESN'T OVERFLOW.

;265	DZN	6-NOV-79
;	REMOVE MULTIPLY-DEFINED GLOBALS $nB, $I, $M WHEN KDDT AND MDDT ARE
;	LOADED TOGETHER.

;DDT %41(265) RELEASED MAY, 1980
;VERSION 41A BEGINS

;266	DIB	18-FEB-80
;	ADD RP20 SUPPORT TO FILDDT.

;267	BPK	11-APR-80
;	REPLACE SUB IN LOOK10 WITH EQUIVALENT CODE THAT DOESN'T OVERFLOW.

;270	BPK	17-APR-80
;	TURN OFF CTRL-O WHENEVER WE STOP AT A BREAKPOINT.

;271	DLM	4-OCT-79
;	FLAG IN TTYMSK FOR INST TYPEOUT ON BPT; WARNING IF BPT INSERTION/REMOVAL
;	FAILS; DIAGNOSTICS ON MEM REF FAILURE; RUN IN NON-0 SEC IF POSSIBLE.

;272	JBS	9-NOV-80	SPR 10-30155
;	ADD ^E TEXT TO -10 HELP MESSAGE.

;273	JBS	10-NOV-80	SPR 10-30019
;	FIX OVERFLOW IN ADD INSTR. AT L4+18.

;274	JBS	12-NOV-80	SPR 10-30058
;	FIX SUB AT DOITX0 THAT SET CARRY1 AND CARRY0 IN USER CONTEXT.

;275	JBS	14-NOV-80
;	FIX ERJMP/ERCAL $X ROUTINES TO AGREE WITH EDIT 274.

;276	JBS	17-NOV-80	SPR 10-30156
;	MOVE "PUSH" OUT OF CONDITIONALS TO AGREE WITH "POP" IN RDBIN.
;277	JBS	18-NOV-80	SPR 20-15067
;	FIX $<RET> AFTER $<TAB>.

;300	JBS	19-NOV-80	SPR 10-30237
;	ADD USER TTY CONTROL BIT FOR $Y ECHO DURING FILE READ/EXECUTION.

;301	JBS	25-NOV-80
;	ALL KINDS OF MISC. EDITS TO FIX LITTLE THINGS HERE AND THERE.

;302	JBS	3-DEC-80	SPR 10-30277
;	FIX MOVING OF PAT.. IN $< MODE.

;303	JBS	4-DEC-80
;	MAKE $Z ABORT WITH "?" IF ANY MEM. WRITE FAILS, REMOVE $$Z,
;	MOVE /H TEXT AROUND FOR -10 VERSION, FIX EXTENDED ADDRESSING BUG.

;304	JBS	10-DEC-80	SPR 10-30337
;	FIX ILDB TYPEOUT IN EXTENDED ADDRESSING MODE - WAS MESSING UP SECTION #
;	WHEN AN AC WAS USED.

;305	JBS	29-DEC-80
;	REMOVE TEMPORARY PATCH THAT BYPASSED MACRO BUG, REVISE EDIT 300.

;306	JBS	29-DEC-80	SPR 10-30404
;	ADD $$1X FEATURE TO DO QUICKER $$X BY NOT CHECKING FOR DANGEROUS
;	INSTRUCTIONS.  USED OVER LONG BUT SAFE PUSHJ'S, ETC.

;307	JBS/RDH	30-JAN-81
;	SETUP LOCATION .JBBPT WITH $0BPT FOR TOPS-10 USER/EXEC DDT'S,
;	CHANGE FLOATING OUTPUT SUBROUTINE "TFLOT" TO USE "FLOUT" JSYS ON
;	TOPS-20, ADD $2F DOUBLE-PRECISION FLOATING TYPEOUT ON TOPS-20,
;	ALLOW READING $M AND $U MASKS IN FILDDT (SPECIAL-CASE THEM),
;	REMOVE $L PAPER TAPE PUNCH CODE, ADD $[ANY DIGIT] COMMAND TO 
;	ABORT PATCH INSERT MODE, MAKE $[ANY DIGIT]< ILLEGAL,
;	CLEAR "PATCH MODE" FLAG AND RESET LOCATION POINTERS AT START-UP,
;	DON'T ALLOW NESTED PATCHING, CHANGE <LF> AND ^H TO RECOGNIZE
;	DOUBLE-WORD MODE ON TOPS20 (I.E., DOUBLE PRECISION FLOATING TYPEOUT),
;	CHANGE $X CODE TO CLEAR INPUT BUFFER AND RESET ^O BEFORE NEXT
;	INSTRUCTION TYPEOUT.
;	(MATCH ANGLE BRACKETS IN [302] >)

;310	JBS	22-JAN-81	SPR 20-15518
;	CHANGE HANDLING OF TEXT INSERTION - AUTOMATICALLY CLOSE LOCATION
;	UPON RECEIPT OF TEXT DELIMITER.

;311	JBS	6-FEB-81
;	REDEFINE PATCH ABORT COMMAND TO $0>, FIX BREAKPOINT TYPEAHEAD
;	CLEARING BUG - WAS MUNCHING FIRST CHR. TYPED AFTER BREAKPOINT
;	STUFF BEGAN TYPING OUT, FIX FILDDT BUG WHICH WOULD SETUP PAGTBL
;	WRONG (SOMETIMES) FOR PAGES OVER 4000, CHANGE TEXT INSERTION MODE
;	SO IT WON'T FORCE A CRLF IF A LOCATION IS OPEN BUT NOTHING HAS
;	BEEN DEPOSITED YET (REVISION OF EDIT 310), REINSTALL EDIT 273
;	WITH A CHANGE (EDIT 303 REMOVED EDIT 273).
;312	RDH/JBS	4-MAR-81
;	(<<MATCH ANGLE BRACKETS)
;	FIX BROKEN NEGATIVE INTEGER TYPEOUT, FIX TOPS-10 OUTPUT BROKEN BY
;	EDIT 305, MAKE $7T MODE DO RIGHT-JUSTIFIED TYPEOUT ONLY IF LEFT 29
;	BITS ARE ALL NULL, CHANGE PATCH ABORT (AGAIN) TO $$0>, MAKE A BOTCHED
;	PATCH-INSERT FIX PTLOC BEFORE LOSING, MAKE $N> SET MAXIMUM SKIP
;	RETURNS FROM PATCH (N=1 GIVES 1 JUMPA, ETC.), FIX BUG THAT WOULD SET
;	"." TO ZERO AFTER ^C/DDT COMMANDS, ADD $0T/$$0T COMMAND TO TYPE THE
;	ASCIZ STRING STARTING AT ".", MAKE XMOVEI TYPE OUT AC CONTENTS AFTER
;	$X.

;313	JBS	10-APR-81
;	EDITS 302 AND 312 MUST BE INSTALLED FIRST -
;	ADD <ADDR.>$0T TO TYPE ASCIZ STRING AT <ADDR.>, CHANGE $0T CODE TO
;	BE MORE EFFICIENT, ALLOW USER TO STOP $0T TYPEOUT ANYTIME, MORE WORK
;	TO GET $T TO WORK RIGHT FOR RIGHT-JUSTIFIED SINGLE CHR., HANDLE RPACS%
;	ERROR IF SECTION DOESN'T EXIST, MAKE FILDDT STOP SEARCHING AFTER EOF
;	ON DATA FILES, FIX MOVING OF PAT.. WHEN AN UNDEFINED SYMBOL EXISTS
;	AND A NEW DEFINITION IS MADE (CACHE PROBLEM), MAKE CONDITIONAL
;	BREAKPOINT INSTRUCTION EXECUTE IN USER CONTEXT, DON'T FORCE $P
;	DEFAULT TO 1 IF USER HAS SPECIFIED OWN NUMBER.

;314	JBS	10-AUG-81
;	REMOVE AUTO CRLF AFTER LONG STRING INSERTION, FIX ANOTHER BUG WITH
;	UNDEFINED SYMBOLS NOT GETTING FIXED UP.

;315	JBS	13-AUG-81	SPR 10-31459
;	OUTPUT RADIX WASN'T SETUP BEFORE TYPING FILOP. ERROR CODE, CAUSING
;	GARBAGE TO PRINT OUT.  FILDDT-10 ONLY.

;316	JBS	17-AUG-81
;	FIND "REAL" EOF FOR A TOPS-20 FILE - EDIT 313 BROKE THIS BECAUSE IT
;	ASSUMED SIZEF% RETURNED EOF.  BUT EOF DOESN'T REALLY EXIST IN TOPS-20!

;317	JBS/RDH	19-AUG-81
;	[JBS] FIX FILDDT FOR BIG DATA FILES AGAIN.
;	[RDH] HANDLE ^S/^Q IN EXEC MODE, IMPLEMENT EXEC MODE TYPEAHEAD,
;	IMPLEMENT XXX<ADR>N$B WHERE "ADR" IS ADDRESS OF COMMAND STRING TO
;	BE EXECUTED ON BREAKPOINT (DEPENDS ON FTYANK), HANDLE $X'ING IN
;	THE ACS IN NON-ZERO SECTION (PC ALWAYS LOCAL, THEREFORE ALWAYS
;	A "REGISTER" ADDRESS)

;THIS SOURCE FILE IS MADE FROM FIELD-IMAGE DDT 42(320), AS RELEASED WITH
;TOPS-20 V5.  IT INCLUDES SOME PUBLISHED AND UNPUBLISHED EDITS MADE TO DDT
;41A.

;320	RDH/JBS	30-SEP-81
;	EDIT 317 BROKE TYPING SOMETHING TO GET OUT OF A (E.G.) SEARCH LOOP 
;	(EXEC MODE ONLY), PRESERVE APR BITS IN EXEC MODE, TYPE "/" INSTEAD OF A
;	SPACE IN $0T COMMAND.  NOTE: THIS EDIT IS NOT IN 42(320).

;321	JBS	30-SEP-81	10-31641
;	REMOVE DEFINITION OF RADIX50 PAT FROM LIST OF PATCH LOCATIONS IN
;	USER MODE.

;322	JBS	6-OCT-81
;	PHYSICALLY REMOVE DESUPPORTED $L CODE.

;323	ALREADY INSTALLED IN 42(320).


;324	JBS	27-JAN-82
;	FIX TYPO IN EDIT 317 THAT CAUSED EDDT-10 TO HANG ON STARTUP.

;DDT %41A(324) RELEASED FEB, 1982
;%42(320) RELEASED ON TOPS-20 VERSION 5 SYSTEMS SUMMER 1982.

;325	RDH/JBS	3-FEB-82
;	FIX PUSH/POPJ MISMATCH THAT HAPPENS IF NO SPT SETUP IN KL-PAGING.

;326	JBS/RDH	19-MAR-82
;	CHANGE CONDITIONAL BREAKPOINT CODE TO COMPLETELY RESTORE THE WORLD
;	BEFORE EXECUTING (IN CASE OF CONSZ PI, ETC. IN EXEC MODE).

;327	JBS	12-MAY-82	20-17648
;	TYPE SYMBOL IN OPEN MODULE IN PREFERENCE TO A GLOBAL, IF THEY BOTH HAVE
;	THE SAME VALUE.

;330	NOT INSTALLED.

;331	JBS/RDH	17-DEC-82	20-17727
;	REWORK $X CODE TO MINIMIZE PROBLEMS WITH PSI SWITCHING.  USER WOULD
;	GET PSI TRAPS WITH DDT'S ACS SET UP, OR NOT GET PSI AT ALL.  THIS DOES
;	NOT ELIMINATE THE PROBLEM COMPLETELY (CAN'T BE DONE ANYWAY), IT JUST
;	HELPS IT A LOT.

;332	JBS	1-SEP-82	10-32308
;	MAKE RDIO NOT CRASH THE SYSTEM WHEN $X'ED ON A KS.  FIXED ON TOPS-10
;	AND EDDT-20; S/UDDT DON'T HAVE ENOUGH ROOM LEFT TO BE FIXED.

;333	DLM/RDH	25-DEC-82
;	NOTE: THIS EDIT IS NOT INSTALLED.  IT IS ONLY FOR FURTHER DOCUMENTATION
;	OF 42(320) AS RELEASED.
;	CREATE SECTIONS AS NEEDED FOR TOPS-20 USER-MODE DDTS; DEFAULT
;	THE SECTION IN ADDRESS EXPRESSION IF ADDRESS IS .LT. 18 BITS, OR
;	IF SPACE OR COMMA TYPED, BUT NEVER IF COMMA-COMMA TYPED; IMPLEMENT
;	"INTERNAL" ADDRESSES (E.G., FOR $M, $I, ETC.) - MAKE $NI, $NM, AND
;	$NU CONSISTENT (ALLOW SETTING AS WELL AS READING OF ALL).

;334	JBS	31-JAN-83	10-33035, 10-33811
;	TYPE I/O INSTRUCTIONS CORRECTLY.

;335	NOT INSTALLED.

;336	JBS	25-MAR-83
;	FIX ERROR MESSAGE TYPEOUT AT REMOER.

;337	JBS	2-FEB-83
;	FIX INEFFICIENT CODE AFTER SYMBOL TABLE CACHE FEATURE TEST WAS ADDED.

;< (match angle brackets)
;340	JBS	2-FEB-83
;	REMOVE $$0> AS PATCH ABORT COMMAND.  LEAVE $0< AS THE COMMAND.
;> (more matching anglies)

;341	NOT INSTALLED.

;342	JBS	16-FEB-83
;	FIX $G TO USE 30 BIT START ADDRESSES ON TOPS-20.

;343	JBS	25-FEB-83
;	REMOVE EXEC-MODE ONLY CODE FROM USER DDTS.  EDIT 331 MUST BE INSTALLED
;	FIRST.

;344	JBS	14-MAR-83
;	DON'T DIE IF USER GIVES BAD FORK NUMBER IN FORK<$$?.
;(MATCH ANGLE BRACKETS:>)

;345	JBS	4-APR-83
;	MOVE SOME CODE TO PAGES 764 AND 765 IN UDDT-20 TO GET CODE SPACE.

;346	JBS	4-APR-83
;	FIX EDIT 343 SO TOPS-10 USER MODE WORKS.  EDIT 343 MUST BE INSTALLED.

;347	JBS	6-APR-83
;	EXPAND EDIT 332 TO WORK IN UDDT-20 AND SDDT-20 ON THE KS.  EDIT 345
;	MADE ENOUGH ROOM TO INSTALL THIS BUG FIX.

;350	JBS	8-APR-83
;	FIX EXEC TYPEAHEAD CHECK AT LOOK2 + A FEW.

;351	JBS	8-APR-83
;	REMOVE DEFINITION OF MRPAC% JSYS FROM SOURCE.

;352	JBS	8-APR-83	20-19074
;	FIX $W IN FILDDT-20.

;353	JBS	6-MAY-83
;	FIX $? COMMAND TO NOT TYPE GARBAGE STRINGS.

;354	JBS	9-MAY-83
;	REMOVE $$? COMMAND FROM FILDDT-20.

;355	JBS	8-JUL-83
;	MOVE SAVE4 LABEL SO EXEC DDT'S START.  FIX TO EDIT 331 AND 332.

;356	NOT INSTALLED.

;357	JBS	26-JUL-83
;	FIX $W FOR DISKS - PAGE ACCESS BITS WERE NOT UPDATED.

;360	JBS	28-JUL-83
;	DO MONITOR FIXUPS RIGHT - PEEK JUST BEFORE POKE.'ING.

;361	RDH	15-NOV-83
;	KEEP THE LAWYERS HAPPY - PUT COPYRIGHT IN THE BINARIES

;362	PTR	20-DEC-83	20-17198
;	FIX NON-ZERO SECTION $X OF XMOVEI, XHLLI, LDB ET AL. BY
;	REMEMBERING THE LOCAL/GLOBAL PART OF THE EA CALC.
;	MAKE A NEW ENTRY IN $XTBL FOR XHLLI, SO SECTION NO. IS PRINTED.
;	ADD CODE TO TBPNT TO DECODE ALL FORMS OF BYTE POINTERS.
;	FIX EA CALC OF BYTE POINTERS AT IXBP; HANDLE ALL THE FORMATS.

;DDT %42A(362) SHIPPED WITH TOPS-10 7.02

;363	JBS	1-FEB-84	RAW
;	MAKE PSECT XCODE READ-ONLY.

;364	PTR	 7-FEB-84	10-34464
;	WRTWIN THOUGHT THE REFERENCED ADDRESS WAS ALWAYS IN R; IT ISN'T.
;	USE THE FILE PAGE NUMBER INSTEAD.

;365	RDH	21-FEB-84
;	ONLY GIVE HARDWARE 8 BITS OF CHAR IN EXEC MODE.

;366	PTR	21-FEB-84
;	DON'T CONFUSE FLOAT INPUT AND SYMBOLS STARTING WITH ".E" SO MUCH

;367	JM	21-JUN-84
;	FIX $O TYPEOUT MODE (N-BIT BYTES) SO THAT ADDRESSES ARE RENDERED
;	SYMBOLICALLY RATHER THAN ABSOLUTELY.

;370	JM	30-AUG-84	10-34852
;	MOVE TYPEOUT MODE SAVE FROM DD2: TO AFTER LIS1:

;371	JM	 2-OCT-84
;	CAUSE RUBOUT OF TEMPORARY TYPEOUT MODE TO WORK AGAIN (BROKEN BY
;	EDIT 370).

;372	JM	21-NOV-84
;	FIX SINGLESTEP OF XPCW:  RESTORE CORRECT CONTEXT; DON'T OVERWRITE
;	SAVED FLAGS WITH SAVED PC.

;373	PTR	 6-DEC-84
;	NOT INSTALLED, EQUIVALENT TO EDIT 621.

;374	PTR	 6-DEC-84
;	ALREADY INSTALLED AS EDIT 601.

;375	PTR	 6-DEC-84
;	NOT INSTALLED, EQUIVALENT TO EDIT 622.

;376	PTR	 6-DEC-84
;	NOT INSTALLED (PARTLY INSTALLED AS EDIT 422).

;377	PTR	 6-DEC-84
;	ALLOW < > AS PATH DELIMITERS AS WELL AS [ ] IN TOPS-10 FILESPECS.
;	MINOR BUG IN <LF> RE TYPEOUT MODE FLAG.
;EDIT NUMBERS THRU 417 RESERVED FOR DDT V42 SPR'S.
;DDT V43 DEVELOPMENT BEGINS AT EDIT 420.

;420	PTR	 9-JAN-84
;	CREATE THIS SOURCE FILE FROM DDT V42(362).  CLEAN UP COMMENTS,
;	MAKE CODE FORMAT CONSISTENT AS POSSIBLE.  NO CODE CHANGES.

;421	PTR	 9-JAN-84
;	SUPPORT INTER-SECTION BREAKPOINTS.  IMPLEMENT $4M.

;422	PTR	18-JAN-84
;	ADD SUPPORT FOR $X OF XJRST INSTRUCTION.  FIX IO INSTRUCTION
;	RESULTS TYPEOUT.

;423	PTR	19-JAN-84
;	NOT INSTALLED.

;424	PTR	19-JAN-84
;	REVISE INSTRUCTION TYPEOUT CODE TO ALLOW FOR SYMBOLS WITH
;	NON-ZERO LEFT HALVES.

;425	PTR	20-JAN-84
;	FIX $X OF STACK INSTRUCTIONS TO WORK WITH LOCAL STACK POINTERS
;	IN NON-DDT SECTIONS.

;426	PTR	23-JAN-84
;	ALWAYS INSERT/REMOVE BREAKPOINTS AROUND INSTRUCTIONS.  JSYS CAN
;	CAUSE RANDOM DISPATCHES, INTERRUPT OR ARITH OVL MAY OCCUR;
;	MAKE SURE DDT HAS A CHANCE OF RECOVERING.

;427	PTR	24-JAN-84
;	REDO SAVEG: A BIT.  MOVE SOME EXEC MODE TYPEAHEAD CHECKS.

;430	PTR	24-JAN-84
;	INSTALL DLM'S SYMBOL TABLE CHANGES VERBATIM -- WILL CHANGE TO
;	MEET SPEC LATER.  INCLUDES MDDT STUFF; RIP OUT WINDOWING CODE.
;	NO MORE "HIDDEN" SYMBOLS ON -20.

;431	PTR	25-JAN-84
;	ADD STACK/ARITH TRAP-CAUSING INSTRUCTIONS TO DANGEROUS OPCODE
;	TABLE; FIX [426] TO INSERT/REMOVE BPTS ONLY FOR DANGEROUS
;	INSTRUCTIONS.  REORGANIZE DANGEROUS OPCODE TABLE DEFINITION.

;432	PTR	26-JAN-84
;	FIX UP SYTSEC TO ASSUME -1,,N FORMAT.  IF WORD IS 0, DEFAULT
;	TO SECDDT.  CLEAR CACHE IF STUFFING NEW SYMBOL POINTERS (SYMCHK).

;433	PTR	30-JAN-84
;	MAKE FILDDT ASSEMBLE AGAIN.  CNTRLZ/CNTRLE WERE TOO BIG FOR COMMAND
;	DISPATCH TABLE.

;434	PTR	 3-FEB-84
;	KEEP SYMCHK FROM SWITCHING SYMBOL TABLES IN MDDT/KDDT.
;	NEVER LOOK OUTSIDE SECTION 0 FOR SYMBOL TABLES IF RUNNING IN ZERO.
;435	PTR	 3-FEB-84
;	FIX [430] TO USE IFIW WHEN ZEROING "@SYMP".
;	CHANGE MAP AC,(R) AND SKIP (R) TO USE @R (SO SEC. 0 REFS FROM
;	NON-ZERO WILL WORK).

;436	PTR	 6-FEB-84
;	FIX [430] SO DOESN'T REFERENCE .EDSEC ON -10.

;437	PTR	 6-FEB-84
;	SPECIAL MDDT BREAKPOINT INTERLOCK; ONLY ONE FORK CAN SET BREAKPOINTS
;	AT A TIME.  SET DEFAULT MDDT/KDDT BREAKPOINT BLOCKS.
;	CHANGE MDDT/KDDT PSECT NAMES.

;440	PTR	15-FEB-84
;	MAKE <FOO>$X DO THE INSTRUCTION IN USER'S SECTION, NOT DDT'S SECTION.
;	FIX CNTRLZ NOT TO USE $X CODE.

;441	PTR	15-FEB-84
;	MAKE $V DEFAULT SECTION IF NONE TYPED.

;442	PTR	16-FEB-84
;	FIX HANDLING OF SYTSEC SO SDDT STILL WORKS.
;	MAKE HISEG S.T. CHECKS DO LOCAL FETCHES.

;443	PTR	23-FEB-84
;	DEFAULT BPBLK TO LAST N WORDS IN SECTION.  MAKE SURE IT HAS ROOM
;	FOR $X NEEDS.

;444	PTR	24-FEB-84
;	FIX SYTSEC HANDLING SOME MORE SO S.T. STUFFING (INCL SDDT) WORKS IN
;	NON-ZERO SECTIONS.

;445	PTR	27-FEB-84
;	MAKE MDDT STACK POINTER GLOBAL.  OTHERS SHOULD STILL BE LOCAL.

;446	PTR	27-FEB-84
;	DON'T DIDDLE PSI STATUS IN MDDT. STACK NOT SET UP AT THAT POINT ANYWAY.

;447	PTR	27-FEB-84
;	IN <INSTR>$X, DON'T INSERT BREAKPOINTS UNLESS WE'RE REALLY GOING
;	TO EXECUTE THE INSTRUCTION.

;450	PTR	27-FEB-84
;	TURN SOME RAW NUMBERS INTO SYMBOLS IN KL PAGING STUFF.
;	FIX EXEC MODE $W, INCLUDE CST WRITE BIT.

;451	PTR	27-FEB-84
;	IMPLEMENT "PERMANENT DEFAULT SECTION," $6M.  IF SET, USE IT INSTEAD
;	OF LLOCS IN DEFSEC.  REWRITE DEFSEC TO INCLUDE NEW ROUTINE GDFSEC
;	(GET DEFAULT SECTION).
;452	PTR	28-FEB-84
;	WHEN A LOCAL AND GLOBAL HAVE THE SAME VALUE, CONSISTENTLY PICK
;	THE GLOBAL FOR TYPEOUT.  IMPROVEMENT ON [327].

;453	PTR	28-FEB-84
;	FIX PROBLEM WITH OKAF.  CLEAR IT IN MORE PLACES, SO # APPEARS
;	AFTER LOCALS CONSISTENTLY.

;454	PTR	 2-MAR-84
;	FIX PROBLEM WITH [447].  INSTR$X COULD DIE IF BREAKPOINTS SET.

;455	PTR	 5-MAR-84
;	IN KDDT USER MODE, JUMP INTO MONITOR ON ^Z SO IT CAN PLAY MAPPING
;	GAMES.  THIS IS SO "@GET SYSTEM:MONITR  @START 140" WILL WORK.

;456	PTR	21-MAR-84
;	OPDEF SOME OPCODES SO THAT DECREPIT VERSIONS OF MACRO CAN STILL
;	ASSEMBLE DDT.

;457	PTR	22-MAR-84
;	FIX SYMCHK NOT TO STEP ON FILDDT'S SYMBOL POINTERS.  FOR NOW
;	FILDDT WILL IGNORE $5M.

;460	PTR	30-MAR-84
;	MAKE $X OF PC-SECTION-REF INSTRUCTIONS (BYTE, EXTEND, BLT, JSYS)
;	EXECUTE IN ORIGINAL PC SECTION.

;461	PTR	18-APR-84
;	MASSIVE EDIT TO RECOGNIZE PDV'S AND THEIR SYMBOL VECTORS.
;	THE IOWD IS HEREBY DEFUNCT.  SYMBOL TABLE POINTERS ARE NOW KEPT
;	INTERNALLY AS TWO-WORD ADDRESS/LENGTH PAIRS.  SYMP AND FRIENDS ARE
;	NOW BLOCKS OF SYMBOL TABLE INFORMATION.  THIS CHANGES HOW SYMBOL
;	TABLES ARE HANDLED ALL OVER DDT.  IN PARTICULAR, SYMFIX, SYMCHK
;	AND CLSFIL HAVE BASICALLY BEEN REWRITTEN.  ALL OTHER PLACES THAT
;	TOUCH SYMBOL TABLE POINTERS HAVE BEEN CHANGED TO ACCOUNT FOR THE
;	NEW FORMAT.  NOTE THIS EDIT NEVER REFLECTS CHANGES TO SYMBOL TABLE
;	POINTERS IN THE USER'S ORIGINAL COPY (EXCEPT FILDDT).

;462	PTR	18-APR-84
;	PROHIBIT PATCHING ACROSS SECTION BOUNDARIES.  USE PATCHED SECTION'S
;	.JBFF, NOT SECTION ZERO'S, WHEN NO SYMBOLS EXIST.

;463	PTR	18-APR-84
;	SIMULATE $X OF JRSTF IN SECTION ZERO WHEN RUNNING IN NON-ZERO.

;464	PTR	19-APR-84
;	PRESERVE SECTION NUMBER OF PATCH SYMBOL.

;465	PTR	19-APR-84
;	PERMANENTLY WRITE-ENABLE BREAKPOINT BLOCK WHEN DOING AN $X,
;	SO THE "SOS FOO" DOESN'T CAUSE AN ILL MEM WRITE.
;466	PTR	23-APR-84
;	IMPLEMENT $$:/TEXT/ TO LOOK UP FIRST PDV WITH NAME TEXT AND
;	SET $5M TO ITS ADDRESS.  USER-FRIENDLY VERSION OF $5M.
;	$$1: TYPES OUT CURRENT PDV NAME IF ANY.

;467	PTR	23-APR-84
;	FIX [461] SO DEFINING NEW SYMBOLS WORKS.

;470	PTR	24-APR-84
;	NEW ROUTINE INCSYP TO UPDATE INTERNAL SYMBOL TABLE POINTERS AS
;	WELL AS USER'S ORIGINAL POINTERS (EXCEPT FILDDT, WHICH UPDATES
;	POINTERS ONLY ON CLOSE).

;471	PTR	25-APR-84
;	FIX SYMCHK TO ALWAYS SET ESTUT (PREVENTS STARTUP PROBLEMS).

;472	PTR	27-APR-84
;	HAVE TTYSAV CALL SYMCHK, SO POINTERS WILL REALLY BE SET UP
;	ON ENTRY.  THAT WAY IF THE FIRST THING THE USER DOES IS "$5M/"
;	IT WILL ALREADY BE SET UP.  MAKE AN EFFORT TO KEEP TOPS-10 EDDT
;	WORKING WITH THIS (NOT TESTED).  NUDGE CONDITIONALS TO PREVENT
;	SOME UNDEFINEDS.

;473	PTR	30-APR-84
;	BYTE POINTERS GIVEN TO A JSYS IN SECTION ZERO MUST BE 1-WORD LOCALS.

;474	PTR	 1-MAY-84
;	TURN ON FTPAGM IN -20 EXEC MODE.

;475	PTR	 3-MAY-84
;	LOOK FOR HISEG TABLE EVEN IF POINTERS ARE STUFFED.

;476	PTR	 7-MAY-84
;	TEACH INCSYP ABOUT 0$5M.  DON'T CALL SYMCHK SO OFTEN (DEPRA).
;	LET FILDDT READ DUMPS AGAIN.  MAKE ERROR MESSAGE IF USER TRIES TO
;	CREATE A PAGE WHEN $$1W.

;477	PTR	 8-MAY-84
;	FIX $NM (OTHER THAN $5M) IN FILDDT TO LOOK LIKE IT ALWAYS DID.

;500	PTR	 8-MAY-84
;	IF DDT IN NON-ZERO, PC IN ZERO, XMOVEI BECOMES PC REF INSTRUCTION.
;	(XMOVEI 1,0 WOULD RETURN 1,,0 INSTEAD OF 0,,0.)
;	FIX TYPEOUT OF XMOVEI 1,0 SO 0 TYPES OUT.

;501	PTR	 9-MAY-84
;	SWITCH MONITOR DDTS BACK TO USING EDV ([430] AND OTHERS HAD THEM
;	USING JOBDAT).  MAKE TTYRE6 LOOK MORE LIKE V42.

;502	PTR	12-MAY-84
;	MAKE SYMCHK SET .JBUSY IF CREATING AN UNDEFINED SYMBOL POINTER
;	OUT OF THIN AIR (JOBDAT ONLY).  MAKE IOWBLK WORK FOR MONITORS.
;	MAKE SURE SYMBOL BLOCKS CLEARED IF NO POINTERS FOUND.
;503	PTR	14-MAY-84
;	IN SAVEG, DON'T SET LLOCS IF IN AN $X SITUATION (SCREWED UP
;	HISEG SYMBOL TABLE).  FIX BUG IN [502].  DON'T MAKE TTYSAV CALL
;	SYMCHK, IT'LL HAPPEN TOO OFTEN -- CALL SYMCHK DIRECTLY WHEN DDT
;	IS STARTED.  DON'T NEED TO ON BREAKPOINT, DISPLAY ROUTINES WILL
;	TAKE CARE OF IT.

;504	PTR	22-MAY-84
;	MAKE UDDT-20 LIVE IN ITS OWN SECTION.  CREATE AN "EXPORT" VECTOR
;	TO BE POINTED TO BY DDT'S PDV.  KEEP DDT FROM FINDING ITS OWN
;	PDV UNLESS RUNNING ALONE IN THE FORK (DETERMINED VIA ENTRY VECTOR).
;	DEFAULT LLOCS TO STUB'S SECTION OR ENTRY VECTOR SECTION (USER-20)
;	OR DDT'S SECTION (MONITOR-20, ALL-10).

;505	JM	31-MAY-84
;	GET DDT TO UNDERSTAND $N"C$ AND $N"/.../ SYNTAX.  REPLACE PEEK
;	JSYS WITH XPEEK% IN FILDDT.

;506	PTR	 5-JUN-84
;	FIX OVERFLOW AT NUM+10.  FIX 3.2E2$F; BUG.  MAKE SURE WE HAVE
;	AN IFIW AT HIDPD1.  ONLY LOOK IN DDT'S SECTION FOR ITS PDV.

;507	PTR	 5-JUN-84
;	TEACH CODE AT UND1, DEF5, AND DEPRA THAT UNDEFINED SYMS HAVE 30-BIT
;	ADDRESS VALUES, SO FIXUPS CAN BE OUTSIDE SYM TAB'S SECTION.
;	CHAINS STILL CAN'T CROSS SECTION BOUNDARIES THOUGH.
;	FIX WHERE [505] BROKE $$: COMMAND.

;510	PTR	 7-JUN-84
;	SUPPORT ERJMPR/ERCALR/ERJMPS/ERCALS IN $X CODE.

;511	PTR	 7-JUN-84
;	TURN HIDPDV INTO ONCE-ONLY CODE TO PROTECT OURSELVES AGAINST OLD LINKS.
;	DDT 43 WILL GO OUT BEFORE LINK 6 SO WE HAVE TO BE CAREFUL.

;512	PTR	 8-JUN-84
;	SPLIT THE "DANGEROUS OPCODE" TABLE INTO TWO PARTS, THE MEMORY MUNGERS
;	AND THE TRULY DANGEROUS.  MEMORY MUNGERS FORCE RECHECK OF SYMTAB,
;	TRULY DANGEROUS GET FULL ENVIRONMENT AND BREAKPOINTS AROUND THE XCT.
;	RESTORE TEMP DISPLAY MODES AT TELLX, SINCE DANGEROUS XCT SMASHES THEM.

;513	PTR	 8-JUN-84
;	$G WOULDN'T WORK FOR A TOPS-10 STYLE ENTRY VECTOR IN A NON-ZERO SECTION.
;	MAKE IT LOOK AT <ENTRY VECTOR SECTION>,,.JBSA INSTEAD OF 0,,.JBSA TO
;	DETERMINE THE SECTION-RELATIVE START ADDRESS.

;514	PTR	12-JUN-84
;	$X OF A DANGEROUS INSTRUCTION FROM SECTION ZERO MUST BE EXECUTED
;	IN ZERO SO ANY GENERATED TRAP/INTERRUPT CAN BE DEALT WITH BY A
;	SECTION ZERO HANDLER.

;515	JM	13-JUN-84
;	FILDDT(TOPS-20):  ADD "ENABLE THAWED" COMMAND AND "GET <FILE>/THAWED"
;	OPTION.  OPEN FILE FOR UNRESTRICTED READ ACCESS WHEN READ ONLY.
;516	PTR	14-JUN-84
;	ADD XMOVEI AND XHLLI TO THE HARDWARE OPCODE TABLE, PERSERVING
;	HLLI AND SETMI FOR TYPEIN.

;517	PTR	14-JUN-84
;	IMPLEMENT $1: COMMAND TO TYPE OUT CURRENT OPEN MODULE (GIVEN IN
;	LAST $: COMMAND).

;520	JM	14-JUN-84
;	IMPLEMENT $1T COMMAND TO SET BYTE POINTER TYPEOUT MODE.

;521	PTR	15-JUN-84
;	REDO $XBLK NOT TO USE SOS'S, SINCE SOS CAN CHANGE USER'S FLAGS.
;	FIX DANGEROUS JRST'S (E.G. XJEN) TO SET DANGEROUS FLAG.
;	HANDLE LUUO'S OUTSIDE SECTION ZERO ON TOPS-20.

;522	PTR	15-JUN-84
;	CLEAN UP WHAT KINDS OF $$? ARE LEGAL IN WHAT FLAVORS.

;523	PTR	18-JUN-84
;	MAKE XDDT BE PSECTED LIKE UDDT WAS (SO CODE PSECT IS WRITE-LOCKED).
;	FIX HIDPDV SO XDDT CAN MODIFY THE (WRITE-LOCKED) PDV, AND SO RDDT
;	WON'T FALL OVER DEAD IN A USER PROGRAM.

;524	PTR	20-JUN-84
;	ON TOPS-20, IF A SECTION ZERO PROGRAM USES OLD-STYLE PSI TABLES TO
;	TRAP PAGE CREATES (E.G. PA1050) AND DDT CAUSES A PAGE CREATE FROM
;	OUTSIDE SECTION ZERO, THE MONITOR TERMINATES THE PROCESS SINCE THE
;	SECTION ZERO TABLE HAS NO PLACE FOR A 30-BIT PC.  TURNING OFF THE
;	PSI SYSTEM ONLY DEFERS THE INTERRUPT, WE MUST ACTUALLY DEACTIVATE
;	THE CHANNEL TO PREVENT TERMINATION.

;525	PTR	20-JUN-84
;	MISCELLANEOUS MINOR FIXES, MOSTLY COSMETIC.  UNDEFINE FLAG POWF
;	(BIT 24) SINCE IT WASN'T DOING ANYTHING USEFUL.

;526	JM	20-JUN-84
;	MOVE THE ROUTINE "TBPNT" OUT OF SINGLE STEPPING CODE INTO GENERAL
;	TYPEOUT SECTION.  THIS WILL MAKE EDIT 520 WORK FOR FILDDT.

;527	PTR	22-JUN-84
;	REDO $X SOME MORE TO LET $X OF ERSTR% JSYS WORK.

;530	JM	25-JUN-84
;	SET DEFAULT SECTION WITH $V, $G, $B, $W, $N, $E, $Z, AND $U.

;531	JM	26-JUN-84
;	MAKE $Z CONSISTENT WITH $W, $N, AND $E IN SETTING "." TO THE LAST
;	LOCATION ZAPPED.

;532	PTR	26-JUN-84
;	CLEAN UP REFERENCES TO SECUDD, ONLY USE IT IN USER DDT.
;	SINCE FETCHL NOW USED ONLY TO CHASE JOBDAT STUFF, MAKE IT RETURN
;	FAILURE IF SYTLOC INDICATES A PDV.
;533	PTR	26-JUN-84
;	CLEAN UP SYMBOL STUFF IN EDDT SO USER MODE EDDT IS MORE LIKE NORMAL
;	USER DDT.  MAKE GEVECS SKIP IF ENTRY VECTOR EXISTS, NON-SKIP IF NOT.
;	FIX SOME SYMBOLS SO DDT STILL ASSEMBLES FOR TOPS-10.
;	HAVE TOPS-20 MONITOR DDTS CHECK MONPDV IN CASE TOPS-20 HAS A PDV.

;534	JM	27-JUN-84
;	SAVE THE STATE OF THE COMF FLAG FOR OBJECTS SCANNED BY THE SYNTAX
;	"LOWER<UPPER>".  USE THIS INFORMATION IN SECTION DEFAULTING FOR THE
;	COMMANDS $Z, $E, $W, AND $N.

;535	JM	29-JUN-84
;	EXECUTE THE CONDITIONAL BREAKPOINT INSTRUCTION IN THE SECTION OF THE
;	BREAKPOINT.

;536	PTR	 2-JUL-84
;	DON'T FORCE SECTION-REF $X TO BE DANGEROUS.  CLEAR I.CJMP FLAG IN THE
;	CONDITIONAL BREAKPOINT INSTRUCTION CODE.

;537	PTR	 2-JUL-84
;	KEEP XDDT FROM INCORRECTLY REMEMBERING TTY STATE AFTER ONCE-ONLY CODE.

;540	JM/PTR	 3-JUL-84
;	PARSE SIGNED EXPONENTS CORRECTLY IN FLOATING POINT TYPEIN.  BAD
;	BEHAVIOR ASCRIBED TO EDIT 506.

;541	PTR	 5-JUL-84
;	FIX HIDPDV TO HANDLE LINK 5.1 CASE CORRECTLY.

;542	JM	 9-JUL-84
;	MAKE LEFT HALF OF ACCCF A DOUBLE COMMA FLAG SO THAT DEFAULT SECTIONING
;	WORKS PROPERLY WITH <TAB> AND "\".  (CF. TOPS-10 MAINTENANCE VERSION)

;543	PTR	10-JUL-84
;	IN DEPMEM WHEN WRITE-ENABLING A PAGE, TURN ON FH%EPN SO REFS TO
;	SECTION 0 WORK.

;544	PTR	10-JUL-84
;	FIX INCSYP ET AL. TO NOT INVALIDATE THE SYMBOL POINTER THEY JUST
;	UPDATED.  ALSO DO BETTER ERROR CHECKING IN DEFIN:.  THIS MAKES
;	DEFINING NEW SYMBOLS WORK (BROKEN SINCE [470]).
;	DON'T CHECK FOR INDIRECTION IN PDV OR SYMBOL VECTOR, ADDRESSES
;	MUST BE EITHER "IFIW LOCAL-ADDR" OR "GLOBAL-ADDR".

;545	PTR	11-JUL-84
;	FIX DEF5 NOT TO STOMP ON W1 (NEEDED FOR THE CALL TO REMUN).  THIS
;	WILL CAUSE DEFINING UNDEFINED SYMBOLS TO WORK AGAIN.
;	REPLACE SAVE OF W DONE IN SYMCHK (REMOVED BY 544).

;546	PTR	11-JUL-84
;	IN WRTSYM, DON'T CHECK FOR HISEG SYMTAB IF PDV.

;547	JM	11-JUL-84
;	GET/SET CORRECT DEFAULT SECTION FOR EFFECTIVE ADDRESS SEARCH.
;550	PTR	13-JUL-84
;	MAKE REFS TO TOPS-20 DATA/CODE BE GLOBAL REFS TO SECTION 1 WHERE
;	NECESSARY, SO SEC. 1 DOESN'T NEED TO BE MAPPED TO DDT'S SECTION.

;551	PTR	17-JUL-84
;	FIX $D SO YOU CAN SUPPRESS THE FIRST SYMBOL IN THE TABLE.

;552	PTR	19-JUL-84
;	MAKE SURE DDTSYV POINTS TO SYMTAB LOCALLY.

;553	PTR	19-JUL-84
;	ADD AN ERJMP AFTER THE PDVOP% IN PDVSE2, JUST IN CASE.
;	.POLOC CAN BE PRONE TO CAUSING ILL INSTR TRAPS.

;554	JM	23-JUL-84
;	SET FLOATING DEFAULT SECTION WHEN OPENING LOCATIONS VIA THE LOCATION
;	SEQUENCE STACK.

;555	PTR	23-JUL-84
;	TRY DOING A PEEK IF XPEEK% FAILS (SO FILDDT WILL RUN ON 5.1 SYSTEMS).

;556	PTR	25-JUL-84
;	IF RESTOR IS GOING BACK TO SEC. 0 AND THE PSI NEEDS TO BE TURNED
;	BACK ON, DON'T DO IT TILL WE'RE ALREADY IN SEC. 0.  THAT WAY DEFERRED
;	INTERRUPTS WON'T CAUSE THE FORK TO HALT.  DON'T BOTHER TREATING
;	PAGE-CREATES AS A SPECIAL CASE ANYMORE (REMOVE [524]).
;	MAKE ^Z RETURN TO THE STUB IF THERE IS ONE (SO PA1050 WILL SEE A HALT
;	PC IN SEC. 0).  EDIT 6 OF UDDT.MAC MUST BE INSTALLED.

;557	JM	 2-AUG-84
;	FILDDT:  IF A LOCATION IS OPENED WITH AN EXPLICIT SECTION TYPED IN,
;	USE THAT SECTION VALUE TO SET THE FLOATING DEFAULT SECTION.  ALSO,
;	DON'T SET THE FLOATING DEFAULT SECTION IF AN ACCUMULATOR IS POPPED
;	OFF OF THE LOCATION SEQUENCE STACK.

;560	PTR	 2-AUG-84
;	RESERVE A FULL 100 WORDS FOR THE BREAKPOINT BLOCK.  MAKE SYMBOLS
;	FOR PC FLAGS.  DON'T REF SECUDD IN EDDT.

;561	PTR	 8-AUG-84
;	MOVE DEFINITION OF SKPUSR ETC. TO AFTER THE .PSECT STATEMENT (SO
;	KDDT CAN BE LOADED IN A NON-ZERO SECTION, AND NOT HAVE THE OPDEFS
;	GET FIXED UP WITH SECTION NUMBERS).

;562	PTR	10-AUG-84
;	REDO $X OF PUSH(J) SO WE DON'T USE STACK MEMORY BEFORE ALLOCATING
;	IT IN THE STACK POINTER.  CAN KILL US IF PSI TRAPS WAITING.

;563	PTR	11-AUG-84
;	MAKE BUNCHES OF EDDT REFS TO EPT (AND OTHERS) BE INDIRECT INSTEAD
;	INDEXED.  THEN THE EPT DOESN'T HAVE TO BE IN EDDT'S SECTION.

;564	PTR	13-AUG-84
;	[461] INADVERTENTLY REMOVED THE LENGTH CHECK FROM CHKSYP.  PUT
;	IN A LENGTH CHECK.
;565	PTR	16-AUG-84
;	ADD FAKDDT ROUTINE TO KDDT.  CALLED DIRECTLY BY MONITOR AFTER KDDT
;	HAS CHANGED SECTIONS, SO BREAKPOINTS BREAK TO PROPER PLACES.

;566	JM	23-AUG-84
;	DEFSEC:  WHEN AN EXPLICIT SECTION IS TYPED IN (EITHER WITH ",," OR BY
;	USING A SYMBOL WITH A SECTION NUMBER IN THE LEFT HALF, ALWAYS SET THE
;	DEFAULT SECTION, EVEN WHEN REFERENCE IS MADE TO AN ACCUMULATOR
;	(E.G. 1,,7).

;567	PTR	23-AUG-84
;	MAKE KDDT USE MONEDV IN PREFERENCE TO JOBDAT, EVEN IN USER MODE.

;570	PTR	 7-SEP-84
;	PREVENT PAGE CREATES FROM GENERATING PAGE-CREATE INTERRUPTS.  THIS
;	IS SO CREATING THE PAGE WHERE THE BREAKPOINT BLOCK SITS DOESN'T MAKE
;	TROUBLE.  THIS ALSO ALLOWS THE USER TO CREATE RANDOM PAGES WITHOUT
;	CAUSING AN INTERRUPT (FORMERLY, CREATING A PAGE WOULD CAUSE AN
;	INTERRUPT WHICH MOST LIKELY WOULD BE ASYNCHRONOUSLY HANDLED/REPORTED).

;571	JM	10-SEP-84
;	NEVER "FIX UP" A BLT INSTRUCTION FOR SINGLESTEPPING.  ADD THE SPECIAL
;	ENTRY "FETCHI" TO THE "FETCH" PROCEDURE.  "FETCHI" IS FOR FETCHING
;	INSTRUCTIONS, AND IT TREATS MEMORY ADDRESSES WITH RIGHT HALF IN THE
;	RANGE 0 THROUGH 20 AS ACCUMULATOR ADDRESSES.

;572	JM	10-SEP-84
;	MONITOR EDDT RUNNING IN USER MODE WILL NOT ATTEMPT TO LEAVE SECTION 0
;	IF IT SHOULD HAPPEN TO FIND ITSELF THERE.

;573	JM	10-SEP-84
;	WHEN PRINTING AN IFIW SECOND WORD OF A 2-WORD BYTE POINTER DISPLAY
;	"<2>" AS WITH AN EFIW WORD.

;574	PTR	12-SEP-84
;	USER-MODE KDDT SHOULD REF MONPDV IN SECTION ZERO, NOT SECTION 1.

;575	PTR	13-SEP-84
;	USER-MODE KDDT SHOULD BE MORE LIKE USER DDT.  DO NORMAL PDV
;	SEARCHING FOR 6.1, STILL WIND UP WITH JOBDAT IN 6.0.

;576	PTR	13-SEP-84
;	GIVE SINGLE-STEP $X AND INSTR$X DISTINCT PORTIONS OF THE BREAKPOINT
;	BLOCK, SO THEY DON'T INTERFERE WITH ONE ANOTHER (WILL HAPPEN IF
;	"CALL FOO$X" AND FOO HAS A BREAKPOINT IN IT).  REQUIRES RECLAIMING
;	THE BREAKPOINT BLOCK SPACE RESERVED FOR BREAKPOINT 0 (WHICH WILL
;	NEVER BE USED).

;577	PTR	19-SEP-84
;	IN FILDDT, CHECK FOR THE LAST EXISTING PAGE IN THE FILE INSTEAD OF
;	ALWAYS USING THE MAXIMUM POSSIBLE LENGTH.  THAT WAY SEARCHES ETC.
;	WILL STOP AT "REAL EOF."
;600	PTR	26-SEP-84
;	SPEED UP FNDPAG, FPVPG AND FRIENDS BY TRYING TO GUESS WHAT THE
;	VIRTUAL PAGE IS GOING TO BE, INSTEAD OF PLODDING THROUGH EVERY
;	PAGE EVERY TIME.

;601	PTR	27-SEP-84
;	ADD "FOO$?" COMMAND TO TYPE ALL SYMBOLS BEGINNING WITH CHARS "FOO".

;602	JM	29-SEP-84
;	IF DDT WAS STARTED FROM THE STUB (UDDT) AND $5M POINTS TO JOBDAT IN
;	THE SAME SECTION OR $5M IS 0, CHECK FOR STUFFED SYMBOL TABLE VALUES
;	ON EACH PASS THROUGH SYMCHK.

;603	PTR	10-OCT-84
;	ADD NEW $L COMMANDS TO TYPE OUT SECTION/PAGE ACCESSES.

;604	PTR	10-OCT-84
;	REVISE [600] SO ONE NEED NOT SUPPLY A GUESS TO FPVPG.

;605	PTR	15-OCT-84
;	CALL LISTEN DURING "FOO$?" SO USER CAN ABORT HIS FOOLISH CHOICE OF
;	PREFIX CHARACTERS.

;606	PTR	18-OCT-84
;	HAVE FILDDT-20 PARSE UNIT, CHANNEL, CONTROLLER NUMBERS IN DECIMAL
;	INSTEAD OF OCTAL.

;607	PTR	18-OCT-84
;	GROW DATA PAGES TO THREE, INCREASE STACK SIZE SO MDDT WON'T
;	FALL OVER FROM DECNET, REVERT MDDT TO LOCAL STACK POINTER IN 6.1.

;610	PTR	18-OCT-84
;	FIX HIDPDV AGAIN SO $W DEFAULT IS PRESERVED.

;611	PTR	22-OCT-84
;	FIX $L NOT TO REPORT BOTH WRITE AND COPY-ON-WRITE FOR THE SAME PAGE.

;612	JM	22-OCT-84
;	DEFINE A GENERAL PURPOSE CHECKPOINT FOR MDDT, AND INSTALL IT AROUND
;	THE BREAKPOINT BLOCK.

;613	PTR	31-OCT-84
;	FIX [600]/[604] AGAIN.

;614	JM	 7-NOV-84
;	CORRECT MDDT INTERLOCK LOGIC (CF. [612]); ALSO MIGRATE TBPNT TO WORD
;	TYPEOUT ROUTINES FROM COMMAND ROUTINES.

;615	JM	 9-NOV-84
;	IF NO ENTRY VECTOR IN FORK, USER DDT20 SETS $5M TO -1,,0 RATHER THAN
;	-1,,SECDDT.  VT2XX COMPATIBILITY FEATURE:  "`" WORKS LIKE "<ESC>".

;616	PTR	12-NOV-84
;	MAKE "ADDR$0T" DO DEFAULT SECTIONING.
;617	PTR	12-NOV-84
;	MINOR BUGS IN FOO$? COMMAND.

;620	JM	16-NOV-84
;	USER DDT:  IF NO ENTRY VECTOR AND NO STUB, SET FLOATING DEFAULT
;	SECTION TO 0 ON ENTRY.  ANALOGOUS TO [615].

;621	RCB/PTR	 6-DEC-84
;	ALLOW TYPEOUT AND TYPEIN OF N-BIT ASCII STRINGS.  $NT AND $N"
;	NOW ALLOW N FROM 5 THRU 36 (DECIMAL).

;622	JMF/PTR	 6-DEC-84
;	PREVENT CLOBBERING PREVIOUS-CONTEXT SECTION WHEN JUMPING INTO
;	NON-ZERO SECTION IN EDDT.

;623	DPM/PTR	 6-DEC-84
;	FIXES TO $L: MAKE SURE NOT IN SYMBOL SPACE IN TOPS-10 EXEC MODE,
;	DON'T MAKE RASH ASSUMPTIONS ABOUT LOWSEG IN CHKADR, DO MORE
;	RATIONAL ARG CHECKING IN FILDDT.

;624	JM	 8-DEC-84
;	FIX SINGLESTEP OF ILDB/IDPB WITH LOCAL ACCUMULATOR REFERENCE TO BYTE
;	POINTER.	

;625	PTR	12-DEC-84
;	SPEED UP CHKADR IN FILDDT-20 BY NOT DOING AN RPACS% ON EVERY
;	CALL.  INSTEAD DO THE RPACS% WHEN THE PAGE IS MAPPED IN AND
;	REMEMBER THE BITS.  THIS WINS BIG ESPECIALLY IN SEARCHES WHEN
;	THE USER HAS SPECIFIED SOME KIND OF MAPPING (E.G. EP$U).

;626	PTR	22-MAR-85
;	FIX TEXTNT TO NOT TYPE GARBAGE FROM THE LEFTOVER BITS IN THE WORD.

;627	JM	10-APR-85
;	TEXTNT TYPES OUT LEFT-JUSTIFIED BYTES ONLY.

;DDT %43(627) SHIPPED WITH TOPS-20 6.1

;630	PTR/RCB/RDH	25-SEP-85
;	FOR TOPS-10, IF .JBSYM .GT. 0 THEN IT IS THE GLOBAL ADDRESS OF A
;	SYMBOL TABLE VECTOR.  DITTO $5M.  LOOK FOR TOPS-10 ENTRY VECTOR
;	ON $G.  FIX UP $L, $Y COMMANDS.  CHKADR, FETCH, STORE CAN SEE
;	BEYOND SEC. 0 FROM SEC. 0 (TOPS-10 EDDT ONLY).  FIX EXEC-MODE CHKSEC.

;631	RCB	 3-OCT-85
;	MAKE DEFAULT PAGING BE KL ALWAYS.  ADD BLTBU/BLTUB TO $X (KS-10).

;632	RDH	7-OCT-85
;	MAKE IO INSTRUCTION TYPEOUT PAY ATTENTION TO CPU TYPE (KS HAS DIFFERENT
;	IO INSTRUCTION SET).  ADD $20/21/22/23U TO SET KA/KI/KL/KS CPU TYPE.

;633	RDH/PTR	 8-OCT-85
;	MAKE SYMBOL "$NB" GLOBAL AS # BREAKPOINTS AVAILABLE (EDDT-10 ONLY);
;	ENHANCE BREAKPOITN INSERT/REMOVE TO DEAL WITH ERRORS (PARTICULARLY
;	BREAKPOINTS THAT MOVED); ONLY TYPE ONE ERROR MESSAGE PER BREAKPOINT
;	FAILURE.

;634	RDH	29-OCT-85
;	MAKE DDT %43 WORK ON TOPS-10 (ASSORTED TYPOS, ETC.). *NEVER* INSERT
;	BREAKPOINTS ON $X (IT CAN'T WORK). IF AN $4M BLOCK HAS BEEN SPECIFIED,
;	UNCONDITIONALLY USE IT (ALWAYS 3-WORD JSR'S, ETC.), OTHERWISE VERIFY
;	THAT DDT IS MAPPED INTO THE APPROPRIATE SECTION AND BLINDLY JUMP
;	INTO THAT SECTION FOR $X'ING. ALLOW NZS REFERENCES FROM SECTION ZERO
;	(RENAMES NZSXCT INTO PZAFI, CALLED LIKE PCAFI; RENAMES DEFSEC INTO
;	CEFFAS). FIX $L. IF NZS SYMBOL TABLE(S) AND DDT IN SECTION 0 THEN
;	TRY FOR NZS, MAPPING SECTION 0 INTO SECTION 1 (USER MODE ONLY) IF
;	POSSIBLE. MAKE <INSTR>$$NX TRY TO EXECUTE THE INSTRUCTION IN SECTION
;	"N" (IF BLANK, THEN OK TO EXECUTE IN DDT SECTION). ALLOW BOTH .JBSYM
;	AND .JBHSM TO POINT TO GLOBAL SYMBOL VECTOR ADDRESS (BUT UNDEFINEDS
;	ONLY FROM .JBSYM).

;635	RCB	9-JAN-86
;	FIX $X OF NZS LUUO (TOPS10). FIX USAGE OF ENTVC. UUO (TOPS10)
;	IN PARTICULAR TO HELP LOCATE USER'S SYMBOL TABLE FOR RUN/USE:N WHERE
;	PROGRAM CAN GET "RELOCATED" TO DIFFERENT SECTION.

;636	RDH	10-JAN-86
;	$M, $I, AND $U DON'T RETURN ADDRESS AS VALUE (EDIT 333 LOST).

;637	RDH	11-JAN-86
;	FILDDT CAN'T UPDATE 7.03 EXE FILE SYMBOL TABLE.

;640	RDH	19-JAN-86
;	MAKE THE "N" OF $NM AND $NI COMMANDS BE *DECIMAL*.

;641	PTR	30-JAN-86
;	MAKE CEFFAS DEAL WITH IMPOSSIBLE SECTION NUMBERS A BIT BETTER.
;	MAKE <INSTR>$X ALWAYS EXECUTE IN THE DEFAULT SECTION, INSTEAD OF
;	SOMETIMES IN DDT'S SECTION.

;642	RDH	4-MAR-86
;	MAKE TAG DEFINITIONS TAKE FULL 36-BIT VALUE, RATHER THAN JUST THE
;	RIGHT-HALF (18-BIT) VALUE OF "."

;DDT %44(642) Released with TOPS10 version 7.03, Spring 1986

;643	RDH	12-Apr-86	QAR 869027
;	$4M falls off end of literal, Ill Mem Refs (typo in [636]).

;DDT %44A(643) Released on Autopatch tape 14, Summer 1986

;644	RCB	1-Jul-86
;	Introduce $X to PMOVE & PMOVEM.  Add them to the opcode tables.

;645	RCB	10-Jul-86
;	Fix effective address calculation wrt global references to ACs.
;	Needed for LUUO handlers and $1T typeout.

;646	RCB	11-Jul-86
;	Fix some problems with supporting $$Y.  Only changes the I/O setup,
;	doesn't add any logic for interpreting .SYM files.

;647	RCB	11-Jul-86
;	Prepare for further changes to TOPS-10 entry vector format by allowing
;	IFIW as well as global address in $[n]G.

;650	RCB	11-Jul-86
;	I don't know what the authors of 626 & 627 meant to accomplish, but
;	those edits broke the symmetry of $nT with $7T.  Restore it, this
;	time correctly.

;651	RCB	15-Jul-86
;	Finally teach EDDT about CPNDDT.  Accomplished via new EDV words:
;	.EDCPN (physical address of CPNDDT) and .EDCPU (AOBJN-style pointer
;	to table of APR serial numbers).

;652	RCB	15-Jul-86
;	Finally teach FILDDT about the EDV.  This allows FILDDT to set up
;	mapping on a crash dump (if MCO 12993 is installed).  Requires EDV
;	word .EDCAC (pointer to crash ACs).

;653	RCB	16-Jul-86
;	Enhance foo$? (ABBREV) to accept LLIMIT, ULIMIT, and WRD2O for
;	additional constraints upon symbol value, flags, and module.
;	$1? will dump the open module (error if none).  $4? will dump only
;	globals.  $40? will dump only half-killed symbols.  The 74 mask
;	is anded and then compared.  2 is reserved.  LLIMIT and ULIMIT are
;	used in the obvious fashion for restricting possible values of
;	symbols to be displayed.

;654	RCB	19-Sep-86
;	Fix up changing sections for NZS symbol table access to account for
;	the fact that the flags are changed by PUSHJ, and hence not always
;	what we expect at the first entry in PDL.

;655	RCB	30-Sep-86
;	Fix up changing sections for $X of pc-reference instructions.  Always
;	do RESTOR/SAVE (rather than SWAP) so that SECDDT and the various
;	SKPS0/SKPNS0 side-effects will be right.

;656	DPM	30-Sep-86
;	Enhance FILDDT-10 by making it type the filespec being examined
;	or patched like the -20 version does.  Also type filespec of
;	file being yanked and the number of symbols loaded.

;DDT %44B(656) released on Autopatch tape 15, Fall 1986

;657	RCB	4-Nov-86
;	Fixup symbol table information typed out by $1: in FILDDT.

;660	RCB	21-Nov-86
;	Fix 0$nB in non-zero sections not to set 1,,0 as the B.P. address.

;661	RCB	6-Jan-87
;	Fix global breakpoints using the breakpoint block not to assume the
;	JSR came from section 0.

;662	RCB	16-Jan-87
;	Fix hidden symbol processing problems with TOPS-10 EDDT, especially
;	for SMP.  This has the side-effect of replacing edit 657.

;663	RCB	21-Jan-87
;	Finally physically remove the papertape code.  This finishes edits 247,
;	307, and 322.  FTPTP has been completely removed.

;664	RCB	26-Jan-87
;	Fix up all symbol tables in the ring of EDVs when using hidden symbol
;	processing.  EDDT-10 only.

;665	RCB	 1-Feb-87
;	Fix up $? for NZS DDT examining a program's symbols in S0.

;666	RCB	 6-Mar-87
;	Fix up $X of ILDB/IDPB with byte pointer in an AC and PC not in DDT's
;	section to not increment the B.P. twice.

;667	RCB	 6-Mar-87
;	Fix up for "3/-1,,400<SP><TAB>" nonsense.
;	Don't mistake garbage for an attempt at a DDT internal address, and
;	allow space after a comma to override the left half for section
;	defaulting.

;670	RCB	10-Mar-87
;	Revoke the second half of 667.

;671	RCB	15-May-87
;	Fix PDFSEC.  It gets in TOPS-20's way, too.

;672	RCB	02-Jun-87
;	Fixup some definitions for TOPS-20 to account for the continued
;	existance of 4.1 monitors.

;673	RCB	03-Jun-87
;	672 is incomplete.  Forgot about FILDDT and XPEEK%.  Deal with it.

;674	RCB	28-Aug-87
;	CEFFAS calls too many low core address ACs.  Fix the mask.

;675	RCB	28-Aug-87
;	Default MDDT's initial floating section to MSEC1 rather than to MDDT's
;	own executing section.  Too many problems with ill-advised $X'ing from
;	section 6 happen otherwise.

;676	RCB	26-Feb-88
;	Fix the copyrights for TOPS-20 7.0 and TOPS-10 7.04.

;677	RCB	26-Feb-88
;	Fix problem with building WHO and with the TOPS-10 monitor's symbol
;	table size in general.  Add FTDSYM, debugging symbols, which defaults
;	off for FTEX10 and on for all other cases.  If FTDSYM is off, then
;	all of DDT's local symbols will be expunged at assembly time.

;700	RCB	26-Feb-88
;	Add the clearm<setm>value$nM flavor of $M.  The 'clearm' is a mask
;	to clear and the 'setm' is a mask to set.  The masking arguments
;	are applied after the 'value' argument if it is also present.
;	This applies to $I as well as to $M, but it's more useful for $M.

;701	RCB	26-Feb-88
;	Fix DEPMEM to be able to handle SEGOP. and .PAGWL for 7.04.

;702	RCB	06-Oct-88
;	Add the $$ flavors of searches to type out the number of matches.

;703	RCB	08-Nov-88
;	Finally handle SEGOP.s for 7.04.  $$:/text/ looks for a hiseg named
;	'text' to use for the hiseg symbol table on a -10.  Also handle
;	name$$: appropriately (even for the -20).

;Become version 45 (due mainly to SEGOP.)

;704	RCB	10-Jan-88
;	Fix "c$ (single-character ASCII input).  Probably broken by edit 703,
;	but I'm not sure.

;705	RCB	11-Mar-89
;	Fix $L typeout for spy pages.  They are off by one when adjacent to any
;	(different) existing pages within a section.

;706	RCB	27-Apr-89
;	Fix $L for virtual spy pages.  The virtual bit was getting lost.

;707	RCB	20-Jun-89
;	Fix $$W, $$N, $$E to type match count again.

;710	RCB	20-Jun-89
;	Fix $U in FILDDT on a crash file when the EDV was good.  Re-use the EDV
;	information rather than reverting to $$U.

;711	RCB	21-Jun-89
;	Fix $L in FILDDT for a .EXE file with mapping in use.  Don't compare
;	virtual page numbers against physical limits.  Translate first.

;712	RCB	22-Jun-89
;	Clean up some symbol definitions (PC$xxx and PG$xxx) by borrowing SYSPRM
;	from GLXMAC.

;713	RCB	23-Jun-89
;	Add FTPURE for starting to do XDDT on the -10.

;714	RCB	23-Jun-89
;	Make $G and ^Z clear BPTIP so that we won't allow $X after a restart.

;715	RCB	18-Sep-89
;	Fix reference to JOBEDV in FILDDT startup (broken on TOPS-20).
SUBTTL	DDT ASSEMBLY SWITCHES

;SWITCHES FOR DDT FEATURES

;FTDEC10	;TOPS-10 FACILITIES
;FTDEC20	;TOPS-20 FACILITIES
;FTEXEC		;EXEC MODE FACILITIES (ALSO RUNS IN USER MODE)
;FTEX20		;TOPS-20 MONITOR EDDT (LOADS ONLY WITH TOPS-20 MONITOR)
;FTFILE		;FILE DDT
;FTYANK		;PAPER TAPE INPUT FACILITIES ($Y)
;FTVMX		;BUILD DDT.VMX FOR TOPS-10 VIRTUAL MEMORY
;FTMON		;TOPS-20 MONITOR DDT
;FTOPX		;EXTENDED OPCODE DECODING FOR TYPEOUT
;FTDBUG		;DEBUGGING FACILITIES FOR DDT ITSELF (ESP EXEC MODE)
;FTPAGM		;PAGE MAPPING FEATURES
;FTSCSH		;SYMBOL TABLE CACHE
;FTUD20		;TOPS-20 USER DDT (SHORTHAND SYMBOL)
;FTEX10		;TOPS-10 EXEC DDT (SHORTHAND FOR FTDEC10&FTEXEC)
;FTUE10		;TOPS-10 NON-FILE DDT (SHORTHAND SYMBOL)
;FTDSYM		;DEBUGGING SYMBOLS (DDT'S OWN SYMBOLS INCLUDED)
;FTPURE		;READ-WRITE PSECT STARTS OUT EMPTY (TWOSEG ON -10)

IFNDEF	FTDEC10,<
	IFNDEF	FTDEC20,<
		FTDEC10==-1
		FTDEC20==0>>
IFNDEF	FTDEC10,<FTDEC10==0>
IFNDEF	FTDEC20,<FTDEC20==0>
IFNDEF	FTFILE,<FTFILE==0>
IFNDEF	FTYANK,<FTYANK==0>
IFNDEF	FTEX20,<FTEX20==0>
IFNDEF	FTEXEC,<
	IFN FTEX20,<FTEXEC==-1>
	IFE FTEX20,<FTEXEC==0>>
IFNDEF	FTVMX,<	FTVMX==0>
IFNDEF	FTMON,<	FTMON==0>
IFNDEF	FTOPX,<FTOPX==-1>
IFNDEF	FTDBUG,<FTDBUG==0>
IFNDEF FTPAGM,<FTPAGM==FTFILE!FTEXEC!FTDEC10> ;NEVER ON TOPS20 USER MODE
IFNDEF FTSCSH,<FTSCSH==-1>	;HAVE CACHE UNLESS EXCLUDED

;NORMALIZE ALL SWITCH VALUES TO 0 OR -1 SO BOOLEAN EXPRESSIONS IN
;CONDITIONALS WORK CORRECTLY.

DEFINE ..N (SW)<
	IRP	SW,<
  IFN SW,<SW==-1>>>

..N	<FTDEC10,FTDEC20,FTEXEC,FTEX20,FTFILE,FTYANK,FTVMX,FTMON>
..N	<FTOPX,FTDBUG,FTPAGM,FTSCSH>

	FTUD20==FTDEC20&<^-FTEXEC>&<^-FTFILE>&<^-FTMON>	;USER -20
	FTEX10==FTDEC10&FTEXEC			;EDDT-10
	FTUE10==FTDEC10&<^-FTFILE>		;NON-FILE -10

IFNDEF	FTDSYM,<FTDSYM==FTDBUG!<^-FTEX10>>
IFNDEF	FTPURE,<FTPURE==FTMON>		;MDDT INITIALIZES IN THE PSB
..N	<FTDSYM,FTPURE>

  IFN FTDEC10&<FTDEC20!FTMON!FTEX20>,<PRINTX ? Illegal FTDEC10>
  IFN FTDEC20&<FTDEC10!FTYANK!FTVMX>,<PRINTX ? Illegal FTDEC20>
  IFN FTEXEC&<FTFILE!FTVMX!FTMON>,<PRINTX ? Illegal FTEXEC>
  IFN ^-FTEXEC&<FTEX20>,<PRINTX ? Illegal ^-FTEXEC>
  IFN FTFILE&<FTEXEC!FTVMX!FTMON!FTEX20>,<PRINTX ? Illegal FTFILE>
  IFN FTPURE&FTEXEC,<PRINTX ? Illegal FTPURE>
SUBTTL	TITLE SETTING AND UNIVERSAL SEARCHING

	SALL			;CLEAN LISTINGS
	.DIREC	FLBLST		;CLEANER LISTINGS


  IFN FTDEC10,<		;TOPS-10 VERSIONS

	SEARCH	JOBDAT,MACTEN,UUOSYM	;ALL STANDARD TOPS-10 DEFINITIONS

  IFE FTDBUG,<
  IFN FTEXEC,<TITLE	EDDT -- TOPS-10 EXEC MODE DDT>
  IFN FTFILE,<TITLE	FILDDT -- TOPS-10 FILE DDT>
  IFN FTVMX,<
    IFN FTPURE,<TITLE	XDDT -- TOPS-10 EXTENDED DDT>
    IFE FTPURE,<TITLE	VMDDT -- TOPS-10 VM DDT>
  >
  IFE FTFILE!FTEXEC!FTVMX,<
	TITLE	UDDT -- TOPS-10 USER MODE DDT>
  > ;END OF IFE FTDBUG
  > ;END OF TOPS-10 TITLES


  IFN FTDEC20,<		;TOPS-20 VERSIONS

	SEARCH	JOBDAT,MONSYM,MACSYM	;ALL STANDARD TOPS-20 DEFINITIONS

  IFE FTDBUG,<
  IFN FTEXEC&<^-FTEX20>,<TITLE	EDDT -- TOPS-20 EXEC MODE DDT>
  IFN FTEXEC&FTEX20,<TITLE	KDDT -- TOPS-20 MONITOR KERNAL DDT>
  IFN FTFILE,<TITLE	FILDDT -- TOPS-20 FILE DDT>
  IFN FTMON,<TITLE	MDDT -- TOPS-20 MONITOR DDT>
  IFE FTEXEC!FTFILE!FTMON,<TITLE	UDDT -- TOPS-20 USER MODE DDT>
  > ;END IFE FTDBUG
  > ;END OF TOPS-20 TITLES

  IFN FTDBUG,<TITLE	DEBDDT -- DEBUGGING VERSION OF DDT>
	SUBTTL	PROGRAM (JOB CONTEXT) PARAMETERS

  IFN FTFILE!FTVMX,<		;ONLY FILDDTS SET UP VERSION NUMBER
	LOC	.JBVER		;WHERE THE TOPS-10 VERSION INFO GOES
	%%DDT			;SET THE VERSION WORD
	RELOC			;BACK TO NORMAL
  > ;END IFN FTFILE!FTVMX

  IFN FTDEC10,<			;ONLY TOPS-10 USES .JBDDT
    IFE FTFILE,<
	LOC	.JBDDT		;CONTAINS DDT END AND START ADDRESSES
	XWD	DDTEND,DDTX	;SET DDT END AND START ADDRESS
	RELOC			;BACK TO NORMAL
    > ;END IFE FTFILE
				;ONLY TOPS-10 USES .JBBPT
    IFE FTFILE,<		;BUT ONLY IF NOT FILDDT
	LOC	.JBBPT		;WHERE THE BREAKPOINT PROCESSOR GOES
	$0BPT			;ADDRESS OF UNSOLICITED BREAKPOINT HANDLER
	RELOC			;BACK TO NORMAL
    > ;END IFE FTFILE
  > ;END IFN FTDEC10
SUBTTL	MACROS, ETC.

;.PHASE AND .DEPHASE MACRO DEFINITIONS
;NEEDED BECAUSE PHASE AND DEPHASE DON'T NEST
;USE THESE IN ALL CASES INSTEAD OF PHASE AND DEPHASE


	..PLVL==0		;INITIAL PHASE NESTING LEVEL

;MACRO TO REFERENCE THE LAST LOCATION AT PHASE LEVEL N

DEFINE	..PL(N)<..PL'N>		;SYMBOL DEFINED BY .PHASE


;SUBSTITUTE FOR PHASE STATEMENT

DEFINE	.PHASE(N),<

	..==10			;;SAVE RADIX
	RADIX	10		;;MOST LEVELS PER CHAR
	..PL(\..PLVL)==.	;;REMEMBER WHERE WE ARE
	RADIX	..		;;RESTORE THE RADIX

  IFE <..PLVL-^D99>,<PRINTX ? .PHASE NESTING OVERFLOW>
	..PLVL==..PLVL+1		;;BUMP NESTING LEVEL

	PHASE	N
  > ;END OF .PHASE DEFINITION


;SUBSTITUTE FOR DEPHASE

DEFINE	.DEPHASE,<

	..PLVL==..PLVL-1

IFL ..PLVL,<PRINTX ? .PHASE NESTING UNDERFLOW>

IFG ..PLVL,<
	..==10			;;SAVE RADIX
	RADIX	10		;;USE RADIX WE WANT
	PHASE	.+..PL(\..PLVL)	;;BACK TO PREVIOUS PHASE LEVEL
	RADIX	..		;;BACK TO OLD RADIX
>

  IFE ..PLVL,<
	DEPHASE			;;JUST DEPHASE AT OUTER LEVEL
>

  > ;END OF .DEPHASE DEFINITION
;SYMBOLS NOT OTHERWISE DEFINED IN STANDARD UNIVSERALS

;TOPS-10 SPECIFIC

  IFN FTDEC10,<

DEFINE	TMSG(TEXT)<
	OUTSTR	[ASCIZ\TEXT\]	;;DEFINED IN MACSYM FOR TOPS-20
>

  > ;END OF IFN FTDEC10



;TOPS-20 SPECIFIC

  IFN FTDEC20,<

DEFINE	ND(S,V),<IF2,<IFDEF S,<S==S>> IFNDEF S,<S==V>> ;NOT IN MACSYM

ND	.CHCNH,.CHBSP		;THE -10 AND THE -20 USE DIFFERENT NAMES
	IF2	<PURGE .CHBSP>	;DON'T CLUTTER UP THE SYM TABLE

	OPDEF	PJRST	[JRST]	;NOT IN MACSYM
	.NODDT	PJRST		;NO TYPEOUT IN OPCODE FIELD

  > ;END OF IFN FTDEC20

;GENERAL MACROS

;SAVE ERROR MESSAGE STRING FOR POSSIBLE LATER TYPEOUT

;REMOVE IFN FTDEC20
DEFINE SMERS (MSG)<
	PUSH P,[[ASCIZ \MSG\]]
	POP P,MEMERS>

;TYPE LITERAL STRING

DEFINE TSTR (MSG)<
	MOVEI W1,[ASCIZ \MSG\]
	PUSHJ P,TSTRG>

;INIT DDT STACK

IFN FTMON,<
  DEFINE INIPDL<
	MOVEI	P,DDTPGA	;;WHERE MDDT THINKS ITS VARS ARE
	CAIN	P,DDTPXA	;;DIRECTLY MAPPED INTO PSB?
	SKIPA	P,[IOWD	LPDL,PDL] ;;YES, WE CAN USE A LOCAL STACK POINTER
	XMOVEI	P,PDL-1>	;;MDDT STACK PTR IS GLOBAL
> ;END IFN FTMON

IFE FTMON,<
  DEFINE INIPDL<MOVE	P,[IOWD LPDL,PDL]>> ;OTHERS ARE LOCAL
;MDDT CHECKPOINT DEFINITIONS

IFN FTMON,<
  DEFINE CHKIN (%CKLAB) <
	SKIPLE	CHKCNT			;;DO WE ALREADY HAVE THE LOCK?
	JRST	%CKLAB			;;YES
	AOSE	@[MSEC1,,MDDLCK]	;;NO, ATTEMPT TO TAKE LOCK
	JRST [	TSTR	<?MDDT BREAKPOINT BLOCK ALREADY IN USE>
		POPJ	P,]		;;FAIL
	PUSH	P,@[MSEC1,,FORKX]	;;SUCCEED
	POP	P,@[MSEC1,,MDDFX]	;;SHOW THE LOCK IS OURS.
%CKLAB:	AOS	CHKCNT>			;;INCREMENT OUR USE COUNT.

  DEFINE CHKOUT<
	SKIPG	CHKCNT			;;DO WE HAVE THE LOCK?
	JRST	.+3			;;NO, DON'T TOUCH IT.
	SOSG	CHKCNT			;;DECREMENT USE COUNT.
	SETOM	@[MSEC1,,MDDLCK]>	;;GIVE UP THE LOCK.

  DEFINE BRKLCK<
	SKIPG	CHKCNT			;;DO WE HAVE THE LOCK?
	JRST	.+3			;;NO, DON'T TOUCH IT.
	SETZM	CHKCNT			;;YES, CLEAR USE COUNT
	SETOM	@[MSEC1,,MDDLCK]>	;;GIVE UP THE LOCK.

> ;END IFN FTMON
SUBTTL	DDT SYMBOLS

;DEFINE ACCUMULATORS

F=0				;FLAGS
P=1				;PUSH DOWN
R=<A==2>			;POINTERS TO TABLES, CORE, ETC.
S=<B==3>
W=<C==4>			;CONTAINS DISPATCH ADDRESS IN WORD ASSEMBLER
T=5				;TRANSFER DATA
W1=6
W2=7
SCH=10				;MODE CONTROL SWITCH FOR OUTPUT
AR=11				;MODE CONTROL SWITCH FOR OUTPUT
ODF=12				;MODE CONTROL SWITCH FOR OUTPUT - CURRENT RADIX
TT=13				;TEMPORARY
TT1=14				;TEMPORARY
TT2=15				;TEMPORARY
TT3=16				;TEMPORARY

.XCREF	F, P, R, S, W, A, B, C, T, W1, W2, TT, TT1, TT2, TT3	;SAVE SOME PAPER
.XCREF	..DD

  IFN FTDEC20,<
T1=1
T2=2
T3=3
T4=4
P=17				;OVERRIDES P=1 ABOVE

.XCREF	T1, T2, T3, T4, P		;SAVE SOME MORE PAPER
.XCREF	..MX1, ..MX2, ..TX1, ..TX2	;SUPPRESS JUNK SYMBOLS
  > ;END OF IFN FTDEC20

;DEFINE PUSHDOWN LIST LENGTH

	ND	LPDL,400	;400 WORDS IS ENOUGH FOR EVERYBODY
				;(INCLUDING MDDT)

;DEFINE NUMBER OF DATA PAGES (MUST AGREE WITH MONITOR FOR MDDT)

	ND	NDDTPG,3	;HERE TO AVOID MACRO BUG WITH FORWARD REF BELOW
SUBTTL	GLOBAL SYMBOLS FOR USE BY THE OUTSIDE WORLD

  IFE FTFILE,<			;FILDDT HAS NO GLOBAL SYMBOLS

    IFE FTMON,<			;DON'T CONFLICT MDDT WITH EDDT

	ENTRY	DDT		;DEFINE THE MAIN DDT START ADDRESS
				;USED ON "R DDT", "DDT$G", ETC.
      IFN FTEXEC,<

	ENTRY	DDTX		;ENTRY POINT USED BY MONITORS
				;ALSO ON TOPS-10 "DDT" MONITOR
				;COMMAND TO CLEAR $Y IN PROGRESS
      > ;END IFN FTEXEC

	INTERN	DDTEND		;END OF DDT, FOR USERS AND MONITOR

    > ;END IFE FTMON

    IFN FTDEC20,<		;TOPS-20 SPECIFIC DEFINITIONS

      IFN FTUD20,<		;TOPS-20 USER DDT DEFINITIONS
	INTERN	DDTEXP		;"EXPORT" VECTOR FOR STUB
      > ;END IFN FTUD20

      IFN FTEX20,<		;TOPS-20 EDDT DEFINITIONS
	ENTRY	$EDDT		;FORCES LOADING OF EDDT IN LIB SEARCH
	$EDDT==0		;DON'T CARE ABOUT THE DEFINITION
	EXTERN	EDDBLK		;BREAKPOINT BLOCK FOR KDDT
	EXTERN	DDTCZ		;KDDT USER-MODE EXIT ROUTINE
	INTERN	FAKDDT		;RECOVER AFTER CHANGING SECTIONS
      > ;END IFN FTEX20

      IFN FTEX20!FTMON,<	;COMMON TOPS-20 MONITOR DEFINITIONS
	EXTERN	MSEC1		;USEFUL MONITOR SECTION
	EXTERN	MONPDV		;MONITOR'S PDVA IF ANY
      > ;END IFN FTEX20!FTMON

      IFN FTMON,<		;TOPS-20 MDDT DEFINITIONS
	ENTRY	$MDDT		;FORCES LOADING OF MDDT IN LIBRARY SEARCH
	$MDDT==0		;DON'T CARE
	ENTRY	MDDTX		;MDDT EQUIVALENT OF DDTX
	MDDTX=DDTX
	EXTERN	DDTPGA,DDTPXA	;MONITOR'S PLACE FOR MDDT'S VARIABLES
	EXTERN	FORKX,MDDLCK,MDDFX  ;MONITOR BPT INTERLOCK LOCATIONS
	EXTERN	MDDBLK		;BREAKPOINT BLOCK FOR MDDT
	EXTERN	MRETN		;MDDT RETURN ON ^Z
	EXTERN	SWPMWE,SWPMWP	;WRITE-ENABLE/LOCK SWAPPABLE MONITOR
	EXTERN	KIEPT,SPT	;ADDRESSES OF USEFUL TABLES
	INTERN	NDDTPG		;MUST AGREE WITH SPACE IN PSB
      > ;END IFN FTMON
    > ;END IFN FTDEC20
  > ;END IFE FTFILE
SUBTTL	MEMORY ALLOCATION PARAMETERS

;THE FOLLOWING PARAMETERS CONTROL WHERE DDT GETS LOADED.

;RUNLOC		WHERE DDT'S CODE WILL GO AT RUNTIME.  IF NEGATIVE,
;		DDT'S CODE WILL START AT RELOCATABLE ZERO.  THIS
;		PARAMETER IS IGNORED IF FTMON OR FTEX20, SINCE THESE
;		FLAVORS OF DDT GO IN SPECIFIC PSECTS OF THE TOPS-20
;		MONITOR.
;
;VARLOC		WHERE DDT'S VARIABLES WILL GO AT RUNTIME.  IF
;		NEGATIVE, DDT'S VARIABLES WILL IMMEDIATELY
;		FOLLOW THE CODE.  IGNORED IF FTMON OR FTEX20.


;THE FOLLOWING VARIABLES DESCRIBE/REMEMBER DDT'S MEMORY LAYOUT

;BEG.C		THE FIRST LOCATION CONTAINING CODE
;END.C		THE LAST LOCATION CONTAINING CODE + 1
;LEN.C		THE LENGTH OF THE CODE (END.C-BEG.C)
;BEG.V		THE FIRST LOCATION CONTAINING VARIABLE STORAGE
;END.V		THE LAST LOCATION CONTAINING VARIABLE STORAGE + 1
;LEN.V		THE LENGTH OF THE VARIABLE AREA (END.V-BEG.V)
;PHVAR		THE LOCATION INSIDE THE CODE AREA WHERE A PURE
;		COPY OF THE VARIABLE AREA STARTS.
;DDTBEG		THE LOWEST ADDRESS THAT IS PART OF DDT (FOR $$Z CODE)
;DDTEND		THE HIGHEST ADDRESS (+1) THAT IS PART OF DDT


;DEFAULT RUNLOC AND VARLOC

  IFN FTVMX,<
	ND	RUNLOC,700000	;VMDDT DEFAULT ORIGIN
    IFN FTPURE,<ND VARLOC,770000>	;TWOSEG VERSION'S VARIABLES
>

  IFN FTUD20,<
	ND	RUNLOC,740000	;TOPS-20 USER DDT'S DEFAULT ORIGIN
	ND	VARLOC,RUNLOC-NDDTPG*1000	;ORIGIN OF -20 UDDT'S VARS
>

	ND	RUNLOC,-1	;DEFAULT TO RELOCATABLE IF NOT GIVEN
	ND	VARLOC,-1	; . . .
;SETUP TO ALLOCATE DDT'S CODE AT THE RIGHT PLACE

  IFN FTEX20,<
	.PSECT	ERCOD		;-20 EDDT IN EXTENDED RESIDENT CODE
  > ;END IFN FTEX20


  IFN FTMON,<
	.PSECT	ENCOD		;-20 MDDT IN EXTENDED NON-RESIDENT CODE
  > ;END IFN FTMON


  IFE FTEX20!FTMON,<


    IFGE RUNLOC,<


	IFGE VARLOC,<
	IFN FTPURE&FTDEC10,<.PSECT .HIGH.,RUNLOC>	;HISEG ON -10
	IFE FTPURE&FTDEC10,<.PSECT DDTCOD/RONLY,RUNLOC>
		;READ-ONLY IF VARS GO ELSEWHERE
	> ;END IFGE VARLOC

	IFL VARLOC,<
	.PSECT	DDTALL/RWRITE,RUNLOC	;READ/WRITE IF WE GET VARS TOO
	> ;END IFL VARLOC
    > ;END IFGE RUNLOC


    IFL RUNLOC,<
	RELOC	0		;START AT RELOCATABLE 0 IF NO RUNLOC
    > ;END IFL RUNLOC
  > ;END IFE FTEX20!FTMON


  IFGE VARLOC,<IFGE RUNLOC,<IFL <VARLOC-RUNLOC>,<
;>>>	DDTBEG:!		;PUT DDTBEG HERE UNLESS SURE VARS ARE LOWER


BEG.C:!				;START OF CODE
DDTOFS:!			;OFFSET FOR COMMAND DISPATCH
SUBTTL	OPDEFS

;GENERAL

OPDEF	SKPUSR	[SKIPL USRFLG]	;SKIP IN USER MODE
OPDEF	SKPEXC	[SKIPGE USRFLG]	;SKIP IN EXEC MODE
OPDEF	SKPKA	[SKIPN KAFLG]	;SKIP FOR KA10
OPDEF	SKPNKA	[SKIPE KAFLG]	;SKIP NOT KA10
OPDEF	SKPKI	[SKIPN KIFLG]	;SKIP FOR KI10
OPDEF	SKPNKI	[SKIPE KIFLG]	;SKIP NOT KI10
OPDEF	SKPKL	[SKIPN KLFLG]	;SKIP FOR KL10
OPDEF	SKPNKL	[SKIPE KLFLG]	;SKIP NOT KL10
OPDEF	SKPKS	[SKIPN KSFLG]	;SKIP FOR KS10
OPDEF	SKPNKS	[SKIPE KSFLG]	;SKIP NOT KS10
OPDEF	SKPKLS	[SKIPN KLSFLG]	;SKIP FOR KL10 OR KS10

OPDEF	SKPKIP	[SKIPN KIPAG]	;SKIP FOR KI-PAGING
OPDEF	SKPKLP	[SKIPN KLPAG]	;SKIP FOR KL-PAGING
OPDEF	SKPS0	[SKIPE SECDDT]	;SKIP IF IN ZERO SECTION 
OPDEF	SKPNS0	[SKIPN SECDDT]	;SKIP IF IN NON-ZERO SECTION

;PROCESSOR

OPDEF	APRID	[700000,,000000];KL-10/KS-10 READ APR ID
OPDEF	RDAPR	[700240,,000000];KS-10 CONI APR,
OPDEF	WRAPR	[700200,,000000];KS-10 CONO APR,
OPDEF	RDCSB	[702040,,000000];KS-10 READ CST BASE
OPDEF	RDSPB	[702000,,000000];KS-10 READ SPT BASE
OPDEF	RDTIMS	[702200,,000000];KS-10 RDTIME
OPDEF	WRTIMS	[702600,,000000];KS-10 WRTIME
OPDEF	BLTBU	[716000,,000000];KS-10 BLT BYTE TO UNIBUS
OPDEF	BLTUB	[717000,,000000];KS-10 BLT UNIBUS TO BYTE
OPDEF	PMOVE	[052000,,000000];KL-10 PHYSICAL MOVE
OPDEF	PMOVEM	[053000,,000000];KL-10 PHYSICAL MOVEM

OPDEF	GFAD	[102B8]		;G-FLOATING ADD
OPDEF	GFSB	[103B8]		;G-FLOATING SUBTRACT
OPDEF	GFMP	[106B8]		;G-FLOATING MULTIPLY
OPDEF	GFDV	[107B8]		;G-FLOATING DIVIDE
OPDEF	XMOVEI	[SETMI]		;MACRO HASN'T GOT IT YET
OPDEF	IFIW	[1B0]		; . . .
.NODDT	IFIW			;DON'T WANT TO OVERRIDE SETZ
OPDEF	NOP	[TRN]		;FAST NO-OP
SUBTTL	MISCELLANEOUS DDT SYMBOLS

;ASSEMBLY CONSTANTS

	ND PAGSIZ,1000		;"BLOCK" SIZE OF LOGICAL DISK/MEMORY ALLOCATION
	PAGMSK==PAGSIZ-1	;"AND" TO MASK TO ADDRESS WITHIN PAGE
	PG2WRD==^D36-^L<PAGSIZ-1> ;"LSH" FOR PAGE TO WORD ADDRESS
	WRD2PG==-PG2WRD		;"LSH" FOR WORD TO PAGE ADDRESS
	VMADR==7777,,777777	;MASK FOR VIRTUAL MEMORY ADDRESS
	VSECNO==7777,,0		;VIRTUAL SECTION NUMBER MASK
	PCFLGS==777740,,0	;PC FLAG MASK
	DDAF==1B0		;DDT INTERNAL ADDRESS
	EFIWX==17B5		;INDEX FIELD IN EFIW
	EFIWI0==1B0		;EFIW INDIRECT BIT 0
	EFIWI1==1B1		;EFIW INDIRECT BIT 1

	ND BLKSIZ,200		;"BLOCK" SIZE OF PHYSICAL DISK ALLOCATION
	BLKMSK==BLKSIZ-1	;"AND" TO MASK TO ADDRESS WITHIN BLOCK
	BL2WRD==^D36-^L<BLKSIZ-1> ;"LSH" FOR BLOCK TO WORD ADDRESS
	WRD2BL==-BL2WRD		;"LSH" FOR WORD TO BLOCK ADDRESS

	PG2BLK==PG2WRD-BL2WRD	;"LSH" FOR PAGE TO BLOCK ADDRESS
	BLK2PG==-PG2BLK		;"LSH" FOR BLOCK TO PAGE ADDRESS

	ND SKPMAX,3		;MAX NUMBER OF SKP'S IN $X LOGIC
	ND NSAVTB,^D17		;NUMBER OF PC'S IN RING BUFFER ($<CR> ETC.)
	ND INDPTH,100		;MAX NESTING IN $E SEARCHES
	ND ADRNGE,1000		;ADDRESS RANGE FOR SYMBOL+VALUE TYPEOUT
	ND XTYPAV,4321		;EXEC-MODE TYPEAHEAD CHECK INTERVAL
	ND XTYPAW,4		;WORDS OF BUFFER FOR EXEC-MODE TYPEAHEAD
	ND PVNAML,^D39		;PDV NAME LENGTH FOR TYPEIN
	PVNMSZ==<PVNAML/5>+1	;WORDS TO STORE PDV NAME

  IFN FTFILE,<ND SCSIZ,^D200>	;SIZE OF SYMBOL TABLE CACHE FOR FILDDT
  IFE FTFILE,<ND SCSIZ,^D100>	; ALL OTHER DDTS

;BREAKPOINT SYMBOLS, BREAKPOINT BLOCK ALLOCATION
;  REPEAT NBP,<BLOCK NBPBW>	;STORAGE FOR EACH BREAKPOINT (1-12)
;				;(NOTE: BREAKPOINT 0 DOESN'T NEED SPACE HERE)
;  BLOCK BPBRST			; FOR USE BY RESTOR
;  BLOCK BPB$XL			; FOR USE BY $X CODE
;  BLOCK BPI$XL			; FOR USE BY INSTR$X CODE

	ND NBP,^D12		;NUMBER OF BREAKPOINTS
  IFN FTEX10,<$NB==:NBP>	;FOR TOPS-10 MONITOR
	ND NBPBW,3		;WORDS PER ENTRY IN BREAKPOINT BLOCK
	BPBRST==NBP*NBPBW	;1ST BPBLK WORD AVAIL TO RESTOR
	ND BPBRSL,4		;WORDS NEEDED BY RESTOR IN BPBLK
	BPB$X==BPBRST+BPBRSL	;1ST BPBLK WORD AVAIL TO $X
	ND BPB$XL,2*<SKPMAX+1>+5;WORDS NEEDED BY $X IN BPBLK
	BPI$X==BPB$X+BPB$XL	;1ST BPBLK WORD AVAIL TO INSTR$X
	ND BPI$XL,2*<SKPMAX+1>+1;WORDS NEEDED BY INSTR$X IN BPBLK
	BPBLEN==BPI$X+BPI$XL	;TOTAL LENGTH OF USED BREAKPOINT BLOCK
	BPBMAX==100		;ADVERTISED LENGTH OF BREAKPOINT BLOCK
				; (MUST AGREE W/ TOPS-20 EDDBLK, MDDBLK)
  IF2,<IFL <BPBMAX-BPBLEN>,<PRINTX ?BREAKPOINT BLOCK TOO LONG>>
;ADDRESS (PAGE) ACCESS BIT DEFINITIONS

DEFINE	SYSPRM(NAM,T10,T20),<
	IFN FTDEC10,<NAM==<T10>>
	IFN FTDEC20,<NAM==<T20>>>

SYSPRM	PG$EXI,	PA.GNE,	PA%PEX	;PAGE EXISTS
SYSPRM	PG$REA,	PA.GRD,	PA%RD	;PAGE CAN BE READ
SYSPRM	PG$WRT,	PA.GWR,	1B15	;PAGE HAS SOME KIND OF WRITE ACCESS
SYSPRM	PG$WT,	PG$WRT,	PA%WT	;PAGE IS REALLY WRITABLE
SYSPRM	PG$CPY,	0,	PA%CPY	;PAGE IS COPY-ON-WRITE
SYSPRM	PG$EXE,	0,	PA%EX	;PAGE IS EXECUTABLE
SYSPRM	PG$ACC,	PA.GAA,	0	;PAGE ACCESS ALLOWED
SYSPRM	PG$PRV,	0,	PA%PRV	;PAGE IS PRIVATE
SYSPRM	PG$SHR,	PA.GSH,	0	;PAGE IS SHARABLE
SYSPRM	PG$HGH,	PA.GHI,	0	;PAGE IS PART OF HIGH SEGMENT
SYSPRM	PG$ABZ,	PA.GAZ,	1B17	;PAGE IS ALLOCATED BUT ZERO
SYSPRM	PG$SPY,	PA.GSP,	0	;PAGE IS ACTUALLY SPYING ON SOMEONE
SYSPRM	PG$VIR,	PA.GVR,	0	;SPY PAGE IS VIRTUAL (ON MONITOR)
SYSPRM	PG$NPG,	PA.GCP,	0	;PAGE CANNOT BE PAGED OUT
SYSPRM	PG$PGO,	PA.GPO,	0	;PAGE IS PAGED OUT
SYSPRM	PG$LCK,	PA.GLK,	0	;PAGE IS LOCKED IN MEMORY
SYSPRM	PG$NCA,	PA.GNC,	0	;PAGE IS NOT CACHED
SYSPRM	PG$SXI,	PA.GSN,	PA%PEX	;SECTION EXISTS
SYSPRM	PG$SMA,	PA.GIN,	1B12	;SECTION MAPPED ELSEWHERE
SYSPRM	PG$SIN,	PA.GIN,	SM%IND	;SECTION MAPPED INDIRECTLY
SYSPRM	PG$SFJ,	0,	1B11	;SECTION MAPPED TO FORK OR JFN
SYSPRM	PG$SEC,	PA.GSC,	37B17	;SECTION NUMBER MAPPED TO
SYSPRM	PG$FRK,	0,	777777	;FORK/JFN MAPPED TO


;BITS AND FIELDS RELEVANT TO KL PAGING.

  IFN FTEXEC!FTMON!FTPAGM,<
	AGEMSK==777B5		;AGE FIELD
	CSWRB==1B18		;CST WRITE ENABLE BIT
	CORMB==1B35		;CST MODIFIED BIT
	PTRCOD==7B2		;POINTER CODE FIELD
	 IMMCOD==1		;IMMEDIATE POINTER CODE
	 SHRCOD==2		;SHARED POINTER CODE
	 INDCOD==3		;INDIRECT POINTER CODE
	IMMPTR==<IMMCOD>B2	;IMMEDIATE POINTER
	PTPUB==1B3		;POINTER PUBLIC BIT
	PTWR==1B4		;POINTER WRITE BIT
	PTCACH==1B6		;POINTER CACHE BIT
	MSECTB==540		;MONITOR SECTION TABLE IN EPT
	PGKLMD==1B21		;KL PAGING MODE (IN CONI PAG,)
	PGTPEN==1B22		;TRAP ENABLE (PAGING ON) (IN CONI PAG,)
	TWUSR==1B0		;USER MODE BIT IN PF AND MAP WORD
	TWHPFF==1B1		;HARD FAILURE BIT
	TWVALD==1B2		;VALID BIT
	TWWRT==1B5		;WRITE REF BIT
  > ;END OF IFN FTEXEC!FTMON!FTPAGM
;PC BITS OF INTEREST

SYSPRM	PC$AFI,	PC.AFI,	PC%AFI	;ADDRESS FAILURE INHIBIT
SYSPRM	PC$USR,	PC.USR,	PC%USR	;USER MODE
SYSPRM	PC$BIS,	PC.BIS,	PC%BIS	;FIRST PART DONE
SYSPRM	PC$UIO,	PC.UIO,	PC%UIO	;USER IO MODE


;TERMINAL CONTROL (IN TTYMSK, N$1M COMMAND)

;LEFT HALF BITS, PRESERVED AND SET ONLY BY USER

	TT$EYB==1B15		;ECHO $Y BIT (0=ECHO, 1=SUPPRESS)
	TT$BPI==1B16		;PRINT INSTRUCTION ON BPT (0=YES, 1=NO)
	TT$SPC==1B17		;3 SPACES OR TAB (0=SPACES, 1=TAB)
				; (CONTROLS ONLY TTAB; TEXT OUTPUT OK)

;RIGHT HALF BITS, SET AUTOMATICALLY ON USER DDT ENTRY (NOT APPLICABLE
;TO TOPS-20), PRESERVED IN EXEC DDT (WHERE THEY MUST MANUALLY BE SET).

	TT$TAB==1B34		;TAB CAPABILITY
				; (IF 1 THEN TERMINAL HANDLES TABS)
	TT$DEL==1B35		;FANCY DELETE HANDLING
				; (IF 1 THEN <BS><SP><BS>)
;FOR FILE DDT ONLY

  IFN FTFILE,<
FIL==1				;PRIMARY FILE I/O CHANNEL

	ND WINMAX,^D20		;PAGE "CACHE" SIZE - PAGES KEPT IN CORE
	ND MEXSIZ,^D512*^D32	;MAX PAGES IN REASONABLE .EXE FILE

;.EXE DIRECTORY INFORMATION

SV$HIS==SV%HIS			;PAGE IS PART OF HIGH SEGMENT
SV$SHR==SV%SHR			;PAGE IS SHARABLE
SV$WRT==SV%WRT			;PAGE IS WRITABLE
SV$CON==SV%CON			;PAGE IS CONCEALED
SV$ABZ==SV%ABZ			;PAGE IS ZERO
SV$MOD==1B17			;PAGE HAS BEEN MODIFIED (WINDIR BIT)
SV$FPN==777,,777777		;FILE PAGE NUMBER MASK

  > ;END OF IFN FTFILE

;************************************************************
;
;	TEMP DEFS TIL UNIVERSALS HAVE THEM INCORPORATED
;
;************************************************************

    IFN FTDEC10,<		;SOME TOPS-10 STUFF
.PVCNT==0			;PDV LENGTH
.PVNAM==1			;POINTER TO NAME STRING
.PVSYM==6			;SYMBOL VECTOR WORD
.PVLVR==12			;LINK VERSION WORD
SV%ABZ==0			;EXE DIRECTORY - PAGE IS ZERO
    > ;END OF TOPS-10 STUFF

    IFN FTDEC20,<		;AND SOME TOPS-20 STUFF
.SVDIR==1776			;EXE DIRECTORY HEADER TYPE
SV%HIS==1B0			;EXE DIRECTORY - PAGE IS HISEG PAGE
SV%SHR==1B1			;EXE DIRECTORY - PAGE IS SHARABLE
SV%WRT==1B2			;EXE DIRECTORY - PAGE IS WRITABLE
SV%CON==0			;EXE DIRECTORY - PAGE IS CONCEALED
SV%ABZ==1B3			;EXE DIRECTORY - PAGE IS ZERO
.PVEXP==.PVSTR			;"EXPORT" VECTOR (USED TO BE START ADR)
    > ;END OF FTDEC20 STUFF

.SVVEC==1775			;EXE DIRECTORY ENTRY VECTOR TYPE
.SVPDV==1774			;EXE DIRECTORY PDV TYPE

;PDV SYMBOL VECTOR SYMBOLS
.STLEN==0			;LENGTH WORD IN SYMBOL VECTOR
.STDAT==0			;TYPE/LENGTH WORD IN SUBTABLE
.STPTR==1			;ADDRESS WORD IN SUBTABLE
ST%TYP==77B5			;TYPE FIELD IN .STDAT WORD
ST%LEN==^-ST%TYP		;LENGTH FIELD IN .STDAT WORD
.UNDFD==0			;UNDEFINED SYMBOL TYPE CODE
.R50D==1			;RADIX-50 DEFINED TYPE CODE
.R50U==2			;RADIX-50 UNDEFINED TYPE CODE
;*** FLAGS IN F ***

FEF==	1B0			;"E" FLAG
COMF==	1B1			;COMMA TYPED
TIF==	1B2			;TRUNCATE TO 18 BITS - SET BY SPACE OR COMMA
DVF==	1B3			;DIVIDE
FPF==	1B4			;"." TYPED
CCF==	1B5			;"$$" TYPED
STF==	1B6			;SUPPRESS TYPEOUT
SAF==	1B7			;RIGHT ANGLEBRACKET TYPED
FAF==	1B8			;LEFT ANGLEBRACKET TYPED
SPF==	1B9			;SPACE TYPED (USED BY CEFFAD)
MLF==	1B10			;MULTIPLY
PTF==	1B11			;ARITHMETIC OPERATOR TYPED
CF==	1B12			;"$" TYPED
LTF==	1B13			;LETTER TYPED IN CURRENT SYLLABLE
DTF==	1B14			;DIGIT TYPED
SF==	1B15			;SYLLABLE
MF==	1B16			;MINUS SIGN TYPED
QF==	1B17			;QUANTITY TYPED IN TO WORD ASSEMBLER
DDLF==	1B18			;DDT INTERNAL SYMBOL TYPED
ROF==	1B19			;REGISTER OPEN
TXF==1B20			;IN TEXT ([$]"/---/) COMMAND
USYMF==1B21			;R POINTS TO THE UNDEFINED SYMBOL TABLE
MDLCLF==1B22			;MULT DEF LOCAL SYMBOL (EVAL)
PNAMEF==1B23			;PROGRAM NAME SEEN IN SYM TABLE SEARCH
;BIT 24 AVAILABLE
LF1==	1B25			;OUTPUT ONE REGISTER IN FORCED MODE
OLF==	1B26			;OUTSIDE LOCAL FLAG IN LOOK
CF1==	1B27			;OUTPUT ONE REGISTER AS CONSTANT
NAF==	1B28			;NEGATIVE ADDRESSES PERMISSABLE
FANYSF==1B29			;EVAL OR LOOK HAS FOUND A SYMBOL
OPTRYF==1B30			;WE'RE TRYING TO DECODE A SYMBOLIC OPCODE
HSYMF==	1B31			;R POINTS TO HISEG SYMBOL TABLE
OKAF==	1B32			;OK AMBIGUOUS (LOOK ROUTINE)
OUTF==	1B33			;OUTPUT
ITF==	1B34			;INSTRUCTION TYPED
Q2F==	1B35			;NUMBER TYPED AFTER $

;DEFINE SYMBOL TABLE SYMBOL TYPES
GLOBL==	04B5			;GLOBAL SYMBOL
LOCL==	10B5
PNAME==	74B5			;PROGRAM NAME
DELI==	20B5			;DELETE INPUT
DELO==	40B5			;DELETE OUTPUT

;DEFINE UNDEFINED SYMBOL TABLE (.JBUSY) TYPES

STADD==	1B0			;IF 1, THEN ADDITIVE REQUEST
STLH==	1B1			;IF 1, THEN REQUEST FOR LEFT HALF
STNEG==	1B4			;IF 1, THEN NEGATIVE REQUEST
;RANDOM SYMBOL DEFINITIONS FOR TOPS-10

  IFN FTDEC10,<

;THE FSBLK BITS

FS$SWT==1B0		;SWITCH SPECIFIED
FS$DEV==1B2		;DEVICE SPECIFIED
FS$NAM==1B3		;FILENAME SPECIFIED
FS$EXT==1B4		;EXTENSION (FILE TYPE) SPECIFIED
FS$PTH==1B5		;DIRECTORY PATH SPECIFIED

FS$FIL==FS$DEV!FS$NAM!FS$EXT!FS$PTH  ;FILE SPEC WAS SPECIFIED


;I/O CHANNELS

    IFN FTYANK,<
	CM==17			;I/O CHANNEL TO READ COMMAND FILES
	ND	YBFSIZ,203	;SIZE OF [INTERNAL] BUFFER FOR COMMAND FILES
    > ;END IFN FTYANK
  > ;END OF IFN FTDEC10
SUBTTL	START DDT

  IFE FTFILE,<

  IFN FTDBUG,<
DEBDDT::>

DDTX:
DDT:

IFN FTPURE&FTDEC10,<DEFINE SETRT1<@[0,,.JBBLT]>>
  IFN FTPURE,<
	MOVEM	T,SETRT1	;SAVE AN AC
    IFN FTDEC10,<
	DMOVEM	TT1,@[0,,.JBBLT+1] ;SAVE SOME MORE ACS
	MOVNI	TT1,<<END.V!PAGMSK+1>-<BEG.V&<^-PAGMSK>>>/PAGSIZ
	XMOVEI	TT2,BEG.V	;GET -VE LENGTH AND ADDRESS
	LSH	TT2,WRD2PG	;CONVERT TO STARTING PAGE NUMBER
	TXO	TT2,PA.GDC	;OK IF PAGES ALREADY EXIST
	MOVE	T,[.PAGCD,,TT1]	;UUO ARGUMENT POINTER
	PAGE.	T,		;TRY TO CREATE THE PAGES
	  TRNA			;CAN'T CREATE IN PHYSICAL MEMORY
	JRST	DDTIN0		;PAGES CREATED
	TXO	TT2,PA.GSL	;TRY TO MAKE THE PAGES ABZ INSTEAD
	MOVE	T,[.PAGCD,,TT1]	;UUO ARGUMENT POINTER
	PAGE.	T,		;TRY TO ALLOCATE THE PAGES
	  TRN			;GIVE UP AND HOPE FOR THE BEST
DDTIN0:	DMOVE	TT1,@[0,,.JBBLT+1] ;RESTORE UUO ARGUMENT ACS
    > ;END OF IFN FTDEC10
	MOVE	T,BPT$B+B$JSR
	CAMN	T,[JSR BCOM]	;VARIABLES AREA INITIALIZED?
	JRST	DDTIN1		;YES
	MOVE	T,[PHVAR,,BEG.V] ;NO, DO IT
	BLT	T,VAREND-1
    IFN FTDEC10,<
	XMOVEI	T,$0BPT		;WHERE ^D SHOULD GO
	MOVEM	T,@[0,,.JBBPT]	;SET IT UP
	SKIPE	@[0,,.JBDDT]	;IF ALREADY HAVE THIS,
	JRST	DDTIN1		;DON'T WASTE THE UUO
	MOVE	T,[DDTEND,,DDT]	;NO--WE NEED TO SET THIS UP
	SETDDT	T,		;SO DO IT
    > ;END OF IFN FTDEC10
DDTIN1:	MOVE	T,SETRT1	;RESTORE SCRATCH AC
  > ;END IFN FTPURE

  IFN FTYANK,<
	SETZM	COMAND>		;INDICATE NO COMMAND FILE IF
				;STARTING BY DDT COMMAND
	JSR	SAVE
	 PUSHJ	P,REMOVB
  IFN FTUD20,<			;CHECK DDTPDV BEFORE CALLING SYMCHK
	SKIPN	DDTPDV		;DID WE LOOK FOR IT YET?
	PUSHJ	P,HIDPDV	;NO, FIND IT.  COME BACK IF NON-EXISTANT.
	SKIPL	T,DDTPDV	;ALREADY LOCATE DDT'S PDV?
	HLL	T,SECDDT	;YES, FIX UP SECTION NUMBER
	MOVEM	T,DDTPDV	;REMEMBER PDVA IN OUR SECTION
  > ;END IFN FTUD20
	PUSHJ	P,SYMCHK	;MAKE SURE SYMBOLS ARE OK
  IFE FTVMX!FTMON,<MOVE W1,[ASCII /DDT/]> ;IDENTIFY USER MODE DDT
  IFN FTVMX,<
    IFE FTPURE,<MOVE W1,[ASCII /VMDDT/]>	;IDENTIFY TOPS-10 VM DDT
    IFN FTPURE,<MOVE W1,[ASCII /XDDT/]>	;IDENTIFY TOPS-10 X DDT
  >
  IFN FTMON,<MOVE W1,[ASCII /MDDT/]>	;IDENTIFY TOPS-20 MDDT
  IFN FTEXEC&<^-FTMON>,<
	SKPUSR				;IF EXEC MODE, THEN
	MOVE	W1,[ASCII /EDDT/]	;IDENTIFY EXEC MODE DDT
  > ;END OF IFN FTEXEC
	PUSHJ	P,TEXT2		;TYPE MESSAGE SAYING WHICH DDT
  IFN FTDBUG,<
	MOVEI	W1,[ASCIZ/ (debugging)/]
	PUSHJ	P,TSTRG		;DIFFERENTIATE FROM REGULAR DDT(S)
  > ;END IFN FTDBUG
	JRST	DD1.0		;GO FOR IT!
  >				;END IFE FTFILE

;RUDE HACK TO TRY TO GET THE COPYRIGHT TO BE INTACT IN DDT.REL

	.ORG	0
	EXP	0
	.ORG

;LEGAL NOTICE FOR BINARIES

	ASCIZ	"
COPYRIGHT (c) DIGITAL EQUIPMENT CORPORATION 1970,1989. ALL RIGHTS RESERVED.
"
SUBTTL	DDT COMMAND PARSER
DD1.0:	SKIPE	T,PTLLC		;GET LAST PATCH LOCATION CHANGED
	MOVEM	T,LLOC		;SET . TO IT, IF WE WERE PATCHING
	SETZM	PTLOC		;DEFINE NO PATCH IN PROGRESS
DD1:	PUSHJ	P,TCRLF
DD1.5:	TXZ	F,ROF		;CLOSE ANY OPEN REGISTER
	MOVE	T,[XWD SCHM,SCH]
	BLT	T,ODF		;LOAD ACS
	MOVE	T,PSVBTS
	MOVEM	T,SVBTS
	MOVE	T,PBYSS
	MOVEM	T,BYSS
	SKIPA			;SKIP TAB TYPEOUT
RET:	PUSHJ	P,TTAB		;TYPE A TAB AND FALL THROUGH TO DD2
  IFN FTMON,<BRKLCK>		;GIVE UP MDDT LOCK IF HOLDING IT.
DD2:	MOVE	T,[SCH,,SCHR]	;SAVE CURRENT TYPEOUT MODES
	BLT	T,ODFR		;IN CASE REPARSE NEEDED
	SETZM	PRNC		;PARENTHESES COUNT
	INIPDL			;INIT STACK POINTER
	SETZM	WAKALL		;SET WAKEUP SET TO PUNCT AND CTRLS
	XMOVEI	T,RET		;INIT TOP OF STACK TO RET
	MOVEM	T,XPDL		;SO COMMAND ROUTINES CAN POPJ
	DMOVE	T,USYMP+S$ADR	;GET ORIGINAL UNDEFINED SYMBOL PTR
	DMOVEM	T,ESTUT		;INIT UNDEFINED SYM ASSEMBLER COPY
LIS0C:	TXZ	F,<^-<STF>&<-1,,0>>!LF1!CF1!OKAF!ITF!Q2F
LIS0E:	TXZ	F,<^-<STF!FAF!SAF>&<-1,,0>>!NAF!DDLF
	SETZM	ACCCF		;CLEAR COMMACOMMA FLAG/VALUE
	SETZM	WRD
LIS1:	SETZM	FRASE
	TXZ	F,FEF		;TURN OFF SCIENTIFIC EXPONENT FLAG
LIS2:	MOVEI	T,1
	MOVEM	T,FRASE1
	TXZ	F,MLF!DVF
L1:	TXZ	F,CF!CCF!SF!FPF!Q2F!LTF!TXF!DTF ;TURN OFF CONTROL, SYL, PERIOD FLAG
L1A:	SETZM	SYL
L1RPR:	SETZM	SYM
	MOVEI	T,6
	MOVEM	T,TEM		;INIT SYMBOL COUNTER
	MOVE	T,[POINT 7,OPTXT]
	MOVEM	T,CHP		;SETUP FOR OPEVAL SYMBOL
	SETZM	DEN
	SETZM	WRD2D
	SETZM	WRD2O

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

L2:	PUSHJ	P,TIN		;PICK UP CHARACTER
	CAIL	T,"A"+40	;LOWER CASE A
	CAILE	T,"Z"+40	;LOWER CASE Z
	JRST	.+2
	TRC	T,40		;CHANGE LOWER CASE TO UPPER CASE
	TXNE	F,CF		;CONTROL FLAG
	JRST	L21
	CAIG	T,"Z"		;Z
	CAIGE	T,"A"		;A
	JRST	.+2
	JRST	LET
L21:	CAIN	T,"`"		;<GRAVE> MAPPED TO <ESC>
	MOVEI	T,.CHESC
	MOVE	R,T
	CAILE	T,137		;DISPATCH TABLE HAS ENTRIES ONLY .LE. 137
	JRST	ERR
	IDIVI	R,3		;REMAINDER GIVES COLUMN, QUOTIENT GIVES ROW
	LDB	W,BDISP(R+1)	;GET 12 BIT ADDRESS FROM DISPATCH TABLE
	CAIGE	W,MULT-DDTOFS	;FIRST EVAL ROUTINE
	JRST	DDTOFS(W)
L0:	MOVE	T,SYL
	TXNN	F,LTF
	JRST	POWER


;TIME TO EVALUATE A SYMBOL.  IF THIS IS IN THE OPCODE FIELD (1ST THING
;TYPED AND TERMINATED WITH A SPACE), THEN SEARCH ORDER IS:
;1. OPDEFS FROM THE S.T. (B0-8 .NE. 0) 2. BUILT-IN OPCODES 3. REST OF S.T.
;IF THE SYMBOL TYPED IS NOT IN THE OPCODE FIELD, THEN THE ORDER IS:
;1. ANY MATCH IN THE S.T. 2. DDT'S BUILT-IN OPCODES.
;THE FLAG OPTRYF INDICATES THAT WE ARE TRYING TO SEARCH FOR AN OPCODE.

	TXO	F,OPTRYF	;ASSUME WE ARE IN THE OPCODE FIELD
	CAIN	W,SPACE-DDTOFS	;IS TERMINATOR A SPACE?
	SKIPE	WRD		;IS CONSTRUCTED WORD SO FAR ZERO?
	TXZ	F,OPTRYF	;NO, NOT AN OPCODE
	PUSHJ	P,EVAL		;TRY FOR A MATCH IN THE S.T.
	 JRST [	TXZ	F,OPTRYF	;SO UNDEF TEST BELOW WILL WORK
		JRST	L27]		;TRY BUILT-IN OPCODES
	TXNE	F,OPTRYF	;ONLY WANT OPDEFS?
	TXNE	T,777B8		;YES, IS THIS ONE?
	JRST	L3		;WE'LL TAKE ANYTHING OR THIS IS AN OPCODE
	MOVEM	T,TENSYM	;ONLY NON-OPCODE FOUND, SAVE TENATIVE MATCH
L27:	PUSHJ	P,OPEVAL	;SEARCH FOR A (BETTER?) MATCH IN OPCODES
	  SKIPA	T,TENSYM	;NOTHING, HAD BETTER BE A SAVED VAL
	JRST	L3		;BETTER MATCH FOUND, GO WITH IT
	TXZN	F,OPTRYF	;DID EARLIER EVAL FIND ANYTHING?
	JRST	UND1		;NO, GIVE UP

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

L3:	CAIN	W,ASSEM-DDTOFS	;DEFINED SYMBOL FOLLOWED BY #?
	JRST	ERR		;IF DEFINED, DON'T ALLOW #
L4:	TXZE	F,MF
	MOVN	T,T
	TXNN	F,SF
	CAIE	W,LPRN-DDTOFS
	JRST	.+2
	JRST	LPRN

	EXCH	T,FRASE1
	TXNN	F,DVF
	IMULB	T,FRASE1
	TXZE	F,DVF
	IDIVB	T,FRASE1
	CAIGE	W,ASSEM-DDTOFS
	JRST	DDTOFS(W)	;MULTIPLY OR DIVIDE
	ADDB	T,FRASE
	CAIGE	W,SPACE-DDTOFS
	JRST	DDTOFS(W)	; + - @ ,

	MOVE	W1,T		;GET A WORKING COPY OF ARGUMENT
	XOR	W1,WRD		;WILL ADD OVERFLOW?
	JUMPL	W1,SKP311	;NO, DO IT NORMALLY
	TLC	T,(1B0)		;YES, TURN OFF SIGN BIT
	ADD	T,WRD		;NOW DO THE ADD
	TLCA	T,(1B0)		;FIX THE SIGN BIT AND SKIP
SKP311:	ADD	T,WRD
	TXNE	F,TIF		;TRUNCATE INDICATOR FLAG
	HLL	T,WRD		;TRUNCATE
	MOVEM	T,WRD
	TXNN	F,QF
	MOVE	T,LWT
	SETZM	R
	DMOVE	W1,ESTUT	;GET ADR AND LENGTH FOR DEPRA
	CAMN	W1,USYMP+S$ADR	;IF THERE ARE ANY UNDEFINED SYMBOLS IN
	JRST	L5		;THE CURRENT EXPRESSION, ANYTHING EXCEPT
	CAILE	W,CARR-DDTOFS	;FURTHER EXPRESSION INPUT, OR DEPOSITING
	JRST	ERR		;  INTO MEMORY IS ILLEGAL
L5:	CAIG	W,RPRN-DDTOFS
	JRST	DDTOFS(W)
	SKIPN	PRNC		;WHEN INSIDE ( ), CURRENT EXPRESSION INVALID
	JRST	DDTOFS(W)	;FOR ANYTHING OTHER THAN MORE EXPRESSION INPUT
	JRST	ERR

;CALL TO EVAL ARGUMENT IF NOT ALREADY DONE (I.E. CODE WAS IN "NO-EVAL"
;ADDRESS RANGE)

XEVAL:	MOVEI	W,[POPJ P,]	;COUNT ON THIS LITERAL BEING AFTER EVERYTHING
	SUBI	W,DDTOFS	;ADJUST FOR OFFSET
	JRST	L0		;GO EVAL, THEN JUMP TO THE POPJ
;HANDLE AN UNDEFINED SYMBOL

UND1:	SKIPN	ESTUT		;ANY UNDEFINED SYMBOL TABLE?
	JRST	UNDEF		;NO, CAN'T DO THIS
	PUSHJ	P,EVALU		;SEE IF SYM IS IN THE UNDEFINED TABLE
	 JRST	UND3		;SYMBOL DOES NOT EXIST
	TXNE	F,ROF		;SYM EXISTS, LOCATION OPEN
	CAILE	W,CARR-DDTOFS	;AND STILL BUILDING WORD FOR IT?
	 JRST	UNDEF		;NO - THEN "U" ERROR (E.G. "=" CMD)
	CAIE	W,ACCF-DDTOFS	;EXPRESSION INVOLVING A COMMA?
	SKIPE	PRNC		;OR INSIDE PARENTHESIS?
	 JRST	UNDEF		;YES - "U" ERROR
	JRST	UND4		;NO, CONTINUE

UND3:	CAIN	W,ASSEM-DDTOFS	;DEFINING SYMBOL VIA "#" CMD
	TXNN	F,ROF		;FOR A LOCATION THAT IS OPEN?
	 JRST	UNDEF		;NO - THEN "U" ERROR
	SKIPE	PRNC		;YES - INSIDE PARENTHESIS?
	 JRST	ERR		;YES - ILLEGAL, "?" ERROR

UND4:	MOVEI	T,"#"
	CAIE	W,ASSEM-DDTOFS
	PUSHJ	P,TOUT
	SOS	ESTUT		;MAKE ROOM IN UNDEF TABLE
	SOS	ESTUT
	AOS	ESTUTL		;UPDATE LENGTH TOO
	AOS	ESTUTL
	MOVE	T,SYM
	TXO	T,GLOBL
	MOVX	R,1B1		;DEPOSIT INTO 1ST WORD OF UNDEF TABLE
	PUSHJ	P,DSYMER	;DEPOSIT AND TYPE ? IF IT FAILS
	MOVE	T,LLOCO		;WANT 30-BIT FIXUP ADDRESS
	TXNE	F,MF
	TXO	T,STNEG		;SET FLAG TO SHOW SUBTRACTIVE REQUEST
	TXO	T,STADD		;SET FLAG TO SHOW UNCHAINED REQUEST
	ADDI	R,1
	PUSHJ	P,DSYMER
	SETZ	T,
	JRST	L4
;DDT'S COMMAND PARSER DETERMINES WHAT TYPE OF COMMAND THIS IS BY
;RANGE-CHECKING THE DISPATCH ADDRESS OF THE COMMAND TO SEE WHICH
;ONE OF THE BELOW REGIONS IT FALLS INTO, THEREFORE:
;
;
;			***** WARNING ******
;
;DO NOT MOVE A COMMAND ROUTINE ACROSS A REGION BOUNDARY UNLESS YOU KNOW
;WHAT YOU ARE DOING!  THE PARSER IS VERY UNFORGIVING IN THIS RESPECT!
;
;
;THE FOLLOWING CLASSES OF COMMAND EXIST:
;
;CLASS 1:	COMMANDS THAT TAKE NO ARGUMENT, OR THAT TAKE A SYMBOL
;		NAME WITHOUT EVALUATION.
;
;CLASS 2:	MULTIPLY AND DIVIDE.
;
;CLASS 3:	COMMANDS THAT ADD SOME FUNCTION OF THE UPCOMING QUANTITY
;		TO THE ACCUMULATING RESULT.
;
;CLASS 4:	LAST COMMANDS THAT ARE LEGAL INSIDE PARENTHESES.
;
;CLASS 5:	LAST COMMANDS THAT ARE LEGAL WHEN THE EXPRESSION
;		CONTAINS UNDEFINED SYMBOLS.
;
;CLASS 6:	EVERYTHING ELSE.  THESE COMMANDS TYPICALLY TAKE A
;		COMPLETELY EVALUATED EXPRESSION, THAT CANNOT CONTAIN
;		REFERENCES TO UNDEFINED SYMBOLS.
;
;
;NOTE THAT THESE CLASSES ARE ONLY APPROXIMATE.  REFER TO THE CODE IN
;THE COMMAND PARSER FOR DEFINITIVE INFORMATION.
SUBTTL	COMMAND DISPATCH TABLE

BDISP:	POINT	12,DISP(R),11
	POINT	12,DISP(R),23
	POINT	12,DISP(R),35
DISP:
DEFINE D (Z1,Z2,Z3)<
	BYTE	(12) Z1-DDTOFS,Z2-DDTOFS,Z3-DDTOFS
  IFN <<Z1-DDTOFS>!<Z2-DDTOFS>!<Z3-DDTOFS>>&<-1,,770000>,
	<PRINTX Z1, Z2, OR Z3 TOO LARGE FOR DISPATCH TABLE> >
;THIS MACRO PACKS 3 ADDRESSES INTO ONE WORD; EACH ADR IS 12 BITS


D (ERR,ERR,ERR);	(0)	^@   ^A   ^B
D (CNTRLZ,ERR,CNTRLE);	(3)	^C   ^D   ^E
D (ERR,ERR,VARRW);	(6)	^F   ^G   ^H
D (TAB,LINEF,ERR);	(11)	^I   ^J   ^K
D (ERR,CARR,ERR);	(14)	^L   ^M   ^N
D (ERR,ERR,ERR);	(17)	^O   ^P   ^Q
D (ERR,ERR,ERR);	(22)	^R   ^S   ^T
D (ERR,ERR,ERR);	(25)	^U   ^V   ^W
D (ERR,ERR,CNTRLZ);	(30)	^X   ^Y   ^Z
D (CONTROL,ERR,ERR);	(33)	^[   ^\   ^]
D (ERR,ERR,SPACE);	(36)	^^   ^_     
D (SUPTYO,TEXI,ASSEM);	(41)	 !    "    #
D (DOLLAR,PERC,ERR);	(44)	 $    %    &
D (DIVD,LPRN,RPRN);	(47)	 '    (    )
D (MULT,PLUS,ACCF);	(52)	 *    +    ,
D (MINUS,PERIOD,SLASH);	(55)	 -    .    /
D (NUM,NUM,NUM);	(60)	 0    1    2
D (NUM,NUM,NUM);	(63)	 3    4    5
D (NUM,NUM,NUM);	(66)	 6    7    8
D (NUM,TAG,SEMIC);	(71)	 9    :    ;
D (LLIM,EQUAL,ULIM);	(74)	 <    =    >
D (QUESTN,INDIRE,ABSA);	(77)	 ?    @    A
D (BPS,CON,SYMD);	(102)	 B    C    D
D (EFFEC,SFLOT,GO);	(105)	 E    F    G
D (HWRDS,PILOC,ERR);	(110)	 H    I    J
D (KILL,PAGMAP,MASK);	(113)	 K    L    M
D (NWORD,BITO,PROCD);	(116)	 N    O    P
D (QUAN,RELA,SYMBOL);	(121)	 Q    R    S
D (TEXO,SETPAG,WATCH);	(124)	 T    U    V
D (DBLU,XEC,TAPIN);	(127)	 W    X    Y
D (ZERO,OCON,ICON);	(132)	 Z    [    \
D (OSYM,VARRW,UNDRL);	(135)	 ]    ^    _

;THIS TABLE DOES NOT HAVE ENTRIES FOR CHARS .GE. 140; THESE
; ARE DETECTED AS ERRORS NEAR L21:
SUBTTL	COMMAND ROUTINES -- CLASS 1

;*************** START OF CLASS ONE COMMANDS ***************

;"ERR" IS THE DISPATCH FOR ALL UNDEFINED COMMANDS.  VARIOUS COMMANDS
;ALSO JUMP TO ERR, WRONG, ETC. IF THEY DETECT SOME KIND OF ERROR.

WRONG:	MOVE	W1,[ASCII /XXX/]
	PUSHJ	P,TEXT
	JRST	WRONG6

RERR:	SETZ	T,		;ERROR RETURN WO PRINTING ANYTHING
	JRST	WRONG2

ERR:	MOVEI	T,"?"		;DDT'S UBIQUITOUS QUESTION MARK
	JRST	WRONG2		;JOIN COMMON ERROR PROCESSING

MULDEF:	SKIPA	T,["M"]		;MULTIPLY-DEFINED SYMBOL
UNDEF:	MOVEI	T,"U"		;UNDEFINED SYMBOL
WRONG2:	INIPDL			;ENSURE FRESH STACK
  IFN FTYANK,<			;IF COMMAND FILES SUPPORTED
	SKIPE	COMAND		;IN A COMMAND FILE?
	SKIPN	YASWF		;YES, ABORT ON COMMAND ERROR?
	JRST	WRONG3		;NO,KEEP ON GOING (IGNORE ERROR)
	PUSH	P,T		;YES, SAVE ERROR SYMBOL
	PUSHJ	P,PTRKIL	;KILL OFF THE COMMAND FILE
	POP	P,T		;RESTORE ERROR SYMBOL
	TXZ	F,ROF		;ARBITRARILY CLOSE OPEN LOCATION
  > ;END IFN FTYANK
WRONG3:	JUMPE	T,WRONG4	;SKIP DINK IF NOTHING TO TYPE HERE
	PUSHJ	P,TOUT		;ISSUE ERROR MESSAGE
	PUSHJ	P,TBEL		;AND DINK THE USER

WRONG4:	PUSHJ	P,TTYCLR	;CLEAR INPUT BUFFER
WRONG6:	TXNN	F,ROF		;REGISTER OPEN?
	JRST	DD1		;NO, CRLF.  OTHERWISE, FALL INTO RET
	JRST	RET
;HERE ON A DIGIT

NUM:	TXO	F,DTF		;DIGIT TYPED
	ANDI	T,17		;T HOLDS CHARACTER
	TXNE	F,CF!FPF
	JRST	NM1
	MOVE	W,SYL
	LSH	W,3
	ADD	W,T
	MOVEM	W,SYL
	MOVE	W1,DEN
	MULI	W1,12		;CONVERT TO DECIMAL WITHOUT OVERFLOW
	ADD	W2,T
	MOVEM	W2,DEN
	AOJA	T,LE1A

DOLLAR:	SKIPA	T,[46+101-13]	;RADIX 50 $ TO BE
PERC:	MOVEI	T,47+101-13	;PERCENT SIGN
LET:	TXC	F,SF!FPF!DTF	;EXPONENT IFF (LTF)'*(FEF)'*(T=105)*(SF)*(FPF)*(DTF)=1
	TXZN	F,LTF!FEF!SF!FPF!DTF
	CAIE	T,"E"
	TXOA	F,LTF
	TXOA	F,FEF
	JRST	LET1
	TXZN	F,MF
	SKIPA	W1,SYL
	MOVN	W1,SYL
	MOVEM	W1,FSV
	SETZM	DEN
LET1:	SUBI	T,101-13	;FORM RADIX 50 SYMBOL
LE1A:	TXO	F,SF!QF
LE2:	SOSGE	TEM		;IGNORE CHARACS AFTER 6
	JRST	L2
	MOVEI	W,50
	IMULM	W,SYM		;MULTIPLY BY RADIX 50
	ADDM	T,SYM		;  AND ADD NEW CHAR INTO SYM
	PUSHJ	P,PSYMT		;CONVERT LETTERS BACK TO ASCII
	IDPB	T,CHP
	JRST	L2
NUM1:	MOVE	W,WRD2O		;OCTAL FORM OF NUMBER AFTER $
	LSH	W,3
	ADD	W,T
	MOVEM	W,WRD2O
	EXCH	T,WRD2D		;DECIMAL FORM OF NUMBER AFTER $
	IMULI	T,12
	ADDM	T,WRD2D
	TRO	F,Q2F
	JRST	L2

NM1:	TXNE	F,CF
	JRST	NUM1
	MOVEI	W1,6		;FORM FLOATING POINT NUMBER
	AOS	NM1A
	XCT	NM1A		;MOVEI W2,..
	MOVSI	R,201400
NM1A1:	TRZE	W2,1
	FMPR	R,FT(W1)
	JUMPE	W2,NM1B
	LSH	W2,-1
	SOJG	W1,NM1A1
NM1B:	MOVSI	W1,211000(T)
	FMPR	R,W1		;COMPUTE VALUE OF NEW DIGIT
	FADRB	R,FH		;ADD VALUE INTO FLOATING NO.
	MOVEM	R,SYL
	AOJA	T,LE1A

POWER:	TXNN	F,FEF
	JRST	L4		;NO EXPONENT
				;REMOVE USELESS CODE
	MOVE	W2,DEN
	SETZM	FRASE
	MOVEI	W1,FT-1
	TXZE	F,MF
	MOVEI	W1,FT01
	SKIPA	T,FSV
POW2:	LSH	W2,-1
	TRZE	W2,1
	FMPR	T,(W1)
	JUMPE	W2,L4
	SOJA	W1,POW2
PERIOD:	TXNN	F,CF!CCF	;$. OR $$. COMMAND?
	JRST	PERIO2		;NO, JUST . CHARACTER BY ITSELF
  IFE FTFILE,<		;YES
	SKIPN	BPTIP		;BREAKPOINT IN PROGRESS?
	JRST	ERR		;NO, THEN NOT LEGAL AFTER ALL
	TXNN	F,CCF		;$. OR $$. COMMAND?
	SKIPA	T,PCWRD		;$.  -- CURRENT $X PC
	MOVE	T,I.NPC		;$$. -- PREVIOUS $X PC
	TXZA	F,CF!CCF	;CLEAR CONTROL FLAGS
  > ;END IFE FTFILE

  IFN FTFILE,<
	JRST	ERR>		;ILLEGAL IN FILDDT

PERIO2:	MOVE	T,LLOC		;JUST ".", LAST LOCATION OPENED
	TXNE	F,SF
	MOVE	T,DEN
	MOVEM	T,SYL
	TXNE	F,FPF		;HAS A PERIOD BEEN SEEN BEFORE?
	TXO	F,LTF		;YES, TWO PERIODS MAKES A SYMBOL
	TXON	F,FPF!SF!QF
	SETZ	T,
	IDIVI	T,400
	SKIPE	T
	TLC	T,243000
	TLC	W1,233000
	FAD	T,[0]		;NORMALIZE T AND W1
	FAD	W1,[0]
	FADR	T,W1
	MOVEM	T,FH
	HLLZS	NM1A
	MOVEI	T,45		;RADIX 50 PERIOD
	JRST	LE2

QUAN:	TXNN	F,CCF		;$Q OR $$Q, WHICH?
	SKIPA	T,LWT		;$Q STRAIGHT
	MOVS	T,LWT		;$$Q SWAPPED
QUAN1:	MOVEM	T,SYL
QUAN2:	TXO	F,SF!QF		;WRD,SYL STARTED
	TXZ	F,CF!CCF
	JRST	L2

;HERE WHEN ESC TYPED

CONTRO:	TXOE	F,CF
	TXO	F,CCF
	SETOM	WAKALL		;SET WAKEUP ON EVERYTHING
	JRST	L2
QUESTN:	PUSHJ	P,TCRLF		;HERE FOR "?"
IFN FTDEC20,<
	TXNE	F,CCF		;TWO ESC?
	JRST [	PUSHJ	P,XEVAL		;YES, EVAL PREV EXPRESSION
		MOVEI	T1,.PRIOU
		HRLOI	T2,.FHSLF	;ASSUME THIS FORK, LAST ERROR
  IFN FTEXEC,<
		SKPUSR			;ONLY LEGAL IN USER MODE
		JRST	ERR		;EXEC MODE, ERROR
  > ;END IFN FTEXEC
  IFN FTFILE,<
		TXC	F,QF		;TEST FOR ILLEGAL COMBINATIONS
		TXNE	F,QF!FAF	;FOO$$? IS ONLY LEGAL FORM
		JRST	ERR		;FORK OR NO ERR CODE, NO GOOD
  > ;END IFN FTFILE
  IFE FTFILE,<
		TXNE	F,FAF		;FORK SPECIFIED?
		HRL	T2,LLIMIT	;YES
		TXNE	F,QF		;ERROR CODE SPECIFIED?
  > ;END IFE FTFILE
		HRR	T2,WRD		;YES
		SETZ	T3,
		ERSTR%
		 ERJMP	ERR		;TRAP ILLEGAL FORK NUMBER FROM USER
		 JRST	ERR
		JRST	DD1]		;DONE
> ;END IFN FTDEC20

	TXNE	F,CF		;ONE ESC?
	 JRST [	TXNE	F,QF!SAF!FAF!Q2F ;YES, ANYTHING TYPED IN FRONT?
		JRST	ABBREV		;YES, GO TYPE SOME SYMBOLS
		SKIPE	W1,MEMERS	;YES, TYPE LAST ERROR MESSAGE
		PUSHJ	P,TSTRG
		JRST	DD1]
	TXNE	F,LTF		;HAS A SYMBOL BEEN TYPED?
	 JRST	QLIST		;YES
	PUSHJ	P,USYSET	;NO, LIST UNDEFINED SYMBOLS

QUEST2:	SOSGE	R		;POINT TO NAME WORD OF PREVIOUS SYMBOL
	PUSHJ	P,ADVSYM	;DONE, SEE IF ANY MORE TABLE
	SKIPA	W2,@SYPTR	;GET THE NAME
	JRST	DD1		;ALL DONE, <CRLF> AND RESTART
	TXZ	W2,PNAME	;CLEAR FLAGS
	PUSHJ	P,PSYM		;TYPE THE SYMBOL
	PUSHJ	P,TCRLF		;END WITH A CRLF
	SOJA	R,QUEST2	;SKIP VAL WORD OF NEXT SYMBOL AND LOOP
;HERE TO LIST ALL REFERENCES TO A SYMBOL

QLIST:	PUSHJ	P,SYMSET	;SET UP TO WALK THROUGH TABLE

QLIST2:	SOSGE	R		;ANY MORE TABLE?
	PUSHJ	P,ADVSYM	;MAYBE NOT, CHECK IT OUT
	SKIPA	W1,@SYPTR	;YES, GET THE NEXT NAME
	JRST	DD1		;ALL DONE, <CRLF> AND GET NEXT COMMAND
	TXZE	W1,PNAME	;IS THIS THE NEXT MODULE NAME?
	JRST	QLIST4		;NO, GO SEE IF THE SYMBOL NAME MATCHES
	MOVE	W2,W1		;SAVE THIS MODULE NAME IN CASE WE MATCH
	SOJA	R,QLIST2	;GET NEXT NAME

QLIST4:	CAME	W1,SYM		;A MATCH?
	SOJA	R,QLIST2	;NO, PROCEED
	PUSHJ	P,PSYM		;YES, TYPE CURRENT MODULE NAME
	MOVE	W1,@SYPTR	;RETRIEVE FLAGS
	TXNN	W1,GLOBL	;A GLOBAL SYMBOL?
	JRST	QLIST6		;NO, GO TYPE CRLF
	PUSHJ	P,TSPC		;YES, TYPE " G"
	MOVEI	T,"G"		; . . .
	PUSHJ	P,TOUT		; . . .

QLIST6:	PUSHJ	P,TCRLF		;END LINE
	SOJA	R,QLIST2	;ON TO ANOTHER SYMBOL
;FOO$? COMMAND -- TYPE OUT SYMBOLS STARTING WITH FOO

ABBREV:	TXNE	F,TIF!COMF!PTF!MF!CCF ;CHECK FOR LEGAL ARGUMENTS
	JRST	ERR		;$$ AND EXPRESSION ARE ILLEGAL
	SKIPN	W1,SYM		;ANYTHING RESEMBLING A SYMBOL TYPED?
	TXNE	F,SAF!FAF!Q2F	;NO, IS IT OK ANYWAY?
	SKIPA	W2,W1		;YES, GET ANOTHER COPY
	JRST	ERR		;NO, COMPLAIN
	TXNN	F,Q2F		;DID WE GET ANY FLAGS?
	SETZM	WRD2O		;NO, MAKE SURE WE KNOW IT
	MOVX	T,1B0		;NEGATIVE INFINITY
	TXNN	F,FAF		;HAVE A LOWER LIMIT?
	MOVEM	T,LLIMIT	;NO, SET IT UP
	TXNE	F,FAF		;CHECK AGAIN
	SKIPA	T,LLIMIT	;YES, COPY IT
	MOVX	T,<^-<1B0>>	;NO, USE POSITIVE INFINITY
	TXNN	F,SAF		;IF NO UPPER LIMIT GIVEN,
	MOVEM	T,ULIMIT	;USE WHAT WE JUST SET UP
	MOVE	T,ULIMIT	;GET UPPER LIMIT
	CAMGE	T,LLIMIT	;LIMITS IN THE RIGHT ORDER?
	JRST	ERR		;NO, COMPLAIN
	MOVEI	T,75		;ONLY MASKS CURRENTLY DEFINED
	ANDCA	T,WRD2O		;SEE IF ANY UNKNOWN BITS ARE ON
	JUMPN	T,ERR		;COMPLAIN IF SO
ABBRE1:	CAMLE	W2,[RADIX50 0,%%%%%]	;PADDED ENOUGH YET?
	JRST	ABBRE2		;YES
	IMULI	W1,50		;SHIFT SYM ONE PLACE TO THE LEFT
	IMULI	W2,50		;THIS ONE TOO
	ADDI	W2,47		;AND PAD TO BE UPPER LIMIT
	JRST	ABBRE1		;SEE IF IT'S ENOUGH

;HERE WITH W1 LEFT JUSTIFIED, BLANK PADDED, AND W2 LEFT JUSTIFIED, MAX PADDED.

ABBRE2:	DMOVEM	W1,ABBSY1	;SAVE THE PADDED SYMBOLS
	PUSHJ	P,SYMSET	;SET UP TO LOOK AT SYMBOL TABLE
	MOVE	T,WRD2O		;GET FLAGS AGAIN
	TRZE	T,1		;WANT ONLY OPEN SYMBOL TABLE?
	TXNN	F,PNAMEF	;YES, IS THERE ONE OPEN?
	CAIA			;IT'S OK, PROCEED
	JRST	ERR		;NO, GIVE UP
	ANDCAM	T,WRD2O		;MAKE 0/NON-0 FLAG FOR LATER
	ROT	T,-6		;SHIFT TO MATCH PNAME
	MOVEM	T,ABBSY3	;SAVE FOR FLAG TESTING
ABBRE3:	TRNN	R,36		;EVERY FEW SYMBOLS
	JRST [	PUSHJ	P,LISTEN	;CHECK FOR TYPEIN
		 JRST	.+1		;NOTHING, KEEP GOING
		 JRST	DD1]		;USER WANTS TO ABORT
	SOSGE	R		;COUNT DOWN SYMBOLS
	PUSHJ	P,ADVSYM	;REACHED END, ANY MORE?
	SKIPA	W2,@SYPTR	;FETCH THE SYMBOL
	JRST	DD1		;NO MORE SYMBOLS, ALL DONE
	MOVE	T,W2		;KEEP A COPY WITH THE FLAGS
	TXZE	W2,PNAME	;IS IT A MODULE NAME?
	TDZA	W1,W1		;NO, REMEMBER THAT
	SETO	W1,		;YES, REMEMBER THAT
ABBRE5:	CAMG	W2,[RADIX50 0,%%%%%]	;PADDED TO SIX CHARS?
	JRST [	IMULI	W2,50		;NO, SHIFT ONE PLACE
		JRST	ABBRE5]		;AND TRY AGAIN
	JUMPE	W1,ABBRE7	;IS IT A MODULE NAME?
	MOVE	W,W2		;YES, SAVE (PADDED) NAME
	SKIPN	WRD2O		;IF ALL MODULES DESIRED,
	SOJA	R,ABBRE3	;TRY NEXT SYMBOL
	AOS	T,WRD2O		;INCREMENT COUNTER
	CAIN	T,2		;IF JUST PASSING OUR DESIRED MODULE NAME,
	SOJA	R,ABBRE3	;KEEP GOING
	JRST	DD1		;ELSE DONE
ABBRE7:	CAML	W2,ABBSY1	;IS IT IN RANGE?
	CAMLE	W2,ABBSY2
	SOJA	R,ABBRE3	;NO, TRY NEXT SYMBOL
	AND	T,ABBSY3	;YES, GET ITS FLAGS
	CAME	T,ABBSY3	;SEE IF A MATCH
	SOJA	R,ABBRE3	;NO, TRY NEXT
	XMOVEI	T,@SYPTR	;POINT TO SYMBOL ENTRY
	AOJ	T,		;WANT VALUE WORD
	MOVE	T,@T		;FETCH IT
	CAML	T,LLIMIT	;IN RANGE?
	CAMLE	T,ULIMIT	;BOTH WAYS?
	SOJA	R,ABBRE3	;NO, TRY NEXT SYMBOL
	PUSH	P,R		;YES, SAVE SYMBOL INDEX
	PUSH	P,T		;AND VALUE
	PUSHJ	P,PSYM		;YES, TYPE OUT THE (PADDED) SYMBOL
	PUSHJ	P,TTAB		;WHITE SPACE
	MOVE	W2,W		;GET MODULE NAME
	PUSHJ	P,PSYM		;TYPE THAT TOO (ALSO PADDED)
	PUSHJ	P,TSPC		;A SPACE
	MOVE	W1,@SYPTR	;GET SYMBOL FLAGS
	MOVEI	T,"G"		;INDICATE GLOBAL SYMBOL
	TXNN	W1,GLOBL	;UNLESS OF COURSE...
	MOVEI	T," "		;IT'S A LOCAL
	PUSHJ	P,TOUT		;TYPE THE INDICATOR
	PUSHJ	P,TTAB		;MORE WHITE SPACE
	MOVE	T,(P)		;RETRIEVE VALUE
	PUSHJ	P,TOC		;TYPE VALUE NUMERICALLY
	POP	P,W1		;GET VALUE BACK
	MOVN	W2,W1		;(X .AND. -X) = RIGHTMOST BIT OF X
	AND	W2,W1		;FIND THE BIT
	CAMN	W2,W1		;TYPE BIT NUMBER ONLY IF SINGLE-BIT VALUE
	 JFFO	W1,.+2		;FIND THE BIT NUMBER INTO W2
	  JRST	ABBRE9		;NOT EXACTLY ONE BIT, DON'T TYPE IT
	MOVE	W1,[ASCII /	(1B/]	;SEPARATING TEXT
	PUSHJ	P,TEXT		;TYPE IT OUT
	MOVE	A,W2		;GET THE NUMBER (NOTE: A=R)
	PUSHJ	P,FP7		;TYPE IT IN DECIMAL
	MOVEI	T,")"		;CLOSING TEXT
	PUSHJ	P,TOUT		;TYPE IT
ABBRE9:	POP	P,R		;RESTORE SYM INDEX
	PUSHJ	P,TCRLF		;CLOSE OUT THE LINE
	SOJA	R,ABBRE3	;AND GO FOR NEXT SYMBOL
;$K COMMAND -- SUPPRESS A SYMBOL TO DDT TYPEOUT OR DELETE IT ENTIRELY

KILL:	TXNN	F,LTF		;DELETE SYMBOLS
	JRST	ERR
	MOVE	S,SYM		;GET SYMBOL
  IFN FTSCSH,<			;ONLY IF USING SYMBOL TABLE CACHE
	PUSHJ	P,DELCSH	;REMOVE SYMBOL FROM SYMBOL TABLE CACHE
  > ;END IFN FTSCSH
	PUSHJ	P,EVAL
	JRST	KILL2
	MOVE	R,W1		;SYMBOL INDEX INTO R
	MOVE	T,W2		;FLAGS INTO T
	TXO	T,DELO		;ASSUME DELETE OUTPUT
	TXNE	F,CCF		;$$K?
	MOVX	T,DELO!DELI!37777B17 ;MAKE SYM DELETED IN AND OUT
	PJRST	DSYMER		;DEPOSIT IF POSSIBLE


KILL2:	SKIPN	ESTUT		;ANY UNDEFINED TABLE?
	JRST	UNDEF		;NO, CAN'T FIND THE SYMBOL

KILL4:	PUSHJ	P,EVALU		;SEE IF ANY MORE OCCURENCES OF SYM
	  POPJ	P,		;NO, DONE
	PUSHJ	P,REMUN
	 JRST	ERR		;CAN'T MODIFY SYMTAB
	JRST	KILL4		;LOOK FOR MORE OCCURENCES


;$D ;DELETE LAST SYM & PRINT NEW

SYMD:	SKIPL	R,SPSAV		;PICK UP POINTER TO LAST SYM
	PUSHJ	P,FETSYM	;PICK UP SYMBOL
	  JRST	ERR		;CAN'T GET IT?
	MOVE	S,T		;COPY SYMBOL
  IFN FTSCSH,<			;ONLY IF USING SYMBOL TABLE CACHE
	PUSHJ	P,DELCSH	;REMOVE IT FROM THE SYMBOL TABLE CACHE
  > ;END IFN FTSCSH
	TXO	T,DELO		;TURN ON "SUPPRESS OUTPUT" BIT
	PUSHJ	P,DSYMER	;STORE BACK IN SYMBOL TABLE
	MOVE	T,LWT
	JRST	CONSYM		;PRINT OUT NEXT BEST SYMBOL
;COLON OR ALT COLON OR ALT ALT COLON COMMANDS

TAG:	TXNE	F,CCF		;SYMBOL OR PDV?
	JRST	PDVSET		;PDV NAME
	TXNE	F,CF		;DEFINE SYMBOL OR OPEN SYMBOL TABLE?
	JRST	NAMSET		;OPEN (SELECT) LOCAL SYMBOL TABLE
	TXNN	F,LTF		; NO LETTERS IS ERROR
	JRST	ERR		; GO SAY ERROR
	TXNE	F,FAF		; DEFINE SYMBOLS
	JRST	DEFIN		;A.LT.B:
	MOVE	W,LLOCO		;DEFINE SYMBOL (TAG) TO BE "."
	MOVEM	W,LLIMIT	;SAVE NEW TAG VALUE

DEFIN:	MOVE	S,LLIMIT	;GET VALUE BEING DEFINED
  IFN FTSCSH,<			;ONLY IF USING SYMBOL TABLE CACHE
	PUSHJ	P,DELCSV	;REMOVE ANY CACHE SYMBOL USING THIS VALUE
  > ;END IFN FTSCSH
	PUSHJ	P,EVAL		;DEFINED SYMBOL?
	 JRST	DEF1		;NO - DEFINE
	MOVE	S,SYM		;YES - GET SYMBOL NAME BEING DEFINED
  IFN FTSCSH,<			;ONLY IF USING SYMBOL TABLE CACHE
	PUSHJ	P,DELCSH	;REMOVE THE SYMBOL FROM THE CACHE
  > ;END IFN FTSCSH
	MOVE	R,W1		;REMEMBER SYMBOL INDEX IN R
	JRST	DEF4		;REDEFINE EXISTING SYMBOL

DEF1:	TXZ	F,HSYMF		;ASSUME LOWSEG SYMBOL TABLE
	SKIPN	SYMP+S$ADR	;DEFINE A NEW SYMBOL
	JRST [	SKIPN	HSYMP+S$ADR	;NO ST, TRY HISEG PTR
		JRST	ERR		;NONE THERE EITHER
		MOVEI	W1,HSYMP	;WANT TO UPDATE HISEG POINTER
		PUSHJ	P,INCSYP	;GO TRY
		 JRST	DMER1		;COULDN'T, GO SAY WHY
		TXO	F,HSYMF		;REMEMBER HISEG TABLE USED
		SKIPL	PRGM		;AN OPEN MODULE IN THE HIGH SEG?
		JRST	DEF2		;NO, CONTINUE
		JRST	DEFF]		;YES, COMPENSATE FOR SUB FIRST
	MOVEI	W1,SYMP		;WANT TO UPDATE LO SEG POINTER
	PUSHJ	P,INCSYP	;GO DO IT
	 JRST	DMER1		;CAN'T, GO SAY WHY
	SKIPG	PRGM		;AN OPEN MODULE IN THE LOWSEG TABLE?
	JRST	DEF2		;NO, CONTINUE
DEFF:	AOS	PRGM		;YES, COMPENSATE FOR THE SUB
	AOS	PRGM		; . . .
DEF2:	AOS	PTFIX		;COMPENSATE FOR THE SUB HERE TOO
	AOS	PTFIX		;SO PAT.. WILL BE MOVED
  IFN FTSCSH,<			;ONLY IF USING SYMBOL TABLE CACHE
	PUSHJ	P,CLRCSH	;CLEAR CACHE, ALL INDEXES NOW WRONG
  > ;END IFN FTSCSH
	SOS	ESTUT		;EAT TWO WORDS OF PATCH SPACE
	SOS	ESTUT		;  FOR NEW SYMBOL TO LIVE IN
	SKIPN	R,ESTUTL	;DOES AN UNDEFINED TABLE EXIST?
	JRST	DEF3		;NO, JUST DEC ADDRESS OF WHERE IT WOULD EXIST

;FALL THROUGH TO NEXT PAGE
;HERE WHEN WE WANT TO INSERT A NEW SYMBOL, BUT THE UNDEFINED SYMBOL
;TABLE IS IN THE WAY.  MOVE THE LAST SYMBOL OF THE UNDEFINED TABLE TO
;RIGHT BEFORE THE FIRST ONE, AND USE THE WORDS FREED TO INSERT THE NEW
;DEFINED SYMBOL.  THIS IS OK BECAUSE THE UNDEFINED TABLE IS NOT ORDERED.

	TXO	R,1B1		;FORM AN UNDEFINED ST SYMBOL INDEX
	PUSHJ	P,FETSYM	;GET 1ST WORD OF LAST SYMBOL
	  JRST	ERR		;ERROR?
	MOVE	W1,R		;SAVE WHERE WE GOT IT
	MOVX	R,1B1		;POINT TO 1ST WORD (USED TO BE IN PATCH AREA)
	PUSHJ	P,DSYMER	;STORE SYMBOL IN NEW HOME
	AOS	R,W1		;POINT TO 2ND WORD OF LAST SYMBOL
	PUSHJ	P,FETSYM	;GET IT
	  JRST	ERR		;ERROR
	MOVX	R,1B1+1		;2ND WORD OF TABLE
	PUSHJ	P,DSYMER	;DEPOSIT


;NOW TO STORE THE SYMBOL TO BE DEFINED.  ENTER AT DEF3 TO APPEND TO THE
;SYMBOL TABLE AS A GLOBAL DEFINITION IN MODULE PAT.., AND AT DEF4 TO
;UPDATE AN EXISTING SYMBOL.

DEF3:	MOVEI	W1,USYMP	;IT ALL WORKED, MAKE OUR WORKING COPY
	PUSHJ	P,DECSYA	; OFFICIAL BY DECREMENTING UNDEF PTR
	 JRST	DMER1		;BUT... BUT...
	PUSH	P,SYM		;IF APPENDING, NEED TO UPDATE THE MODULE
	MOVX	R,<RADIX50 0,PAT..> ;  LENGTH FOR THE MODULE "PAT.."
	MOVEM	R,SYM		;SAVE WHERE NAMSRH CAN FIND IT
	PUSHJ	P,NAMSRH	;LOOK UP PAT.. IN THE TABLE
	  JRST	DEF3A		;NOT THERE, GIVE UP
	PUSHJ	P,FETSYM	;GET ITS VALUE WORD
	  JRST	DEF3A		;NOT ACCESSIBLE?
	JUMPGE	T,DEF3A		;DON'T IF COUNT IS 0 (OLD LINK BUG)
	SUB	T,[2,,0]	;COUNT ANOTHER SYMBOL
	PUSHJ	P,DEPSYM	;STORE NEW VALUE
	  JFCL			;??
DEF3A:	POP	P,SYM		;RESTORE SYM FOR DEF4
	TXNN	F,HSYMF		;CHANGING HISEG TABLE?
	TDZA	R,R		;NO, POINT TO 0'TH WORD OF LOWSEG TABLE
	MOVX	R,1B0		;YES, POINT TO 0'TH WORD OF HISEG TABLE
DEF4:	MOVX	T,GLOBL
	IOR	T,SYM
	PUSHJ	P,DSYMER
	MOVE	T,LLIMIT
	ADDI	R,1
	PUSHJ	P,DSYMER

;FALL THROUGH TO NEXT PAGE
;NOW TO SEARCH THE UNDEFINED TABLE, LOOKING FOR REFERENCES TO THIS SYMBOL.
;IF WE FIND ANY, FIX UP THE LOCATION(S) THEY POINT TO, AND REMOVE THEM
;FROM THE UNDEFINED TABLE.

DEF5:	PUSHJ	P,EVALU		;SEARCH UNDEFINED TABLE
	  POPJ	P,		;NOT FOUND, ALL DONE
	SKIPL	R,T		;ADDITIVE OR CHAINED FIXUP?
	JRST	DEF7		;CHAINED, GO HANDLE
	MOVE	W2,R		;GET A COPY OF THE FIXUP FLAGS
	ANDX	R,VMADR		;REDUCE R TO 30-BIT ADDRESS
	PUSHJ	P,FETCHV	;GET OBJECT CELL
	 JRST	ERR
	TXNN	W2,STNEG	;ADDITIVE OR SUBTRACTIVE?
	SKIPA	S,LLIMIT	;ADDITIVE
	MOVN	S,LLIMIT	;SUBTRACTIVE
	TXNE	W2,STLH		;RIGHT OR LEFT HALF?
	JRST [	HRLZS	S	;LEFT HALF
		ADD	T,S	;ADD INTO LEFT HALF
		JRST	DEF6]
	ADD	S,T		;RIGHT HALF, ADD HALVES
	HRR	T,S		;  AND REPLACE RIGHT HALF
DEF6:				;DO FIXUPS RIGHT IN TOPS-10 MONITOR
  IFN FTFILE&FTDEC10,<		;PEEK BEFORE POKE
	SKIPE	FILING		;POKING MONITOR?
	 JRST	DEF60		;NO, SKIP AHEAD
	PUSH	P,T		;SAVE NEW WORD TO POKE
	PUSHJ	P,FETCHV	;YES, GET CURRENT WORD IN MONITOR
	 JRST	ERR		;PEEK FAILED
	MOVEM	T,POKBLK+1	;PUT INTO POKE. BLOCK
	POP	P,T		;RESTORE T
DEF60:
  > ;END IFN FTFILE&FTDEC10
	PUSHJ	P,STOREV	;STORE RESULT BACK INTO MEMORY
	 JRST	ERR		;FAILED
	JRST	DEF8		;GO REMOVE SYMBOL AND TRY AGAIN

DEF7:	MOVE	S,R		;COPY INITIAL FIXUP ADDRESS
DEF7A:	JUMPE	S,DEF8		;IF CHAIN REACHES 0, WE'RE DONE
	PUSHJ	P,FETCHV	;GET OBJECT CELL
	 JRST	ERR
	HRRZ	S,T		;SAVE CHAIN POINTER
	HRR	T,LLIMIT	;REPLACE WITH NEW VALUE
	PUSHJ	P,STOREV	;AND STORE BACK INTO MEMORY
	 JRST	ERR		;FAILED
	HRR	R,S		;LOOP IN-SECTION TO END
	JRST	DEF7A		;  OF CHAIN

DEF8:	PUSHJ	P,REMUN
	 JRST	ERR		;CAN'T MODIFY SYMTAB
	JRST	DEF5
;HERE ON A NAME$: COMMAND -- OPEN A MODULE'S SYMBOL TABLE

NAMSET:	TXNE	F,Q2F		;2ND QUANTITY TYPED?
	SKIPA	TT,WRD2D	;YES, FETCH IT
	SETZ	TT,		;NO, DEFINITELY OURS
	JUMPN	TT,NAMTYP	;IF NOT $0:, GO SEE IF $1:
	TXNE	F,FAF!SAF!TIF!COMF!PTF!MF ;MOST ARGS BEFORE $0: ARE ILLEGAL
	JRST	ERR		;RESERVE THEM
	TXNE	F,QF		;ANYTHING TYPED?
	JRST	NAMS2		;YES, SET NEW MODULE
	SETZM	PRGM		;NO, JUST CLEAR CURRENT MODULE
	SETZM	SEGNAM		;AND HISEG IT CAME FROM
IFN FTSCSH,<
	JRST	CLRCSH>	;CLEAR SYMBOL TABLE CACHE
IFE FTSCSH,<
	POPJ	P,>

;HERE TO SET A NEW MODULE NAME.

NAMS2:	PUSHJ	P,NAMSRH	;SEARCH FOR THE NAME
	  JRST	UNDEF		;NOT FOUND
  IFN FTSCSH,<			;ONLY IF USING SYMBOL TABLE CACHE
	PUSHJ	P,CLRCSH	;FOUND IT, CLEAR THE SYMBOL TABLE CACHE
  > ;END OF IFN FTSCSH
	MOVEM	R,PRGM		;STORE AS NEW OPEN MODULE
	JUMPGE	R,CPOPJ		;DONE IF R POINTS TO LOW SEG
	MOVEI	R,.JBHNM	;POINTS TO HI SEG, POINT TO SEGMENT NAME
	PUSHJ	P,HFETCH	;GET IT
	 SETZ	T,		;NO HI SEG, OR EXEC MODE
	MOVEM	T,SEGNAM	;STORE SEGMENT NAME FOR SYMCHK
	POPJ	P,		;DONE

;HERE TO TYPE OUT CURRENT OPEN MODULE NAME

NAMTYP:	SOJN	TT,NAMLST	;IF NOT $1:, SEE IF $2:
	TXNE	F,QF!FAF!SAF!SF	;MOST ARGS ILLEGAL FOR $1:
	JRST	ERR		;RESERVE THEM
	SKIPN	T,PRGM		;IS THERE AN OPEN MODULE?
	POPJ	P,		;NO, JUST RETURN
	SOS	R,T		;POINT TO FIRST WORD OF SYMBOL ENTRY
	PUSHJ	P,FETSYM	;GET THE WORD
	 JRST	ERR		;CAN'T HAPPEN
	PUSH	P,T		;SAVE OVER TOUT CALL
	MOVEI	T,"/"		;SEPARATE TEXT FROM COMMAND
	PUSHJ	P,TOUT		; WITH A SLASH
	POP	P,W2		;GET SYMBOL BACK
	PUSHJ	P,PSYM		;TYPE IT OUT
	SKIPG	PRGM		;HISEG MODULE?
	SKIPN	T,SEGNAM	;WITH A NAME?
	POPJ	P,		;NO OR NO, ALL DONE
	MOVEM	T,LWT		;YES, SAVE IT AWAY
	PUSHJ	P,TTAB		;SEPARATE THE NAMES
	PJRST	SIXBP		;AND GO TYPE THE HISEG NAME

;HERE FOR $2: TO LIST ALL KNOWN MODULES

NAMLST:	SOJN	TT,ERR		;$2: WAS YOUR LAST CHANCE
	TXNE	F,QF!FAF!SAF!SF	;MOST ARGS ILLEGAL FOR $2:
	JRST	ERR		;RESERVE THEM
	PUSHJ	P,SYMCHK	;MAKE SURE OF SYMBOLS BEFORE HFETCH
	MOVEI	R,.JBHNM	;OFFSET FOR HISEG NAME
	PUSHJ	P,HFETCH	;GET THE NAME
	  SETZ	T,		;NONE THERE
	MOVE	W,T		;SAVE THE HISEG NAME FOR LATER USE
	PUSHJ	P,SYMSET	;SETUP TO SEARCH THE SYMBOL TABLE
	SOJ	R,		;ACCOUNT FOR AOSGE BELOW
	PUSHJ	P,TCRLF		;START AT LEFT MARGIN

;HERE TO GET NEXT MODULE

NAMLS2:	AOSGE	R		;IF OUT OF SYMBOLS IN THIS TABLE,
	PUSHJ	P,ADVSYM	;THEN ADVANCE THE POINTER
	SKIPA	T,@SYPTR	;GET NEXT VALUE WORD
	JRST	DD1		;DONE WITH LISTING
	HLRE	T,T		;GET -VE LENGTH OF THIS TABLE
	SOSGE	R		;BACK OFF TO MODULE NAME WORD
	PUSHJ	P,ADVSYM	;ADVANCING IF NECESSARY
	SKIPA	W2,@SYPTR	;GET THE NAME
	JRST	ERR		;VALUE BUT NO NAME IS BAD FORMAT
	TXNE	W2,PNAME	;MUST LOOK LIKE A MODULE NAME
	JRST	ERR		;ELSE IS BAD FORMAT
	ADD	R,T		;BACKUP POINTER TO NEXT MODULE
	SKIPN	T		;ZERO IS PAT.. BEFORE LINK BUG WAS FIXED,
	MOVNI	R,2		;SO SET TO ADVANCE TABLES
	PUSHJ	P,PSYM		;TYPE THE MODULE NAME
	TXNE	F,HSYMF		;IF NOT HISEG,
	SKIPN	W		;OR NAME NOT KNOWN,
	JRST	NAMLS3		;SKIP TYPING THE SEGMENT NAME
	MOVE	W1,TOHPS	;GET CURRENT HPOS
	SUBI	W1,7		;GET -VE DISTANCE UNTIL WE'VE PADDED ENOUGH
	MOVEI	T," "		;LOAD UP A SPACE
	PUSHJ	P,TOUT		;TYPE ONE
	AOJL	W1,.-1		;PAD UNTIL DONE
	MOVE	W1,W		;GET THE SEGMENT NAME
	PUSHJ	P,TSIXN		;TYPE IT IN SIXBIT
NAMLS3:	PUSHJ	P,TCRLF		;END THE LINE
	JRST	NAMLS2		;TYPE ALL KNOWN MODULES

;HERE ON $$: COMMAND -- READ PDV NAME AND SET $5M

  IFN FTEX20!FTMON!<FTDEC10&FTFILE>,<PDVSET==ERR>  ;ILLEGAL IN MONITORS, -10

  IFE FTEX20!FTMON!<FTDEC10&FTFILE>,<

PDVSET:
  IFN FTFILE,<
	SKIPE	FILING		;MUST BE LOOKING AT A FILE
	SKIPN	EXEFMT		;IN .EXE FORMAT
	JRST	ERR		;OR WE CAN'T DO IT
  > ;END IFN FTFILE
  IFN FTEXEC,<
	SKPUSR			;MUST BE IN USER MODE
	JRST	ERR		;OR WE CAN'T DO IT
  > ;END IFN FTEXEC
	TXNE	F,Q2F		;$$1: ?
	SKIPA	T,WRD2D		;MAYBE, GET THE FLAG
	SETZ	T,		;NO, IT'S OURS
	JUMPN	T,PDVTYP	;IF NOT $$0:, GO SEE IF $$1:
	TXNE	F,FAF!SAF!TIF!COMF!PTF!MF ;MOST ARGS BEFORE $$0: ARE ILLEGAL
	JRST	ERR		;BAD SYNTAX
IFN FTDEC20,<
	TXZ	F,CF!TXF	;CLEAR SOME FLAGS FOR TEXI
	XMOVEI	T,1(P)		;STORE PDV NAME ON STACK
	MOVEM	T,TEM		;REMEMBER WHERE
	MOVEM	T,WRD		;KEEP AN ORIGINAL COPY
	ADJSP	P,PVNMSZ	;MAKE ROOM FOR NAME
	ADDI	T,PVNMSZ-1	;GET LAST ADDRESS OF BLOCK
	MOVEM	T,TEM1		;SAVE THAT TOO
	MOVEI	T,7		;NORMAL ASCII BYTE SIZE
> ;END IFN FTDEC20
IFN FTDEC10,<
	TXZ	F,ROF!TXF	;CLEAR SOME FLAGS FOR TEXI
	MOVEI	T,6		;BYTE SIZE FOR SIXBIT TYPEIN
> ;END IFN FTDEC10
	MOVEM	T,WRD2D		; FOR BUILDING BYTE POINTERS
	TXNN	F,QF		;IF NO ARG,
	JRST	TEXI1		;GO READ THE STRING
	SETZ	T,		;GET A NULL
	IDPB	T,CHP		;FINISH THE SYMBOL TYPEIN
IFN FTDEC20,<
	DMOVE	TT,OPTXT	;GET THE TEXT
	DMOVEM	TT,@WRD		;PUT IT WHERE WE LOOK FOR IT
	MOVE	R,TEM1		;POINT PAST THE COPIED OPTXT
	;FALL INTO PDVSE2
> ;END IFN FTDEC20
IFN FTDEC10,<
	MOVE	TT,[POINT 7,OPTXT] ;SOURCE BYTE POINTER
	MOVE	W2,[POINT 6,W]	;DESTINATION BYTE POINTER
	SETZ	W,		;CLEAR ACCUMULATOR
PDVSE1:	ILDB	T,TT		;GET SOURCE BYTE
	JUMPE	T,PDVSE2	;DONE AT END OF STRING
	SUBI	T," "		;CONVERT TO SIXBIT
	IDPB	T,W2		;APPEND TO SEGMENT NAME
	JRST	PDVSE1		;LOOP OVER THE PROPOSED NAME
> ;END IFN FTDEC10

;HERE AFTER THE STRING HAS BEEN READ IN

PDVSE2:
IFN FTDEC20,<
	CAMG	R,TEM1		;PAST END OF BLOCK?
	MOVEM	W,(R)		;NO, STORE END OF STRING
	MOVEI	R,377		;RIGHT-MOST BYTE
	ANDCAM	R,@TEM1		;MAKE SURE WE'RE ASCIZ

  IFE FTFILE,<			;FIRST THE NON-FILDDT CASE
	PUSHJ	P,PDVINI	;SET UP PDVOP% ARG BLOCK
	MOVEI	T1,.POLOC	;LOCATE FUNCTION
	XMOVEI	T2,PDVARG	;ADDRESS OF ARG BLOCK
	HRRO	T3,WRD		;MAKE A BYTE POINTER TO PDV NAME
	PDVOP%			;FIND THE PDV
	 ERJMP	ERR		;SOMETHING DIED, GUESS IT'S NOT THERE
	SKIPN	PDVARG+.POCT2	;ANYTHING FOUND?
	JRST	ERR		;NO, DON'T DIDDLE ANYTHING
	ADJSP	P,-PVNMSZ	;RECLAIM STACK SPACE
	MOVE	T1,PDVA		;GET THE PDVA
	MOVEM	T1,SYTLOC	;SET $5M
	SETZM	SYMVAL		;DON'T TRUST IT
	PJRST	SYMCHK		;GO CHECK IT OUT NOW
  > ;END IFE FTFILE
;STILL IFE FTEX20!FTMON!<FTDEC10&FTFILE> AND IFN FTDEC20

;FILDDT CASE AFTER THE STRING HAS BEEN READ IN

;FALL IN FROM PDVSE2

  IFN FTFILE,<
	SKIPG	W1,PDVNUM	;ANY PDVS EXIST?
	JRST	ERR		;NO, DON'T BOTHER LOOKING
	SETO	W2,		;START WITH FIRST ONE
PDVSE3:	PUSHJ	P,NXTPDV	;GET THE PDVA
	ADDI	R,.PVNAM	;GET NAME ENTRY
	PUSHJ	P,FETCH		;GRAB THE WORD
	 JRST	ERR		;NAUGHTY!
	TXNE	T,IFIW		;IS NAME POINTER LOCAL?
	HLL	T,R		;YES, SET REAL SECTION NUMBER
	MOVE	R,T		;MOVE INTO RIGHT AC
	SKIPN	@WRD		;USER TYPE NULL STRING?
	JRST [	JUMPE	R,PDVSE5	;YES, ZERO ADDRESS IS A MATCH
		PUSHJ	P,FETCH		;FETCH FIRST STRING WORD
		 JRST	ERR		;BAD POINTER
		TLNN	T,774000	;IS FIRST BYTE ZERO?
		JRST	PDVSE5		;YES, STRING IS NULL
		JRST	PDVSE4]		;NO, TRY TRY AGAIN
	JUMPE	R,PDVSE4	;ZERO ADDRESS WILL NEVER MATCH
	MOVE	T,WRD		;USER'S STRING ADDRESS
	PUSHJ	P,CMPSTR	;COMPARE NAMES
PDVSE4:	 SOJG	W1,PDVSE3	;NO MATCH, TRY AGAIN
	JUMPE	W1,ERR		;DIDN'T FIND ANY MATCHES
PDVSE5:	MOVE	T,@PDVTBL	;MATCHED, GET THE PDVA
	MOVEM	T,SYTLOC	;SET $5M
	ADJSP	P,-PVNMSZ	;RECLAIM STACK SPACE
	JRST	MASK5C		;GO TRADE SYMBOL TABLES
;STILL IFE FTEX20!FTMON!<FTDEC10&FTFILE> AND IFN FTDEC20 AND IFN FTFILE

;CMPSTR -- COMPARE TWO ASCIZ STRINGS
;CALL:
;	MOVX	T,<GLOBAL ADDRESS OF INTERNAL STRING>
;	MOVX	R,<GLOBAL ADDRESS OF PROG'S STRING>
;	PUSHJ	P,CMPSTR
;RETURNS +1: STRINGS NOT IDENTICAL
;	+2: STRINGS IDENTICAL
;USES ONLY TT,TT1,TT2

CMPSTR:	PUSHJ	P,SAVRST	;AS ADVERTISED
	PUSH	P,W1		;SAVE SOME MORE ACS
	PUSH	P,W2
	TLO	T,610000	;MAKE GLOBAL "POINT 7,"
	MOVE	W1,T		;SAVE IN ANOTHER AC
CMPST1:	MOVE	W2,[POINT 7,T]	;MAKE A POINTER FOR PROG
	PUSHJ	P,FETCH		;GET A WORD OF PROG'S STRING
	 JRST	ERR		;SIGH....
	MOVEI	TT,5		;FIVE BYTES TO A WORD
CMPST2:	ILDB	TT1,W1		;GET SOME BYTES
	ILDB	TT2,W2		; TO LOOK AT
	CAIL	TT1,"a"		;SEARCH MUST BE
	CAILE	TT1,"z"		; CASE INSENSITIVE
	CAIA			;DON'T CONVERT
	TRC	TT1,40		;CONVERT
	CAIL	TT2,"a"		;SEARCH MUST BE
	CAILE	TT2,"z"		; CASE INSENSITIVE
	CAIA			;DON'T CONVERT
	TRC	TT2,40		;CONVERT
	CAME	TT2,TT1		;SAME?
	JRST	CMPST4		;NO, ALL DONE
	JUMPE	TT1,CMPST3	;LOOP UNLESS WE GOT A NULL
	SOJG	TT,CMPST2	;LOOP THROUGH THIS WORD
	AOJA	R,CMPST1	;TRY NEXT WORD
CMPST3:	AOS	-2(P)		;SUCCESS!!
CMPST4:	POP	P,W2		;RESTORE THE ACS
	POP	P,W1
	POPJ	P,		;ALL DONE

  > ;END IFN FTFILE
;STILL IFE FTEX20!FTMON!<FTDEC10&FTFILE> AND IFN FTDEC20

;HERE TO TYPE OUT CURRENT PDV NAME

PDVTYP:	SOJN	T,PDVLST	;IF NOT $$1:, SEE IF $$2:
	TXNE	F,QF!FAF!SAF!SF!LTF ;NO ARGS DEFINED
	JRST	ERR		;RESERVE THEM
	SKIPG	R,SYTLOC	;PDV OR JOBDAT?
	POPJ	P,		;JOBDAT, DON'T TYPE ANYTHING
	ADDI	R,.PVNAM	;POINT TO NAME WORD
	PUSHJ	P,FETCH		;GET THE POINTER
	 JRST	ERR		;CAN'T DO IT
	JUMPE	T,CPOPJ		;AIN'T ONE
	TXNE	T,IFIW		;LOCAL POINTER?
	HLL	T,R		;YES, GET REAL ADDRESS
	PUSH	P,LLOCO		;TYPZ WILL BOMB THIS
	MOVEM	T,LLOCO		;WHERE TYPZ EXPECTS ADDR
	PUSHJ	P,TYPZ		;TYPE USER STRING
	POP	P,LLOCO		;RESTORE ADDRESS
	POPJ	P,		;ALL DONE

PDVLST:	SOJN	T,ERR		;$$2: WAS YOUR LAST CHANCE
	TXNE	F,QF!FAF!SAF!SF!LTF ;NO ARGS DEFINED
	JRST	ERR		;RESERVE THEM
	PUSHJ	P,TCRLF		;START OFF AT LEFT MARGIN
  IFN FTFILE,<			;FILDDT CASE
	SKIPG	W1,PDVNUM	;IF NO PDVS,
	JRST	DD1		;END COMMAND NOW
	SETO	W2,		;SETUP TO GET THE FIRST ONE
  > ;END IFN FTFILE
  IFE FTFILE,<			;NON-FILDDT SETUP
	PUSHJ	P,PDVINI	;SETUP THE ARG BLOCK
	SETZM	PDVA		;START FROM THE BEGINNING
	PUSHJ	P,NXTPDV	;GET THE FIRST PDVA
	HLRZ	W1,PDVARG+.POCT2 ;SEE HOW MANY PDVS EXIST
	JUMPE	W1,DD1		;GET OUT NOW IF NONE
	TRNA			;KEEP THIS ADDRESS FIRST TIME THROUGH
  > ;END IFE FTFILE
PDVLS1:	PUSHJ	P,NXTPDV	;GET NEXT ADDRESS
	ADDI	R,.PVNAM	;OFFSET TO THE NAME POINTER
	PUSHJ	P,FETCH		;GET NAME POINTER
	  SETZ	T,		;SIGH
	TXNE	T,IFIW		;IF SECTION-LOCAL,
	HLL	T,R		;MAKE IT GLOBAL
	SKIPN	R,T		;PUT IN RIGHT REGISTER
	JRST	PDVLS3		;ZERO NAME ADDRESS MEANS DON'T TYPE IT
	PUSHJ	P,FETCH		;GET FIRST WORD FROM NAME
	  SETZ	T,		;SIGH
	TLNN	T,(177B6)	;SEE IF NON-NULL
	JRST	PDVLS3		;SKIP NAME IF NULL
	PUSH	P,W1		;NO, SAVE SOME NEEDED REGISTERS
	PUSH	P,W2		;AROUND TYPZ0
	PUSH	P,LLOCO		;AND THE OPEN LOCATION
	MOVEM	R,LLOCO		;FAKE IT OUT
	PUSHJ	P,TYPZ0		;TYPE ASCIZ NAME WITHOUT LEADING SLASH
	POP	P,LLOCO		;RESTORE OPEN CELL ADDRESS
	POP	P,W2		;AND PDVTBL INDEX
	POP	P,W1		;AND REMAINING COUNT OF PDVS
	PUSHJ	P,TCRLF		;END THE LINE
PDVLS3:	SOJG	W1,PDVLS1	;LOOP OVER ALL KNOWN PDVS
	JRST	DD1		;TYPE EXTRA CRLF AND END WHEN DONE WITH LIST

> ;END IFN FTDEC20
;STILL IN FTEX20!FTMON!<FTDEC10&FTFILE>

;HERE FOR TOPS-10 CASES

  IFN FTDEC10,<
;REST OF PDVSET FOR TOPS-10

PDVSE2:	JUMPE	W,[SETZM SYTLOC	;0$5M
		   SETZM SYMVAL	;MAKE SURE WE CHECK
		   PJRST SYMCHK] ;GO VALIDATE IT
	MOVEM	W,SEGOPB+.SGSNM	;SET UP THE SEGMENT NAME
	SETZM	SEGOPB+.SGSGN	;DON'T KNOW THE NUMBER
	SETZM	SEGOPB+.SGFLG	;CLEAR THE STEP FLAG
	MOVSI	W,.SGORG+1	;GET THE DESIRED LENGTH
	HLLM	W,SEGOPB	;SET FOR THE UUO
	XMOVEI	W,SEGOPB	;POINT TO THE ARG BLOCK
	SEGOP.	W,		;FIND THE SEGMENT
	  JRST	PDVSE3		;CAN'T DO IT THIS WAY, SEE IF OLD WAY WORKS
	HRRZ	R,SEGOPB+.SGORG	;GET LOCAL PAGE ORIGIN
	LSH	R,PG2WRD	;CONVERT TO ADDRESS
	JRST	PDVSE4		;HAVE THE HISEG ORIGIN, GO VALIDATE IT
PDVSE3:	MOVE	W1,SYTLOC	;SAVE THE CURRENT POINTER
	SETZM	SYTLOC		;MAKE GETHSO LOOK HARD
	PUSHJ	P,GETHSO	;SEE IF WE HAVE A HISEG ORIGIN
	MOVEM	W1,SYTLOC	;RESTORE CURRENT $5M
	JUMPE	T,ERR		;NO HISEG
	MOVE	R,T		;COPY THE POINTER
	ADDI	R,.JBHNM	;POINT AT THE SEGMENT NAME
	PUSHJ	P,FETCHV	;AND GRAB IT
	  JRST	ERR		;NO GO
	CAME	T,W		;IF NOT THE RIGHT SEGMENT,
	JRST	ERR		;CAN'T USE IT
	TRZ	R,PAGMSK	;BACK OFF TO THE ORIGIN AGAIN
				;FALL INTO PDVSE4
PDVSE4:	ADDI	R,.JBHSM	;POINT TO ITS SYMBOL TABLE POINTER
	PUSHJ	P,FETCHV	;GET ITS SYMBOL LIST
	  JRST	ERR		;NO GO
	JUMPE	T,[SMERS <No symbols> ;SAY WHAT'S WRONG
		   JRST  ERR]	;AND PUNT
	SKIPG	T		;IF GLOBAL POINTER, JUST USE IT
	MOVE	T,R		;NO, USE ADDRESS OF IOWBLK POINTER
	MOVEM	T,SYTLOC	;SET AS $5M ARGUMENT
	SETZM	SYMVAL		;DON'T TRUST IT YET
	PJRST	SYMCHK		;GO VALIDATE IT

PDVTYP:	SOJN	T,PDVLST	;IF NOT $$1:, SEE IF $$2:
	TXNE	F,QF!FAF!SAF!SF!LTF ;NO ARGS DEFINED
	JRST	ERR		;RESERVE THEM
	SKIPG	R,SYTLOC	;GET ADDRESS OF SYMBOL TABLE
	POPJ	P,		;BE SILENT IF JOBDAT FORMAT
	PUSHJ	P,CHKADR	;SEE IF WE KNOW ITS BITS
	TXNE	TT,PG$HGH	;MUST BE PART OF A HISEG
	TXNE	TT,PG$SPY	;AND NOT A SPY-SEG
	POPJ	P,		;WRONG, TYPE NOTHING
	PUSHJ	P,GETHSO	;GET THE START OF ITS SEGMENT
	JUMPE	T,CPOPJ		;SHOULD NEVER HAPPEN....
	MOVE	R,T		;COPY THE ADDRESS
	ADDI	R,.JBHNM	;POINT TO ITS NAME WORD
	PUSHJ	P,FETCHV	;GET ITS NAME
	  JRST	ERR		;THIS IS BAD NEWS
	MOVE	W1,T		;COPY THE NAME TO SOMEWHERE SAFE
	MOVEI	T,"/"		;INTRODUCER CHARACTER
	PUSHJ	P,TOUT		;TYPE IT
	PJRST	TSIXN		;TYPE THE SIXBIT SEGMENT NAME AND RETURN

PDVLST:	SOJN	T,ERR		;$$2: WAS YOUR LAST CHANCE
	TXNE	F,QF!FAF!SAF!SF!LTF ;NO ARGS DEFINED
	JRST	ERR		;RESERVE THEM
	PUSHJ	P,TCRLF		;START AT LEFT MARGIN
  IFE FTFILE,<
	SETZM	SEGOPB+.SGSGN	;START WITH FIRST SEGMENT
	SETZM	SEGOPB+.SGSNM	;NAME NOT KNOWN YET
	MOVSI	R,.SGSNM+1	;THE DESIRED LENGTH
	HLLM	R,SEGOPB	;SET UP FOR UUO
	MOVX	R,SG.STP	;THE STEP FLAG
	MOVEM	R,SEGOPB+.SGFLG	;SET TO FIND ALL HISEGS
PDVLS1:	XMOVEI	R,SEGOPB	;POINT AT UUO BLOCK
	SEGOP.	R,		;GET THE NEXT HISEG
	  JRST	PDVLS3		;OLD MONITOR?
	SKIPN	SEGOPB+.SGSGN	;IF NO NEXT SEGMENT NUMBER,
	JRST	DD1		;WE'RE DONE
	SKIPN	W1,SEGOPB+.SGSNM ;IF BLANK NAME,
	JRST	PDVLS1		;SKIP THIS SEGMENT
	PUSHJ	P,TSIXN		;TYPE THE NAME
	PUSHJ	P,TCRLF		;END THE LINE
	JRST	PDVLS1		;LOOP OVER ALL KNOWN SEGMENTS
  > ;END IFE FTFILE
PDVLS3:	MOVEI	R,.JBHNM	;OLD MONITOR
	PUSHJ	P,HFETCH	;TRY FOR NAME OF THE ONLY HISEG
	  JRST	DD1		;NONE AT ALL
	JUMPE	T,DD1		;DON'T BOTHER WITH A BLANK NAME
	MOVE	W1,T		;POSITION FOR TYPEOUT
	PUSHJ	P,TSIXN		;TYPE THE NAME
	PUSHJ	P,TCRLF		;END THE LINE
	JRST	DD1		;END THE COMMAND

  > ;END IFN FTDEC10

  > ;END IFE FTEX20!FTMON!<FTDEC10&FTFILE>
;TEXT COMMANDS:	$n"c$, $n"/.../, XXXX$5"
;			"X$	(same as $7c$),
;			$"X$		($6c$),
;			"/.../		($7"/.../),
;			$"/.../		($6"/.../)

TEXI:	MOVEI	T,7		;START OFF AS "X$ OR "/.../
	TXNE	F,CF		;<ESC> SEEN?
	SOS	T		;YES, CHANGE TO $"X$ OR $"/.../
	TXZN	F,Q2F		;NUMBER AFTER <ESC>?
	MOVEM	T,WRD2D		;NO, SIMULATE CORRECT VALUE.
	MOVE	T,WRD2D		;GET THE BYTE WIDTH.
	CAIL	T,5		;WIDTH MUST BE BETWEEN 5 AND
	CAILE	T,^D36		;36 INCLUSIVE.
	JRST	ERR
	CAIN	T,5		;XXXX$5" ?
	JRST [	MOVE	T,SYM		;YES, TAKE PREVIOUS SYL AS RADIX50
		TXZ	F,FPF!FEF!LTF	;REINIT SYL
		JRST	QUAN1]
	CAIE	T,6		;SIXBIT?
	TXZ	F,CF		;NO, CLEAR <ESC> SEEN FLAG.
	TXO	F,TXF		;FLAG PROCESSING TEXT 
	MOVE	T,LLOCO		;GET ADR OF OPEN REG
	MOVEM	T,TEM		;SAVE IT FOR LOCAL USE
TEXI1:	PUSHJ	P,TIN		;GET TERMINATOR
	MOVEM	T,SYL		;SAVE TERMINATOR
	PUSHJ	P,TIN		;GET FIRST CHARACTER
  IFE FTEX20!FTMON!<FTDEC10&FTFILE>,<	;IF USER MODE -20 OR -10,
	TXNN	F,TXF		;IN TEXT COMMAND?
	JRST	TEXI4		;NO, SKIP TEST
  > ;END IFE FTEX20!FTMON!<FTDEC10&FTFILE>
	TXNN	F,CCF		;DOUBLE-ESCAPE MEANS NO SINGLE-CHARACTER MODE
	CAIE	T,.CHESC	;ESC?
	JRST	TEXI4		;NO, HANDLE AS TEXT
	MOVE	T,SYL		;YES, RESTORE THE CHARACTER
	PUSHJ	P,TEXIN1	;CONVERT TO SIXBIT IF NECESSARY
	JRST	QUAN1		;EQUALS ONE ASCII/SIXBIT CHAR
TEXI4:	MOVE	W1,WRD2D	;FETCH BYTE SIZE
	LSH	W1,^D24		;SHIFT BYTE SIZE TO PROPER PLACE
	IOR	W1,[POINT 0,W]	;BUILD THE REST OF THE BYTE POINTER
	SETZ	W,		;INIT WORD TO 0
TEXI2:	CAMN	T,SYL		;REACHED TERMINATOR?
	JRST [	MOVE	R,TEM		;LAST ADDRESS
  IFE FTEX20!FTMON!<FTDEC10&FTFILE>,<	;MONITORS DON'T HAVE PDVS
		TXNN	F,TXF		;PDV NAME?
		JRST	PDVSE2		;YES, GO CHECK IT OUT
  > ;END IFE FTEX20!FTMON!<FTDEC10&FTFILE>
		MOVEM	R,LLOC		;SET LOC TO END OF INPUT
		MOVEM	R,LLOCO		;UPDATE LLOCO TOO
		MOVE	T,W		;GET LAST WORD
		JRST	QUAN1]		;NO, DONE
	IBP	W1		;POINT TO NEXT BYTE.
	TRNE	W1,^-W		;STILL POINTING TO W?
	JRST	TEXI3		;NO
	PUSHJ	P,TEXIN1	;CONVERT TO SIXBIT IF NECESSARY
	DPB	T,W1		;BYTE GOES INTO W.
	PUSHJ	P,TIN		;GET ANOTHER INPUT CHARACTER
	JRST	TEXI2
;HERE WHEN WORD FULL

TEXI3:	MOVEI	W1,W		;ONLY GET HERE ONCE IF NO LOC OPEN
	MOVE	R,TEM		;GET LOC OF NEXT REGISTER
  IFE FTMON!FTEX20!FTDEC10,<	;NO REAL PDV ON A -10 OR -20 MONITORS
	TXNN	F,TXF		;IF READING A PDV NAME
	JRST [	CAMLE	R,TEM1		;PAST END OF BLOCK?
		JRST	TEXI2		;YES, STOP STORING
		MOVEM	W,(R)		;NO, STORE THE WORD
		JRST	TEXI5]		;AND CONTINUE
> ;END IFE FTMON!FTEX20!FTDEC10
	TXNN	F,ROF		;REGISTER OPEN?
	JRST	TEXI2		;NO, LOSE ANY ADDITIONAL INPUT
	PUSH	P,T		;SAVE CHARACTER
	MOVE	T,W		;GET FULL WORD
	PUSHJ	P,DMEMER	;STORE WORD IF POSSIBLE
	POP	P,T		;RECOVER CHARACTER
TEXI5:	AOS	TEM		;BUMP LOC
	JRST	TEXI4		;GO REINIT WORD AND CONTINUE INPUT

;CONVERT INPUT CHARACTER TO SIXBIT IF NECESSARY

TEXIN1:	TXNN	F,CF		;SIXBIT MODE?
	POPJ	P,		;NO
	CAIL	T,"A"+40	;IS CHAR BETWEEN LOWER CASE "A" AND
	CAILE	T,"Z"+40	; LOWER CASE "Z"?
	SKIPA			;NO
	TRC	T,40		;YES, CONVERT TO UPPER CASE
	CAIL	T," "		;IS CHAR IN SIXBIT SET?
	CAILE	T,"_"
	JRST	ERR		;NO
	ANDI	T,77		;YES, MASK TO 6 BITS
	TRC	T,40		;CONVERT TO SIXBIT FORM
	POPJ	P,
;DDT EXIT AND RESTART COMMANDS (^C, ^E, AND ^Z)

;FIRST, THE NON-FILDDT CASE

  IFE FTFILE,<
CNTRLZ:

  IFN FTEXEC,<
	SKPUSR			;SEE IF USER MODE
	JRST	ERR		;NO--ERROR  
  > ;END IFN FTEXEC

  IFN FTMON,<
	MOVE	T,[MSEC1,,MRETN]>  ;MDDT RETURN
  IFN FTEX20,<
	MOVEI	T,DDTCZ>	;KDDT USER-MODE RETURN
  IFE FTMON!FTEX20,<
	XMOVEI	T,HLTA		;NORMAL DDT RETURN
    IFN FTUD20,<		;NO STUB EXCEPT USER-20
	SKIPGE	R,SECUDD	;IS THERE A STUB?
	JRST	CTLZ1		;NO
	HRRI	R,770003	;RETURN @770003 OF STUB
	PUSHJ	P,FETCH		;GET THE ADDRESS
	 JRST	ERR		;CAN'T??
	HLL	T,R		;FIX UP SECTION NUMBER
CTLZ1:
    > ;END IFN FTUD20
  > ;END IFE FTMON!FTEX20
	JRST	GO1		;RESTORE CONTEXT AND JUMP

;HERE AFTER ^Z WITH ALL BREAKPOINTS INSERTED AND CONTEXT RESTORED.

  IFE FTMON,<
HLTA:
  IFN FTDEC10,<
	EXIT	1,>		;TOPS-10 MONRET
  IFN FTDEC20,<
	HALTF%>			;TOPS-20 MONRET
	JRST	DDT		;CONTINUE IS LIKE START NOW
  > ;END IFE FTMON


	CNTRLE==ERR		;^E ONLY WORKS IN FILDDT

  > ;END IFE FTFILE

;NOW THE FILDDT CASE

  IFN FTFILE,<
CNTRLZ:	JRST	CTLZ		;JUMP TO REAL ROUTINE

CNTRLE:	JRST	CTLE		;JUMP TO REAL ROUTINE

  > ;END IFN FTFILE

SUBTTL	COMMAND ROUTINES -- CLASS 2

;*************** START OF CLASS TWO COMMANDS ***************

MULT:	TXOA	F,PTF!MLF	;*
DIVD:	TXO	F,DVF!PTF	;SINGLE QUOTE
	JRST	L1
SUBTTL	COMMAND ROUTINES -- CLASS 3

;*************** START OF CLASS THREE COMMANDS ***************

ASSEM:	JRST	LIS2		;#
MINUS:	TXO	F,MF
PLUS:	TXO	F,PTF
	JRST	LIS2

LPRN:	PUSH	P,F		;RECURSE FOR OPEN PAREN
	PUSH	P,ACCCF		;PUSH COMMACOMMA FLAG/VALUE
	PUSH	P,WRD
	PUSH	P,FRASE
	PUSH	P,FRASE1
	AOS	PRNC
	SETZM	WAKALL		;SET WAKEUP SET TO PUNCT AND CTRLS
	JRST	LIS0C		;AND READ NEW EXPRESSION

INDIRE:	HRLZI	W,20		;@
	IORB	W,WRD
	TXO	F,QF
	JRST	LIS2


ACCF:	MOVE	R,ESTUT		;GET UNDEFINED PROCESSOR SO FAR
	CAME	R,USYMP+S$ADR	;ANY UNDEFINED'S CREATED YET?
	 JRST	ERR		;YES, ERROR
				;(CAN ONLY GET HERE ON "FOO#," ETC.)
	MOVE	R,T		;COMMA PROCESSOR
	TXOE	F,COMF		;COMMA TYPED BEFORE?
	JRST	ACCF1		;YES
	HRRZM	R,ACCCF		;NO, SAVE POTENTIAL "A" OF "A,,B"
	HLLZ	T,R
	LDB	W1,[POINT 3,WRD,2] ;CHECK FOR IO INSTRUCTION
	CAIE	W1,7		;7XX?
	JRST	ACCF0		;NO, ASSUME AC FIELD
	MOVX	W1,774B11	;YES, CHECK DEVICE CODE FIELD
	TDNE	W1,WRD		;DEVICE CODE FILLED IN YET?
ACCF0:	TDZA	W1,W1		;YES, OPCODE WAS UMOVE, RDTIME, ETC.
				;  ASSUME AC FIELD
	MOVEI	W1,1		;NO, OPCODE WAS CONO, DATAO, ETC.
				;  ASSUME DEVICE CODE
	LSH	R,27(W1)	;MOVE QUANTITY TO CORRECT FIELD
	ADD	T,R
	ADDB	T,WRD
	JRST	SPACE1

ACCF1:	HRRZ	T,ACCCF		;RETRIEVE "A" OF "A,,B" EXPRESSION
	ADD	T,WRD		;FOR ",," GET LEFT HALF TOGETHER
	HRLZM	T,WRD		; AND PUT IT IN LEFT HALF
	HRROM	T,ACCCF		;FLAG COMMACOMMA CONSTRUCTION
	JRST	SPACE1
SUBTTL	COMMAND ROUTINES -- CLASS 4

;*************** START OF CLASS FOUR COMMANDS ***************

SPACE:	TXO	F,SPF		;(E.G., "JRST PAT..") FLAG SPACE TYPED
SPACE1:	TXO	F,TIF		;FLAG TRUNCATE (ADD MOD 2**18)
	TXZ	F,MF!PTF
	JRST	LIS1


RPRN:	TXNN	F,QF		;)
	SETZ	T,
	MOVS	T,T
	SOSGE	PRNC
	JRST	ERR
	POP	P,FRASE1
	POP	P,FRASE
	POP	P,WRD
	POP	P,ACCCF		;POP COMMACOMMA FLAG/VALUE
	POP	P,F
	TXNE	F,PTF
	TXNE	F,SF
	JRST	RPRN1
	MOVEM	T,SYL
	TXO	F,QF!SF
	JRST	L1RPR
RPRN1:	ADDB	T,WRD
	TXO	F,QF
	JRST	L1A
SUBTTL	COMMAND ROUTINES -- CLASS 5

;*************** START OF CLASS FIVE COMMANDS ***************

;CRLF AND OPEN NEXT REGISTER SUBROUTINE

LI0:	PUSHJ	P,TCRLF		;TYPE <CR><LF>
	JRST	LINEF0		;JOIN COMMON CODE


;"^" COMMAND - CLOSE CURRENT AND OPEN PREVIOUS SEQUENTIAL LOCATION

VARRW:	PUSHJ	P,DEPRA		;^
	PUSHJ	P,TCRLF		;TYPE <CR><LF>
	MOVE	T,LLOC
	HRRI	T,-1(T)		;DECREMENT CURRENT LOC
	JRST	LI1		;JOIN COMMON CODE


;<LF> COMMAND, CLOSE CURRENT AND OPEN NEXT SEQUENTIAL LOCATION

LINEF:	PUSHJ	P,DEPRA		;NEXT REGISTER
	PUSHJ	P,TCR		;DO CR ONLY
LINEF0:	MOVE	T,LLOC		;BUMP LOC
	HRRI	T,1(T)		;BUT DON'T CHANGE SECTION
LI1:	MOVEM	T,LLOC		;NEW LAST LOCATION
	MOVEM	T,LLOCO		;NEW LAST LOCATION OPEN
LI1P:	PUSHJ	P,PADR		;PRINT AS ADDRESS
	MOVEI	T,"/"		;"/" TO INDICATE OPEN ADDRESS
	CAME	SCH,SCHM	;TEMP MODE SAME AS PERM?
	JRST [	CAIN	SCH,FTOC	;NO, CONSTANT?
		MOVEI	T,"["		;YES - INDICATE "[" MODE
		CAIE	SCH,PINQ	;EITHER KIND OF
		CAIN	SCH,PIN		;INSTRUCTION?
		MOVEI	T,"]"		;YES - INDICATE "]" MODE
		JRST	.+1]		;USE APPROPRIATE INDICATION
	TXNE	F,STF		;SUPPRESSING OUTPUT?
	MOVEI	T,"!"		;YES - THEN OVER-RIDE WITH "!" MODE
	PUSHJ	P,TOUT		;TELL USER WHAT IS HAPPENING
LI2:	PUSHJ	P,TTAB		;TYPE A <TAB>
	TXO	F,ROF		;MARK REGISTER OPEN
	TXNE	F,STF		;SUPPRESS TYPEOUT OF LOCATION?
	POPJ	P,		;YES, DONE
	MOVE	R,LLOCO		;GET ADDRESS OF OPEN LOC
	MOVEI	W1,"?"		;TYPE ? IF FETCH FAILS
	PUSHJ	P,FETCH		;FETCH CONTENTS
	 JRST	TEXT		;CAN'T -- GO TYPE ?
	PJRST	CONSYM		;LIST CONTENTS OF OPEN LOC
;<CR> COMMAND - CLOSE CURRENT LOCATION

CARR:	PUSHJ	P,DEPRA		;CLOSE REGISTER
	PUSHJ	P,TIN		;GLOBBLE UP FOLLOWING LINEFEED
	SETZM	CHINP		;REINIT INPUT LINE
	SETZM	CHINC
	TXZ	F,STF		;DON'T SUPPRESS TYPEOUT ANYMORE
	MOVE	T,LLOC		;GET CURRENT LOC
	TXNE	F,CF		; $ PRECEEDED?
	JRST	LI1		;YES, GO OPEN REGISTER
	JRST	DD1.5		;NO, JUST GO AWAIT COMMAND
SUBTTL	COMMAND ROUTINES -- CLASS 6

;*************** START OF CLASS SIX COMMANDS ***************

SUBTTL	COMMAND ROUTINES -- REGISTER DEPOSIT AND OPEN

;"\" COMMAND - OPEN NEW LOCATION, PRESERVING PC SEQUENCE

ICON:	PUSHJ	P,DEPRA0	;BACKSLASH
	PUSHJ	P,CEFFAD	;COMPUTE EFF ADR
	 JRST	ERR		;MEMORY READ ERROR
	JRST	SLASH4		;JOIN COMMON CODE


;<TAB> COMMAND - OPEN NEW LOCATION, BREAKING PC SEQUENCE

TAB:	PUSHJ	P,DEPRA0	;OPEN REGISTER OF Q
	PUSHJ	P,CEFFAD	;COMPUTE EFF ADR
	 JRST	ERR		;MEMORY READ ERROR
	HRRI	T,-1(T)		;CAUSE LI0 AOS'S LLOC
	PUSHJ	P,PSHLLC	;PUSH OLD SEQUENCE
	MOVEM	T,LLOC		;SETUP NEW SEQUENCE
	JRST	LI0		;JOIN COMMON OPEN/TYPEOUT CODE


;"[" COMMAND - OPEN LOCATION IN CONSTANT TYPEOUT MODE

OCON:	TXNE	F,QF		;QUANT TYPED?
	MOVEI	SCH,FTOC	;YES, CHANGE TEMP MODE TO CONSTANT
	TRO	F,LF1+CF1	;OPEN AS CONSTANT
	JRST	SLASH		;TYPE
;"]" COMMAND - OPEN LOCATION IN SYMBOLIC TYPEOUT MODE

OSYM:	TXNE	F,QF		;QUANT TYPED?
	MOVEI	SCH,PIN		;YES, CHANGE TEMP MODE TO INSTRUCTION
	TRZ	F,CF1		;OPEN SYMBOLICALLY
	TROA	F,LF1		; . . .
				;SKIP/FALL INTO SLASH ROUTINE


;"!" COMMAND - OPEN LOCATION SUPPRESSING TYPEOUT OF CONTENTS

SUPTYO:	TXOA	F,STF		;SUPPRESS TYPEOUT
				;SKIP/FALL INTO COMMON CODE

;"/" COMMAND - OPEN A NEW LOCATION IN CURRENT TYPEOUT MODE

SLASH:	TXZ	F,STF		;TYPE OUT NOT SUPPRESSED
	PUSHJ	P,CEFFAD	;COMPUTE EFF ADR
	 JRST	ERR		;MEMORY READ ERROR
	TXNN	F,QF		;USING LWT?
	JRST	SLASH4		;YES. DO NOT CHANGE MAIN SEQUENCE
	PUSHJ	P,PSHLLC	;PUSH OLD SEQUENCE
	MOVEM	T,LLOC		;SETUP NEW SEQUENCE
SLASH4:	MOVEM	T,LLOCO		;SET NEW OPEN LOCATION
	JRST	LI2		;AND GO HANDLE TYPEOUT
;CEFFAD - CALCULATE ADDRESS ARGUMENT FOR "/", "!", ETC.
;CEFFAS - CALCULATE ADDRESS ARGUMENT FOR $G, ETC. (SECTION DEFAULT ONLY)
;CALL IS:
;
;	MOVX	T,<ADDR>
;	PUSHJ	P,CEFFAD
;	 ERROR RETURN
;	NORMAL RETURN
;
;WHERE <ADDR> IS THE EXPLICITLY-TYPED ADDRESS EXPRESSION (IF ANY).
;
;BASICALLY ADDRESSING NOW WORKS AS FOLLOWS:
;
; FOR CEFFAD (E.G., "/", <TAB>, ETC.) ONLY: IF AN EXPLICIT QUANTITY HAS
;  NOT BEEN TYPED BY THE USER THEN THE LAST WORD TYPED IS USED AS THE BASIS
;  FOR ADDRESS CALCULATION. IF THE COMMAND WAS PREFIXED WITH A SINGLE <ESC>
;  (E.G., $/) THEN THE FULL-WORD VALUE FROM ABOVE WILL BE TREATED AS AN
;  INSTRUCTION-FORMAT-INDIRECT-WORD (IFIW) WHOSE EFFECTIVE ADDRESS "E" WILL
;  BE CALCULATED AS IT WOULD BE BY THE HARDWARE WERE IT TO EXECUTE THE WORD
;  AS AN INSTRUCTION (ASSUMING A VALID OPCODE); IF THE COMMAND IS PRECEDED
;  WITH A DOUBLE <ESC> (E.G., $$/) THEN THE FULL WORD VALUE FROM ABOVE WILL
;  BE TREATED AS AN EXTENDED-FORMAT-INDIRECT-WORD (EFIW) WHOSE EFFECTIVE
;  ADDRESS "E" WILL BE CALCULATED AS IT WOULD BE BY THE HARDWARE WERE IT TO
;  ENCOUNTER THE WORD AS AN INDIRECTED WORD IN AN EFFECTIVE ADDRESS CALCULA-
;  TION IN A NON-ZERO SECTION.
;
;  IF THE COMMAND WAS NOT PREFIXED BY ANY <ESC>'S, AND IF NO EXPLICIT QUANTITY
;  WAS TYPED, THEN THE ADDRESS VALUE (THE LAST WORD TYPED) IS REDUCED TO A
;  SECTION-LOCAL ADDRESS VALUE (I.E., RH ONLY, THE LH IS ZEROED).
;
; FOR CEFFAS (E.G., $G) AND CEFFAD (FROM ABOVE): IF ",," WAS USED IN THE
;  ADDRESS EXPRESSION THEN THE ADDRESS VALUE IS EXACTLY AS TYPED BY THE USER;
;  OTHERWISE IF EITHER A SPACE OR COMMA WAS USED IN THE ADDRESS EXPRESSION,
;  OR IF THE ADDRESS EXPRESSION IS A SECTION-LOCAL VALUE (AS ABOVE) THEN THE
;  SECTION-VALUE (LEFT HALF) OF THE ADDRESS VALUE WILL BE DEFAULTED FROM THE
;  CURRENT SECTION (I.E., LH OF ".").
;
;NOTE:	IF A DDT-INTERNAL ADDRESS VALUE WAS USED IN THE ADDRESS EXPRESSION
;	(LEGAL ONLY FOR CEFFAD, ERROR FOR CEFFAS-CLASS COMMANDS) THEN THE
;	ADDRESS VALUE IS ASSUMED TO BE A SECTION-LOCAL VALUE IN DDT'S
;	EXECUTING SECTION. THE VALUE IS FLAGGED "DDT-INTERNAL", AND LEFT
;	FOR FETCH/ETC TO ACTUALLY PROCESS.
;
;IF A FETCH ERROR OCCURS, OR AN ILLEGAL EFIW WORD IS ENCOUNTERED IN AN
;EFFECTIVE-ADDRESS CALCULATION, OR IF A DDT-INTERNAL ADDRESS IS SUPPLIED
;TO CEFFAS, THE ERROR RETURN IS TAKEN; OTHERWISE THE SUCCESSFUL (SKIP)
;RETURN IS TAKEN WITH THE 36-BIT GLOBAL ADDRESS VALUE IN REGISTER T.
;
;USES ACS R, S, W.
;CALCULATE EFFECTIVE ADDRESS

CEFFAD:	TXNE F,DDLF		;DDT INTERNAL LOCATION TYPED?
	JRST	[HRLI T,(DDAF)	;YES, FLAG IN ADDRESS
		JRST CPOPJ1]	;DO NOTHING ELSE
	TXNN	F,QF		;EXPLICIT ADDRESS EXPRESSION TYPED?
	MOVE	T,LWT		;NO, USE LAST WORD TYPED
	TXNE	F,CCF		;DOUBLE <ESC> TYPED?
	JRST	CEFFE		;YES, EFIW ADDRESS CALCULATION
	TXNE	F,CF		;SINGLE <ESC> TYPED?
	JRST	CEFFI		;YES, IFIW ADDRESS CALCULATION
	TXNN	F,QF		;EXPLICIT ADDRESS EXPRESSION TYPED?
	ANDI	T,-1		;NO, REDUCE TO SECTION-LOCAL LWT

;ENTER HERE TO GENERATE SECTION DEFAULT ADDRESS VALUE

CEFFAS:	TXNE	F,DDLF		;DDT INTERNAL LOCATION TYPED?
	POPJ	P,		;YES - TSK TSK - BOMB THE KLOWN
	SKIPGE	ACCCF		;COMMACOMMA PROCESSING ENCOUNTERED?
	JRST	CEFFAZ		;YES, USE ADDRESS VALUE EXACTLY AS IT WAS TYPED
	TDNN	T,[777777,,777760]  ;ADDRESS VALUE A "LOCAL REGISTER"?
	JRST	CEFFAC		;YES, CHECK NEED FOR GLOBAL REFERENCE
				; NOTE THAT "1,,REG" WILL BE HANDLED "RIGHT"
				; BY FETCH/ET AL, AND WILL ALSO SET THE
				; DEFAULT SECTION TO "1" . . . CAVEAT EMPTOR
	TXNN	F,SPF!COMF	;SPACE OR COMMA TYPED (I.E., AN INSTRUCTION)?
	TLNN	T,-1		;OR IS THE VALUE SECTION-LOCAL (LH = 0)?
	JRST	CEFFS5		;YES, DEFAULT THE SECTION
	TXNN	T,77B5		;IS THE LH OBVIOUSLY NOT A SECTION NUMBER?
	JRST	CEFFAZ		;ASSUME IT'S A SECTION NUMBER
CEFFS5:	HLL	T,LLOCS		;GET DEFAULT ADDRESS VALUE SECTION
	SKIPL	PDFSEC		;OVER-RIDING DEFAULT SECTION ($6M) SET?
	HLL	T,PDFSEC	;YES, IT OVERRIDES LLOCS DEFAULT
CEFFAZ:	HLLZM	T,LLOCS		;SET NEW DEFAULT SECTION
	JRST	CPOPJ1		;RETURN WITH ADDRESS VALUE IN T

CEFFAX:	PUSHJ	P,CEFFAS	;CALCULATE SECTION DEFAULT (IF NEEDED)
	 JFCL			;IGNORE NON-SKIP RETURN
	POPJ	P,		;AND RETURN NON-SKIP ALWAYS

CEFFAC:	HLL	T,LLOCS		;GET CURRENT DEFAULT SECTION
	TLZE	T,-1		;IS THIS GLOBAL?
	TLO	T,1		;YES, FLAG IT
	JRST	CPOPJ1		;RETURN SUCCESS TO CEFFAD



;GDFSEC -- GET DEFAULT SECTION NUMBER
;	PUSHJ	P,GDFSEC
; T/  <DEFAULT SECTION>,,0

GDFSEC:	SETZ	T,		;SECTION NUMBER ONLY
GDFSE0:	HLL	T,LLOCS		;USE TEMP DEFAULT
	SKIPL	PDFSEC		;PERM. DEFAULT SET?
	HLL	T,PDFSEC	;YES, USE PERM. DEFAULT
	POPJ	P,
;SETUP TO CALCULATE IFIW EFFECTIVE ADDRESS

CEFFI:	HLLZ	S,LLOCS		;PRELOAD (FAKE) CURRENT SECTION
CEFFIX:	MOVEI	W,INDPTH	;MAX LOOP COUNT FOR INDIRECTION
	MOVEM	W,TEM		;SO WE DON'T GET CAUGHT

;CALCULATE IFIW

CIFIW:	PUSH	P,T		;SAVE FOR LATER INDIRECTION CHECK
	MOVEM	T,LASEAF	;ALSO SAVE FOR JRSTF BITS IN $X
	SETZM	EAGLOB		;IFIW'S GIVE LOCAL RESULTS
	HRRZ	W,T		;IFIW: Y FIELD (18 BITS)
	LDB	R,[POINT 4,T,17];IFIW: X FIELD
	HLL	T,S		;GLOBAL ADR IN CASE ONLY INDIRECTION
	JUMPE	R,CIFIW6	;SKIP INDEXING IF NO INDEX REGISTER

;DO IFIW INDEXING

	MOVE	T,AC0(R)	;FETCH THE INDEX REGISTER
	MOVEM	T,LASEAF	;SAVE FOR JRSTF BITS IN $X
	MOVE	R,T		;SCRATCH COPY
	JUMPE	S,CIFIW2	;IF SECTION 0 INDEX
	JUMPL	R,CIFIW2	;OR LH(X) .LT. 0
	TLNN	R,-1		;OR LH(X) .EQ. 0
CIFIW2:	TLZA	T,-1		;THEN ONLY 18-BITS OF INDEXING
	HRRE	W,W		;ELSE SIGN-EXTEND Y TO 36-BITS
	ADD	T,W		;DO THE INDEXING
	JUMPE	S,CIFIW4	;IF SECTION 0
	JUMPL	R,CIFIW4	;OR LH(X) .LT. 0
	TLNN	R,-1		; OR LH(X) .EQ. 0
	 JRST	CIFIW4		;THEN LOCAL INDEXING
	SETOM	EAGLOB		;ELSE GLOBAL INDEXING
	CAIA			;DON'T DIDDLE SECTION
CIFIW4:	HLL	T,S		;THEN E STAYS IN LOCAL SECTION
	ANDX	T,VMADR		;KEEP ONLY Y FIELD
	HLL	S,T		;UPDATE S TO NEW CURRENT SECTION

;CHECK IFIW INDIRECTION

	SKIPE	EAGLOB		;LOCAL INDEXING?
	TDNN	T,[777776,,777760]  ;NO, GLOBAL REFERENCE TO AC
CIFIW6:	TRNE	T,777760	;IS LOCAL REFERENCE TO A REGISTER?
	CAIA			;NO, MEM. REF.
	ANDI	T,17		;YES, REDUCE TO UNAMBIGUOUS AC
				; (NOTE "SECTION-NESS" STILL IN S)
	POP	P,R		;GET BACK ORIGINAL WORD
	TXNN	R,@		;IFIW I BIT ON?
	PJRST	CEFIW9		;NO, CHECK OUT AC'S AND RETURN
CIFIW8:	MOVE	R,T		;YES, ADDRESS OF NEW ADDRESS
	PUSHJ	P,FETCH		;GO GET INDIRECTED WORD
	 POPJ	P,		;CAN'T ACCESS WORD, DIE
	SOSG	TEM		;INFINITE LOOP?
	 POPJ	P,		;APPARENTLY, GO COMPLAIN AT USER
CIFIW9:	JUMPE	S,CIFIW		;ONCE IN SECTION 0, ALWAYS IN SECTION 0
	JUMPGE	T,CEFIW		;IF BIT 0 .EQ. 0 THEN EFIW
	TXNN	T,1B1		;BIT 0 AND BIT 1 ON?
	JRST	CIFIW		;JUST BIT 0, IFIW FORMAT
	POPJ	P,		;ILLEGAL COMBINATION
;SETUP TO CALCULATE EFIW EFFECTIVE ADDRESS

CEFFE:	HLLZ	S,LLOCS		;PRE-LOAD CURRENT SECTION
CEFFEX:	MOVEI	W,INDPTH	;MAX LOOP COUNT FOR INDIRECTION
	MOVEM	W,TEM		;SO WE DON'T GET CAUGHT
	JRST	CIFIW9		;DISPATCH ON TYPE OF INDIRECTION

;EFIW FORMAT

CEFIW:	PUSH	P,T		;SAVE FOR LATER INDIRECTION CHECK
	SETOM	EAGLOB		;EFIW'S GIVE GLOBAL RESULTS
	LDB	R,[POINTR T,EFIWX] ;EFIW: X FIELD
	ANDX	T,VMADR		;Y FIELD ONLY
	MOVE	W,T
	JUMPE	R,CEFIW6	;SKIP INDEXING IF NO INDEX REGISTER

;DO EFIW INDEXING

	MOVE	T,AC0(R)	;GET INDEX REGISTER
	ADD	T,W		;INDEX THE Y FIELD
	ANDX	T,VMADR		;KEEP ONLY Y FIELD

;CHECK EFIW INDIRECTION

CEFIW6:	POP	P,R		;GET BACK ORIGINAL WORD
	HLLZM	T,LLOCS		;SAVE SECTION
	HLLZ	S,T		;SAVE FOR CEFIW9
	TXNE	R,EFIWI1	;EFIW I BIT ON?
	JRST	CIFIW8		;YES, LOOP ON INDIRECTION
				;NO, CHECK OUT AC'S AND RETURN

;CHECK AC ADDRESSING

CEFIW9:	TDNN	T,[-2,,-20]	;AC REFERENCE?
	TLNN	S,-1		;FROM NON-ZERO SECTION?
	JRST	CPOPJ1		;NO, JUST RETURN IT
	HRLI	T,1		;YES, MAKE IT GLOBAL
	JRST	CPOPJ1		;RETURN SUCCESS FROM CEFFAD
;HERE WHEN REGISTER CLOSED TO DEPOSIT NEW CONTENTS AND SET NEXT LOCATION

DEPRA:	TXNE	F,CF		;$ PRECEEDED?
	PUSHJ	P,POPLLC	;YES, POP OLD SEQUENCE
DEPRA0:	TXNE	F,ROF		;IF REGISTER IS BEING CHANGED
	TXNN	F,QF		;REMOVE ALL PREVIOUS UNDEFINED
	JRST	DEPRS		;SYMBOL REFERENCES TO IT
	DMOVE	TT,USYMP+S$ADR	;GET POINTER TO ALL OLD UNDEF ITEMS
	SUB	W2,TT1		;FIND OUT HOW MANY NEW ONES THERE ARE
	JUMPE	W2,DEPRA4	;DON'T UPDATE IF NO NEW SYMS
	DMOVEM	TT,ESTUT	;FAKE OUT USYSET
	MOVEI	W1,USYMP	;WANT TO UPDATE UNDEF BY THAT MANY
	PUSHJ	P,DECSYP	;DECREMENT EVERYBODY
	 JFCL			;??
DEPRA4:
  IFN FTFILE,<
	SKIPN	FILING		;SEE IF /M
	JRST	DEPRS		;YES--NO UNDEF FIXUPS
  > ;END IFN FTFILE
	MOVEM	T,LWT		;SAVE T IN LWT, DEPRS DOES IT ANYWAY
DEPRA1:	PUSHJ	P,USYSET	;SETUP TO SEARCH UNDEFINEDS
	ADDI	R,1		;WANT VALUE WORDS THIS TIME

DEPRA2:	SOSGE	R		;ANY MORE SYMBOLS?
	PUSHJ	P,ADVSYM	;MAYBE, MAKE SURE
	SKIPA	W,@SYPTR	;YES, GET VALUE WORD
	JRST	DEPRA6		;ALL DONE, GO DO THE STORE
	JUMPG	W,DPRS3		;1B0=0 IMPLIES CHAINING
	LDB	T,[POINTR W,VMADR]  ;GET ADDRESS OF FIXUP
	SKIPE	T		;DELETE ENTRY IF ADR=0, OR
	CAMN	T,LLOCO		; IF ADR IS BEING CHANGED
DEPRA3:	SKIPA	W1,R2IDX	;WANT TO DELETE IT, FORM SYM INDEX
	SOJA	R,DEPRA2	;KEEP IT, GET NEXT VALUE
	ADD	W1,R		;SYM INDEX NOW IN W1
	SUBI	W1,1		;POINT TO 1ST WORD OF SYMBOL PAIR
	PUSHJ	P,REMUN		;GET RID OF THE SYMBOL
	 JRST	DEPRA6		;CAN'T, SKIP ALL THIS
	JRST	DEPRA1		;RESTART, SINCE REMUN CALLED SYWSET

DEPRA6:	MOVE	T,LWT		;RESTORE QUANTITY
	JRST	DEPRS		;DO THE STORE
;HERE IF THE UNDEFINED SYMBOL REQUESTS A CHAINED FIXUP.

DPRS3:	PUSH	P,R		;SAVE R OVER ALL THIS
	SETO	S,		;FLAG TO USE DEPSYM
	JUMPE	W,DEPRA8	;DON'T BOTHER IF POINTS TO ZERO
	MOVE	W1,W		;INITIALIZE W1 SO EXCH WILL WORK
	MOVE	R,W		;FIRST TIME GET FULL ADDRESS
	JRST	DPRS5		;ALLOW CHAIN TO N,,0

DPRS4:	HRR	R,W		;GET NEXT ADR (AFTER ADR IN W1)
	TRNN	R,-1		;CHAIN REACHED 0?
	JRST	DEPRA8		;YES, ALL DONE
DPRS5:	PUSHJ	P,FETCHV	;GET CONTENTS OF ADR IN R
	 JRST	DEPRA8		;****UNDEFINED SYMBOL TABLE OR FIXUP
				; CHAIN POINTS TO ILL. MEM. TRY
				; TO CONTINUE.
	EXCH	T,W		;W/NEW LINK    T/OLD LINK
	EXCH	W1,R
	CAME	W1,LLOCO	;IS THIS WORD BEING CHANGED?
	AOJA	S,DPRS4		;NO, CHECK REST OF CHAIN
	HRR	T,W		;YES, PATCH CHAIN AROUND ADDRESS
	JUMPL	S,DPRS6		;FIRST ENTRY?
	PUSHJ	P,DMEMER	;NO, WRITE INTO USER ADDRESS SPACE
	JRST	DEPRA8		;CHECK REST OF UNDEFINEDS

DPRS6:	POP	P,R		;FIRST LINK IN CHAIN - GET SYMBOL ADDR.
	TRNN	T,-1		;CHAIN OF LENGTH 1?
	JRST	DEPRA3		;YES, JUST DELETE THE SYMBOL
	TXO	R,1B1		;CHAIN STARTS IN UNDEFINED TABLE
	PUSHJ	P,DSYMER	;NO, PATCH CHAIN AROUND MODIFIED ADDR.
	TXZ	R,1B1		;WANT A STRAIGHT INDEX AGAIN
	SOJA	R,DEPRA2	;CONTINUE

DEPRA8:
  IFN FTEX10,<
	PUSHJ	P,SYMSPC	;MAKE SURE AFTER FETCHL AND DMEMER
  > ;END IFN FTEX10

	POP	P,R		;RESTORE R
	SOJA	R,DEPRA2	;GET NEXT SYMBOL
;ROUTINES TO HANDLE RING BUFFER OF LOCATIONS

;'PUSH' CURRENT LOCATION

PSHLLC:	AOS	TT,SAVLP	;BUMP POINTER
	CAIL	TT,NSAVTB	;AT END OF TABLE?
	SETZB	TT,SAVLP	;YES, WRAPAROUND
	PUSH	P,LLOC		;GET CURRENT LOCATION
	POP	P,SAVLTB(TT)	;ADD IT TO TABLE
	POPJ	P,

;'POP' CURRENT LOCATION

POPLLC:	MOVE	TT,SAVLP	;GET POINTER
	MOVE	TT,SAVLTB(TT)	;REMOVE FROM TABLE
	MOVEM	TT,LLOC		;SET AS CURRENT LOC
	TDNE	TT,[-2,,-20]	;SKIP IF LOC IS ACCUMULATOR.
	HLLZM	TT,LLOCS	;SET FLOATING DEFAULT SECTION.
	SOS	TT,SAVLP	;DECREMENT PTR
	JUMPGE	TT,POPLC1	;AT TOP OF TABLE?
	MOVEI	TT,NSAVTB-1	;YES, WRAPAROUND
	MOVEM	TT,SAVLP
POPLC1:	POPJ	P,
SUBTTL	COMMAND ROUTINES -- RETYPE LAST QUANTITY

SEMIC:	MOVEM	T,LWT		;SEMICOLON TYPES IN CURRENT MODE
	JRST	(SCH)

EQUAL:	TROA	F,LF1+CF1	;=
UNDRL:	TRZ	F,CF1		;_
	TRO	F,LF1
	PUSHJ	P,CONSYM
	JRST	RET
SUBTTL	COMMAND ROUTINES -- TYPEOUT MODE CONTROL

TEXO:	MOVEI	T,7		;$T, ASSUME 7 BIT ASCII
	TXNE	F,Q2F		;IF $NT,
	MOVE	T,WRD2D		;GET "RADIX" OF TEXT
	JUMPE	T,TYPZ		;TYPE ASCIZ STRING AT "." IF $0T/$$0T
	CAIN	T,7		;CHECK FOR $7T
	MOVEI	R,TEXTT		;SET MODE SWITCH FOR 7-BIT ASCII
	CAIN	T,6		;CHECK FOR $6T
	MOVEI	R,SIXBP		;SET MODE SWITCH FOR SIXBIT ASCII
	CAIN	T,5		;CHECK FOR $5T
	MOVEI	R,R50PNT	;SET MODE SWITCH FOR RADIX 50
	CAIN	T,1		;CHECK FOR $1T
	MOVEI	R,TBPNT		;SET MODE SWITCH FOR BYTE POINTERS
	JUMPN	R,SMOD1		;SET MODE IF ONE DETERMINED YET
	CAIL	T,7		;NOT DETERMINED, CHECK BYTE SIZE
	CAILE	T,^D36		;MUST BE 7 TO 36
	JRST	ERR		;BAD BYTE SIZE
	MOVEI	R,TEXTNT	;MODE IS N-BIT ASCII
	MOVEM	T,BYSS		;SAVE BYTE SIZE
	JRST	SMOD1		;GO SET MODE


;TYPE THE ASCIZ STRING AT CURRENTLY OPEN LOCATION

TYPZ:	MOVEI	T,"/"		;LOAD A SLASH
	PUSHJ	P,TOUT		;SEPARATE TEXT FROM USER COMMAND
	MOVE	T,WRD		;GET ADDRESS, IF SUPPLIED
	TXNN	F,QF		;EXPLICIT ADDRESS GIVEN?
	SKIPA	T,LLOCO		;NO, USE "."
	PUSHJ	P,CEFFAX	;YES, DEFAULT SECTION IF NEEDED
	MOVEM	T,LLOCO		;SAVE NEW "."
	MOVE	R,T		;GET LAST LOCATION OPEN
TYPZ0:	PUSHJ	P,LISTEN	;ANY USER TYPEIN?
	 SKIPA	W,[POINT 7,W1]	;NO, CONTINUE AND LOAD ASCII BYTE PTR.
	 POPJ	P,		;YES, EXIT
	MOVEI	W2,5		;LOAD LOOP COUNTER
	PUSHJ	P,FETCH		;FETCH 5 CHARACTERS FROM ADDRESS
	 JRST	ERR		;FAILED
	MOVE	W1,T		;PUT WORD IN T
TYPZ1:	ILDB	T,W		;GET THE NEXT BYTE
	JUMPE	T,[AOS	LLOCO		;YES, INCREMENT TO NEXT WORD
		   POPJ	P,]		;DONE
	PUSHJ	P,TOUT		;NO, TYPE THE CHARACTER
	SOJG	W2,TYPZ1	;LOOP UNTIL DONE
	AOS	R,LLOCO		;DONE, GO TO NEXT WORD IN STRING
	JRST	TYPZ0		;AND KEEP DOING IT

HWRDS:	MOVEI	R,HLFW		;H - HALFWORD OUTPUT FORMAT
	JRST	SMOD1
SFLOT:	MOVEI	R,TFLOT		;F - FLOATING POINT OUTPUT FORMAT
  IFN FTDEC20,<
	TXNN	F,Q2F>		;WAS AN ARGUMENT GIVEN TOO?
	JRST	SMOD1		;NO, NORMAL $F OR $$F FORMAT
  IFN FTDEC20,<			;DBL. PRECISION TYPEOUT ONLY ON TOPS-20
	SKIPE	TT,WRD2O	;YES, WAS IT 0?
	CAIN	TT,1		;OR A 1?
	JRST	SMOD1		;YES, TREAT LIKE $F OR $$F
	CAIE	TT,2		;NO, WAS IT 2?
	JRST	ERR		;NO, DON'T KNOW WHAT IT WAS
	MOVEI	R,DFLOUT	;YES, LOAD DBL. PRECISION ADDR.
	JRST	SMOD1
  > ;END IFN FTDEC20

SYMBOL:	MOVEI	R,PIN		;ASSUME REGULAR SYMBOL TYPEOUT
	SKIPE	WRD2D		;$1S?
	MOVEI	R,PINQ		;YES, OPTYPE FIRST FLAVOR
	JRST	SMOD1		;NO, KEEP OUR ASSUMPTION

CON:	MOVEI	R,FTOC		;C TYPEOUT FORMAT
SMOD1:	HRRZM	R,SCH
	JRST	BASE1

RELA:	TRZE	F,Q2F		;CHANGE ADDRESS MODE TO RELATIVE
	JRST	BASECH
	MOVEI	R,PADSO-TOC
ABSA:	ADDI	R,TOC		;A
	HRRZM	R,AR
	JRST	BASE1

BASECH:	MOVE	T,WRD2D		;$NR  CHANGE OUTPUT RADIX TO N, N .GT. 1
	CAIGE	T,2
	JRST	ERR
	HRRZM	T,ODF
BASE1:	TXNN	F,CCF
	JRST	LIS1
	MOVS	S,[XWD SCHM,SCH]	;SAVE SPACE IN LITERAL POOL
	BLT	S,ODFM		;WITH $$, MAKE MODES PERMANENT
	MOVE	S,SVBTS		;MAKE THE CURRENT FORMAT MASK
	MOVEM	S,PSVBTS	;THE PERMANENT FORMAT MASK.
	MOVE	S,BYSS
	MOVEM	S,PBYSS
	JRST	RET
;BYTE COMMAND AND TYPEOUT ROUTINES

BITO:	TRZN	F,Q2F		;DOES <N> EXIST FOR $<N>O?
	 JRST	BITO5		;NO, DEFAULT TO CURRENT MASK

	SETZB	W2,SVBTS	;MAKE ROOM FOR A NEW MASK
	MOVEI	W1,1		;PROTOTYPE BIT
	MOVN	T,WRD2D		;FOR SHIFTING THE PROTOTYPE BIT
BITO2:	LSHC	W1,(T)		;POSITION TO A BYTE BOUNDRY
	IORM	W2,SVBTS	;MARK NEXT BYTE BOUNDRY
	JUMPN	W2,BITO2	;LOOP FOR ALL BYTES

BITO5:	MOVEI	SCH,BITT	;BYTE TYPEOUT
	PJRST	BASE1		;HANDLE $$ IF NEED BE . . .



;HERE FOR ACTUAL BYTE TYPEOUT

BITT:	PUSH	P,LWT		;SAVE LAST WORD TYPED . . .
	SKIPN	T,SVBTS		;GET CURRENTLY PREVAILING $O MASK
	MOVE	T,BYTMSK	;BLANK, USE $3M MASK INSTEAD
	IORI	T,1B35		;BIT 35 ALWAYS MARKS END OF A BYTE
	PUSH	P,T		;SET WORKING COPY OF MASK
	PUSH	P,LWT		;WORKING COPY OF WORD TO BE TYPED
	JRST	BITT4		;ENTER LOOP

BITT2:	MOVEI	T,","		;SEPARATE BYTES WITH A COMMA
	PUSHJ	P,TOUT		;TYPE IT OUT
BITT4:	POP	P,T		;[REMNANTS OF] WORD TO BE TYPED
	POP	P,W1		;[REMNANTS OF] BYTE MASK
	JFFO	W1,.+3		;GET NEXT COUNT OF BITS
	 POP	P,LWT		;DONE, RESTORE LWT FOR OTHERS
	 POPJ	P,		;RETURN
	LSH	W1,1(W2)	;UPDATE MASK
	PUSH	P,W1		;SAVE AWAY FOR NEXT ROUND
	LSHC	T,-^D36+1(W2)	;GET NEXT BYTE TO BE TYPED
	MOVEM	T,LWT		;SET IN COMMON STORAGE PLACE
	PUSH	P,W1		;SAVE REMAINING BYTES FOR NEXT ROUND
	PUSHJ	P,TOCA		;TYPE OUT A CONSTANT
	SKIPE	-1(P)		;MORE BYTES COMING UP?
	JRST	BITT2		;YES, TYPE A COMMA
	JRST	BITT4		;NO, CLEAN UP STACK AND LEAVE
SUBTTL	COMMAND ROUTINES -- LIMITS AND PATCHING

LLIM:	TXNE	F,CF!CCF	;$< OR $$< COMMAND?
	JRST	PTCHB		;YES, PATCH COMMAND
	MOVEM	T,LLIMIT	;NO, SET FIRST ARGUMENT
	TXO	F,FAF		;AND FLAG FIRST ARGUMENT SEEN
	MOVEM	F,LLREGF	;SAVE "F" FOR SETUP/LLMSEC/CEFFAS
	MOVE	TT1,ACCCF	;ALSO SAVE "ACCCF" FLAG
	MOVEM	TT1,LLACCF	; FOR SETUP/LLMSEC/CEFFAS
	JRST	ULIM1

ULIM:	TXNE	F,CCF		;$$> ?
	JRST	ERR		;YES, NOT DEFINED
	TXNE	F,CF		;NO, $> ?
	JRST	PTCHE		;YES, END PATCH
	MOVEM	T,ULIMIT	;NO, SET SECOND ARG
	TXO	F,SAF		;AND FLAG SECOND ARGUMENT SEEN
	MOVEM	F,ULREGF	;SAVE "F" FOR SETUP/ULMSEC/CEFFAS
	MOVE	TT1,ACCCF	;ALSO SAVE "ACCCF" FLAG
	MOVEM	TT1,ULACCF	; FOR SETUP/ULMSEC/CEFFAS
ULIM1:	TXNN	F,QF
	JRST	ERR
	JRST	LIS0E
;HERE FOR THE PATCH BEGIN COMMAND

PTCHB:	TXNE	F,Q2F		;SPECIAL FLAVOR?
	JRST	PTCHX		;YES, CANCEL PATCHING MAYBE
	SKIPN	PTLOC		;ALREADY IN PATCH MODE?
	TXNN	F,ROF		;OR NO LOCATION OPEN?
	JRST	ERR		;YES, CAN'T PATCH
	SETZM	PTORG		;NO, ASSUME EXPRESSION TYPED
	TXNE	F,TIF!COMF!PTF!MF  ;EXPRESSION TYPED?
	JRST	PTCHB4		;YES, JUST GO USE IT
	TXNE	F,QF		;ANYTHING AT ALL TYPED?
	TXNE	F,LTF		;NUMBER OR SYMBOL?
	  CAIA			;NOTHING OR SYMBOL TYPED
	JRST	PTCHB4		;NUMBER, JUST GO USE IT
	TXNE	F,QF		;ANYTHING TYPED?
	JRST [	PUSHJ	P,EVAL		;YES, LOOKUP SYMBOL
		 JRST	ERR		;STRANGE TYPEIN, LOSE
		JRST	PTCHB2]		;FOUND, USE VALUE AS PATCH LOC
	MOVSI	W,-NPSYM	;SETUP TO SCAN PATCH SYMBOLS
PTCHB1:	MOVE	T,PCHSYM(W)	;GET A POSSIBLITY
	MOVEM	T,SYM		;SET IT UP FOR EVAL
	PUSHJ	P,EVAL		;TRY TO FIND VALUE
	 AOBJN	W,PTCHB1	;NOT FOUND, TRY NEXT SYMBOL
	JUMPL	W,PTCHB2	;FOUND A SYMBOL, USE IT
  IFN FTEXEC,<
	SKPUSR			;USER MODE?
	JRST	ERR		;EXEC MODE LOSES HERE
  > ;END IFN FTEXEC
	MOVEI	R,.JBFF		;NONE OF THE SYMBOLS EXIST, USE .JBFF
	HLL	R,LLOCO		;IN THE PATCH SECTION
	PUSHJ	P,FETCH		;GET CONTENTS OF .JBFF
	 JRST	ERR		;USER LOSES
	AOS	PTORG		;PTORG = 1 TO FLAG FROM .JBFF
	JRST	PTCHB4		;FAKE PATCH SYMBOL FOUND
PTCHB2:	SETOM	PTORG		;PTORG = -1 TO FLAG A SYMBOL
	MOVE	R,SYM		;GET SYMBOL BEING USED
	MOVEM	R,PTSYM		;SAVE FOR CLOSING PATCH LATER
	AOS	R,W1		;POINT TO VALUE WORD
PTCHB4:	CAIL	T,.JBDA		;HAVE REASONABLE PATCH ADDRESS?
	TDNN	T,[777776,,777760]  ;CAN'T BE AN AC
	JRST	ERR		;NO
	TLNN	T,-1		;SECTION GIVEN?
	JRST	PTCHB5		;NO, SKIP THE CHECK
	HLLZ	TT,T		;YES, SEE IF THAT SECTION
	CAMN	TT,LLOCS	; IS SECTION OF "."
	JRST	PTCHB5		;YES, GO ON
	SMERS	<CAN'T PATCH ACROSS SECTIONS>	;SET MESSAGE
PTCHBE:	SETZM	PTLOC		;PATCH NEVER BEGAN
	JRST	DMER1		;ALTERNATE DMEMER ENTRY (ERR MSG)

PTCHB5:	MOVEM	T,PTVAL		;SAVE ORIGINAL SYMBOL VALUE
	HLL	T,LLOCO		;FORCE SECTION SAME AS OPEN REG
	MOVEM	T,PTLOC		;YES, SAVE IT
	MOVEM	R,PTFIX		;SAVE WHERE IT CAME FROM
	MOVE	R,LLOCO		;LOC OF OPEN REGISTER
	MOVEM	R,PTLLC		;SAVE IT
	PUSHJ	P,FETCH		;GET CONTENTS
	 JRST	ERR		;FETCH FAILED
	MOVEM	T,PTWRD		;SAVE ORIGINAL WORD
	PUSHJ	P,DEPMEM	;TRY TO DEPOSIT INTO MEMORY
	 JRST	PTCHBE		;FAILED, STOMP ON THE PATCH
	SETZM	PTAFTR		;ASSUME PATCH BEFORE
	TXNE	F,CCF		;SAVE BEFORE/AFTER FLAG
	SETOM	PTAFTR		;0 MEANS BEFORE, -1 MEANS AFTER
	PUSHJ	P,TCRLF		;OUTPUT <CR><LF>
	MOVE	T,PTLOC		;START OF PATCHING AREA
	PUSHJ	P,LI1		;OPEN LOCATION AND TYPEOUT
	SKIPL	PTAFTR		;PATCH BEFORE OR AFTER?
	POPJ	P,		;BEFORE, DONE FOR NOW
	MOVE	R,LLOCO		;CURRENT OPEN LOCATION
	MOVE	T,PTWRD		;ORIGINAL INSTRUCTION
	PUSHJ	P,DMEMER	;PUT AS FIRST IN PATCH AREA
	PUSHJ	P,LI2		;NOW TYPE OUT SO USER CAN SEE
	PJRST	LI0		;AND OPEN/TYPE NEXT LOCATION

;TABLE OF SYMBOLS IDENTIFYING PATCH AREAS

PCHSYM:
  IFN FTEX10,<
	RADIX50 0,PAT>		;TOPS-10 MONITOR PATCH AREA
  IFN FTEX20!FTMON,<
	RADIX50 0,FFF>		;TOPS-20 MONITOR PATCH AREA
	RADIX50	0,PAT..		;USUAL LINK SYMBOL
	RADIX50	0,PATCH		;ANOTHER LIKELY POSSIBILITY
NPSYM==.-PCHSYM
;HERE FOR THE PATCH END COMMAND

PTCHE:	SKIPN	PTLOC		;PATCH IN PROGRESS?
	JRST	ERR		;NO, ERROR
	TXZ	F,CF		;NO, FLUSH FLAGS BEFORE DEPRA
	TXZN	F,STF		;DID USER SEE LAST LOC? (CLEAR FLAG FOR LI0)
	SKIPE	LWT		;AND WAS IT ZERO?
	JRST	PTCHE0		;NO, PROCEED
	TXNE	F,ROF		;REGISTER OPEN?
	TXNN	F,QF		;AND NOTHING YET TYPED?
	SOS	LLOC		;YES - DO NOT STORE A 0 WORD.
PTCHE0:	PUSHJ	P,DEPRA		;STORE LAST WORD IF ANY
	SKIPGE	PTAFTR		;PATCH BEFORE?
	JRST	PTCHE1		;NO
	PUSHJ	P,LI0		;OPEN AND TYPE NEXT LOCATION
	MOVE	R,LLOCO		;CURRENT OPEN LOCATION
	MOVE	T,PTWRD		;USER ORIGINAL INSTRUCTION
	PUSHJ	P,DMEMER	;PUT AT END OF PATCH CODE
	PUSHJ	P,LI2		;AND TYPE OUT FOR USER TO SEE
PTCHE1:	TXNE	F,Q2F		;WAS "SKIPNESS" SUPPLIED?
	SKIPA	T,WRD2D		;YES, USE USER-REQUESTED COUNT
	MOVEI	T,2		;NO, DEFAULT SINGLE-SKIP
	JUMPE	T,PTCHE6	;DON'T BOTHER IF NOTHING TO DO
	PUSH	P,T		;ELSE SAVE ITERATION COUNTER
	PUSH	P,[JUMPA]	;AND BASIC PATCH RETURNER
PTCHE3:	PUSHJ	P,LI0		;OPEN AND TYPE NEXT LOCATION
	MOVE	R,LLOCO		;CURRENT OPEN LOCATION
	MOVE	T,[Z 1,1]	;INCREMENT
	ADD	T,(P)		;  THE RETURNER
	TXNN	T,<Z 17,>	;OVERFLOWED THE AC FIELD YET?
	HRLI	T,(JUMPA 17,)	;YES, LIMIT AT JUMPA 17,
	MOVEM	T,(P)		;SET BASIC JUMPA TEMPLATE
	HRRZ	T,PTLLC		;ORIGINAL USER LOCATION
	ADD	T,(P)		;GENERATE A JUMPA N,C(PTLLC)+N
	PUSHJ	P,DMEMER	;PUT IN PATCH AREA
	PUSHJ	P,LI2		;KEEP USER UPDATED
	SOSLE	-1(P)		;COMPLETED MAXIMUM SKIPNESS YET?
	JRST	PTCHE3		;NO, LOOP TILL DONE
	POP	P,T		;YES, ADJUST
	POP	P,T		;STACK POINTER

;CONTINUED ON NEXT PAGE
;FALL IN FROM ABOVE

;NOW TO DECIDE WHAT POINTER (IF ANY) TO UPDATE

PTCHE6:	SKIPN	PTORG		;ANYTHING TO UPDATE?
	JRST	PTCHE8		;NO, GO INSTALL JUMPA TO PATCH
	AOS	T,LLOC		;GET NEXT FREE PATCH LOC
	SKIPG	PTORG		;SYMBOL OR .JBFF?
	JRST	PTCHE7		;SYMBOL, PROCEED
	MOVEI	R,.JBFF		;.JBFF, SET UP TO UPDATE IT
	HLL	R,LLOCO		;IN PATCHED SECTION
	PUSH	P,T		;SAVE T
	HRRZ	T,T		;NEW VALUE EXCLUDES SECTION
	PUSHJ	P,DMEMER	;UPDATE C(.JBFF) ACCORDINGLY
	HRRI	R,.JBSA		;C(.JBFF) ALSO STORED IN LH(.JBSA)
	PUSHJ	P,FETCH		;SO GET .JBSA
	 JRST	ERR		;BZZZT?
	HRL	T,(P)		;NEW LH(.JBSA)
	PUSHJ	P,DMEMER	;SET AND HOPE FOR BEST
	POP	P,T		;RESTORE STACK
	JRST	PTCHE8		;AND FINISH OFF PATCH

PTCHE7:	MOVE	R,PTVAL		;GET ORIGINAL SYMBOL VALUE
	TLNN	R,-1		;DEFINED WITH SECTION NO.?
	HRRZ	T,T		;NEW SYMBOL VALUE EXCLUDES SECTION
	MOVE	R,PTFIX		;WHERE VALUE CAME FROM
	PUSHJ	P,DSYMER	;DEPOSIT NEW SYMBOL VALUE
	MOVE	S,PTSYM		;GET SYMBOL USED FOR PATCHING
  IFN FTSCSH,<			;ONLY IF USING SYMBOL TABLE CACHE
	PUSHJ	P,DELCSH	;REMOVE FROM THE SYMBOL TABLE CACHE
  > ;END IFN FTSCSH
	MOVE	S,T		;GET VALUE SYMBOL WAS REDEFINED AS
  IFN FTSCSH,<			;ONLY IF USING SYMBOL TABLE CACHE
	PUSHJ	P,DELCSV	;REMOVE VALUE FROM CACHE TOO
  > ;END IFN FTSCSH
PTCHE8:	PUSHJ	P,TCRLF		;TYPE <CR><LF>
	MOVE	T,PTLLC		;ORIGINAL USER LOCATION
	PUSHJ	P,LI1		;OPEN AND TYPE ORIGINAL LOCATION
	MOVE	R,LLOCO		;CURRENT OPEN LOCATION
	MOVSI	T,(JUMPA)	;JUMP TO PATCH AREA INSTRUCTION
	HRR	T,PTLOC		;ADDRESS OF START OF PATCH
				; NOTE ADDRESS IN LOCAL SECTION
	PUSHJ	P,DMEMER	;PUT IN JUMP INSTRUCTION
	PUSHJ	P,LI2		;AND SHOW USER
	SETZM	PTLOC		;SAY NO PATCH IN PROGRESS
	POPJ	P,		;DONE

PTCHX:	SKIPE	WRD2D		;$0< ?
	 JRST	ERR		;NO, UNDEFINED COMMAND
	MOVE	T,PTLLC		;YES, GET ADDR. OF PATCH INSERT
	MOVEM	T,LLOC		;DEFINE IT TO BE "."
	MOVEM	T,LLOCO		;AND LAST LOCATION OPEN
	SETZM	PTLOC		;DEFINE NO PATCH IN PROGRESS
	JRST	RET		;ABORT THE COMMAND

;(MATCH ANGLE BRACKETS: >)
SUBTTL	COMMAND ROUTINES -- MEMORY AND PAGING CONTROL

;HERE ON AN $W OR $$W.
;
;IF FORM WAS "LOWER<UPPER>WORD$W" THEN IS WORD SEARCH, OTHERWISE
;COMMAND IS TO ENABLE MEMORY-MANAGEMENT FLAGS.
;
;A SINGLE <ESC> ENABLES THE CONDITION, A DOUBLE <ESC> CLEARS IT:
;
;	$[$]0W		;ENABLE [DISABLE] AUTO WRITE-ENABLE
;	$[$]1W		;ENABLE [DISABLE] AUTO PAGE CREATE

DBLU:	TXNE	F,QF		;USER TYPE AN ARG?
	JRST	WORD		;YES, THIS IS A WORD SEARCH
	TXNE	F,FAF!SAF	;ANY ANGLIES TYPED?
	JRST	ERR		;YES, THAT'S BAD
  IFN FTFILE,<
	SKIPN	PHYSIO		;ARE WE EXAMINING A REAL DISK FILE?
	SKIPN	FILING		;MAYBE, ARE WE?
	CAIA			;NO
	JRST	ERR		;YES, CAN'T CHANGE PATCHS WITHOUT
				;  RE-OPENING THE FILE
  > ;END IFN FTFILE
	TXNE	F,CCF		;$$W?
	TDZA	T,T		;YES, CLEAR FLAG
	SETO	T,		;NO, SET FLAG
	TXNE	F,Q2F		;USER TYPE SECOND ARG?
	SKIPA	R,WRD2D		;YES, GET INDEX
	SETZ	R,		;NO, DEFAULT IS 0 (WRITE ENABLE)
	JUMPL	R,ERR		;MUST BE .GE. 0
	CAIL	R,PAMAX		;AND .LT. PAMAX
	JRST	ERR		;NOT IN RANGE, CALL ERROR
	MOVEM	T,PATCHS(R)	;STORE NEW WRITE-ENABLE WORD
  IFN FTFILE,<
	SETOM	DEPNCT		;RESET PATCHING-TRIED FLAG
	SETOM	LASTPG		;DON'T KNOW PAGE ACCESS BITS ANYMORE
  > ;END IFN FTFILE
	JRST	RET
;COMMAND TO MAKE LIFE EASIER ON VIRTUAL ADDRESSING MACHINES
;FORMAT IS ARG$NU, WHERE N IS:
;
;	BLANK	SAME AS 0
;	0	MAP THROUGH EPT AT PAGE ARG (ON -10, CAN BE UPT<EPT$U)
;	1	MAP THROUGH UPT AT PAGE ARG
;	2	MAP THROUGH SECTION MAP AT PAGE ARG
;	3	FAKEAC FLAG: NON-ZERO TO USE FAKE ACS
;	4	SET AC BLOCK TO ARG (EDDT ONLY)
;	5	LOAD ACS FROM 20 WORD BLOCK AT ARG
;	6	SET SPT BASE TO ARG
;	7	SET CST BASE TO ARG
;	8	SET ADDRESS RELOCATION (ADDED TO ALL USER ADDRESSES)
;	9	SET ADDRESS PROTECTION (MAX LEGAL USER ADDRESS)
;	10	SET KI-PAGING MODE (FOR EMULATION, IGNORED IN EDDT)
;	11	SET KL-PAGING MODE (FOR EMULATION, IGNORED IN EDDT)
;	12-19	RESERVED FOR FUTURE
;	20	SET KA-10 CPU TYPE (FOR EMULATION, IGNORED IN EDDT)
;	21	SET KI-10 CPU TYPE (FOR EMULATION, IGNORED IN EDDT)
;	22	SET KL-10 CPU TYPE (FOR EMULATION, IGNORED IN EDDT)
;	23	SET KS-10 CPU TYPE (FOR EMULATION, IGNORED IN EDDT)
;	24+	RESERVED FOR FUTURE
;
;(MATCH ANGLE BRACKETS:>)
;
;FOR MAPPING FUNCTIONS, TWO ALTS MEANS ARG IS AN SPT INDEX INSTEAD OF
;A PAGE NUMBER.
;
;$U WITH NO ARGUMENTS CLEARS 0,1,2,8 AND SETS 3 (I.E., RESTORES "NORMAL
;VIRTUAL ADDRESSING"). $$U WITH NO ARGUMENTS SETS PHYSICAL ADDRESSING
;MODE.
;
;$NU OR $$NU WILL RETURN THE ADDRESS OF THE APPROPRIATE WORD INTERNAL
;TO DDT WHICH CORRESPONDS TO THE FUNCTION. FOR FUNCTIONS 0, 1, AND 2
;THE $$ FORM RETURNS THE MAPPING FUNCTION WORD (I.E., PHYSICAL OR
;VIRTUAL OR SPT-RELATIVE ADDRESSING) WHILE THE $ FORM RETURNS THE
;USER ARGUMENT. FOR ALL OTHER FUNCTION CODES AN ERROR OCCURS.
  IFN FTPAGM,<		;ONLY AVAILABLE IN FILDDT ON TOPS20
SETPAG:	TXNE	F,QF		;ANY ARG?
	JRST	SETPA2		;YES, A FUNCTION TO PERFORM
	TXNE	F,Q2F		;WANT TO READ BACK?
	JRST	SETPA4		;YES, GO TYPE IT OUT
	TXNE	F,FAF!SAF	;$U OR $$U, ANY SUPERFLUOUS ARGS?
	JRST	ERR		;YES, ILLEGAL
	TXNE	F,CCF		;$U OR $$U?
	JRST	SETPHY		;$$U, SET PHYSICAL ADDRESSING
	SETZM	MAPFN		;UNMAPPED VIRTUAL ADDRESSING
  IFN FTFILE,<			;SPECIAL FILDDT DEFAULTING
	SETZM	FAKEAC		;UNMAPPED 0-17 ALSO, UNLESS
	SKIPN	PHYSIO		;IF DOING SUPER I/O
	SKIPN	EXEFMT		;OR IF LOOKING AT A DATA FILE
	SKIPA			;DO NOT USE FAKE ACS
  > ;END OF IFN FTFILE
	SETOM	FAKEAC		;ASSUME BACK TO INTERNAL FAKE ACS
  IFN FTDEC10&FTFILE,<
	SKIPN	JOBEDV		;IF NOTHING FROM THE EDV WAS AVAILABLE,
	POPJ	P,		;GET OUT NOW
	MOVE	T,EDVEPT	;WE HAD SOMETHING
	MOVEM	T,MAPPG		;RESTORE THE EPT
	MOVE	T,EDVSPT	;THE SPT
	MOVEM	T,SPTWRD	;RESTORED
	MOVE	T,EDVCST	;AND THE CST
	MOVEM	T,CSTWRD	;...
	AOS	MAPFN		;ENABLE THE SIMULATION
  > ;END OF IFN FTDEC10&FTFILE
	POPJ	P,		;THAT'S IT


;HERE ON AN $U WITH AN ARGUMENT.  FIGURE OUT WHICH FUNCTION TO PERFORM.

SETPA2:	TXNN	F,Q2F		;ANY FUNCTION CODE?
	TDZA	W,W		;NO, ASSUME 0
	MOVE	W,WRD2D		;YES, GET IT (DECIMAL)
	JUMPL	W,ERR		;NEGATIVE IS ILLEGAL
	CAIL	W,PFNMAX	;TOO BIG?
	JRST	ERR		;ILLEGAL
	HLLO	TT,F		;FLAGS,,-1
	AND	TT,PFNDSP(W)	;CHECK FOR ILLEGAL FLAGS
	SKPKLP			;KI PAGING?
	TXNN	F,CCF		;YES, $$ ALWAYS ILLEGAL. WAS IT TYPED?
	TLNE	TT,-1		;OR ANY ILLEGAL FLAGS SET?
	JRST	ERR		;YES, ILLEGAL
	ADDI	W,1		;BASE FUNCTIONS AT 1 FOR STORE
	JRST	(TT)		;DISPATCH
;STILL IFN FTPAGM

;HERE TO RETURN ADDRESS OF DDT WORD FOR USER TO SEE

SETPA4:	SKIPL	W,WRD2D		;GET FUNCTION CODE
	CAIL	W,PFNMAX	;TOO BIG?
	JRST	ERR		;ILLEGAL
	TXNN	F,CCF		;$ OR $$ TYPED?
	SKIPA	T,PFNADR(W)	;$NU
	MOVS	T,PFNADR(W)	;$$NU
	TRNN	T,-1		;SOMETHING THERE?
	JRST	ERR		;NO, USER ERROR
	ANDI	T,-1		;CONCOCT AN INTERNAL-TO-DDT ADDRESS
	PJRST	MASK02		;AND RETURN VALUE AS IF USER TYPED IT
;STILL IFN FTPAGM

;DISPATCH TABLE FOR $U FUNCTION CODES.
;FORMAT IS:   ILLEGAL FLAG BITS,,DISPATCH ADDRESS
;CHANGES HERE SHOULD ALSO GO IN MFNDSP AND COMMENT ON PREVIOUS PAGE.

PFNDSP:	SAF+		SETEPT	;(00) SET EPT
	FAF!SAF+	SETMAP	;(01) SET UPT
	FAF!SAF+	SETSEC	;(02) SET SECTION MAP
	FAF!SAF!CCF+	SETFAC	;(03) SET FAKE ACS
	FAF!SAF!CCF+	SETACB	;(04) SET AC BLOCK
	FAF!SAF!CCF+	SETCAC	;(05) LOAD "CRASH ACS" FROM ADDRESS
	FAF!SAF!CCF+	SETSPT	;(06) SET SPT BASE
	FAF!SAF!CCF+	SETCST	;(07) SET CST BASE
	FAF!SAF!CCF+	SETREL	;(08) SET RELOCATION
	FAF!SAF!CCF+	SETPRT	;(09) SET PROTECTION
	FAF!SAF!CCF+	SETKIP	;(10) SET KI-PAGING EMULATION
	FAF!SAF!CCF+	SETKLP	;(11) SET KL-PAGING EMULATION
	FAF!SAF!CCF+	ERR	;(12) RESERVED
	FAF!SAF!CCF+	ERR	;(13) RESERVED
	FAF!SAF!CCF+	ERR	;(14) RESERVED
	FAF!SAF!CCF+	ERR	;(15) RESERVED
	FAF!SAF!CCF+	ERR	;(16) RESERVED
	FAF!SAF!CCF+	ERR	;(17) RESERVED
	FAF!SAF!CCF+	ERR	;(18) RESERVED
	FAF!SAF!CCF+	ERR	;(19) RESERVED
	FAF!SAF!CCF+	SETKAC	;(20) SET KA-10 CPU TYPE
	FAF!SAF!CCF+	SETKIC	;(21) SET KI-10 CPU TYPE
	FAF!SAF!CCF+	SETKLC	;(22) SET KL-10 CPU TYPE
	FAF!SAF!CCF+	SETKSC	;(23) SET KS-10 CPU TYPE
PFNMAX==.-PFNDSP


PFNADR:	MAPFN,,	MAPPG		;(00) SET EPT (ADDRESSING MODE)
	MAPFN,,	MAPPG		;(01) SET UPT (ADDRESSING MODE)
	MAPFN,,	MAPPG		;(02) SET SECTION MAP (ADDRESSING MODE)
	0,,	FAKEAC		;(03) SELECT INTERNAL FAKE ACS
	0,,	ACWRD		;(04) SELECT HARDWARE AC BLOCK
	0,,	FAKEAD		;(05) ADDRESS OF ORIGIN OF FAKE ACS
	0,,	SPTWRD		;(06) BASE ADDRESS OF SPT
	0,,	CSTWRD		;(07) BASE ADDRESS OF CST
	0,,	UBASE		;(08) RELOCATION ADDRESS
	0,,	UPROT		;(09) PROTECTION ADDRESS
	0,,	KIPAG		;(10) KI-PAGING FLAG
	0,,	KLPAG		;(11) KL-PAGING FLAG
	0,,	777777		;(12) RESERVED
	0,,	777777		;(13) RESERVED
	0,,	777777		;(14) RESERVED
	0,,	777777		;(15) RESERVED
	0,,	777777		;(16) RESERVED
	0,,	777777		;(17) RESERVED
	0,,	777777		;(18) RESERVED
	0,,	777777		;(19) RESERVED
	0,,	KAFLG		;(20) KA-10 FLAG
	0,,	KIFLG		;(21) KI-10 FLAG
	0,,	KLFLG		;(22) KL-10 FLAG
	0,,	KSFLG		;(23) KS-10 FLAG
;STILL IFN FTPAGM

;SET PHYSICAL ADDRESSING

SETPHY:	SETZM	FAKEAC		;USE REAL 0-17
	SETO	W,		;-1 IN MAPFN MEANS PHYSICAL ADDRESSING
	JRST	SETMA4		;JOIN COMMON CODE



;SET EPT (AND POSSIBLY UPT FOR PER-PROCESS AREA IF KI PAGING)

SETEPT:	SKPKIP			;KI PAGING?
	JRST	SETMAP		;NO, JUST LIKE UPT
	TXNE	F,FAF		;USER GIVE UPT?
	SKIPA	TT,LLIMIT	;YES, USE IT
	SETO	TT,		;NO, -1 MEANS PER-PROCESS AREA INACCESSIBLE
	HRL	T,TT		;STORE USER,,EXEC IN MAPPG
	JRST	SETMA2		;JOIN COMMON CODE



;SET SECTION MAP

SETSEC:	SKPKLP			;ONLY LEGAL IF KL PAGING
	JRST	ERR		;OTHERWISE FORGET IT


;SET ANY MAP-THE-ADDRESS-SPACE FUNCTION.  $U FUNCTION CODE IS STILL IN W.

SETMAP:	TXNE	F,FAF		;EXTRA ARG?
	JRST	ERR		;YES, COMPLAIN
SETMA2:	TXNE	F,CCF		;TWO ALTS?
	TXO	W,1B1		;YES, 1B1 MEANS FETCH SPT INDEX
	SETOM	FAKEAC		;USE FAKE ACS BY DEFAULT
SETMA4:	MOVEM	W,MAPFN		;STORE FUNCTION FOR MAPADR
	MOVEM	T,MAPPG		;PAGE OR SPT OFFSET
	POPJ	P,		;DONE
;STILL IFN FTPAGM

;SET FAKE ACS


SETFAC:	SKIPE	T		;USER SAY TO USER FAKE ACS?
	SETO	T,		;YES, FLAG IT AS SUCH
	MOVEM	T,FAKEAC	;STORE USER ARG
	POPJ	P,		;DONE



;SET AC BLOCK

  IFE FTEXEC,<SETACB==ERR>	;EDDT ONLY

  IFN FTEXEC,<
SETACB:	SKPEXC			;EXEC MODE?
	JRST	ERR		;NO, ILLEGAL IN USER MODE
	PUSHJ	P,CEFFAX	;DEFAULT SECTION IF NEEDED
	MOVE	W2,T		;ARG WHERE SELAC WANTS IT
	PUSHJ	P,SELAC		;SELECT AC BLOCK
	  JRST	ERR		;SOMETHING'S WRONG
	POPJ	P,		;DONE
  > ;END IFN FTEXEC
;STILL IFN FTPAGM

;LOAD ACS FROM ADDRESS

SETCAC:	PUSHJ	P,CEFFAX	;DEFAULT SECTION IF NEEDED
	MOVE	R,T		;ADDRESS IN R
SETCA1:	MOVEM	R,FAKEAD	;SAVE FOR USER TO READ LATER
	MOVSI	S,-20		;LOOP COUNT/INDEX
	SETZM	FAKEAC		;DON'T GET FAKE ACS FROM FAKE ACS
SETCA2:	PUSHJ	P,FETCH		;GET A WORD FROM MEMORY
	 JRST	ERR		;ERROR
	MOVEM	T,AC0(S)	;SAVE AC AWAY IN INTERNAL AC BLOCK
	ADDI	R,1		;ADVANCE TO NEXT AC
	AOBJN	S,SETCA2	;GET ALL 20 ACS
	SETOM	FAKEAC		;FLAG USING FAKE 0 - 17
	POPJ	P,		;DONE




;SET SPT BASE

SETSPT:	PUSHJ	P,CEFFAX	;DEFAULT SECTION IF NEEDED
	MOVEM	T,SPTWRD	;STORE USER ARG
	POPJ	P,		;DONE


;SET CST BASE

SETCST:	PUSHJ	P,CEFFAX	;DEFAULT SECTION IF NEEDED
	MOVEM	T,CSTWRD	;STORE USER ARG
	POPJ	P,		;DONE
;STILL IFN FTPAGM

;SET PROTECTION AND RELOCATION

SETREL:	PUSHJ	P,CEFFAX	;DEFAULT SECTION IF NEEDED
	MOVEM	T,UBASE		;STORE RELOCATION ADDRESS
	POPJ	P,		;DONE

SETPRT:	PUSHJ	P,CEFFAX	;DEFAULT SECTION IF NEEDED
	MOVEM	T,UPROT		;STORE PROTECTION ADDRESS
	POPJ	P,		;DONE



;SET PAGING MODE (KI/KL), ERROR IF IN EXEC MODE

SETKIP:	SKIPE	W1,T		;TURNING ON OR OFF?
	SETO	W1,		;ON
	SETZ	W2,		;THEREFORE NO KL-PAGING
	JRST	SETKXP		;COMMON CODE

SETKLP:	SKIPE	W2,T		;TURNING ON OR OFF?
	SETO	W2,		;ON
	SETZ	W1,		;THEREFORE NO KL-PAGING

SETKXP:
  IFN FTEXEC,<			;EXEC MODE IS ILLEGAL
	SKPUSR			;IN USER OR EXEC MODE?
	JRST	ERR		;EXEC, THEN DON'T DO IT ERE DEATH RESULT
  > ;END IFN FTEXEC

	MOVEM	W1,KIPAG	;SET APPROPRIATE KI-PAGING FLAG
	MOVEM	W2,KLPAG	;SET APPROPRIATE KL-PAGING FLAG
	POPJ	P,		;END OF COMMAND

;SET KA/KI/KL/KS CPU TYPE, ERROR IF IN EXEC MODE

SETKAC:	PUSHJ	P,SETKZC	;INITIALIZE CPU FLAGS
	MOVEM	T,KAFLG		;SET KA-10 EMULATION
	POPJ	P,		;DONE

SETKIC:	PUSHJ	P,SETKZC	;INITIALIZE CPU FLAGS
	MOVEM	T,KIFLG		;SET KI-10 EMULATION
	POPJ	P,		;DONE

SETKLC:	PUSHJ	P,SETKZC	;INITIALIZE CPU FLAGS
	MOVEM	T,KLFLG		;SET KL-10 EMULATION
	MOVEM	T,KLSFLG	;SET KL/KS EMULATION
	POPJ	P,		;DONE

SETKSC:	PUSHJ	P,SETKZC	;INITIALIZE CPU FLAGS
	MOVEM	T,KSFLG		;SET KS-10 EMULATION
	MOVEM	T,KLSFLG	;SET KL/KS EMULATION
	POPJ	P,		;DONE

SETKZC:				;HELPER TO CLEAR CPU FLAGS AND SUCH
  IFN FTEXEC,<			;NEVER NEVER DO THIS IN EXEC MODE!
	SKPUSR			;USER MODE?
	JRST	ERR		;EXEC, DISALLOW UNDER THREAT OF DEATH
  > ;END IFN FTEXEC
	SETZM	BZ$CPF		;CLEAR START OF CPU FLAGS AREA
	MOVE	TT,[BZ$CPF,,BZ$CPF+1]	;BLT POINTER TO
	BLT	TT,ZZ$CPF-1	;CLEAR REST OF CPU FLAGS AREA
	CAIE	T,0		;ARG TO "SET" OR "CLEAR"?
	SETO	T,		;SET, NORMALIZE TO -1
	POPJ	P,		;GO SET/CLEAR APPROPRIATE FLAG
  > ;END IFN FTPAGM

IFE FTPAGM,<SETPAG==ERR>	;DOESN'T EXIST
;$L AND $$L COMMANDS - LIST PAGE (SECTION) ACCESSABILITY
;
;    $[$]L	TYPE ACCESS OF ALL PAGES (SECTIONS)
;   N$[$]L	TYPE ACCESS FOR SECTION N
; N<M$[$]L	TYPE ACCESS FOR SECTIONS N THRU M
;
;(MATCH ANGLE BRACKETS: >)

PAGMAP:	TXNN	F,Q2F		;$NL FORMAT?
	TXNE	F,SAF		;OR SECOND ANGLE?
	JRST	ERR		;USER IS CONFUSED
  IFN FTFILE,<			;FILDDT MIGHT LUCK OUT
	SKIPE	FILING		;IF IT'S MEMORY
	SKIPN	EXEFMT		; OR DATA FILE/DISK
	JRST	PGMA10		;THEN LIFE IS SIMPLER
  > ;END IFN FTFILE
	TXNN	F,QF		;UPPER LIMIT TYPED?
	MOVEI	T,37		;NO, DEFAULT TO MAX
	JUMPL	T,ERR		;NEG ARG IS NO GOOD
	CAILE	T,37		;CAN GO UP TO 37
	JRST	ERR		;OUT OF RANGE, SORRY
	MOVEM	T,ULIMIT	;SAVE UPPER LIMIT AWAY
	TXNN	F,FAF		;LOWER LIMIT GIVEN?
	JRST	[TXNN	F,QF	;NO, WAS THERE AN EXPLICIT ARG?
		SETZ	T,	;NO, DEFAULT TO ZERO
		MOVEM	T,LLIMIT ;SET THE LOWER LIMIT
		JRST	PAGMA2]	;JOIN COMMON CODE
	SKIPL	T,LLIMIT	;FETCH SPECIFIED LOWER LIMIT
	CAILE	T,37		;IN RANGE?
	JRST	ERR		;NO WAY
PAGMA2:	CAMLE	T,ULIMIT	;IS LOWER .LE. UPPER?
	JRST	ERR		;NO, FORGET THIS

;FALL THROUGH TO NEXT PAGE
;FALL IN FROM ABOVE

;HERE WITH A VALID RANGE OF SECTIONS TO LOOK AT

  IFN FTUE10,<
	SETZM	OLDSPY		;NOT YET KNOWN IF PA.GPN IS VALID
  > ;END IFN FTUE10
	PUSHJ	P,TCRLF		;START OFF RIGHT
	SOS	LLIMIT		;COMPENSATE FOR LATER AOS
  IFN FTEX10,<PUSHJ P,NORSPC>	; MAKE SURE WE'RE IN NORMAL SPACE
PAGMA3:	PUSHJ	P,LISCK		;USER WANT TO HANG IT UP?
	  JRST	PAGM30		;NO, KEEP SCANNING
	 JRST	DD1		;YES, QUIT
	MOVEI	W1,[ASCIZ\Scanning memory: \] ;"?", NICE TEXT
	PUSHJ	P,TSTRG		;TELL USER
	MOVE	T,LLIMIT	;LAST SECTION CHECKED
	ADDI	T,1		;CURRENT SECTION TO BE CHECKED
	HRLZ	T,T		;CURRENT WORD ADDRESS TO BE CHECKED
	PUSHJ	P,PADR		;TYPE OUT ADDRESS
	PUSHJ	P,TCRLF		;CAP OFF "?" SUMMARY WITH <CR><LF>
PAGM30:	AOS	TT,LLIMIT	;GET NEXT SECTION TO CHECK
	CAMLE	TT,ULIMIT	;PAST LAST SECTION?
	JRST	DD1		;YES, QUIT
	PUSHJ	P,CHKSEC	;GET ACCESS FOR THIS SECTION
	TXNN	TT,PG$SXI	;DOES IT EXIST?
	JRST	PAGMA3		;NO, TRY NEXT SECTION

;CONTINUED ON NEXT PAGE
;CONTINUED FROM PREVIOUS PAGE

	TSTR	< Section >	;YES, SAY WHAT WE ARE
	PUSH	P,ODF		;SAVE OUTPUT RADIX FOR A SECOND
	MOVEI	ODF,8		;SET TO OCTAL
	MOVE	T,LLIMIT	;GET THE SECTION NUMBER
	PUSHJ	P,TOC		;TYPE IT IN OCTAL
	TXNN	TT,PG$SMA	;SECTION MAPPED ELSEWHERE?
	JRST	PAGM34		;NO, JUST TYPE ACCESS BITS
	MOVEI	W1,[ASCIZ / shared/]	;ASSUME SHARED
	TXNE	TT,PG$SIN		;UNLESS PROVEN INDIRECT
	MOVEI	W1,[ASCIZ / indirect/]	;IT'S INDIRECT
	PUSHJ	P,TSTRG			;TELL 'EM
  IFN FTEXEC,<
	SKPUSR		;USER MODE?
	JRST PAGM34	;SKIP THIS STUFF
  > ;END IFN FTEXEC
  IFE FTMON,<
	MOVEI	W1,[ASCIZ / to section /] ;SAY WHERE TO
	PUSHJ	P,TSTRG			;TYPE IT
	LDB	T,[POINTR TT,PG$SEC]	;GET THE TARGET SECTION
	PUSHJ	P,TOC		;AND TYPE IT TOO
  IFN FTDEC20,<			;-20 CAN MAP TO FILES, OTHER FORKS
	TXNN	TT,PG$SFJ	;MAPPED TO EITHER FORK OR JFN?
	JRST	PAGM34		;NO, ALL DONE
	MOVEI	W1,[ASCIZ /, fork /]	;ASSUME FORK
	TXZN	TT,.FHSLF		;FORK OR FILE?
	MOVEI	W1,[ASCIZ /, JFN /]	;IT'S A FILE
	PUSHJ	P,TSTRG		;TYPE WHICH
	HRRZ	T,TT		;LOAD UP FORK/JFN NUMBER
	PUSHJ	P,TOC		;AND TYPE IT TOO
  > ;END IFN FTDEC20
  > ;END IFE FTMON
PAGM34:	POP	P,ODF		;RESTORE RADIX
	PUSHJ	P,TTAB		;SPACE OVER A LITTLE
	PUSHJ	P,TYPACC	;TYPE ACCESS INFO TO FINISH THE LINE
	TXNE	F,CCF		;ARE WE TALKING PAGES HERE?
	JRST	PAGMA3		;NO, JUST SECTIONS

;FALL THROUGH TO NEXT PAGE
;FALL IN FROM ABOVE

;HERE TO LOOP THROUGH ALL PAGES OF A SECTION, TYPING ACCESS OF EACH GROUP.

	SETOM	LOWPAG		;INIT LOW PAGE NUMBER
	MOVE	R,LLIMIT	;CURRENT SECTION NUMBER
	LSH	R,PG2WRD	;MAKE IT A PAGE NUMBER
	MOVEM	R,HGHPAG	;INIT HIGH PAGE NUMBER
	JRST	PAGMA5		;SKIP THE CHECK FIRST TIME AROUND
PAGMA4:	PUSHJ	P,LISCK		;USER WANT TO HANG IT UP?
	  JRST	PAGM40		;NO, PROCESS NEXT PAGE
	 JRST	DD1		;YES, ABORT
	MOVEI	W1,[ASCIZ\Scanning memory: \] ;"?" TEXT, NICE TEXT
	PUSHJ	P,TSTRG		;TELL USER
	MOVE	T,HGHPAG	;LAST PAGE CHECKED
	ADDI	T,1		;CURRENT PAGE TO BE CHECKED
	LSH	T,PG2WRD	;MAKE A WORD ADDRESS
	PUSHJ	P,PADR		;TYPE OUT ADDRESS
	PUSHJ	P,TCRLF		;CAP OFF "?" SUMMARY WITH <CR><LF>
PAGM40:	AOS	R,HGHPAG	;GET NEXT PAGE
	TRNN	R,PAGMSK	;REACHED END OF SECTION?
	JRST	[MOVE	TT,OLDBTS	;YES, GET MOST RECENT ACCESS BITS
		TXNN	TT,PG$EXI	;DID PAGE 777 EXIST?
		JRST	PAGMA3		;NO, GO FOR NEXT SECTION
		JRST	PAGMA7]		;YES, GO TYPE THE ACCESS
PAGMA5:	PUSHJ	P,PAGACC	;GET PAGE ACCESS BITS
	MOVE	T,HGHPAG	;GET CURRENT PAGE AGAIN
	SKIPGE	LOWPAG		;FIRST TIME THROUGH?
	JRST	PAGMA6		;YES, NO OLD ACCESS TO CHECK
  IFN FTUE10,<
	TXNN	TT,PG$SPY	;IF NOT A SPY PAGE,
	JRST	PAGM58		;WE DON'T CARE
	SKIPE	OLDSPY		;DO WE KNOW YET IF PA.GPN IS VALID?
	JRST	PAGM57		;YES, DON'T FIND OUT TWICE
	SETO	TT1,		;GET AN ILLEGAL ADDRESS
	TRNE	TT,PA.GPN	;IF FIELD IS NON-ZERO,
	TDZA	TT1,TT1		;THEN IT'S VALID
	IPCFM.	TT1,		;NO, CHECK FOR 7.03 OR LATER MONITOR
	MOVEM	TT1,OLDSPY	;NEGATIVE IF PA.GPN INVALID
	JUMPL	TT1,PAGM58	;DO IT OLD WAY IF NOT VALID
	AOS	OLDSPY		;MAKE SURE IT'S POSITIVE
PAGM57:	SKIPG	OLDSPY		;IF NOT VALID,
	JRST	PAGM58		;DO IT THE OLD WAY
	MOVE	TT1,OLDBTS	;YES, GET PREVIOUS FLAGS
	TXNN	TT1,PG$SPY	;IF NOT A SPY PAGE BEFORE,
	JRST	PAGM59		;THEN TIME TO TYPE
	AOS	TT1		;ADJUST COPY OF OLDBTS FOR COMPARISON
	CAME	TT1,TT		;IF NO MATCH,
	JRST	PAGM59		;THEN TIME TO TYPE
	AOS	OLDBTS		;YES, MAKE SURE SEQUENTIAL PAGES MATCH
	;PJRST	PAGM58		;NOW DO IT THE OLD WAY
  > ;END IFN FTUE10
PAGM58:	CAMN	TT,OLDBTS	;SAME ACCESS AS LAST TIME?
	JRST	PAGMA4		;YES, GO FOR NEXT PAGE
	MOVE	TT1,OLDBTS	;NO, GET OLD BITS
PAGM59:	TXNE	TT1,PG$EXI	;DID IT EXIST?
	JRST	PAGMA7		;YES, GO TYPE THE ACCESS
PAGMA6:	MOVEM	T,LOWPAG	;NO, SAVE LOW END PAGE NUMBER
	MOVEM	TT,OLDBTS	;AND ACCESS BITS
  IFN FTUE10,<
	TXNE	TT,PG$SPY	;IF NOT A SPY PAGE,
	SKIPE	OLDSPY		;OR WE ALREADY KNOW ABOUT PA.GPN
	JRST	PAGMA4		;GO FOR THE NEXT PAGE
	SETO	TT1,		;GET AN INVALID ADDRESS
	TRNE	TT,PA.GPN	;IF THE FIELD IS PRESENT,
	TDZA	TT1,TT1		;THEN WE ALREADY KNOW
	IPCFM.	TT1,		;NO, CHECK FOR 7.03 OR LATER MONITOR
	MOVEM	TT1,OLDSPY	;SETUP FLAG FOR LATER
	JUMPL	TT1,PAGMA4	;SKIP THIS IF OLD MONITOR
	AOS	OLDSPY		;MAKE SURE WE KNOW IT WORKS
  > ;END IFN FTUE10
	JRST	PAGMA4		;GO FOR NEXT PAGE
;HERE TO DO THE EASY FILDDT CASE, OF MEMORY/DATA FILE/DISK.
;ACCESS TO THE ENTIRE TARGET IS THE SAME, SO JUST REPORT IT ONCE.

  IFN FTFILE,<
PGMA10:	PUSHJ	P,TCRLF		;START OFF CLEAN
	SKIPE	FILING		;LOOKING AT A FILE?
	JRST	[MOVEI	W1,[ASCII /File/] ;YES, MAYBE
		SKIPE	PHYSIO		  ;COULD BE A DISK, THOUGH
		MOVEI	W1,[ASCII /Disk/] ;YEP, A DISK
		JRST	PGMA11]		  ;GO TYPE THE MESSAGE
	MOVEI	W1,[ASCII /Monitor/] ;ASSUME MONITOR
    IFN FTDEC10,<		;-10 CAN SEE JOBS TOO
	SKIPE	JOBING		;LOOKING AT A JOB?
	MOVEI	W1,[ASCII /Job memory/] ;YES, SAY IT IS
    > ;END IFN FTDEC10
PGMA11:	PUSHJ	P,TSTRG		;TYPE THE TARGET TYPE
	TSTR	< access is >	;MORE MESSAGE
	SETZ	R,		;ALL ADDRESSES ARE EQUAL IN THESE CASES
	PUSHJ	P,PAGACC	;GET THE USER'S ACCESS BITS
	PUSHJ	P,TYPACC	;TYPE 'EM OUT
	JRST	DD1		;ALL DONE
  > ;END IFN FTFILE
;HERE TO TYPE OUT THE RANGE OF THE PAGE GROUP AND ITS ACCESS

PAGMA7:	MOVE	W1,LOWPAG	;GET LOW PAGE NUMBER
	PUSHJ	P,PAGOUT	;TYPE IT OUT
	MOVE	W2,LOWPAG	;GET LOW PAGE AGAIN
	MOVE	W1,HGHPAG	;GET HIGH PAGE
	SOS	W1		;DECREMENT TO LAST PAGE OF THIS GROUP
	CAMN	W1,W2		;JUST ONE PAGE?
	JRST	[MOVE	W1,[ASCIZ /    /] ;YES, SPACE OVER SOME
		PUSHJ	P,TEXT2		;SO COLUMNS LINE UP NICELY
		JRST	PAGMA9]		;GO TYPE ACCESS
	MOVEI	T,"-"		;NO, TYPE DASH
	PUSHJ	P,TOUT		;AS SEPARATOR
	PUSHJ	P,PAGOUT	;AND SECOND PAGE NUMBER
PAGMA9:	PUSHJ	P,TTAB		;MOVE OVER FROM PAGE NUMBERS
	EXCH	TT,OLDBTS	;SWAP ACCESS BITS, GET OLD GROUP
	PUSHJ	P,TYPACC	;TYPE ALL THE BIT MEANINGS
	MOVE	T,HGHPAG	;GET NEXT PAGE NUMBER
	MOVEM	T,LOWPAG	;SET NEW LOW PAGE FOR NEXT GROUP
	TRNE	T,PAGMSK	;AT END OF SECTION?
	JRST	PAGMA4		;NO, GO FOR NEXT PAGE GROUP
	JRST	PAGMA3		;YES, GO FOR NEXT SECTION

;PAGOUT - TYPE A PAGE NUMBER IN EXACTLY THREE COLUMNS
;PAGE NUMBER IN W1, DESTROYS W1, W2

PAGOUT:	SETZ	W2,		;CLEAR DESTINATION
  REPEAT 3,<			;FOR EACH DIGIT,
	LSHC	W1,-3		;SHIFT THE OCTAL DIGIT
	LSH	W2,-4		;PLUS FOUR TO MAKE 7-BIT BYTES
  > ;END REPEAT 3
	ADD	W2,[ASCII /000/];TURN IT INTO TEXT
	MOVE	W1,W2		;PUT IT IN THE RIGHT PLACE
	PJRST	TEXT2		;AND TYPE IT OUT
;PAGACC - DETERMINE ACCESS TO A PAGE
;
;	MOVX	R,<PAGE NUMBER>
;	PUSHJ	P,PAGACC
;	RETURN
;
;RETURNS ACCESS BITS IN AC TT, ACCORDING TO CHKADR EXCEPT IN THE CASE
;OF FILDDT'ING AN EXE FILE.  IN THAT CASE PAGACC LOOKS AT THE EXE FILE'S
;DIRECTORY ACCESS BITS.
;
;CAN DESTROY TT1, SAVES ALL OTHER ACS

PAGACC:	PUSHJ	P,SAVR		;SAVE THIS OVER CALLS
  IFN FTFILE,<			;FILDDT HAS SOME THINGS TO CHECK FIRST
	SKIPE	FILING		;IF MEMORY,
	SKIPN	EXEFMT		;OR DATA FILE/DISK,
	CAIA			;JUST LIKE EVERYBODY ELSE.
	JRST	PAGAC5		;EXE FILES ARE DIFFERENT
  > ;END IFN FTFILE
	LSH	R,PG2WRD	;CHKADR WANTS AN ADDRESS
  IFN FTPAGM,<
	PUSHJ	P,MAPADR	;FIRST DO SPECIFIED MAPPING
	 TDZA	TT,TT		;CAN'T, CLAIM NO ACCESS
  > ;END IFN FTPAGM
	PUSHJ	P,CHKADR	;GET THE ACCESS
  IFN FTFILE,<
	TXZ	TT,PG$EXE!PG$SHR!PG$PRV	;CLEAR NONSENSE BITS
  > ;END IFN FTFILE
  IFN PG$CPY,<
	TXNE	TT,PG$WRT	;WRITE ACCESS ALLOWED?
	TXNE	TT,PG$CPY	;THAT ISN'T COPY-ON-WRITE?
	TRNA			;DON'T CLAIM WRITE IF ONLY COPY-ON-WRITE
	TXO	TT,PG$WT	;YES, SET BIT FOR TYPACC
  > ;END IFN PG$CPY
  IFN FTUE10,<
    IFN FTEXEC,<
	SKPUSR			;IF EXEC MODE,
	TXCA	TT,PG$EXI!PG$SXI ;NEUTER THE TXC BELOW (NO PAGE. UUO HERE)
    > ;END IFN FTEXEC
	MOVE	TT,LASTAF	;GET REAL BITS FROM PAGE. UUO
	TXC	TT,PG$EXI!PG$SXI ;FIX THE EXISTENCE FLAGS
	TXNE	TT,PG$SPY	;IF A SPY PAGE,
	TXZ	TT,PG$LCK!PG$NCA ;DON'T SAY LOCKED OR NOT CACHED
	TLZ	TT,^-<ACXBTS_-22>	;KEEP ONLY BITS WE CARE ABOUT
  > ;END IFN FTUE10
	POPJ	P,		;ALL DONE
;HERE TO DETERMINE ACCESS FOR EXE FILES IN FILDDT

  IFN FTFILE,<			;NOW THE REAL WORK
PAGAC5:	SETZ	TT,		;START WITH NO ACCESS
    IFN FTPAGM,<
	SKIPG	MAPFN		;IF NO REAL MAPPING,
	JRST	PAGAC7		;DON'T WASTE TIME WITH IT
	LSH	R,PG2WRD	;MAPADR WANTS AN ADDRESS
	PUSHJ	P,MAPADR	;DO ANY NECESSARY TRANSLATION
	  JRST	[SETZ TT,	;NONE POSSIBLE, CLEAR THE BITS
		 JRST PAGAC9]	;AND PUNT
	LSH	R,WRD2PG	;BACK TO A PAGE NUMBER FOR INDEXING INTO PAGTBL
	SETZ	TT,		;CLEAR THE BITS AGAIN (CLOBBERED BY MAPADR)
	PUSHJ	P,PAGAC7	;GET BITS FOR THE PAGE FROM THE FILE DIRECTORY
	JUMPE	TT,PAGAC9	;GET OUT NOW IF NO ACCESS
	SKPNKA			;IF A KA10
	JRST	PAGAC9		;THERE ARE NO BITS
	MOVE	TT1,MAPBTS	;GET THE ACCUMULATED ACCESS BITS
	SKPKLP			;SIGH--I CAN'T FIND MY KI10 MANUAL
	JRST	PAGAC9		;SO JUST RETURN THIS ACCESS FOR KI-STYLE PAGING
	TXNN	TT1,PTWR	;CHECK WHETHER MAP SAYS IT'S WRITABLE
	TXZA	TT,PG$WT	;NO--CLEAR BIT
	TXO	TT,PG$WT	;YES--SET BIT
      IFN FTDEC10,<
	TXNN	TT1,PTPUB	;CHECK STATUS OF PM.PUB
	TXZ	TT,PG$REA	;CONCEALED
	TXNN	TT1,PTCACH	;SIMILARLY FOR PM.CSH
	TXOA	TT,PG$NCA	;UNCACHED
	TXZ	TT,PG$NCA	;CACHED
      >
	JRST	PAGAC9		;FINALLY RETURN THE BITS
    >
PAGAC7:	MOVE	TT1,R		;NEED INDEX INTO PAGTBL
	CAMGE	TT1,PGTLEN	;PAST EOF?
	SKIPN	TT1,@PAGTBL	;OR NON-EXISTENT?
	JRST	PAGAC9		;YES, NO ACCESS POSSIBLE
	TXO	TT,PG$EXI!PG$SXI!PG$EXE!PG$REA  ;THE PAGE IS REAL AND READABLE
  IFN FTDEC10,<
	TXNE	TT1,SV$SHR	;SHARABLE?
	TXO	TT,PG$SHR	;YES, SET THE SHARE BIT
	TXNE	TT1,SV$HIS	;HISEG PAGE?
	TXO	TT,PG$HGH	;YES, SET THE BIT
	TXNE	TT1,SV$WRT	;WRITABLE?
	TXO	TT,PG$WT	;YES, SET THE BIT
	TXNE	TT1,SV$CON	;CONCEALED?
	TXZ	TT,PG$REA	;YES, NOT READABLE
	ANDX	TT1,SV$FPN	;REDUCE TO FILE PAGE NUMBER
	SKIPN	TT1		;IS IT A REAL PAGE?
	TXO	TT,PG$ABZ	;NO, FLAG ZERO PAGE
  > ;END IFN FTDEC10
  IFN FTDEC20,<
	TXNN	TT1,SV$WRT	;WRITABLE AT ALL?
	JRST	PAGAC8		;NO, SKIP ALL THIS
	TXNE	TT1,SV$SHR	;YES, SHARED WRITE?
	TXOA	TT,PG$WT	;YES, REALLY WRITABLE
	TXO	TT,PG$CPY	;NO, REALLY MEANS COPY-ON-WRITE
PAGAC8:	TXNE	TT1,SV$ABZ	;IS IT A ZERO PAGE?
	TXO	TT,PG$ABZ	;YES, SET THE BIT
  > ;END IFN FTDEC20
PAGAC9:	POPJ	P,		;ALL ACCESSES DETERMINED
  > ;END IFN FTFILE
;TYPACC - TYPE TEXT FOR PAGE (SECTION) ACCESS BITS.
;
;	MOVX	TT,<ACCESS BITS>
;	PUSHJ	P,TYPACC
;	RETURN
;
;TYPES TEXT FOR EACH KNOWN ACCESS BIT, AND TERMINATES WITH A CRLF.

TYPACC:	TXNN	TT,ACCBTS	;ANY ACCESS BITS SET?
	JRST	TYPAC9		;NO, DON'T BOTHER CHECKING INDIVIDUAL BITS
	SETZ	S,		;FLAG NOTHING TYPED YET
	MOVSI	W2,-NPGBTS	;LOOP OVER ALL BITS
TYPAC1:	TDNN	TT,PAGBTS(W2)	;THIS BIT SET?
	JRST	TYPAC3		;NO, GO CHECK NEXT ONE
	MOVE	W1,[ASCIZ /, /]	;GET SEPARATOR TEXT
	SKIPE	S		;FIRST FLAG FOUND?
	PUSHJ	P,TEXT2		;NO, TYPE THE COMMA
	MOVE	W1,PAGTXT(W2)	;GET TEXT ADDRESS
	PUSHJ	P,TSTRG		;TYPE IT OUT
	SETOM	S		;FLAG WE DID ONE
TYPAC3:	AOBJN	W2,TYPAC1	;GO BACK FOR NEXT BIT
  IFN FTUE10,<
	TXNN	TT,PG$SPY	;GUARD AGAINST SPY SEGS
	TXNN	TT,PG$HGH	;IS THIS A HISEG?
	JRST	TYPAC5		;NO, CHECK FOR SPY SEG/PAGES
	TXNN	TT,PA.GSG	;DO WE KNOW WHICH SEGMENT?
	JRST	TYPAC9		;NO, GIVE UP
	ANDI	TT,PA.GSG	;ISOLATE SEGMENT NUMBER
	MOVEM	TT,SEGOPB+.SGSGN ;SAVE FOR .SGINF
	SETZM	SEGOPB+.SGSNM	;DON'T KNOW THE NAME YET
	SETZM	SEGOPB+.SGFLG	;DON'T STEP PAST IT
	MOVSI	TT,.SGFSP+1	;LENGTH OF BLOCK DESIRED
	HLLM	TT,SEGOPB	;SET FOR UUO
	XMOVEI	TT,SEGOPB	;POINT TO THE BLOCK
	SEGOP.	TT,		;AND GET THE DATA
	  JRST	TYPAC9		;OLD MONITOR?
	SKIPN	SEGFIL+.SGFDV	;IF NO DEVICE,
	SKIPE	SEGOPB+.SGSNM	;AND NO NAME
	TRNA			;AT LEAST ONE, KEEP GOING
	JRST	TYPAC9		;NEITHER, GIVE UP
	MOVEI	T,","		;YES, GET MORE PUNCTUATION
	PUSHJ	P,TOUT		;TYPE IT
	MOVE	TT,SEGOPB+.SGSNM ;GET THE SEGMENT NAME
	CAMN	TT,SEGFIL+.SGFNM ;IS IT THE SAME AS ITS FILE NAME?
	JRST	TYPAC4		;YES, WE'RE DONE HERE
	MOVSI	W1,(ASCII / (/)	;GET TEXT TO TYPE
	PUSHJ	P,TEXT		;TYPE IT
	MOVE	W1,TT		;GET SIXBIT SEGMENT NAME
	PUSHJ	P,TSIXN		;AND TYPE IT OUT
	MOVEI	T,")"		;AND CLOSE PAREN
	PUSHJ	P,TOUT		;TYPE THAT AS WELL
TYPAC4:	SKIPN	SEGFIL+.SGFDV	;IF NO DEVICE,
	JRST	TYPAC9		;WE'RE DONE (NONSHARABLE)
	PUSHJ	P,TCRLF		;GET TO A NEW LINE
	MOVEI	T," "		;SPACE OVER
	MOVEI	W1,7		;THE WIDTH OF THE PAGE RANGE
	PUSHJ	P,TOUT		;TYPE THE SPACE
	SOJG	W1,.-1		;TYPE SEVERAL
	PUSHJ	P,TTAB		;FINALLY, MAKE SURE THE INDENTATION MATCHES
	MOVEI	W1,[ASCIZ /from /]
	PUSHJ	P,TSTRG		;SAY WHAT THIS IS
	MOVEI	TT,SEGFIL	;ADDRESS OF FILESPEC
	PUSHJ	P,TYPRFS	;TYPE THE FILESPEC
	JRST	TYPAC9		;DONE WITH SHARABLE HISEG
TYPAC5:	TXNN	TT,PG$SPY	;ARE THESE PAGES SPYING?
	JRST	TYPAC9		;NO, GIVE UP
	MOVSI	W1,(ASCII /, /)	;YES, GET SEPARATOR
	PUSHJ	P,TEXT		;TYPE IT
	MOVEI	W1,[ASCIZ /monitor/] ;ASSUME VIRTUAL
	TXNN	TT,PA.GVR	;IS THAT RIGHT?
	MOVEI	W1,[ASCIZ /core/] ;NO, CHANGE THE TEXT
	PUSHJ	P,TSTRG		;SAY WHICH KIND OF SPY PAGE
	MOVEI	W1,[ASCIZ / page/] ;ADD THE WORD
	PUSHJ	P,TSTRG		;TO SAY WHAT THIS IS
	MOVE	W1,HGHPAG	;GET FIRST NON-EX PAGE
	SUB	W1,LOWPAG	;GET NUMBER OF PAGES
	MOVEI	T,"s"		;CHARACTER TO MAKE PLURAL
	CAIE	W1,1		;IF NOT JUST ONE PAGE,
	PUSHJ	P,TOUT		;MAKE IT PLURAL
	SKIPG	OLDSPY		;IF NO TARGET INFORMATION,
	JRST	TYPAC9		;DON'T TYPE JUNK
	MOVEI	T," "		;SEPARATION
	PUSHJ	P,TOUT		;NEATNESS COUNTS
	SOJLE	W1,TYPAC6	;SKIP THIS IF NOT MULTIPLE PAGES
	SUBM	TT,W1		;BACK OFF TO ORIGINAL PAGE NUMBER
	ANDI	W1,PA.GPN	;ISOLATE TO JUST PAGE NUMBER
	PUSHJ	P,TOCTW		;TYPE THE STARTING PAGE NUMBER
	MOVEI	T,"-"		;INDICATE A RANGE
	PUSHJ	P,TOUT		;TYPE THE SEPARATOR
TYPAC6:	MOVE	W1,TT		;COPY BITS
	ANDI	W1,PA.GPN	;ISOLATE PAGE NUMBER
	PUSHJ	P,TOCTW		;TYPE IT IN OCTAL
	;PJRST	TYPAC9		;DONE WITH SPY PAGES
  > ;END IFN FTUE10
TYPAC9:	PUSHJ	P,TCRLF		;NO MORE BITS, FINISH OFF LINE
	POPJ	P,		;AND RETURN

DEFINE	BITS <
X	PG$REA,<Read>		;PAGE CAN BE READ
X	PG$WT,<Write>		;PAGE CAN BE WRITTEN
X	PG$CPY,<Copy-on-write>	;PAGE IS COPY-ON-WRITE
X	PG$EXE,<Execute>	;PAGE CAN BE EXECUTED FROM
X	PG$ACC,<AA>		;PAGE ACCESS ALLOWED
X	PG$PRV,<Private>	;PAGE IS A PRIVATE PAGE
X	PG$SHR,<Sharable>	;PAGE CAN BE SHARED
X	PG$HGH,<Hiseg>		;PAGE IS PART OF HIGH SEGMENT
X	PG$ABZ,<Zero>		;PAGE ALLOCATED BUT ZERO
X	PG$SPY,<Spying>		;PAGE IS ACTUALLY SPYING ON SOMEONE
X	PG$NPG,<Cannot page>	;PAGE CANNOT BE PAGED OUT
X	PG$PGO,<Paged out>	;PAGE IS PAGED OUT
X	PG$LCK,<Locked>		;PAGE IS LOCKED IN CORE
X	PG$NCA,<Not cached>	;PAGE IS NOT CACHED
>

DEFINE	X(B,S) <IFN <B>,<EXP B
	ACCBTS==ACCBTS!<B>>>
ACCBTS==0
PAGBTS:	BITS			;MAKE THE BIT TABLE
NPGBTS==.-PAGBTS

DEFINE	X(B,S) <IFN <B>,<EXP [ASCIZ /S/]>>
PAGTXT:	BITS			;MAKE THE TEXT TABLE

IFN FTUE10,<ACXBTS==ACCBTS!PG$EXI!PG$SXI!PG$SEC!PG$VIR> ;BIT MASK FOR PAGACC
SUBTTL	COMMAND ROUTINES -- BREAKPOINT FACILITY

  IFE FTFILE,<

;ALL $B COMMANDS GET HERE IN FORM: <A>$<N>B
;
;NOTE THAT BREAKPOINT 0 IS TREATED SPECIAL IN THAT IT IS RESERVED FOR
;"UNSOLICITED" BREAKPOINTS - I.E., OCCASIONS WHEREIN CONTROL ARBITRA-
;RILY PASSES TO DDT WITHOUT DDT'S EXPECTING IT - EITHER BY THE USER PRO-
;GRAM EXECUTING A "JSR $0BPT" OR VIA A MONITOR/EXEC INTERRUPT. IN EITHER
;CASE THERE IS NO INSTRUCTION TO BE SAVED/RESTORED/EXECUTED, NO PROCEED
;COUNT, NO CONDITIONAL BREAK INSTRUCTION, ETC. ON PROCEED CONTROL IS
;SIMPLY RETURNED TO THE "INTERRUPTED" PROGRAM.

BPS:	SKIPE	MAPFN		;ANY MAPPING IN EFFECT
	 JRST	ERR		;NOT STRAIGHT VIRTUAL
	TXNE	F,QF		;HAS <A> BEEN TYPED?
	JRST	BPS1		;YES
	TXNE	F,FAF!SAF	;HAS ADDR TO TYPEOUT BEEN TYPED?
	JRST	ERR		;YES, ILLEGAL UNLESS WE SAW <A> TOO
	TXNE	F,Q2F		;HAS <N> BEEN TYPED?
	JRST	BPS2		;YES
	MOVE	T,[BPT$B+B$SIZ,,BPT$B+B$SIZ+1]  ;NO - COMMAND IS $B
	SETZM	BPT$B+B$SIZ	;ZERO FIRST WORD OF BREAKPOINT STUFF
	BLT	T,BPT$E-1	;CLEAR OUT ALL BREAKPOINTS
	POPJ	P,
;STILL IFE FTFILE

BPS1:	PUSHJ	P,CEFFAX	;DEFAULT SECTION IF NEEDED
	TDNN	T,[^-1,,^-17]	;IS THIS AN AC?
	HRRZS	T		;YES, FIX UP JUST IN CASE OF ZERO
	SKIPN	R,T		;SAVE COPY OF BREAKPOINT ADDRESS
	JRST	BPS1A		;<A> = 0 MEANS CLEAR A BPT, NOT SET ONE
	PUSHJ	P,FETCH		;CAN BREAKPOINT BE INSERTED HERE?
	 JRST ERR		;NO
	PUSHJ	P,DMEMER	;CAN'T SET BPT IF CAN'T WRITE
	SKIPE	BPBLK		;INTER-SECTION BPT POSSIBLE?
	 JRST	BPS1A		;YES, DON'T NEED TO HAVE DDT THERE
	PUSH	P,R		;HANG ON TO R FOR MOMENT
	HRRI	R,DDT		;HANDY DANDY LOCATION WE KNOW ABOUT
	PUSHJ	P,FETCH		;READ THAT SECTION ADDRESS IN OTHER SECTION
	 JRST [	SMERS	<CAN'T SET BREAKPOINT, $4M NOT SET>	;CAN'T
		JRST	ERR]	;TELL 'EM WHY NOT
	CAME	T,DDT		;DO WE SEEM TO BE IN OTHER SECTION?
	JRST	ERR		;NO, SO NO BREAKPOINT THERE
	POP	P,R		;NOW RESTORE R
BPS1A:	TXNN	F,Q2F		;HAS <N> BEEN TYPED?
	JRST	BPS3		;NO
BPS2:	MOVE	S,WRD2D		;YES - GET DESIRED BREAKPOINT NUMBER
	CAIL	S,0		;WITHIN RANGE?
	CAILE	S,NBP		; . . .
	JRST	ERR		;NO - COMPLAIN AT USER
	IMULI	S,B$SIZ		;YES, MAKE INTO BREAKPOINT "INDEX"
	TXNN	F,QF		;NOW - WAS <A> SPECIFIED?
	JRST [	XMOVEI	T,BPT$B(S)	;NO - RELOCATE INTO BREAKPOINT AREA
		JRST	MASK02]		;TREAT AS DDT INTERNAL ADDRESS
	JUMPE	R,[SETZM BPT$B+B$ADR(S)	;IF 0$<N>B, JUST CLEAR BPT N
		   POPJ	P,]	;DONE
	MOVE	T,R		;BREAKPOINT ADDRESS INTO T
	MOVEI	R,B$SIZ		;START WITH $1B
BPS2E:	CAMN	T,BPT$B+B$ADR(R);SOME OTHER BREAKPOINT HAVE THIS ADDRESS?
	SETZM	BPT$B+B$ADR(R)	;YES - BUT NOT ANYMORE!
	ADDI	R,B$SIZ		;ADVANCE TO NEXT BREAKPOINT SLOT
	CAIGE	R,B$SIZ*<NBP+1>	;CHECKED THEM ALL YET?
	JRST	BPS2E		;NOPE - GO GET THE REST
	JRST	BPS5		;YES - GO DEFINE THIS (NEW) BREAKPOINT
;STILL IFE FTFILE

BPS3:	SKIPN	T,R		;PUT THE BREAKPOINT ADR BACK IN T
	JRST	ERR		;0$B IS ILLEGAL
	MOVEI	S,B$SIZ		;PROCESS THE COMMAND A$B