Google
 

Trailing-Edge - PDP-10 Archives - BB-J845A-SM - source/ddt60.mac
There are 2 other files named ddt60.mac in the archive. Click here to see a list.
TITLE	DDT60 -- PROGRAM TO DEBUG DN60'S -- V1(51)
; Revision History

; 1(50) 24-Mar-79 JW	Add code to run on a 2020
; 1(51) 7-May-79 SMJ	Change 2020 code to conditionally execute at run time.
; 1(52) 16-May-79	Fix ASJFN so it doesn't use FE0:

;DDT60 VERSION NUMBER
;
VWHO==0		;WHO LAST EDITED
VDDT60==1	;MAJOR VERSION NUMBER
VMINOR==0	;MINOR VERSION NUMBER
VEDIT==52	;EDIT NUMBER
;
IFN	FTJSYS,<
SEARCH	MONSYM,MACSYM,MACTEN
SALL>
FLG=0
	F.FLIP==000001
	F.FLOP==000002
	F.LOPN==000004	;CURRENT LOCATION IS OPEN
	F.MOPN==000010	;MASK OPEN
	F.MASK==000020	;ESCAPE M TYPED
	F.ENDL==000100	;END OF INPUT LINE (GIVE PROMPT)
	F.IOCT==000200	;ASSEMBLING AN OCTAL NUMBER
	F.IDEC==000400	;ASSEMBLING A DECIMAL NUMBER
	F.IHEX==001000	;ASSEMBLING A HEX NUMBER
	F.ISIX==002000	;ASSEMBLING A SIXBIT SYMBOL
	F.SYMB==004000	;ASSEMBLING A SYMBOL
	F.CACH==010000	;USE CACHE IF POSSIBLE
	F.WRIT==020000	;WE ARE OPENING FILE FOR OUTPUT
	F.LOCK==040000	;PROGRAM IS LOCKED
	F.WENB==100000	;PATCHING WAS ENABLED WITH /PATCH
	F.PDP8==200000	;WORKING WITH 8'S INSTEAD OF 11'S
	F..ESC==400000	;TYPED ESCAPE TWICE
T1=1
T2=T1+1
T3=T2+1
T4=T3+1
T5=T4+1
DOT=6		;CURRENT LOCATION
DOTFOO=7	;IN CASE IS 32 OR 48 BIT INSTRUCTION
P1=10		;FOR PASSING ARGS AROUND SUBR
EXPRESS=11	;BUILD EXPRESSIONS IN THIS AC
STATE=12
SYM=13		;PONTER TO SYMBOL BLOCK
SYMBOL=14	;CURRENT SYMBOL WE ARE BUILDING
P=17

OPDEF	CAL11.	[CALLI	125]
OPDEF	NODE.	[CALLI 157]
OPDEF	PJRST	[JRST]
INTERNAL .JBVER
.JBVER==137
LOC	.JBVER
	BYTE (3)VWHO(9)VDDT60(6)VMINOR(18)VEDIT
RELOC	0

	EXMAX=140	;MAXIMUM NUMBER OF BYTES TO EXAMINE AT ONCE

IFNDEF FT2SEG <
	FT2SEG=0	;IF NONZERO MAKE 2 SEGMANT PROGRAM
>

IFNDEF FTPROM <FTPROM=1	>;IF NONZERO INCLUDE CODE TO PUNCH ROMS.
IFN	FTPROM	<
IFNDEF	ROMTYP	<ROMTYP=1		;DEFAULT ROM IS M9301
;					;FOR BM873 SET ROMTYP=0
>;END OF IFNDEF ROMTYP
>;END OF IFN FTPROM
COMMENT %

DDT60 VERSION 1 -- DERIVED FROM DDT11 VERSION 1

INITIAL SWITCHES:

/BINARY:FILSPEC		READ A ".BIN" FILE (OUTPUT FROM MACDLX)

/DUMP:FILESPEC		READ A CORE DUMP LISTING (OUTPUT OF
			  BOOT11 OR NETLDR)

/DIMAGE:FILESPEC	READ A CORE IMAGE FILE (OUTPUT OF
			  DTELDR OR DASLOD)


/EXIT			RETURN TO MONITOR

/LINE			SPECIFY LINE FROM NODE (SIMILAR TO
			  NETLDR)

/NODE			SPECIFY NODE TO DEBUG OR (WITH /LINE)
			  NODE ADJACENT TO NODE TO DEBUG

/PATCH			ALLOW WRITING INTO CORE

/PDP8			REMOTE CPU IS A PDP-8 (I.E., DC71 OR DC72)
			  (THIS FACILITY ONLY PARTIALLY IMPLEMENTED)

/PORT			SPECIFY DL10 PORT FOR DC76, DN85, DN87
			  OR DAS60. (0-3 ON DL10 NUMBER 1, 4-7
			  ON DL10 NUMBER 2, 10-13 ARE DTE 0-3.)

/SYMBOLS:FILESPEC	READ SYMBOL TABLE FROM A CROSS-REFERENCE
			  LISTING. (OUTPUT FROM MACDLX)

NOTE: /BINARY, /DUMP, /DIMAGE, /NODE AND /PORT CAUSE
  IMMEDIATE EXIT FROM INITIAL DIALOG, WITHOUT PROCESSING
  ANY SUBSEQUENT TEXT ON THE LINE.
DEBUGGING LANGUAGE:

THE LANGUAGE MIMICS DDT-10 FOR EXAMINING MEMORY AND
BUILDING SYMBOLS.  SPECIAL FUNCTIONS ARE INTRODUCED BY "ESC".
NUMERIC ARGUMENTS GO BETWEEN THE "ESC" AND THE LETTER.
LOWER CASE LETTERS ARE PERMITTED.  THE NOTATION "TEMP/PERM"
MEANS THE MODE IS SET UNTIL A CARRIAGE RETURN IS INPUT
UNLESS IT IS INTRODUCED BY TWO "ESC"S, JUST AS IN DDT-10.

THE FOLLOWING IS THE LIST OF FUNCTION LETTERS INTRODUCED
BY "ESC".

A	SET "ADDRESS" TYPEOUT MODE.  TEMP/PERM.  ARG=LENGTH

B	SET "BYTE" TYPEOUT MODE.  TEMP/PERM.  ARG=LENGTH

C	SET "NUMERIC" (CONSTANT) TYPEOUT MODE.  TEMP/PERM.
	  ARG=LENGTH

D	DUMP MEMORY ONTO A FILE.  THE RANGE IS SPECIFIED
	  AS: LOW<HIGH>ESC D.  ARG = DUMP TYPE: 0 = NORMAL,
	  1 = NO INSTRUCTION TYPEOUT

G	CAUSE CPU TO BRANCH TO EXPRESSION.  (ONLY WITH /NODE)

I	SET "EBCDIC" OUTPUT MODE.  TEMP/PERM.  ARG=LENGTH

K	SUPPRESS TYPEOUT OF PRECEEDING SYMBOL.

M	LOCATION FOR "MASK" FOR SEARCHES

N	"NOT WORD" SEARCH FOR PRECEEDING EXPRESSION.  SEARCH
	  IS MASKED BY LOCATION "$M" AND LIMITED BY RANGE,
	  EXPRESSED AS FOR $D.

P	PUNCH BINARY TAPE OF CORE IMAGE (NOT YET
	  IMPLEMENTED)

R	SET RADIX IN RANGE 2 TO 15.  TEMP/PERM.  ARG=RADIX

S	SET "INSTRUCTION" OUTPUT MODE (DEFAULT).  TEMP/PERM.
	  ARG=LENGTH

T	SET "ASCII" OUTPUT MODE.  TEMP/PERM.  ARG=LENGTH

V	WATCH OPEN LOCATION, TYPE OUT CHANGES, STOP WHEN
	  CARRIAGE RETURN TYPED.

W	"WORD" SEARCH, SIMILAR TO $N.

%
;
IFN	FTJSYS,<
; THE FOLLOWING DATA STRUCTURE IS USED FOR SENDING AND RECEIVING
; DATA TO/FROM THE FRONT-END PDP-11
;
DEFSTR(D10DF,SBUF,^D15,^D16)		;FUNCTION FOR SENDING TO FE
DEFSTR(D10AD,SBUF,^D31,^D16)		;ADDRESS FOR EX/DEP FUNCTION
DEFSTR(D10DT,SBUF+1,^D15,^D16)		;DATA FOR DEPOSIT
;
DEFSTR(D11RS,RBUF,^D7,^D8)		;RESULT CODE FROM FE
DEFSTR(D11DF,RBUF,^D15,^D8)		;FUNCTION CODE
DEFSTR(D11AD,RBUF,^D31,^D16)		;ADDRESS FOR EX/DEP
DEFSTR(D11DT,RBUF+1,^D15,^D16)		;DATA FOR EXAMINE
;
DEXFUN=11		;EXAMINE FUNCTION
DEPFUN=12		;DEPOSIT FUNCTION
>
IFN FT2SEG <
	TWOSEG
	RELOC	400000
	>
DDT60:	JFCL
	RESET
	SETZ	0,		;ZERO FIRST AC
	MOVEI	17,1		;MAKE BLT POINTER
	BLT	17,17		;CLEAR ALL AC'S
	MOVE	P,[IOWD PDLEN,PDL]
	PUSHJ	P,IDTYPE	;IDENTIFY OURSELF
	PUSHJ	P,CRLTYP	;END WITH A FLOURISH

	MOVE	T1,[0,,0]	;DEFAULT OUTPUT MODE IS SYMBOLIC
	MOVEM	T1,O.MODE
	SETZM	MEMORY
	SETZM	CACHEL		;HIGHEST ADDR IN CACHE
	SETZM	NODE		;HAVEN'T SPECIFIED NODE YET
	SETZM	LINE		;OR LINE ON NODE
	JRST	INI.03
INI.00:	OUTSTR	[ASCIZ \
?Respond with /PORT:#, /NODE:#, /NODE:name,
  /BINARY:filespec, /DIMAGE:filespec or /DUMP:filspec\]
	CLRBFI			;FLUSH TYPEAHEAD
INI.03:	TRZ	FLG,F.ENDL	;DONT CARE IF END OF LINE
	OUTSTR	[ASCIZ \
Input:	\]
INI.XX:	TRZE	FLG,F.ENDL	;END OF LINE?
	JRST	INI.03		;YES, GIVE PROMPT AGAIN.
	PUSHJ	P,SIXIN		;SHOULD RETURN JUST "/"
	  JRST	INI.00
	JUMPN	T1,INI.00
	CAIN	T5,15		;END OF LINE?
	JRST	INI.03		;YES, GIVE PROMPT AGAIN.
	CAIE	T5,"/"
	  JRST	INI.00
INI.YY:	PUSHJ	P,SIXIN		;GET COMMAND
	  JRST	INI.00
	MOVNI	T2,1		;BUILD MASK
INI.04:	MOVSI	T3,-4
INI.05:	SKIPN	T4,[	SIXBIT	\BINARY\	;FILE IS BINARY
			SIXBIT	\DUMP\		;FILE IS A DUMP
			SIXBIT	\DIMAGE\	;FILE IS A DUMP IMAGE
			SIXBIT	\EXIT\		;EXIT TO MONITOR
			SIXBIT	\LINE\		;SPECIFY LINE FROM NODE
			SIXBIT	\NODE\		;SPECIFY NODE TO DEBUG
			SIXBIT	\PATCH\		;ENABLE PATCHING
			SIXBIT	\PDP8\		;DO PDP-8'S, NOT PDP-11'S
			SIXBIT	\PORT\		;SPECIFY PORT OF LOCAL PDP-11
			SIXBIT	\SYMBOL\	;SPECIFY FILE OF SYMBOLS
			Z	](T3)
	  JRST	INI.06
	AND	T4,T2
	CAMN	T1,T4		;MATCH ?
	  JRST	INI.08		;FOUND MATCH
	AOJA	T3,INI.05	;ON TO NEXT ENTRY
INI.06:	LSH	T2,6		;ADJUST MASK
	JUMPN	T2,INI.04
	JRST	INI.00		;DON'T UNDERSTAND
INI.08:	JRST	@[	SETBIN		;/BINARY
			SETDMP		;/DUMP
			SETIMG		;/DIMAGE
			SETXIT		;/EXIT
			SETLIN		;/LINE
			SETNOD		;/NODE
			SETWEN		;/PATCH
			SETPD8		;/PDP8
			SETPRT		;/PORT
			RSYMB		;/SYMBOL
			 ](T3)

;HERE BECAUSE FILE TO BE READ IS BINARY TAPE
SETBIN:	TRO	FLG,F.FLOP
	PUSHJ	P,RDDUMP	;READ THE BINARY FILE
	JRST	LEVL.0		;GO DEBUG IT

;HERE BECAUSE FILE TO BE READ IS NETLDR (OR EQUIVALENT) DUMP
SETDMP:	TRZ	FLG,F.FLOP
	PUSHJ	P,RDDUMP	;READ THE DUMP FILE
	JRST	LEVL.0		;GO DEBUG IT

;HERE FOR /DIMAGE
SETIMG:	PUSHJ	P,RDDIMG	;READ DUMP IMAGE
	JRST	LEVL.0		;GO DEBUG IT

;HERE FOR /PATCH
SETWEN:	TRO	FLG,F.WENB	;ENABLE PATCHING
	JRST	SET.X9

SETLIN:	PUSHJ	P,SIXIN		;GET LINE ARGUMENT
	  JRST	INI.00
	PUSHJ	P,SIXOCT	;CONVERT TO NUMBER
	  JFCL
	AOS	T1
	MOVEM	T1,LINE
SET.X9:	CAIE	T5,"/"
	JRST	INI.XX
	JRST	INI.YY
SETPD8:	TRO	FLG,F.PDP8
	JRST	SET.X9
SETNOD:	PUSHJ	P,SIXIN		;GET NODE ARGUMENT
	  JRST	INI.00
	PUSHJ	P,SIXOCT	;CONVERT TO NUMBER
	  JFCL
	MOVEM	T1,NODE		;SAVE NODE NAME
	MOVEI	T1,1		;CODE TO LOCK
	LOCK	T1,
	  JRST	LOCKER
	TRO	FLG,F.LOCK	;REMEMBER WE DID
	JRST	LEVL.0
;
SETPRT:	PUSHJ	P,SIXIN		;GET SIXBIT ARGUMENT
	  JRST	INI.00
	PUSHJ	P,SIXOCT	;CONVERT TO OCTAL
	  JRST	INI.00
	CAILE	T1,13		;UNREASONABLE?
	  JRST	INI.00		;YES, REJECT.
	MOVEM	T1,PORT#	;NO, SAVE PORT NUMBER
IFN	FTJSYS,<
	PUSHJ	P,ASJFN		;GET JFN FOR FE DEVICE
>
	JRST	LEVL.0

RSYMB:	PUSHJ	P,RDSYMB	;READ IN SYMBOLS
	MOVE	T5,LASCAR	;RETRIEVE LAST CHAR INPUT
	JRST	SET.X9		;AND LOOK FOR MORE SWITCHES

SETXIT:	EXIT			;EXIT TO THE MONITOR
IFN	FTJSYS,<
; THIS SECTION OF CODE ASSIGNS A JFN TO DEVICE FE
; OPENS IT AND SPECIFIES ITS FRONT-END
;

ASJFN:
	SKIPN	APRNUM		; Check for proccessor type known yet
	 PUSHJ	P,PRCTYP	;  No .. go get it
	SKIPN	KSFLG		; Check for a 2020
	 JRST	ASJF.1		;  No .. go do SIN/SOUT type FE I/O
	MOVE	T1,PORT#	;GET THE PORT NUMBERT
	SUBI	T1,10		;GET THE DMC LINE #
	MOVEM	T1,D60JFN	;STORE AS THE "JFN"
	POPJ	P,		;RETURN TO CALLER

ASJF.1:	SETZB	P1,D60JFN	;INITIALIZE PTR TO JFN
	MOVEI	P1,1		; Start looking at FE1:
D60ST2:	MOVE	T1,[POINT 7,D60BUF] ;BUFFER TO HOLD JFN
	MOVEI	T2,"F"		;STICK FE FOR DEVICE IN THE BUFFER
	IDPB	T2,T1		;IN THE JFN
	MOVEI	T2,"E"		;PUT IN E OF THE "FE"
	IDPB	T2,T1		;IN THE JFN BUFFER
	LDB	T2,[POINT 3,P1,32] ;3-BIT BYTE PTR
	JUMPE	T2,D60ST3
	ADDI	T2,"0"		;FOR FE 0
	IDPB	T2,T1		;PUT IN THE JFN
D60ST3:	LDB	T2,[POINT 3,P1,35]	;BUILD A 3-BIT BYTE PTR
	ADDI	T2,"0"		;FOR FE "0"
	IDPB	T2,T1		;DEPOSIT IN JFN
	MOVEI	T2,":"		;COMPLETES DEVICE NAME
	IDPB	T2,T1		;IN THE JFN
	SETZ	T2,		;ZERO BYTE AT THE END
	IDPB	T2,T1		;IN THE JFN
	MOVX	T1,GJ%OLD!GJ%SHT ;OLD FILE,SHORT JFN
	HRROI	T2,D60BUF	;BUFFER TO HOLD JFN
	GTJFN			;GO GET JFN FOR FE DEVICE
	 ERJMP	 D60ST4		;UNABLE TO GET JFN FOR THIS FE#
	MOVEM	T1,D60JFN	;GOT IT ,SAVE JFN
	PUSHJ	P,ENQDEV	;LOCK DEVICE FOR OUR USE
	MOVE	T1,D60JFN	;FET JFN IN T1
	MOVX	T2,<^D8>B5!OF%RD!OF%WR ;WRITE ,READ,8 LONG JFN
	OPENF			;OPEN THE DEVICE
	 ERJMP	 D60ST5		;UNABLE TO OPEN THIS DEVICE
	MOVX	T2,.MODTE	;FUNCTION CODE TO GET DTE FE
	MOVE	T3,PORT#	;GET THE PORT NO
	SUBI	T3,10		;GET THE DTE#
	MTOPR			;GET A DTE FE
	 ERJMP	 FATAL		;MUST NOT HAPPEN
	PUSHJ	P,DEQDEV	;RELEASE DEVICE IF LOCKED
	POPJ	P,		;RETURN TO CALLER

;
;
;SUBROUTINE TO RELEASE A DEVICE IF LOCKED
;
DEQDEV:	SKIPN	ENQFLG		;DO WE HAVE THE DEVICE LOCKED?
	 JRST	 DQEXIT		;NO,JUST EXIT
	SETZM	ENQFLG		;FLAG DEVICE RELEASED
	MOVX	T1,.DEQDR	;DEQ FUNCTION CODE
	MOVEI	T2,ENQBLK	;POINT TO THE FUN BLOCK
	DEQ			;UNLOCK THE DEVICE
	 ERJMP	 FATALQ		;DEQ FAILED
DQEXIT:	POPJ	P,		;RETURN
;
ENQDEV:	MOVE	T1,PORT#	;GET THE PORT NO
	DPB	T1,[POINT 3,ENQBUF+1,20] ;AND PUT IN LOW ORDER DIGIT
	LSH	T1,-3		;GET NEXT DIGIT
	DPB	T1,[POINT 3,ENQBUF+1,13] ;PUT IN HIGH DIGIT
	MOVX	T1,.ENQBL	;ENQ FUNCTION CODE
	MOVEI	T2,ENQBLK	;POINT TO ARGUMENT BLOCK
	ENQ			;REQUEST ACCESS OF RESOURCE
	 ERJMP	[ CAIE	T1,ENQX6 ;LOCK ALREADY REQUESTED?
		  PJRST   FATAL   ;FATAL ERROR
	MOVEI	T1,^D500	;SLEEP FOR 1-SECOND
	DISMS			;SLEEP JSYS
	JRST	ENQDEV ]	;TRY AGAIN
	SETOM	ENQFLG		;FLAG THAT WE GOT DEVICE
	POPJ	P,		;RETURN
;
;

;HERE IF THE GTJFN FAILS
;
D60ST4:	CAIE	T1,GJFX29	;DEVICE NOT AVAILABLE
	 JRST	 D60STK		;NO,SOMETHING'S WRONG
	AOJA	P1,D60ST2	;YES,TRY NEXT FE DEVICE
;
; HERE IF OPENF FAILS
;
D60ST5:	CAIE	T1,OPNX9	; Simultanoues access or
	CAIN	T1,OPNX7	;  device not available?
	 CAIA			;   Yes .. so clean up and move to next one
	 JRST	 D60STK		; No, something's wrong
	MOVE	T1,D60JFN	; Release the JFN
	RLJFN			; JSYS to do release
	 ERJMP	 D60STK		;  JSYS error in release
	PUSHJ	P,DEQDEV	; Unlock the device
	AOJA	P1,D60ST2	; Get another JFN
;
; HERE IF A FATAL JSYS ERROR
;
D60STK:	JRST	FATAL		;FATAL ERROR
;

FATAL:	PUSHJ	P,DEQDEV	;UNLOCK DEVICE IF LOCKED
FATALQ:	HRROI	T1,[ASCIZ/
?/]
	PUSHJ	P,ERROR		;GO TO PRINT THE ERROR
	HALTF			;STOP
;
ERROR:	PSOUT			;PUT OUT THE STRING
	MOVE	T1,[.PRIOU]	;OUTPUT DEVICE FOR ERROR MESSAGES
	MOVE	T2,[.FHSLF,,-1] ;CURRENT FORK,,LAST ERROR
	SETZB	T3,T4		;NO LIMIT,FULL MESSAGE
	ERSTR			;JSYS TO OUTPUT ERROR MESSAGE
	JFCL			;IGNORE  UNDEFINED ERROR NUMBER
	JFCL			;IGNORE ERROR DURING EXECUTION OG ERSTR
	POPJ	P,		;RETURN TO CALLER
;
ENQFLG:	BLOCK	1		;IF NON-ZERO,WE HAVE DEVICE
ENQBLK:	XWD	1,5		;1 LOCK,,LENGH IS 5
	XWD	0,0		;CHN 0,,ID
	EXP	EN%BLN+EN%LTL+<0,,-3>	;FLAGS,,WHEEL OR OPR
	POINT	7,ENQBUF	;STRING POINTER
	XWD	0,0		;1 RESOURCE,,NO OF ACCESSES
;
ENQBUF:	ASCIZ	\DN60-P00\	;BUILD ENQ/DEQ STRING HERE
;
>
LEVL.0:	OUTSTR	[BYTE (7)15,12,0]
LEVEL0:	SETZM	OHD
	TRZ	FLG,F.LOPN!F.MASK!F.MOPN!F.CACH!F.WRIT
	HLRS	ORADIX		;RESET OUTPUT RADIX
	HLRS	O.MODE		;RESET CURRENT OUTPUT MODE FROM PERMANENT
	HLRS	BYTCNT		;RESET REPETITION COUNT
LEVEL1:	MOVE	P,[IOWD PDLEN,PDL]
	TRZ	FLG,F.SYMB!F.IOCT!F.IDEC!F.IHEX
LEVEL2:	MOVEI	STATE,STATE0	;DISPATCH TABLE WHEN IDLE
LEVEL3:	TRZ	FLG,F..ESC
	SETZM	INPOPR		;CLEAR INPUT OPERATOR
	SETZM	EXPRESS		;EXPRESSION WE HAVE BUILT
	SETZM	OCTIN#
	SETZM	DECIN#
	SETZM	HEXIN#
	SETZM	SYMBOL
	MOVE	T4,[POINT 6,SYMBOL]

LOOP:	PUSHJ	P,GETCHR	;GET A COMMAND CHAR
	MOVEM	T1,T2
	ADD	T2,STATE
	JRST	@(T2)		;DISPATCH ON CHARACTER
;HERE WHEN USER TYPES IN AN ILLEGAL CHARACTER
ILLCHR:	OUTSTR	[BYTE (7)7,"?",7,11,7,0]
	CLRBFI			;CLEAR TYPEAHEAD
	JRST	LEVEL1

;HERE WHEN THE USER TYPES A TAB COMMAND
COMHT:	OUTSTR	[BYTE (7)15,12,0]
	SKIPN	DOT,LSTADR	;IN CASE SET IN FUNNY WAY
	  MOVE	DOT,DATA	;LAST DATA BECOMES ADR
	JRST	COMLF1

;HERE WHEN THE USER TYPES A LINE FEED COMMAND
COMLF:	SKIPE	DOTFOO
	  MOVE	DOT,DOTFOO
	SETZM	DOTFOO
	OUTCHR	[15]		;CARRIAGE RETURN
	ADDI	DOT,2
COMLF1:	TRO	FLG,F.LOPN	;FLAG LOCATION IS OPEN
	ANDI	DOT,177776	;FLUSH EXTRA BITS
	MOVE	T1,DOT
	PUSHJ	P,ADRTYP	;TYPE ADR
	MOVEI	T1,"/"
	PUSHJ	P,TYPCHR
COMLF2:	CAMGE	DOT,CACHEL	;IS THIS ALREADY IN CACHE ?
	  SETZM	CACHEL		;YES SO FLUSH CACHE
	PUSHJ	P,TABTYP
	TRO	FLG,F.CACH	;USE CACHE AFTER 1ST WORD
	PUSHJ	P,DATYPE
	JRST	LEVEL2

;HERE WHEN USER TYPES =
EQUALS:	TRNN	FLG,F.LOPN	;IS LOCATION OPEN ?
	  JRST	ILLCHR		;NO SO ILLEGAL
	PUSH	P,O.MODE	;SAVE OUTPUT MODE
	MOVEI	T1,2		;OUTPUT AS NUMERIC
	HRRM	T1,O.MODE
	PUSH	P,BYTCNT
	SKIPN	T5,DOTFOO
	  HRRZ	T5,DOT
	SUBI	T5,-2(DOT)
	ANDI	T5,777777	;HALF WORD ONLY
	LSH	T5,-1
	HRRM	T5,BYTCNT
	PUSH	P,DOTFOO
	SETZM	DOTFOO
	TRO	FLG,F.CACH	;USE CACHE IF POSSIBLE
	PUSHJ	P,DATYPE	;TYPE DATA
	POP	P,DOTFOO
	POP	P,BYTCNT
	POP	P,O.MODE	;RESTORE OUTPUT MODE
	JRST	LOOP
;HERE WHEN USER TYPES / AT END OF A NUMBER
OPNLOC:	TRZE	FLG,F.MASK	;ASKING ABOUT THE MASK ?
	  JRST	[	PUSHJ	P,TABTYP
			HRRZ	T1,S.MASK	;GET THE MASK
			PUSHJ	P,RADTYP	;DISPLAY IT
			TRO	FLG,F.MOPN	;MAKS NOW OPEN
			PUSHJ	P,TABTYP
			JRST	LEVEL2	]
	PUSHJ	P,ACCUM
	HRRZ	DOT,EXPRESS
	SETZM	DOTFOO
	TRO	FLG,F.LOPN	;FLAG LOCATION IS OPEN
	JRST	COMLF2

;HERE WHEN USER TYPES A RUBOUT
COMRUB:	OUTSTR	[ASCIZ \xxx	\]
	JRST	LEVEL1

;HERE WHEN THE USER TYPES AN UP ARROW COMMAND
COMARR:	OUTSTR	[BYTE (7)15,12,0]
	SETZM	DOTFOO
	HRRZ	T1,BYTCNT	;NUMBER OF BYTES
	HRRZ	T2,O.MODE	;GET OUTPUT MODE
	JUMPE	T2,COMAR0	;SYMBOLIC ?
	CAIN	T2,1		; OR ADDRESS ?
	  ASH	T1,1		;CONVERT WORD COUNT TO BYTES
	CAIN	T2,2		;OR NUMERIC
	  ASH	T1,1		;CONVERT WORD COUNT TO BYTES
	SUBI	DOT,(T1)
	JRST	COMLF1		;REST LIKE A LINE FEED COMMAND

;HERE IF DID UP ARROW WHEN IN SYMBOLIC MODE
; TRY TO MAKE A GUESS HOW FAR BACK TO GO
COMAR0:	ANDI	DOT,177776	;INSTRUCTIONS BEGIN ON WORD BOUNDRY
	TRZ	FLG,F.CACH	;DON'T USE CACHE
	MOVEI	T4,1		;TRY ONE WORD INSTRUCTION FIRST
;HERE TO COUNT WORDS IN INSTRUCTION
COMAR1:	MOVE	T2,T4		;NUMBER OF WORDS TO LOOK FOR
	ASH	T2,1		;TIMES 2 FOR BYTES
	MOVEI	T1,(DOT)	;CURRENT ADR
	SUBI	T1,(T2)		;BACK UP CURRENT ADR
	PUSHJ	P,GETWRD	;TRY TO GET THE DATA
	  JRST	COMAR9		;LOSES
	PUSHJ	P,INVLFN	;SEE IT THERE IS ANY SUCH INSTRUCTION
	  JRST	COMAR8		;NO = LOSE
	HLLZ	T2,1(SYM)	;GET FLAGS FOR INSTRUCTION
	AOS	T2		;ONE FOR INSTRUCTION
	TLNN	T2,SMF.SS	;IS THIS SSDD FORMAT ?
	  JRST	COMAR6		;NO
	LDB	T3,[POINT 6,T1,29]	;GET SS FIELD
	PUSHJ	P,COMARX	;ADJUST NUMBER OF WDS IN INSTRUCTION
COMAR6:	TLNN	T2,SMF.DD!SMF.SS	;IS DD PRESENT ?
	  JRST	COMAR7		;NO
	LDB	T3,[POINT 6,T1,35]	;GET DD FIELD
	PUSHJ	P,COMARX
COMAR7:	CAIE	T4,(T2)		;IS THAT WHAT WE WANTED ?
	  JRST	COMAR8		;NO
	SUBI	DOT,(T4)
	SUBI	DOT,(T4)
	JRST	COMLF1		;PRINT INSTRUCTION
COMAR8:	AOS	T4		;TRY FOR LARGER INSTRUCTION
	CAIE	T4,4		;IS THAT TOO LARGE ?
	  JRST	COMAR1		;NO
COMAR9:	SUBI	DOT,2		;JUST BACK UP ONE WORD
	JRST	COMLF1
COMARX:	CAIE	T3,27		;IS THIS IMMEDIATE (#FOO)
	CAIN	T3,37		;OR ABSOLUTE
	  AOS	T2		;YES SO ANOTHER WORD IN INSTRUCTION
	LDB	T3,[POINT 3,T3,32]
	CAIE	T3,6		;IS THIS RELATIVE
	CAIN	T3,7		;OR RELATIVE DEFERRED ?
	  AOS	T2		;YES SO ANOTHER WORD
	POPJ	P,
;HERE WHEN THE USER TYPE A ^Z
COMCZ:	CALLI	1,12
	JRST	LEVEL0

;HERE WHEN THE USER ENDS AN EXPRESSION WITH A BACKSLASH
COMBSE:	PUSHJ	P,ACCUM		;FINISH ACCUMULATING EXPRESSION
	MOVE	T1,EXPRESS	;MAKES ADDRESS
	JRST	COMBS5
;HERE WHEN THE USER TYPES A BACKSLASH
COMBSL:	SKIPN	T1,LSTADR
	  MOVE	T1,DATA
COMBS5:	PUSHJ	P,TABTYP
	PUSH	P,DOT
	MOVEM	T1,DOT
	PUSHJ	P,DATYPE
	POP	P,DOT
	JRST	LEVEL2

;HERE WHEN USER TYPE A BACK ARROW
BKARRW:	PUSHJ	P,ACCUM		;FINISH ACCUMULATING EXPRESSION
	MOVE	T1,EXPRESS
	PUSHJ	P,ADRTYP	;AND TYPE OUT SYMBOL FOR IT
	PUSHJ	P,TABTYP
	JRST	LEVEL0		;AND DONE
ACCUM:	SETZ	T1,
	TRZE	FLG,F.IOCT
	  MOVE	T1,OCTIN
	TRZE	FLG,F.IDEC
	  MOVE	T1,DECIN
	TRZE	FLG,F.IHEX
	  MOVE	T1,HEXIN
	TRZE	FLG,F.SYMB
	  PUSHJ	P,EVLSYM
ACCUM0:	MOVE	T2,INPOPR	;GET INPUT OPERATOR
	XCT	[	ADD	EXPRES,T1
			SUB	EXPRES,T1
			IMUL	EXPRES,T1
			IDIV	EXPRES,T1
			IOR	EXPRES,T1
			AND	EXPRES,T1
			XOR	EXPRES,T1 ](T2)
	ANDI	EXPRESS,177777	;16 BITS ONLY
	MOVEI	STATE,STATEE
	SETZM	OCTIN
	SETZM	DECIN
	SETZM	HEXIN
	SETZM	SYMBOL
	MOVE	T4,[POINT 6,SYMBOL]
	POPJ	P,
FINEXP:	PUSHJ	P,ACCUM		;ACCUMULATE WHATEVER WE HAVE
	JRST	COMLF2

EXPLUS:	TDZA	T1,T1		;CODE FOR NEXT TIME IS 0

EXPMIN:	MOVEI	T1,1
	JRST	EXP.DO

EXPMUL:	MOVEI	T1,2
	JRST	EXP.DO

EXPDIV:	MOVEI	T1,3
	JRST	EXP.DO

EXPIOR:	MOVEI	T1,4
	JRST	EXP.DO

EXPAND:	MOVEI	T1,5
	JRST	EXP.DO

EXPXOR:	MOVEI	T1,6
EXP.DO:	PUSH	P,T1		;SAVE CODE FOR NEXT TIME
	PUSHJ	P,ACCUM		;ACCUMULATE EXPRESSION
	POP	P,INPOPR	;NEXT INPUT OPERATION
	JRST	LOOP		;THEN DONE

EXPEQU:	PUSHJ	P,ACCUM		;ACCUMULATE EXPRESSION
	MOVE	T1,EXPRESS	;GET EXPRESSION
	PUSHJ	P,RADTYP
	PUSHJ	P,TABTYP
	JRST	LEVEL2

SLOWLM:	PUSHJ	P,ACCUM		;ACCUMULATE EXPRESSION
	MOVE	T1,EXPRESS	;GET EXPRESSION
	HRRZM	T1,SBEGIN	;SET LOWER LIMIT FOR SEARCH
	JRST	LEVEL2
SUPLIM:	PUSHJ	P,ACCUM		;ACCUMULATE EXPRESSION
	MOVE	T1,EXPRESS	;GET EXPRESSION
	HRRZM	T1,S..END	;SET UPPER LIMIT FOR SEARCH
	JRST	LEVEL2
;HERE WHEN ASSEMBLING NUMBER AND FIND A PERIOD
ASSPER:	TRNN	FLG,F.IDEC!F.IOCT
	  JRST	ASSYMB
	TRO	FLG,F.IDEC
	TRZ	FLG,F.IOCT!F.IHEX
	JRST	ASYMB2
;HERE WHEN NUMBER MUST BE DECIMAL
ASSDEC:	TRO	FLG,F.IDEC
	TRZ	FLG,F.IOCT

;HERE WHEN ASSEMBLING A OCTAL, DECIMAL OR HEX NUMBER
ASSNUM:	TRNN	FLG,F.IDEC!F.IHEX
	TRO	FLG,F.IOCT
	MOVEI	STATE,STATEE
	MOVE	T2,OCTIN
	LSH	T2,3
	;CAIL	T1,70
;	  TRO	FLG,F.IDEC	;NUMBER IS DECIMAL
	ADDI	T2,-60(T1)
	MOVEM	T2,OCTIN
	MOVE	T2,DECIN
	IMULI	T2,^D10
	ADDI	T2,-60(T1)
	MOVEM	T2,DECIN
	MOVE	T2,HEXIN
	LSH	T2,4
	ADDI	T2,-60(T1)
	MOVEM	T2,HEXIN
	;TRNN	FLG,F.IDEC!F.IHEX
	;  TROA	FLG,F.IOCT
	;  TRZ	FLG,F.IOCT
	JRST	ASYMB2

;HERE WHEN ASSEMBLING A SYMBOL
ASSYMB:	MOVEI	STATE,STATEE
	TRO	FLG,F.SYMB
	TRZ	FLG,F.IDEC!F.IOCT!F.IHEX

ASYMB2:	SUBI	T1,40		;CONVERT CHAR TO SIXBIT
	CAME	T4,[POINT 6,SYMBOL,35]
	  IDPB	T1,T4		;ADD CHAR TO SYMBOL
	JRST	LOOP
;HERE BECAUSE USER FINISHED SYMBOL WITH ":"
DEFSYM:	TRNE	FLG,F.SYMB
	SKIPN	T1,SYMBOL	;SYMBOL HE DEFINED
	  JRST	ILLCHR
	HRRZ	T2,DOT		;CURRENT ADR
	PUSHJ	P,ADDSYM
	PUSHJ	P,TABTYP
	JRST	LEVEL1

;HERE TO EVALUATE A SYMBOL
EVLSYM:	MOVE	T1,SYMBOL
	CAMN	T1,[SIXBIT \.\]
	  JRST	[	HRRZ	T1,DOT
			POPJ	P, ]
	PUSHJ	P,SYMFND	;TRY TO FIND SYMBOL
	  JRST	SYMERR
	MOVE	T1,1(SYM)	;GET VALUE OF SYMBOL
	TLNN	T1,SMF.IN	;WAS THAT AN INSTRUCTION ?
	  JRST	[	ANDI	T1,-1	;STRIP FLAGS
			POPJ	P, ]
	ANDI	T1,-1
	POPJ	P,

SYMERR:	OUTSTR	[ASCIZ \U	\]
	JRST	LEVEL0
;HERE IF TERMINATES EXPRESSION WITH A HT
STEHT:	PUSHJ	P,STEFIN
	JRST	COMHT		;NOW DO TAB FUNCTION

;HERE IF TERMINATES EXPRESSION WITH A CARRIAGE RETURN
STECR:	PUSHJ	P,STEFIN	;STORE IF APPROPRIATE
	JRST	LEVEL0

;HERE TO DO DEPOSIT MAYBE AFTER CR OR LF OR UP ARROW
STEFIN:	TRZE	FLG,F.MOPN	;IS MASK OPEN ?
	  JRST	SETMSK		;SET MASK
	TRZN	FLG,F.LOPN	;IS LOCATION OPEN ?
	  POPJ	P,		;NO SO JUST RETURN
	TRNN	FLG,F.WENB	;WAS PATCHING ENABLED ?
	  JRST	WRTLCK		;IS WRITE LOCKED
	PUSHJ	P,ACCUM		;DO LAST MINUTE ACCUMULATION
	MOVE	T1,DOT		;GET ADR TO EXAMINE
	MOVE	T2,EXPRESS	;GET JUNK TO DEPOSIT
	PUSHJ	P,PUTWRD	;TRY TO DEPOSIT IT
	  PUSHJ	P,CAL1ER
	POPJ	P,

WRTLCK:	OUTSTR	[ASCIZ \?patching was not enabled by /PATCH
\]
	JRST	LEVEL0

;HERE TO SET MASK
SETMSK:	PUSHJ	P,ACCUM		;DO LAST MINUTE ACCUMULATION
	HRRM	EXPRESS,S.MASK	;SET MASK
	POPJ	P,

;HERE IF TERMINATES EXPRESSION WITH A LF
STELF:	PUSHJ	P,STEFIN	;DEPOSIT LOCATION MAYBE
	JRST	COMLF		;DID DEPOSIT

;HERE IF TERMINATES EXPRESSION WITH AN UP ARROW
STEARR:	PUSHJ	P,STEFIN
	JRST	COMARR
;HERE IS USER TYPES ESCAPE WHILE INPUTTING AN EXPRESSION
ESCEXP:	PUSHJ	P,ACCUM		;ACCUMULATE EXPRESSION SO FAR

;HERE IF USER TYPES ESCAPE
ESCAPE:	PUSHJ	P,ACCUM		;FINISH PREVIOUS INPUT
	MOVEI	STATE,STATSC	;SET ESCAPE FLAG
	SETZ	T5,
	JRST	LOOP

ESCESC:	TRO	FLG,F..ESC
	JRST	LOOP

;HERE TO ACCUMULATE NUMBER AFTER ESCAPE
ESC..0:	IMULI	T5,^D10
	ADDI	T5,-60(T1)	;ACCUMULATE NUMBER
	JRST	LOOP

ESC..A:	MOVEI	T1,1		;SETTING ADDRESS MODE
	JRST	ESCMOD

ESC..B:	MOVEI	T1,3		;SETTING BYTE MODE
	SKIPN	T5		;DID HE TYPE NUMBER ?
	  MOVEI	T5,2		;NO SO 2 BYTES
	JRST	ESCMOD

ESC..C:	MOVEI	T1,2		;SETTING NUMERIC MODE
	JRST	ESCMOD

ESC..G:	MOVE	T1,EXPRESS	;GET ADDRESS HE TYPED
	MOVEM	T1,GOTO		;REMEMBER IT FOR LATER
	SKIPE	MEMORY		;ARE DIDDLING DUMP OR BIN FILE ?
	  JRST	TABDNE		;YES SO DONE
	SKIPN	NODE		;ARE WE DOING STUFF WITH A NODE ?
	  JRST	ILLCHR		;NO SO THIS IS IMPOSSIBLE
	TRNN	FLG,F.WENB	;WAS PATCHING ENABLED ?
	  JRST	WRTLCK		;CAN'T DO IT
	MOVE	T1,EXPRESS	;GET ADDRESS HE TYPED
	PUSHJ	P,SETUPN	;SETUP NODE UUO
	EXP	3		;CODE FOR GOTO IS 3
	PUSHJ	P,NODSET	;GO DO NODE UUO
TABDNE:	OUTSTR	["	"]
	JRST	LEVEL2		;WE DID IT

ESC..K:	JUMPE	SYM,ILLCHR	;DID A SYMBOL PRECEDE $K ?
	PUSHJ	P,TABTYP	;TYPE TAB SO HE KNOWS HE WON
	MOVSI	T1,SMF.SU	;FLAG TO SUPRESS OUTPUT
	IORM	T1,1(SYM)	;SUPRESS SYMBOL
	TRZN	FLG,F..ESC	;DID HE WANT TO FLUSH SYMBOL ?
	  JRST	LEVEL2		;NO SO DONE
	JRST	LEVEL2
ESC..R:	CAIG	T5,^D16
	CAIG	T5,1		;IS RADIX REASONABLE ?
	  JRST	ILLCHR		;NO SO FLUSH REQUEST
	HRRM	T5,ORADIX	;YES SET NEW RADIX
	TRZE	FLG,F..ESC	;SETTING PERMANENT MODE ?
	  HRLM	T5,ORADIX	;YES
	PUSHJ	P,TABTYP
	JRST	LEVEL2		;AND KEEP GOING

ESC..S:	MOVEI	T1,0		;SETTING INSTRUCTION MODE
	JRST	ESCMOD

ESC..I:	SKIPA	T1,[EXP 5]	;SETTING EBCDIC OUTPUT
ESC..T:	MOVEI	T1,4		;SETTING ASCII OUTPUT
	SKIPN	T5		;DID USER SPECIFY NUMBER OF BYTES ?
	  MOVEI	T5,2		;DEFAULT IS 2
ESCMOD:	SKIPN	T5
	  MOVEI	T5,1		;DEFAULT IS ONLY ONE
	HRRM	T5,BYTCNT
	PUSHJ	P,TABTYP
	HRRM	T1,O.MODE	;SET CURRENT MODE
	TRZN	FLG,F..ESC
	  JRST	LEVEL2		;NOT SETTING PERMANENT MODE
	HRLS	BYTCNT		;LOCAL COUNT IS PERMANT COUNT
	HRLM	T1,O.MODE	;SET PERMANT MODE
	JRST	LEVEL2
;ESCAPE V - WATCH A LOCATION FOR VARIANCE
ESC..V:	SKIPE	MEMORY
	  JRST	ILLCHR
	TRNN	FLG,F.LOPN	;IS LOCATION OPEN ?
	  JRST	ILLCHR		;GIVE USER "?"
	TRO	FLG,F.FLOP
ESC.V0:	MOVEI	T1,0		;MINIMUM SLEEP
	SLEEP	T1,
	MOVE	T1,DOT		;GET ADDRESS TO WATCH
	HRRZ	T2,BYTCNT	;NUMBER OF BYTES TO DISPLAY
	HRRZ	T3,O.MODE	;OUTPUT MODE
	CAIG	T3,2
	  ASH	T2,1		;WORD MODE SO TIMES 2 BYTES
	TRZ	FLG,F.CACH
	PUSHJ	P,GETWRD	;GET DATA
	  JRST	ILLCHR
	MOVE	T2,T1		;COPY DATA
	XOR	T2,DATA		;COMPARE TO LAST TIME
	AND	T2,S.MASK	;MASK OFF IRREVELANT BITS
	TRZN	FLG,F.FLOP
	JUMPE	T2,ESC.V9	;BRANCH IF SAME AS BEFORE
ESC.V2:	OUTSTR	[BYTE (7)15,12,0]
	PUSH	P,T1		;SAVE NEW DATA
	MOVEM	T1,DATA		;SAVE NEW DATA
	MOVE	T1,DOT		;GET ADDRESS
	PUSHJ	P,ADRTYP
	OUTSTR	[ASCIZ \/	\]
	TRO	FLG,F.CACH
	PUSHJ	P,DATYPE	;TYPE NEW DATA
	POP	P,DATA		;IN CASE DATYPE CHANGED IT
ESC.V9:	SKPINC			;HAS USER TYPED A CHARACTER ?
	JRST	ESC.V0		;NO SO KEEP WATCHING
	OUTSTR	[ASCIZ \
<done watching>
\]
	JRST	LEVEL2		;GO PROCESS NEXT COMMAND
ESC..M:	TRO	FLG,F.MASK	;MASK IS OPEN
	MOVEI	STATE,STATEE	;EVALUATE AS AN EXPRESSION
	JRST	LEVEL3		;GET REST OF COMMAND

ESC..N:	TROA	FLG,F.FLIP	;FLAG WE ARE DOING NOT SEARCH
;HERE FOR (ALTMODE)W WHICH IS WORD SEARCH
ESC..W:	TRZ	FLG,F.FLIP	;FLAG WE WANT MATCHES
	MOVE	T1,EXPRESS	;GET WHAT TO SEARCH FOR
	AND	T1,S.MASK
	MOVEM	T1,S.WORD
	MOVE	DOT,SBEGIN
	SETZM	CACHEL		;NOTHING IN CACHE SO FAR
	TRO	FLG,F.CACH	;USE CACHE IF WE CAN
ESC.W2:	MOVE	T1,DOT
	MOVE	T2,S..END
	ADDI	T2,2
	SUB	T2,T1		;NUMBER OF WORDS TO GET TO FINSIH SEARCH
	CAILE	T2,EXMAX
	  MOVEI	T2,EXMAX		;MAXIMUM NUMBER OF WORDS FOR THIS REQUEST
	PUSHJ	P,GETWRD
	  JRST	LEVEL0
	MOVEM	T1,DATA		;SAVE DATA
	AND	T1,S.MASK	;MASK SOME OF THE BITS
	TRNE	FLG,F.FLIP	;ARE WE LOOKING FOR MATCH ?
	  JRST	[	CAMN	T1,S.WORD	;DON'T WANT MATCH
			  JRST	ESCW.8
			JRST	ESCW.6 ]
	CAME	T1,S.WORD
	  JRST	ESCW.8
ESCW.6:	OUTSTR	[BYTE (7)15,12,0]
	MOVE	T1,DOT		;GET ADDRESS
	PUSHJ	P,ADRTYP
	OUTSTR	[ASCIZ \/	\]
	PUSHJ	P,DATYPE
	SKPINC			;ANY TYPEAHEAD ?
	  JRST	ESCW.8
	JRST	ESCW.9		;YES SO STOP
ESCW.8:	ADDI	DOT,2
	CAMLE	DOT,S..END
	  JRST	ESCW.9
	TRNN	DOT,377		;DON'T DO TOO MANY UUO'S
	SKPINC			;TYPEING AHEAD ?
	  JRST	ESC.W2		;NO
ESCW.9:	OUTSTR	[ASCIZ \
<search done>
\]
	JRST	LEVEL2
;ROUTINE TO GET A WORD FROM THE PDP-11
; CALL	PUSHJ	P,GETWRD	;WITH ADR IN T1, NUMBER OF BYTES IN T2
;	ERROR RETURN
;	SUCCES	DATA IN T1
GETWRD:	PUSH	P,T3
	PUSH	P,T4
	SKIPN	T2
	  HALT
	SKIPE	CACHEL		;IS THERE DATA IN CACHE ?
	TRNN	FLG,F.CACH	;AND MAY WE USE CACHE ?
	  JRST	GETWD1		;NO CACHE OR CAN'T USE IT
	CAMGE	T1,CACHEL	;IS REQUEST TOO LARGE ?
	CAMGE	T1,CACHEA	;OR TOO SMALL
	  JRST	GETWD1		;NO
GETWD0:	MOVE	T4,[POINT 8,CACHE]	;POINTER TO CACHE
	MOVE	T3,T1		;COPY ADDRESS OF BYTE TO GET
	SUB	T3,CACHEA	;MAKE RELATIVE
	CAIA
	IBP	T4		;SKIP NEXT BYTE
	SOJGE	T3,.-1
	ILDB	T1,T4		;GET LOW ORDER BYTE OF REQUESTED WORD
	ILDB	T2,T4		;GET HIGH ORDER BYTE OF REQUESTED WORD
	DPB	T2,[POINT 8,T1,27]
GETWD3:	AOS	-2(P)		;SKIP RETURN
GETWD4:	POP	P,T4
	POP	P,T3
	POPJ	P,

GETWD1:	SKIPE	T4,MEMORY	;DO WE HAVE MEMORY IN CORE ?
	  JRST	GETMEM		;YUP
	SKIPE	NODE		;ARE WE WORKING REMOTELY ?
	  JRST	GETNOD		;YES SO DO IT
IFE	FTJSYS,<
;HERE TO DO CALL11 UUO TO GET DATA
	SETZ	T4,
	HRRZM	T1,T3
	MOVEI	T2,1		;FUNCTION 1
GETWD2:	MOVE	T1,[3,,T2]
	HRL	T2,PORT#	;ADD PORT NUMBER
	CAL11.	T1,
	  JRST	[CAIE T1,4	;FACILITY IN USE?
		JRST GETWD4	;NO, ERROR RETURN.
		MOVEI T1,1	;YES, SLEEP A SECOND
		SLEEP T1,
		JRST GETWD2]	; AND TRY AGAIN.
>
;
IFN	FTJSYS,<
;
;TO DO EXAMINES FUNCTION 11(OCTAL) IS SENT TO THE FE AND
;THE RESULT OF EXAMINE IS READ BY DOING A SIN JSYS.
;
	HRRZM	T1,SAVT3	;SAVE ADR IN T3
	MOVEM	T4,SAVT4	;SAVE T4
	MOVEI	T4,DEXFUN	;EXAMINE FUNCTION
	STOR	T4,D10DF	;SET IN THE HEADER
	STOR	T1,D10AD	;THE ADDRESS TO EXAMINE IN -11
	SETZ	T4,		;CLEAR T4
	STOR	T4,D10DT	;CLEAR THE CELL
	PUSHJ	P,ENQDEV	;LOCK DEVICE FOR OUR USE
	SKIPE	KSFLG		;Check for a 2020
	 PUSHJ	P,FLSHFE	; Yes .. flush any ddcmp buffers hanging around
	MOVE	T1,D60JFN	;JFN  IN T1
	MOVE	T2,[POINT 8,SBUF] ;BUILD PTR TO SEND BUFFR
	MOVNI	T3,6		;#OF BYTES TO XFER
	SKIPE	KSFLG		;Check for a 2020
	 JRST	EXS.1		; Yes .. go do 2020 style I/O
	SOUT			;SEND IT TO FE
	MOVEI	T3,1		;DO NOT SEND EOF
	MOVE	T1,D60JFN	;JFN 
	MOVEI	T2,.MOEOF	;FORCE PARTIAL RECORDS
	MTOPR			;TO THE FE DEVICE
	  ERJMP	FATAL		;SHOULD NOT HAPPEN
	MOVEI	T4,^D1000	;MAX 2-SECOND WAIT
INPWT:
	MOVE	T1,D60JFN	;JFN  IN T1
	SIBE			;CHECK IF MONITOR BUFFER IS EMPTY?
	 JRST	 SOMEIN		;GOT SOME INPUT
	MOVEI	T1,2		;SLEEP FOR 2 MS
	DISMS			;DISMISS PROCESS FOR 2MS
	SOJG	T4,INPWT	;DONE WAITING?
	JRST	 FATAL		;FATAL ERROR,BUFFER EMPTY

EXS.1:	CALL	WR200		;WRITE TO THE DN200
	 JRST	FATAL		;FATAL ERROR

SOMEIN:	MOVE	T1,D60JFN	;GET JFN 
	MOVE	T2,[POINT 8,RBUF] ;BUILD A BYTE PTR TO RECV BUFFER
	MOVNI	T3,6		;6 BYTES TO BE READ
	SKIPE	KSFLG		;Check for a 2020
	 JRST	EXS.5		; Yes go talk to DDCMP link
	SIN			;READ IN THE STRING
	 ERJMP	 FATAL		;SIN ERROR RETURN
	MOVEI	T3,1		;DO NOT SEND EOF
	MOVE	T1,D60JFN	;JFN 
	MOVEI	T2,.MOEOF	;SEND THE ACK
	MTOPR			;TO THE FE DEVICE
	  ERJMP	FATAL		;SHOULD NOT HAPPEN
	JRST	EXS.6

EXS.5:	CALL	RD200		;READ IN STING
	 JRST	FATAL		;ERROR

EXS.6:	PUSHJ	P,DEQDEV	;DEQ DEVICE IF LOCKED
	LOAD	T1,D11RS	;HOW DID WE DO IN EXAMINE?
	CAIE	T1,1		;SUCCESSFUL??
	JRST	GETWD4		;NO,ERROR RETURN
	MOVE	T3,SAVT3	;RESTORE T3
	MOVE	T4,SAVT4	;RESTORE T4
	LOAD	T1,D11DT	;DATA IN T1
>
;
;
; HERE WHEN WE MUST EXAMINE MORE
;
GETWD5:	HRRZ	T2,T3		;GET ADDRESS WE WERE GETTING
	PUSHJ	P,PUTBCH	;PUT BYTE INTO THE CACHE
	LSH	T1,-^D8		;ADJUST DATA
	AOS	T2
	PUSHJ	P,PUTBCH	;ALSO HIGH ORDER BYTE
	MOVE	T1,T3		;GET ADDRESS AGAIN
	MOVEI	T2,2		;NUMBER OF BYTES TO GET
	JRST	GETWD0		;GET DATA FROM THE CACHE
;HERE TO GET A WORD FROM CORE IN 10 MEMORY
GETMEM:	CAMLE	T1,MEMLIM	;IS IT IN RANGE ?
	  JRST	GETWD4		;ERROR RETURN
	IDIVI	T1,4		;WE KEEP 4 BYTES IN 36BIT WORD
	ADD	T1,MEMORY	;ADD RELOCATION
	ADD	T1,[	POINT 9,0,8
			POINT 9,0,17
			POINT 9,0,26
			POINT 9,0,35 ](T2)
	LDB	T2,T1
	ILDB	T1,T1
	ROT	T2,-^D8
	LSHC	T1,^D8
	ANDI	T1,177777	;STRIP EXTRA BITS
	JRST	GETWD3

;HERE TO EXAMINE MEMORY FROM ANOTHER NETWORK NODE
GETNOD:	PUSHJ	P,SETUPN	;BEGIN BUILDING MSG<LINE><CODE><ADR>
	EXP	1		;CODE FOR EXAMINE REQUESTS IS 1
	MOVEM	T1,T3		;SAVE ADDRESS
	ADDI	T1,(T2)		;MAKE LIMIT ADDRESS
	PUSHJ	P,PUTADR	;PUT LIMIT ADDRESS INTO THE MESSAGE
	PUSHJ	P,NODSET	;DO NODE UUO
	CAIE	T1,12		;CODE FOR EXAMINE DATA IS 12
	  JRST	STCERR
	PUSH	P,T3		;SAVE ADDRESS WE WENT FOR
	HLRZ	T3,NODARG+3	;GET BYTE COUNT FROM MSG
	SUBI	T3,4		;SUBTRACT BYTES WE ALREADY READ
	ILDB	T2,T4		;GET LOW ORDER 8 BITS OF ADDRESS
	ILDB	T1,T4		;GET HIGH ORDER 8 BITS
	DPB	T1,[POINT 8,T2,27]
	TRNE	FLG,F.PDP8
	  JRST	GTNOD3
	SOS	T3		;COUNT BYTE
	ILDB	T1,T4
	DPB	T1,[POINT 8,T2,19]
GTNOD3:	ILDB	T1,T4		;GET NEXT BYTE OF DATA
	PUSHJ	P,PUTBCH	;PUT BYTE INTO THE CACHE
	AOS	T2		;ADVANCE ADDRESS
	SOJG	T3,GTNOD3
	POP	P,T1		;GET ADDRESS WE WENT FOR
	JRST	GETWD0
;HERE TO BEGIN A NODE UUO MSG <LINE><CODE><ADDRESS>
; CALL	MOVE	T1,<ADR>
;	PUSHJ	P,SETUPN
;	EXP	<CODE>
SETUPN:	PUSH	P,T1		;SAVE ADDRESS
	MOVE	T4,[POINT 8,STCMSG]	;POINTER TO STATION CONTROL MSG
	MOVE	T1,LINE		;0 = SELF, 1-N IS LINE NUMBER
	IDPB	T1,T4		;MSG IS FOR NODE
	MOVE	T1,@-1(P)	;GET CODE
	IDPB	T1,T4
	POP	P,T1		;GET ADDRESS BACK
	PUSHJ	P,PUTADR	;PUT ADDRESS INTO THE MESSAGE
	AOS	(P)		;SKIP ARGUMENT
	POPJ	P,

;HERE TO DO A NODE UUO
; CALL	MOVEI	T1,<COUNT>	;OF BYTES IN MSG TO SEND
;	RETURNS WITH T4 POINTING TO INPUT MSG AND CODE IN T1
NODSET:	PUSH	P,[POINT 8,STCMSG]
	MOVEI	T1,1		;INITIALIZE LENGTH COUNTER
	IBP	(P)		;ADVANCE DUMMY POINTER
	CAME	T4,(P)
	  AOJA	T1,.-2
	HRLI	T1,STCMSG
	MOVSM	T1,NODARG+2
	POP	P,T1		;CLEAN OFF STACK
	MOVEI	T1,4		;NUMBER OF WORDS IN ARGUMENT
	MOVEM	T1,NODARG
	MOVE	T1,NODE		;NODE NAME
	MOVEM	T1,NODARG+1
	MOVE	T1,[400,,STCIMS]	;INPUT MSG SLOT
	MOVEM	T1,NODARG+3
	MOVE	T1,[3,,NODARG]	;FUNCTION IS SEND STC MSG
	NODE.	T1,
	  JRST	NODERR
	MOVE	T4,[POINT 8,STCIMS]	;POINTER TO INPUT MESSAGE
	ILDB	T1,T4		;GET FIRST BYTE (= LINE# OR SELF)
	CAME	T1,LINE
	  JRST	NODERR
	ILDB	T1,T4		;GET MESSAGE SUBTYPE
	POPJ	P,

STCERR:	OUTSTR	[ASCIZ	\STC error - msg =\]
	HLRZ	T4,NODARG+3
	SKIPA	T5,[POINT 8,STCIMS]
STCER3:	OUTCHR	[","]
	OUTCHR	["<"]
	ILDB	T1,T5
	PUSHJ	P,OCTYPE
	OUTCHR	[">"]
	SOJG	T4,STCER3
	JRST	LEVEL0
;HERE TO PUT A BYTE INTO THE CACHE
; CALL	MOVE	T1,<BYTE>
;	MOVE	T2,<ADR>
;	PUSHJ	P,PUTBCH
;	  RETURN
PUTBCH:	PUSH	P,T1
	PUSH	P,T2
	PUSH	P,T3
	PUSH	P,T4
	SKIPE	T3,CACHEL	;IS CACHE EMPTY ?
	CAMG	T2,CACHEA	;IS NEW BYTE BELOW CACHE ADDRESS ?
	  JRST	PTBCH2		;FLUSH CACHE
	SUB	T3,CACHEA	;HOW MANY BYTES ALREADY IN THE CACHE ?
	CAIGE	T3,CACHSZ	;SMALL ENOUGH ?
	  JRST	PTBCH1		;YES
	MOVEI	T3,4		;REDUCE CONTENTS BY 4 BYTES = ON 10 WORD
	ADDM	T3,CACHEA
	MOVE	T3,[CACHE+1,,CACHE]	;BLT POINTER
	BLT	T3,CACHE+<CACHSZ/4>-1	;SHUFFLE CACHE
PTBCH1:	CAMN	T2,CACHEL	;ARE TRYING TO ADD ONE BYTE TO CACHE ?
	  JRST	PTBCH4		;YES
PTBCH2:	MOVEM	T2,CACHEA	;BEGIN CACHE HERE
PTBCH4:	MOVEM	T2,CACHEL	;THIS IS THE NEW CACHE LIMIT
	AOS	CACHEL		;MAKE ONE PLUS
	SUB	T2,CACHEA	;HOW MANY BYTES TO NEW BYTE ?
	MOVE	T3,[POINT 8,CACHE]
	CAIA
	IBP	T3
	SOJGE	T2,.-1
	IDPB	T1,T3		;PUT BYTE INTO THE CACHE
	POP	P,T4
	POP	P,T3
	POP	P,T2
	POP	P,T1
	POPJ	P,
;ROUTINE TO DEPOSIT A WORD IN PDP-11 MEMORY
; CALL	PUSHJ	P,PUTWRD	;WITH ADR IN T1 & DATA IN T2
PUTWRD:	PUSH	P,T3
	PUSH	P,T4
	MOVEM	T1,T3
PUTWD1:	SKIPE	T4,MEMORY	;DID WE READ A DUMP ?
	  JRST	PUTMEM		;DEPOSIT INTO MEMORY
	SKIPE	NODE		;WORKING REMOTELY ?
	  JRST	PUTNOD		;YES
IFE	FTJSYS,<		;THE FOLLOWING ASSEMBLES FOR TEN
	MOVEM	T2,T4
	MOVEI	T2,0		;FUNCTION 0
PUTWD2:	MOVE	T1,[3,,T2]
	HRL	T2,PORT#	;ADD PORT NUMBER
	CAL11.	T1,
	  JRST	[CAIE T1,4	;FACILITY IN USE?
		JRST GETWD4	;NO, ERROR RETURN.
		MOVEI T1,1	;YES, WAIT A SECOND
		SLEEP T1,
		JRST PUTWD2]	; AND TRY AGAIN.
>
;
; HERE TO USE SIN/SOUT FOR TOPS-20 F.E. DEVICE
;
IFN	FTJSYS,<
	MOVEM	T3,SAVT3	;SAVE T3
	MOVEM	T4,SAVT4	;SAVE T4
	MOVEI	T4,DEPFUN	;DEPOSIT FUNCTION
	STOR	T4,D10DF	;SETUP IN HEADER TO FE
	STOR	T1,D10AD	;ADR TO EXAMINE IN THE -11
	SETZ	T4,		;CLEAR T4
	STOR	T2,D10DT	;DATA TO DEPOSIT IN ABOVE ADR
	PUSHJ	P,ENQDEV	;LOCK DEVICE FOR OUR USE
	SKIPE	KSFLG		;Check for a 2020
	 PUSHJ	P,FLSHFE	; Yes .. flush any ddcmp buffers hanging around
	MOVE	T1,D60JFN	;ADR OF JFN
	MOVE	T2,[POINT 8,SBUF] ;BYTE PTR TO SEND BUFFER
	MOVNI	T3,6		;6 BYTES TO XFER
	SKIPE	KSFLG		;Check for a 2020
	 JRST	SS20.1		; Yes .. go talk to DDCMP link
	SOUT			;SEND TO THE FE
	MOVEI	T3,1		;DO NOT SEND EOF
	MOVE	T1,D60JFN	;JFN 
	MOVEI	T2,.MOEOF	;WRITE PARTIAL RECORDS
	MTOPR			;WITH THIS JSYS
	  ERJMP	FATAL		;SHOULD NOT HAPPEN
	MOVE	T4,^D1000	;2-SECOND MAXIMUM WAIT
INWAIT:	
	MOVE	T1,D60JFN	;JFN 
	SIBE			;CHECK IF MONITOR BUFFER EMPTY
	 JRST	 SOMINP		;GOT SOME INPUT
	MOVEI	T1,2		;SLEEP FOR 2 MS
	DISMS			;JSYS FOR SLEEPING
	SOJG	T4,INWAIT	;WAITED ENOUGH?
	 JRST	 FATAL		;YES,TIMEOUT FATAL ERROR

SS20.1:	CALL 	WR200		;SEND TO REMOTE CPU
	 JRST	FATAL

SOMINP:	MOVE	T1,D60JFN	;GET JFN 
	MOVE	T2,[POINT 8,RBUF] ;BYTE PTR TO REC BUFFER
	MOVNI	T3,6		;#BYTES TO BE READ
	SKIPE	KSFLG		;Check for a 2020
	 JRST	SS20.5		; Yes .. talk to DDCMP
	SIN			;READ STRING DATA
	MOVEI	T3,1		;DO NOT SEND EOF
	 ERJMP	 FATAL		;SIN FATAL ERROR
	MOVE	T1,D60JFN	;JFN 
	MOVEI	T2,.MOEOF	;WRITE PARTIAL RECORDS
	MTOPR			;WITH THIS JSYS
	  ERJMP	FATAL		;SHOULD NOT HAPPEN
	JRST	SS20.6

SS20.5:	CALL	RD200		;READ THE ANSWER
	 JRST	FATAL

SS20.6:	PUSHJ	P,DEQDEV	;DEQ IF LOCKED
	LOAD	T1,D11RS	;CHECK THE RESULT CODE
	CAIE	T1,1		;SUCCESSFUL??
	JRST	GETWD4		;NO,ERROR RETURN
;
>
	JRST	GETWD3		;YES,WIN RETURN
;
PUTMEM:	CAML	T1,MEMLIM	;IS ADR IN RANGE ?
	  JRST	GETWD4		;NO SO REJECT IT
	EXCH	T1,T2		;SWAP ADR AND DATA
	PUSHJ	P,PUTBYT	;PUT LOW ORDER BYTE INTO MEMORY
	LSH	T1,-^D8		;POSITION HIGH ORDER BYTE
	AOS	T2
	PUSHJ	P,PUTBYT
	JRST	GETWD3
PUTNOD:	PUSHJ	P,SETUPN	;BEGIN NODE. MSG <LINE><CODE><ADR>
	EXP	2		;CODE FOR DEPOSIT IS 2
	IDPB	T2,T4		;PUT HIGH ORDER BYTE OF DATA INTO MSG
	LSH	T2,-^D8
	IDPB	T2,T4
	PUSHJ	P,NODSET	;SEND MSG
	CAIE	T1,11		;DID WE GET AN ACCEPT ?
	  JRST	STCERR
	JRST	GETWD3

PUTADR:	PUSH	P,T1
	TRNE	FLG,F.PDP8
	  ANDI	T1,077777	;STRIP EXTRA BITS
	IDPB	T1,T4		;PUT LOW ORDER BYTE OF ADR INTO MSG
	ROT	T1,-^D8
	IDPB	T1,T4
	ROT	T1,-^D8
	TRNE	FLG,F.PDP8
	  JRST	TPOPJ
	IDPB	T1,T4
TPOPJ:	POP	P,T1
	POPJ	P,

CAL1ER:	OUTCHR	["?"]
	PUSHJ	P,OCTYPE
	OUTSTR	[ASCIZ \?	\]
	POPJ	P,

	IFN FT2SEG <RELOC>
NODARG:	BLOCK	5
STCMSG:	BLOCK	20
STCIMS:	BLOCK	110
	IFN FT2SEG <RELOC>
SUBTTL	SYMBOL TABLE ROUTINES

;SYMBOLS ARE KEPT IN THREE WORD BLOCKS(ALPHABETIZED)
;  STARTING AT LOCATION POINTED TO BY SYMBEG
; 1ST WORD IN BLOCK IS SIXBIT SYMBOL
; 2ND WORD IS HALF WORD FLAGS,,VALUE
	SMF.SU==000001	;SYMBOL IS SUPPRESSED(DEFINED WITH =)
	SMF.RG==000002	;SYMBOL IS A REGISTER VALUE
	SMF.MK==000004	;MARK NN
	SMF.IN==000010	;SYMBOL IS AN INSTRUCTION
	SMF.DD==000020	;LOW ORDER SIX BITS ARE DESTINATION
	SMF.SS==000040	;LOW ORDER 12 BITS ARE SSDD
	SMF.XX==000100	;LOW ORDER 8 BITS ARE XXX(E.G. BR)
	SMF.SB==000200	;SOB TYPE ADDRESS
	SMF.RT==000400	;RTS TYPE REGISTER USAGE
	SMF.JS==001000	;JSR TYPE REGISTER USAGE
	SMF.EM==002000	;EMT TYPE ARGUMENT
	SMF.AS==004000	;ASH TYPE NN ARG
	SMF.PL==010000	;SET PROCESSOR LEVEL
	SMF.FL==020000	;FLOATING POINT (FP11-B)
; 3RD WORD IS LINK TO NEXT SYMBOL BLOCK

;HERE TO FIND A MATCH FOR A SYMBOL
; CALL	MOVE	T1,[SIXBIT \SYMBOL\]
;	PUSHJ	P,SYMFND
;	  ERROR RETURN
;	SUCCESS RETURN	SYM POINTS TO SYMBOL
SYMFND:	SKIPN	SYM,SYMBEG	;GET ADR OF BEGINING OF SYMBOL TABLE
	  POPJ	P,		;CAN'T FIND SYMBOL
SYMFN1:	CAMN	T1,(SYM)	;HAVE WE FOUND THE SYMBOL ?
	  JRST	CPOPJ1		;YES
	HRRZ	SYM,2(SYM)	;GET ADR OF NEXT SYMBOL BLOCK
	JUMPN	SYM,SYMFN1
	POPJ	P,		;CAN'T FIND SYMBOL
;HERE TO SEE IF WE CAN FIND A MATCH FOR AN INSTRUCTION
; CALL	MOVEI	T1,<VALUE>
;	PUSHJ	P,INVLFN
;	LOSE RETURN
;	WIN RETURN WITH SYM SET UP
INVLFN:	SKIPN	SYM,SYMBEG	;ADDRESS OF FIRST SYMBOL BLOCK
	  POPJ	P,		;NO SYMBOL TABLE
INVLF1:	MOVE	T2,1(SYM)	;GET SYMBOL VALUE
	TLNN	T2,SMF.IN	;IS THIS AN INSTRUCTION ?
	  JRST	INVLF8
	TLNE	T2,SMF.SU	;IS INSTRUCTION SUPPRESSED?
	JRST	INVLF8		;YES, DON'T USE IT.
	LDB	T3,[POINT 4,1(SYM),3]	;GET NUMBER OF BITS IN INSTRUCTION -1
	MOVE	T3,MASKTB(T3)	;GET MASK FOR INSTRUCTION
	AND	T3,T1		;MASK ARGUMENT
	CAIE	T3,(T2)		;IS THIS A MATCH ?
	  JRST	INVLF8		;NO
CPOPJ1:	AOS	(P)		;FOR SKIP RETURN
CPOPJ:	POPJ	P,
INVLF8:	HRRZ	SYM,2(SYM)	;GET ADR OF NEXT SYMBOL BLOCK
	JUMPN	SYM,INVLF1
	POPJ	P,
MASKTB:	EXP	100000
	EXP	140000,160000,170000
	EXP	174000,176000,177000
	EXP	177400,177600,177700
	EXP	177740,177760,177770
	EXP	177774,177776,177777
IFN	FTJSYS,<
;THE FOLLOWING BUFFERS ARE USED BY DECSYSTEM-20 ONLY
;
SBUF:	BLOCK	2		;FOR SENDING HEADER TO  FE
RBUF:	BLOCK	2		;FOR RECEIVING HEADERS FROM FE
D60JFN:	BLOCK	1		;TO HOLD JFN 
D60BUF:	BLOCK	20		;TO HOLD JFN
SAVT3:	BLOCK	1		;TO SAVE T3
SAVT4:	BLOCK	1		;TO SAVE T4
;
>
;HERE TO FIND A NAME FOR A REGISTER
; CALL:	MOVEI	T1,#	;REGISTER NUMBER
;	PUSHJ	P,RGFNDN
;	LOSE
;	BINGO
RGFNDN:	SKIPN	SYM,SYMBEG	;GET FIRST SYMBOL BLOCK ADR
	  POPJ	P,		;NO SYMBOL TABLE
RGFND1:	MOVE	T2,1(SYM)	;GET SYMBOL VALUE
	TLNN	T2,SMF.RG	;IS THIS A REGISTER ?
	  JRST	RGFND8		;NO
	CAIE	T1,(T2)		;IS THIS WHAT WE WANTED ?
	  JRST	RGFND8		;NO
	TLNE	T2,SMF.SU	;IS SYMBOL SUPPRESSED?
	JRST	RGFND8		;YES, DON'T USE IT.
	AOS	(P)		;SKIP RETURN
	POPJ	P,
RGFND8:	HRRZ	SYM,2(SYM)	;GET NEXT SYMBOL BLOCK
	JUMPN	SYM,RGFND1		;NOT YET
	POPJ	P,		;ERROR RETURN
;HERE TO ADD A SYMBOL TO TABLE
; CALL	PUT SYMBOL IN T1, PUT VALUE AND FLAGS IN T2, MISC IN T3
ADDSYM:	MOVE	SYM,SYMBEG	;GET ADDRESS OF FIRST SYMBOL BLOCK
ADSYM1:	CAMN	T1,@SYM		;DOES THIS MATCH ?
	  JRST	[	MOVEM	T2,1(SYM)	;YES SO THIS REPLACES PREVIOUS
			POPJ	P, ]
	HRRZ	SYM,2(SYM)	;GET ADDRESS OF NEXT SYMBOL BLOCK
	JUMPN	SYM,ADSYM1

;MAKE A NEW SYMBOL BLOCK
	MOVE	T4,.JBFF	;ADDRESS OF NEW SYMBOL BLOCK
	ADDI	T4,3
	MOVEM	T4,.JBFF
	HRLM	T4,.JBSA##
	PUSHJ	P,GETCOR
	SUBI	T4,3		;MAKE ADDRESS OF BLOCK AGAIN
	MOVE	SYM,SYMEND	;GET ADDRESS OF LAST SYMBOL BLOCK
	HRRZM	T4,2(SYM)
	HRRZM	T4,SYMEND
	MOVEM	T4,SYM
	MOVEM	T1,0(SYM)
	MOVEM	T2,1(SYM)
	SETZM	2(SYM)
	POPJ	P,

;HERE TO FIND A NEAR MATCH FOR A VALUE
; CALL	MOVEI	T1,VALUE TO MATCH
;	PUSHJ	P,VALFND
;	  ERROR RETURN
;	RETURN WITH SYM SET UP
VALFND:	PUSH	P,T4
	SETZ	SYM,
	MOVE	T2,SYMBEG	;ADR OF FIRST SYMBOL BLOCK
VLFND1:	MOVE	T3,1(T2)	;GET SYMBOL'S VALUE
	TRNE	T3,177777	;IS VALUE ZERO ?
	TLNE	T3,SMF.SU!SMF.IN!SMF.RG	;IS SYMBOL SUPPRESSED OR INSTRUCTION ?
	  JRST	VLFND7		;YES SO DON'T TRY IT
	CAIGE	T1,400(T3)	;IS SYMBOL VALUE MUCH LESS THAN DESIRED ?
	CAIGE	T1,(T3)		;IS SYMBOL VALUE .LE. DESIRED VALUE ?
	  JRST	VLFND7		;NO
	JUMPE	SYM,VLFND4
	CAIL	T4,(T3)		;IS SYMBOL BETTER THAN LAST MATCH ?
	  JRST	VLFND7		;NO
VLFND4:	MOVE	SYM,T2		;BEST MATCH SO FAR
	HRRZ	T4,T3		;COPY VALUE FOR FUTURE REFERENCE
VLFND7:	HRRZ	T2,2(T2)	;GET ADDRESS OF NEXT BLOCK
	JUMPN	T2,VLFND1
	SKIPE	SYM
	AOS	-1(P)
	POP	P,T4
	POPJ	P,
GETCOR:	PUSH	P,T1
	HRRZ	T1,.JBFF##		;GET NEW AMOUNT OF CORE WE NEED
	CAMG	T1,.JBREL##
	  JRST	GTCOR9
	TRNE	FLG,F.LOCK
	  JRST	[	MOVEI	T1,1	;CODE FOR LOW SEG
			UNLOK.	T1,	;CAN'T BE LOCKED WHEN WE DO THIS
			  JRST	LOCKER	;OLD MONITOR PERHAPS ?
			HRRZ	T1,.JBFF##	;GET CORE ARG BACK
			CORE	T1,
			  JRST	CORERR	;CAN'T HAVE MORE ?
			MOVEI	T1,1	;CODE TO LOCK LOW SEG
			LOCK	T1,
			  JRST	LOCKER
			JRST	GTCOR6 ]
	CORE	T1,
	  JRST	CORERR
GTCOR6:	
REPEAT 0,<
	OUTCHR	["["]
	PUSH	P,T2
	PUSH	P,T3
	HRRZ	T1,.JBREL##
	AOS	T1
	LSH	T1,-^D9
	PUSHJ	P,DECTYP
	POP	P,T3
	POP	P,T2
	OUTSTR	[ASCIZ \P core]
\]
>
GTCOR9:	POP	P,T1
	POPJ	P,

;HERE IF CAN'T GET CORE WE WANT
CORERR:	OUTSTR	[ASCIZ	\ CORE UUO failed\]
	EXIT
;HERE TO READ A SYMBOL TABLE FROM A LISTING

RDSYMB:	MOVE	T1,[SIXBIT \FOOBAR\]	;DEFAUL FILE NAME
	MOVE	T2,[SIXBIT \LSTCRF\]	;DEFAULT EXTENSIONS
	PUSHJ	P,OPNFL0	;OPEN FILE TO READ SYMBOLS FROM
	  JRST	LEVEL0
	MOVE	T1,[FILDEV,,SYMDEV]
	BLT	T1,SYMDEV+3
GETSC0:	SETZ	T5,		;COUNT OF SYMBOLS
	PUSHJ	P,GETSCH
	CAIE	T1,14		;IS THIS A FORM FEED ?
	  JRST	GETSC0		;LOOK FOR ONE
GETSC1:	PUSHJ	P,GETSCH
	CAIE	T1,12		;IS THIS A LINE FEED ?
	  JRST	GETSC1		;LOOK FOR ONE
GETSC2:	PUSHJ	P,GETSCH
	CAIE	T1,12		;IS THIS A LINE FEED ?
	  JRST	GETSC2		;LOOK FOR ONE
	SETZB	T3,SYMBOL	;BUILD SYMBOL HERE
	MOVE	T2,[POINT 6,SYMBOL]
GETSC3:	PUSHJ	P,GETSCH
	CAIN	T1,"="		;EQUAL SIGN?
	JRST	[CAME T2,[POINT 6,SYMBOL,35]
		JRST GETSC2
		JRST GETSC7]
	CAIG	T1,40		;IN SIXBIT RANGE (EXCEPT BLANK)?
	  JRST	GETSC4		;IF NOT HAVE FINISHED SYMBOL
	SUBI	T1,40		;CONVERT TO SIXBIT
	CAMN	T2,[POINT 6,SYMBOL,35]	;FILLED WORD YET ?
	JRST	GETSC2		;YES, MUST NOT BE A SYMBOL
	IDPB	T1,T2		;NO SO KEEP FILLING
	JRST	GETSC3
;
GETSC4:	CAIE	T1,40		;SYMBOLS END WITH A SPACE
	  JRST	GETSC2		;NOT SYMBOL - FLUSH LINE
GETSC7:	JUMPE	SYMBOL,GETSC2	;IF NO SYMBOL FLUSH LINE
	TDZA	T4,T4		;FLAGS
GETSC5:	PUSHJ	P,GETSCH
	CAIN	T1,40
	  JRST	GETSC5
	CAIN	T1,"="
	  JRST	[	TRO	T4,SMF.SU	;SUPPRESSED SYMBOL
			JRST	GETSC5	]
	CAIN	T1,"%"
	  JRST	[	TRO	T4,SMF.RG	;REGISTER NAME
			TRZ	T4,SMF.SU	;NOT SUPPRESSED
			JRST	GETSC5	]
	CAIL	T1,60
	CAILE	T1,67
	  JRST	GETSC2		;FLUSH REST OF LINE
GETSC6:	IMULI	T3,^D8
	ADDI	T3,-60(T1)
	PUSHJ	P,GETSCH
	CAIL	T1,60
	CAILE	T1,67
	  CAIA
	JRST	GETSC6
	MOVE	T1,SYMBOL	;COPY SYMBOL
	HRRZ	T2,T3		;VALUE
	HRL	T2,T4		;FLAGS
	SETZ	T3,
	PUSH	P,SYMEND
	PUSHJ	P,ADDSYM
	POP	P,T1		;GET OLD SYMEND
	CAME	T1,SYMEND
	  AOS	T5		;COUNT SYMBOL
	JRST	GETSC2		;FLUSH REST OF LINE
GETSCH:	SOSGE	IHD+2
	  JRST	GTSCH5
	ILDB	T1,IHD+1
	POPJ	P,
GTSCH5:	IN
	  JRST	GETSCH
	OUTSTR	[ASCIZ \ Loaded \]
	MOVE	T1,T5
	PUSHJ	P,DECTYP
	OUTSTR	[ASCIZ \ symbols
\]
	POP	P,T1		;ADJUST THE STACK
	POPJ	P,

SYMDEV:	EXP	0
	EXP	0
	EXP	0
	EXP	0
SUBTTL	GENERAL FILE ROUTINES

;HERE TO OPEN A FILE TO READ
; CALL	MOVE	T1,[SIXBIT \FILE\]	;DEFAULT FILE NAME
;	MOVE	T2,[SIXBIT \EXTEXT\]	;DEFAULT EXTENSIONS
;	PUSHJ	P,OPNFIL
;	  LOSE RETURN
;	WIN RETURN
OPNFIL:	TROA	FLG,F.FLIP	;FLAG WE SHOULD PROMPT
OPNFL0:	TRZ	FLG,F.FLIP	;NO PROMPT PLEASE
	MOVEM	T1,FILNAM	;SAVE DEFAULT FILE NAME
	MOVEM	T2,FILEXT	;SAVE DEFAULT EXTENSIONS
	SETZM	FILPPN
OPFIL1:	MOVSI	T1,'DSK'	;DEFAULT DEVICE NAME
	MOVEM	T1,FILDEV
	TROE	FLG,F.FLIP	;WANT PROMPT ?
	  OUTSTR	[ASCIZ \
FILE:	\]
	PUSHJ	P,SIXIN		;GET FILE NAME
	  JRST	OPFIL1
	CAIE	T5,":"		;WAS THIS A DEVICE SPECIFICATION ?
	  JRST	OPFIL5
	MOVEM	T1,FILDEV	;YES SO WAS A DEVICE
	PUSHJ	P,SIXIN		;GET FILE NAME
	  JRST	OPFIL1
OPFIL5:	SKIPE	T1		;WAS THERE A FILE NAME ?
	  MOVEM	T1,FILNAM	;SAVE FILE NAME
	CAIE	T5,"."		;GIVING AN EXTENSION ?
	  JRST	OPFIL6		;NO
	PUSHJ	P,SIXIN		;GET EXTENSION
	  JRST	OPFIL1
	HLLZM	T1,FILEXT
OPFIL6:	CAIE	T5,"["		;GIVING A PPN ?
	  JRST	OPFIL7
	PUSHJ	P,SIXIN
	  JRST	OPFIL7
	CAIE	T5,","
	  JRST	OPFIL7
	PUSHJ	P,SIXOCT
	  JRST	OPFIL7
	HRLM	T1,FILPPN
	PUSHJ	P,SIXIN
	  JRST	OPFIL1
	PUSHJ	P,SIXOCT
	  JRST	OPFIL1
	HRRM	T1,FILPPN
OPFIL7:	SETZ	T1,
	MOVE	T2,FILDEV
	MOVEI	T3,IHD
	TRNE	FLG,F.WRIT
	  HRLZI	T3,OHD
	OPEN	T1
	  JRST	FILER0
	PUSH	P,.JBFF##
	MOVEI	T2,INPBUF
	MOVEM	T2,.JBFF##
	MOVE	T1,[INBUF 1]
	TRNE	FLG,F.WRIT
	HRLI	T1,(OUTBUF)
	XCT	T1
	  JFCL
	POP	P,.JBFF##
OPNFL8:	MOVE	T1,[LOOKUP T2]
	TRNE	FLG,F.WRIT
	  HRLI	T1,(ENTER)
	MOVE	T2,FILNAM
	HLLZ	T3,FILEXT	;GET DEFAULT EXTENSION
	SETZ	T4,
	MOVE	T5,FILPPN
	XCT	T1
	  CAIA			;LOOKUP OR ENTER LOST
	JRST	OPNFL9
	TRNE	FLG,F.WRIT	;WRITING ?
	  JRST	FILER0		;HE LOSES
	HRLZS	T3,FILEXT	;TRY DEFAULT EXTENSION
	JUMPE	T3,FILER0	;IF NONE DON'T TRY AGAIN
	JRST	OPNFL8
OPNFL9:	HLLZS	FILEXT	;SAVE REAL FILE EXTENSION
	JRST	CPOPJ1		;RETURN TO CALLER
FILER0:	OUTSTR	[ASCIZ \can't LOOKUP/ENTER file \]
FILERR:	MOVEI	T1,FILDEV
	PUSHJ	P,FILTYP
	OUTSTR	[ASCIZ \
\]
	POPJ	P,
FILTYP:	PUSH	P,T1		;SAVE POINTER TO FILE DESCRIPTOR
	MOVE	T1,@(P)		;GET DEVICE NAME
	PUSHJ	P,SIXTYP
	MOVEI	T1,":"
	PUSHJ	P,TYPCHR
	AOS	(P)
	MOVE	T1,@(P)		;GET FILE NAME
	PUSHJ	P,SIXTYP
	MOVEI	T1,"."
	PUSHJ	P,TYPCHR
	AOS	(P)		;ADVANCE TO FILE EXTENSION
	HLLZ	T1,@(P)		;GET EXTENSION
	PUSHJ	P,SIXTYP
	AOS	(P)
	SKIPN	T1,@(P)
	  JRST	FILTY6
	PUSH	P,T1		;SAVE PPN
	MOVEI	T1,"["
	PUSHJ	P,TYPCHR
	HLRZ	T1,(P)
	PUSHJ	P,OCTYPE
	MOVEI	T1,","
	PUSHJ	P,TYPCHR
	POP	P,T1		;GET RH OF PPN
	ANDI	T1,-1
	PUSHJ	P,OCTYPE
	MOVEI	T1,"]"
	PUSHJ	P,TYPCHR
FILTY6:	POP	P,T1
	POPJ	P,

;HERE TO CLOSE OUTPUT FILE
DONE.W:	SKIPN	OHD
	  POPJ	P,
	OUT
	CLOSE
	RELEASE
	SETZM	OHD
	POPJ	P,

	IFN FT2SEG < RELOC >
IHD:	BLOCK	3
INPBUF:	BLOCK	203
FILDEV:	SIXBIT	\DSK\
FILNAM:	BLOCK	1
FILEXT:	BLOCK	1
FILPPN:	BLOCK	1
	IFN FT2SEG < RELOC >
;HERE TO GET NEXT CHAR FROM A FILE
; CALL	PUSHJ	P,FILCHR
;	ERROR RETURN
;	NORMAL RETURN WITH CHAR IN T1
FILCHR:	SOSGE	T1,IHD+2	;IS THERE MORE STUFF IN BUFFER ?
	  JRST	FLCHR5		;NO
	ILDB	T1,IHD+1	;GET NEXT CHAR
	JUMPE	T1,FILCHR	;FLUSH NULLS
	AOS	(P)		;SKIP RETURN
	POPJ	P,
FLCHR5:	IN			;GET NEXT BUFFER
	  JRST	FILCHR		;TRY AGAIN
	POPJ	P,
;HERE TO INPUT AN OCTAL NUMBER
; CALL:	PUSHJ	P,INPOCT
;	ERROR RETURN
;	RETURN WITH OCTAL NUMBER IN T1, BREAK CHAR IN T2
INPOCT:	PUSH	P,T3
	PUSH	P,T4
	SETZB	T3,T4
INPRD2:	PUSHJ	P,FILCHR	;GET NEXT INPUT CHAR
	  JRST	INPRD9		;NO MORE IN FILE
	JUMPE	T1,INPRD2
	CAIE	T1," "		;LEADING SPACE ?
	CAIN	T1,"	"	;OR TAB ?
	  JRST	INPRD2		;YES
INPRD5:	CAIL	T1,"0"
	CAILE	T1,"7"
	   JRST	INPRD7
	IMULI	T3,^D8
	ADDI	T3,-60(T1)
	PUSHJ	P,FILCHR
	  CAIA			;EOF
	JRST	INPRD5
INPRD7:	MOVE	T2,T1
	MOVE	T1,T3
	AOS	-2(P)		;SKIP RETURN
INPRD9:	POP	P,T4
	POP	P,T3
	POPJ	P,
;HERE TO GET A SIXBIT WORD FROM TTY
SIXIN:	MOVE	T4,[POINT 6,T5]
	SETZ	T5,
SIXIN2:	PUSHJ	P,RDCHAR	;GET A CHAR FROM TTY
	CAIN	T1,177
	  JRST	[	OUTSTR	[ASCIZ \xxx\]
			POPJ	P, ]
	CAIL	T1,"0"
	CAILE	T1,"Z"
	  JRST	SIXIN9		;RETURN
	CAILE	T1,"9"
	CAIL	T1,"A"
	  CAIA
	JRST	SIXIN9		;RETURN
	SUBI	T1,40
	CAME	T4,[POINT 6,T5,35]	;HAVE WE ALREADY FILLED WORD ?
	  IDPB	T1,T4		;NOT YET
	JRST	SIXIN2
SIXIN9:	EXCH	T1,T5
	CAIN	T5,15		;END OF LINE?
	TRO	FLG,F.ENDL	;YES, NOTE THAT.
	JRST	CPOPJ1

;HERE TO CONVERT SIXBIT TO OCTAL
SIXOCT:	MOVE	T4,[POINT 6,T1]
	SETZ	T2,
SIXOC1:	ILDB	T3,T4
	JUMPE	T3,SIXOC9
	CAIL	T3,20
	CAILE	T3,27
	  POPJ	P,		;CAN'T CONVERT
	IMULI	T2,^D8
	ADDI	T2,-20(T3)
	CAME	T4,[POINT 6,T1,35]	;DONE ALL OF WORD ?
	  JRST	SIXOC1
SIXOC9:	EXCH	T1,T2
	JRST	CPOPJ1
SUBTTL	TTY ROUTINES

;HERE TO DISPLAY CONTENTS OF T1 AS AN ADDRESS
ADRTYP:	ANDI	T1,177777	;SIXTEEN BITS ONLY PLEASE
	HRROM	T1,LSTADR	;SAVE LAST ADDRESS DISPLAYED
	PUSHJ	P,VALFND	;SEE IF WE CAN FIND A SYMBOL
	  JRST	RADTYP		;TYPE ADDR IN CURRENT RADIX
	PUSH	P,T1		;SAVE VALUE
	MOVE	T1,(SYM)	;GET SYMBOL NAME
	PUSHJ	P,SIXTYP	;TYPE SYMBOL
	POP	P,T1		;GET VALUE AGAIN
	SUB	T1,1(SYM)	;GET DISPLACEMENT
	ANDI	T1,177777	;STRIP EXTRA BITS
	JUMPE	T1,CPOPJ	;IF EXACT WE ARE DONE
	PUSH	P,T1		;SAVE REMAINDER
	MOVEI	T1,"+"
	PUSHJ	P,TYPCHR
	POP	P,T1
	JRST	RADTYP		;TYPE REST IN CURRENT RADIX

;HERE TYPE DATA
DATYPE:	MOVE	T1,DOT
	HRRZ	T2,BYTCNT	;BYTE COUNT
	HRRZ	T3,O.MODE	;OUTPUT MODE
	CAIG	T3,2		;IS THIS A WORD MODE
	  ASH	T2,1		;YES SO BYTE=WORDS*2
	PUSHJ	P,GETWRD
	  JRST	[	PUSHJ	P,CAL1ER
			JRST	LEVEL0 ]
	MOVEM	T1,DATA
	HRRZ	T5,BYTCNT	;REPETITION COUNT
	SETZM	LSTADR
	SETZM	DOTFOO
	MOVE	T1,DATA		;GET DATA TO TYPE
	HRRZ	T2,O.MODE	;GET OUTPUT MODE
	PUSHJ	P,@[EXP	DATINS,DATADR,DATNUM,DATBYT,DATASC,DATEBC](T2)
	MOVEI	T1,[ASCIZ \   \]
	PJRST	TYPSTR
;
DATNUM:	PUSHJ	P,RADTYP	;TYPE AS NUMERIC
	SOJLE	T5,DATYP8
	PUSHJ	P,BLANKT
	PUSHJ	P,NXTDWD	;GET NEXT DATA WORD
	JRST	DATNUM
NXTDWD:	SKIPN	DOTFOO		;DONE 2ND WORD YET
	  MOVE	DOTFOO,DOT
	ADDI	DOTFOO,2
	MOVE	T1,DOTFOO
	MOVEI	T2,2
	PUSHJ	P,GETWRD	;FIND WHAT NEXT WORD IS
	  JRST	DATYP8		;CAN'T READ NEXT WORD !
	MOVEM	T1,DATA
	POPJ	P,
;HERE TO TYPE DATA AS AN ADDRESS
DATADR:	PUSHJ	P,ADRTYP
	SOJLE	T5,DATYP8	;HAVE WE DONE ENOUGH ?
	PUSHJ	P,BLANKT	;TYPE A SPACE TO SEPERATE FIELDS
	PUSHJ	P,NXTDWD	;GET NEXT DATA WORD
	JRST	DATADR		;AND TYPE NEXT WORD
;HERE TO TYP DATA AS INSTRUCTIONS
DATINS:	PUSHJ	P,INVLFN	;SEE IF WE CAN FIND AN INSTRUCTION TO MATCH
	  JRST	DATNUM
	MOVE	T1,(SYM)	;GET INSTRUCTION NAME
	PUSHJ	P,SIXTYP
	MOVE	T5,1(SYM)	;GET FLAGS AGAIN
	PUSHJ	P,BLANKT	;TYPE A BLANK
	TLNE	T5,SMF.MK	;MARK INSTRUCTION?
	  JRST	[	LDB	T1,[POINT 6,DATA,35]
			PUSHJ	P,OCTYPE
			JRST	DATYP8]
	TLNE	T5,SMF.PL	;SPL TYPE INSTRUCTION ?
	  JRST	[	LDB	T1,[POINT 3,DATA,35]	;GET ARGUMENT
			PUSHJ	P,OCTYPE
			JRST	DATYP8 ]
	TLNE	T5,SMF.EM	;EMT TYPE ARGUMENTS ?
	  JRST	[	LDB	T1,[POINT 8,DATA,35]	;GET ARGUMENT
			PUSHJ	P,RADTYP	;TYPE ARGUMENT AS NUMBER
			JRST	DATYP8 ]
	TLNE	T5,SMF.RT	;RTS TYPE ?
	  JRST	[	LDB	T1,[POINT 3,DATA,35]	;GET REG ADR
			PUSHJ	P,DATIN9	;TYPE REG NAME
			JRST	DATYP8	]
	TLNE	T5,SMF.JS	;JSR TYPE ?
	  JRST	[	LDB	T1,[POINT 3,DATA,29]
			PUSHJ	P,DATIN9	;TYPE REG NAME
			PUSHJ	P,COMTYP
			JRST	.+1 ]
	TLNE	T5,SMF.AS	;ASH TYPE NN ?
	  JRST	[	LDB	T1,[POINT 6,DATA,29]	;GET NN
			TRNE	T1,40			;CHECK FOR NEGATIVE
			  IORI	T1,177740		;EXTEND SIGN
			JRST	RADTYP ]
	TLNE	T5,SMF.SB	;SOB TYPE ?
	  JRST	[	LDB	T1,[POINT 3,DATA,29]	;GET REGISTER
			PUSHJ	P,DATIN9	;TYPE REG NAME
			PUSHJ	P,COMTYP
			LDB	T1,[POINT 6,DATA,35]	;GET OFFSET
			IMULI	T1,-2
			ADDI	T1,2(DOT)
			ANDI	T1,177777
			PUSHJ	P,ADRTYP
			JRST	DATYP8	]
	TLNN	T5,SMF.SS	;12BIT SSDD FORMAT ?
	  JRST	DATIN2		;NO
	LDB	T4,[POINT 6,DATA,29]	;GET SS CODE
	PUSHJ	P,DATIN8
	PUSHJ	P,COMTYP
DATIN2:	TLNN	T5,SMF.SS!SMF.DD	;IS THERE A 6 BIT DESTINATION CODE ?
	  JRST	DATIN4		;NO
	LDB	T4,[POINT 6,DATA,35]	;GET DD CODE
	PUSHJ	P,DATIN8
DATIN4:	TLNN	T5,SMF.XX	;IS THIS BR TYPE ADDRESSING ?
	  JRST	DATIN6		;NO
	LDB	T1,[POINT 8,DATA,35]	;GET OFFSET
	TRNE	T1,200		;CHECK FOR NEGATIVE OFFSET
	  IORI	T1,177400
	AOS	T1
	LSH	T1,1		;MAKE WORD ADDRESS
	ADD	T1,DOT
	ANDI	T1,177777	;16 BITS ONLY
	PUSHJ	P,ADRTYP	;TYPE ADDRESS
DATIN6:	JRST	DATYP8
DATIN8:	CAIN	T4,27		;CHECK FOR IMMEDIATE MODE
	  JRST	[	PUSHJ	P,HSHTYP	;TYPE A #
			SKIPN	DOTFOO
			  MOVE	DOTFOO,DOT
			ADDI	DOTFOO,2
			MOVE	T1,DOTFOO
			MOVEI	T2,2
			PUSHJ	P,GETWRD
			  POPJ	P,
			JRST	ADRTYP ]
	CAIN	T4,37		;CHECK FOR ABSOLUTE MODE
	  JRST	[	SKIPN	DOTFOO
			  MOVE	DOTFOO,DOT
			ADDI	DOTFOO,2
			MOVE	T1,DOTFOO
			MOVEI	T2,2
			PUSHJ	P,GETWRD
			  POPJ	P,
			JRST	ADRTYP ]
	CAIL	T4,10		;IS THIS (REGSITER)?
	CAILE	T4,16		;EXCEPT (PC)?
	SKIPA			;NO.
	JRST	[	MOVEI	T1,"(" ;YES.
			PUSHJ	P,TYPCHR
			LDB	T1,[POINT 3,T4,35]
			PUSHJ	P,DATIN9
			MOVEI	T1,")"
			PJRST	TYPCHR]
	TRNE	T4,10		;CHECK FOR DEFERRED MODE
	  PUSHJ	P,[	MOVEI	T1,"@"
			PJRST	TYPCHR ]
	CAIE	T4,77		;CHECK FOR RELATIVE DEFERRED MODE
	CAIN	T4,67		;CHECK FOR RELATIVE MODE
	  JRST	[	SKIPN	DOTFOO
			  MOVE	DOTFOO,DOT
			ADDI	DOTFOO,2
			MOVE	T1,DOTFOO
			MOVEI	T2,2
			PUSHJ	P,GETWRD
			  POPJ	P,
			ADD	T1,DOTFOO	;MAKE RELATIVE
			ADDI	T1,2
			JRST	ADRTYP ]
	LDB	T1,[POINT 3,T4,32]	;GET MODE
	CAIE	T1,4
	CAIN	T1,5
	  PUSHJ	P,MINTYP
	CAIL	T1,6		;CHECK FOR INDEX OR INDEX DEFERRED
	  JRST	[	SKIPN	DOTFOO
			  MOVE	DOTFOO,DOT
			ADDI	DOTFOO,2
			MOVE	T1,DOTFOO
			MOVEI	T2,2
			PUSHJ	P,GETWRD
			  POPJ	P,
			PUSHJ	P,ADRTYP
			JRST	.+2 ]
	TRNE	T1,6
	  PUSHJ P,[	MOVEI	T1,"("
			PJRST	TYPCHR ]
	LDB	T1,[POINT 3,T4,35]	;GET REGISTER VALUE
	PUSHJ	P,DATIN9	;TYPE REGISTER NAME
	TRNN	T4,60
	  POPJ	P,		;PLAIN REGISTER MODE
	MOVEI	T1,")"
	PUSHJ	P,TYPCHR
	LDB	T1,[POINT 3,T4,32]
	CAIE	T1,2
	CAIN	T1,3
	  PUSHJ	P,PLUTYP
	POPJ	P,
DATIN9:	PUSHJ	P,RGFNDN		;FIND REGISTERS NAME
	  JRST	[	PUSHJ	P,PCNTYP	;TYPE A %
			PUSHJ	P,OCTYPE
			POPJ	P, ]
	MOVE	T1,(SYM)	;GET REGISTERS NAME
	JRST	SIXTYP
;HERE TO TYPE DATA AS ASCII TEXT
DATASC:	ANDI	T1,377
	MOVEM	T1,T3
	PUSHJ	P,DATAS3
	SOJLE	T5,DATYP8
	LDB	T1,[POINT 8,DATA,27]
	MOVEM	T1,T3		;SAVE IN CASE ILLEGAL
	PUSHJ	P,DATAS3
	SOJLE	T5,DATYP8
	PUSHJ	P,NXTDWD	;GET NEXT DATA WORD
	JRST	DATASC
DATAS3:	ANDI	T1,177		;STRIP PARITY BIT
	CAIL	T1,40
	CAILE	T1,176
	CAIA			;SPECIAL HANDLING
	JRST	TYPCHR		;JUST TYPE CHARACTER
DATAS4:	PUSH	P,T3		;SAVE WEIRD CHARACTER
	MOVEI	T1,"<"
	PUSHJ	P,TYPCHR
	POP	P,T1		;GET CHAR
	PUSHJ	P,RADTYP
	MOVEI	T1,">"
	PJRST	TYPCHR

;HERE TO TYPE DATA AS TEXT
DATEBC:	PUSHJ	P,DATEB3
	SOJLE	T5,DATYP8
	LDB	T1,[POINT 8,DATA,27]
	PUSHJ	P,DATEB3
	SOJLE	T5,DATYP8
	PUSHJ	P,NXTDWD	;GET NEXT DATA WORD
	JRST	DATEBC
DATEB3:	ANDI	T1,377
	MOVEM	T1,T3
	SETZ	T2,
	LSHC	T1,-2
	ROT	T2,2
	LDB	T1,[	POINT	8,EB.TRN(T1),7
			POINT	8,EB.TRN(T1),15
			POINT	8,EB.TRN(T1),23
			POINT	8,EB.TRN(T1),31 ](T2)
	PJRST	DATAS3
;HERE TO TYPE DATA AS BYTES
DATBYT:	ANDI	T1,377
	PUSHJ	P,RADTYP
	SOJLE	T5,DATYP8
	MOVEI	T1,","
	PUSHJ	P,TYPCHR
	LDB	T1,[POINT 8,DATA,27]
	PUSHJ	P,RADTYP	;TYPE IN CURRENT RADIX
	SOJLE	T5,DATYP8
	MOVEI	T1,","
	PUSHJ	P,TYPCHR
	PUSHJ	P,NXTDWD	;GET NEXT DATA WORD
	JRST	DATBYT
;
DATYP8:	POPJ	P,		;RETURN.

DECTYP:	SKIPA	T3,[EXP ^D10]
OCTYPE:	MOVEI	T3,^D8
	JRST	RADTY2
RADTYP:	HRRZ	T3,ORADIX
	CAIE	T3,^D10
	  JRST	RADTY2
	PUSHJ	P,RADTY2
	MOVEI	T1,"."
	PJRST	TYPCHR
RADTY2:	JUMPGE	T1,RADTY5
	MOVMS	T1
	PUSH	P,T1
	PUSHJ	P,MINTYP
	POP	P,T1

RADTY5:	IDIVI	T1,(T3)
	HRLM	T2,(P)
	SKIPE	T1
	PUSHJ	P,RADTY5
	HLRZ	T1,(P)
	ADDI	T1,"0"
	CAILE	T1,"9"
	  ADDI	T1,7		;DOING HEX
	PJRST	TYPCHR

SIXTYP:	MOVEM	T1,T2
SXTYP1:	SETZ	T1,
	LSHC	T1,6
	ADDI	T1,40
	PUSHJ	P,TYPCHR
	JUMPN	T2,SXTYP1
	POPJ	P,
TABTYP:	PUSH	P,T1
	MOVEI	T1,"	"
TYPEIT:	PUSHJ	P,TYPCHR
	POP	P,T1
	POPJ	P,

CRLTYP:	PUSH	P,T1
	MOVEI	T1,15		;CARRIAGE RETURN
	PUSHJ	P,TYPCHR
	MOVEI	T1,12		;LINEFEED
	PJRST	TYPEIT

BLANKT:	PUSH	P,T1
	MOVEI	T1," "
	PJRST	TYPEIT

COMTYP:	PUSH	P,T1
	MOVEI	T1,","
	PJRST	TYPEIT

PCNTYP:	PUSH	P,T1
	MOVEI	T1,"%"
	PJRST	TYPEIT

HSHTYP:	PUSH	P,T1
	MOVEI	T1,"#"
	PJRST	TYPEIT

MINTYP:	PUSH	P,T1
	MOVEI	T1,"-"
	PJRST	TYPEIT

PLUTYP:	PUSH	P,T1
	MOVEI	T1,"+"
	PJRST	TYPEIT
;HERE TO TYPE OR PRINT A STRING OF CHARACTERS
TYPSTR:	PUSH	P,T2
	MOVE	T2,[POINT 7,0]
	ADDI	T2,(T1)		;COPY STRING POINTER
TYPST3:	ILDB	T1,T2		;GET NEXT CHAR
	JUMPE	T1,TYPST5
	PUSHJ	P,TYPCHR	;TYPE THE CHARACTER
	JRST	TYPST3
TYPST5:	POP	P,T2		;RESTORE REGISTER
	POPJ	P,

;HERE TO TYPE A SPACE
SP.TYP:	MOVEI	T1," "		;A SPACE

;HERE TO TYPE OR PRINT A SINGLE CHARACTER
TYPCHR:	SKIPE	OHD		;DOING A DUMP ?
	  JRST	TYPCH3		;YES
	OUTCHR	T1
	POPJ	P,

TYPCH3:	SOSGE	OHD+2		;ROOM IN BUFFER
	  JRST	TYPCH4		;NO
	IDPB	T1,OHD+1
	POPJ	P,
TYPCH4:	OUT
	  JRST	TYPCH3
	HALT

	IFN FT2SEG < RELOC >
OHD:	BLOCK	3
	IFN FT2SEG < RELOC >
;HERE
;HERE TO TYPE PROGRAM NAME
IDTYPE:	MOVEI	T1,[ASCIZ \DDT60 \]
	PUSHJ	P,TYPSTR
	LDB	T1,[POINT 9,.JBVER,11]
	PUSHJ	P,OCTYPE
	LDB	T1,[POINT 6,.JBVER,17]
	MOVEI	T1,100(T1)
	CAIE	T1,100
	  PUSHJ	P,TYPCHR
	MOVEI	T1,"("
	PUSHJ	P,TYPCHR
	HRRZ	T1,.JBVER
	PUSHJ	P,OCTYPE
	MOVEI	T1,")"
	PUSHJ	P,TYPCHR
	LDB	T1,[POINT 3,.JBVER,2]
	MOVNS	T1
	SKIPE	T1
	  PUSHJ	P,OCTYPE
	HRROI	T1,3		;CODE FOR PROGRAM NAME
	GETTAB	T1,
	  JRST	IDTYP2
	CAMN	T1,[SIXBIT \DDT60\]
	  JRST	IDTYP2
	PUSH	P,T1
	MOVEI	T1,[ASCIZ	\ = \]
	PUSHJ	P,TYPSTR
	POP	P,T1
	PUSHJ	P,SIXTYP
IDTYP2:	SKIPN	SYMDEV
	  JRST	IDTYP3
	MOVEI	T1,[ASCIZ \ /Symbols:\]
	PUSHJ	P,TYPSTR
	MOVEI	T1,SYMDEV
	PUSHJ	P,FILTYP
IDTYP3:	PUSHJ	P,SP.TYP
	POPJ	P,
;NOW TYPE THE DATE
DATETY:	DATE	T1,
	IDIVI	T1,^D31*^D12	;LEAVE YEAR-64 IN T1
	ADDI	T1,^D64
	PUSH	P,T1		;SAVE YEAR
	IDIVI	T2,^D31
	LSH	T2,1		;MULTIPLY BY 2
	ADDI	T2,MONTAB
	PUSH	P,T2		;SAVE ADR OF MONTH NAME
	AOS	T1,T3		;GET DAY
	PUSHJ	P,DECTYP
	POP	P,T1		;GET MONTH
	PUSHJ	P,TYPSTR	;TYPE MONTH NAME
	POP	P,T1		;GET YEAR
	PUSHJ	P,DECTYP
	PUSHJ	P,BLANKT	;TYPE A SPACE

;HERE TO TYPE THE TIME OF DAY
TIMTYP:	PUSH	P,T1
	PUSH	P,T2
	PUSH	P,T3
	MSTIME	T1,		;GET TIME OF DAY IN MS
	IDIVI	T1,^D1000	;GET RID OF MS
	IDIVI	T1,^D60		;LEAVES SECONDS IN T2
	PUSH	P,T2
	IDIVI	T1,^D60		;LEAVES MIN IN T2
	PUSH	P,T2
	PUSHJ	P,DECTYP
	MOVEI	T1,":"
	PUSHJ	P,TYPCHR
	POP	P,T1
	PUSHJ	P,DC2TYP	;TYPE 2 DIGIT DECIMAL NUMBER
	MOVEI	T1,":"
	PUSHJ	P,TYPCHR
	POP	P,T1
	PUSHJ	P,DC2TYP	;TYPE 2 DIGIT DECIMAL NUMBER
	POP	P,T3
	POP	P,T2
	POP	P,T1
	POPJ	P,
DC2TYP:	CAIL	T1,^D10
	  JRST	DECTYP
	PUSH	P,T1
	MOVEI	T1,"0"
	PUSHJ	P,TYPCHR
	POP	P,T1
	JRST	DECTYP
MONTAB:	ASCIZ	\-Jan-\
	ASCIZ	\-Feb-\
	ASCIZ	\-Mar-\
	ASCIZ	\-April-\
	ASCIZ	\-May-\
	ASCIZ	\-June-\
	ASCIZ	\-July-\
	ASCIZ	\-Aug-\
	ASCIZ	\-Sept-\
	ASCIZ	\-Oct-\
	ASCIZ	\-Nov-\
	ASCIZ	\-Dec-\
LOCKER:	OUTSTR	[ASCIZ	\?LOCK UUO failed - code \]
	PUSHJ	P,OCTYPE
	EXIT

NODERR:	PUSHJ	P,DONE.W	;CLOSE OUTPUT IF ANY
	OUTSTR	[ASCIZ	\?NODE UUO failed - code \]
	PUSHJ	P,OCTYPE
	EXIT
SUBTTL	DUMP TO FILE

ESC..D:	MOVEM	T5,DUMPF	;SAVE ARG TO $D COMMAND
	TRO	FLG,F.WRIT	;REMEMBER WE ARE WRITING
	HRROI	T1,3
	GETTAB	T1,		;GET NAME OF JOB
	  MOVE	T1,[SIXBIT \DDT60\]
	MOVSI	T2,'LSD'
	PUSHJ	P,OPNFIL
	  JRST	DUMP9
	SETZM	CACHEL		;SWEEP CACHE
	TRO	FLG,F.CACH	;PUT USE IT AFTER IT IS SET UP
	MOVE	DOT,SBEGIN	;WHERE TO BEGIN DUMP
	SETZM	DUMPL		;FORCE TOP OF PAGE
;
; COME HERE TO DUMP THE NEXT WORD
;
DUMP3:	PUSHJ	P,CRLTYP	;GO TO NEXT LINE
	SOSG	DUMPL		;ROOM ON PAGE?
	PUSHJ	P,DUMP7		;NO, GO TO NEXT.
	HRRZ	T1,DOT		;CURRENT LOCATION
	ANDI	T1,177777
	PUSHJ	P,OCTYPE	;LOCATION IN OCTAL
	PUSHJ	P,TABTYP
	HRRZ	T1,DOT
	PUSHJ	P,VALFND	;FIND SYMBOL, IF ANY.
	  JRST	DUMP1		;THERE IS NONE.
	MOVE	T1,0(SYM)	;GET SYMBOL NAME
	PUSHJ	P,SIXTYP
	PUSHJ	P,TABTYP
	HRRZ	T1,DOT
	SUB	T1,1(SYM)	;COMPUTE OFFSET
	ANDI	T1,177777
	JUMPE	T1,DUMP2	;THERE IS NONE
	PUSH	P,T1		;SAVE OFFSET
	PUSHJ	P,PLUTYP	; TYPE "+"
	POP	P,T1		;GET OFFSET
	PUSHJ	P,OCTYPE	;TYPE OFFSET
	JRST	DUMP2		;ONLYTWO TABS

DUMP1:	PUSHJ	P,TABTYP
DUMP2:	PUSHJ	P,TABTYP
	PUSHJ	P,TABTYP
	MOVE	T1,DOT
	MOVE	T2,S..END
	SUB	T2,T1		;COMPUTE BYTES TO GO IN DUMP
	CAIL	T2,EXMAX	;TOO MANY?
	  SKIPA	T2,[EXP EXMAX]	;YES, REDUCE TO MAX
	  ADDI	T2,2
	PUSHJ	P,GETWRD	;GET THIS WORD (AND SOME FOLLOWING)
	  JRST	DUMP8		;NOT AVAILABLE, END THE DUMP
	MOVEM	T1,DATA		;SAVE VALUE GOTTEN
	PUSHJ	P,OCTYPE	;TYPE AS OCTAL WORD
	PUSHJ	P,TABTYP
	MOVE	T1,DATA
	ANDI	T1,377		;LOW BYTE
	PUSHJ	P,OCTYPE
	PUSHJ	P,COMTYP
	LDB	T1,[POINT 8,DATA,27] ;HIGH BYTE
	PUSHJ	P,OCTYPE
	PUSHJ	P,TABTYP
;
; NOW TYPE AS DECIMAL
;
	MOVE	T1,DATA
	PUSHJ	P,DECTYP
	PUSHJ	P,TABTYP
	MOVE	T1,DATA
	ANDI	T1,377		;LOW BYTE
	PUSHJ	P,DECTYP
	PUSHJ	P,COMTYP
	LDB	T1,[POINT 8,DATA,27] ;HIGH BYTE
	PUSHJ	P,DECTYP
	PUSHJ	P,TABTYP
	HRRZ	T1,DATA
	PUSHJ	P,VALFND	;FIND SYMBOL FOR ADDRESS
	  JRST 	DUMP4
	MOVE	T1,0(SYM)
	PUSHJ	P,SIXTYP
	PUSHJ	P,TABTYP
	HRRZ	T1,DATA
	SUB	T1,1(SYM)	;COMPUTE OFFSET
	ANDI	T1,177777
	JUMPE	T1,DUMP5	;OFFSET IS ZERO
	PUSH	P,T1		;SAVE OFFSET
	PUSHJ	P,PLUTYP
	POP	P,T1
	PUSHJ	P,OCTYPE	;TYPE OFFSET
	JRST	DUMP5

DUMP4:	PUSHJ	P,TABTYP
DUMP5:	PUSHJ	P,TABTYP
	MOVE	T1,DATA
	ANDI	T1,377		;LOW BYTE
	MOVE	T3,T1
	PUSHJ	P,DUMP6		;PRINT AS ASCII
	PUSHJ	P,COMTYP
	LDB	T1,[POINT 8,DATA,27]
	MOVE	T3,T1
	PUSHJ	P,DUMP6		;LIKEWISE HIGH BYTE
	PUSHJ	P,TABTYP
;
; NOW TYPE AS EBCDIC
;
	MOVE	T1,DATA
	ANDI	T1,377
	MOVE	T3,T1
	SETZ	T2,
	LSHC	T1,-2
	ROT	T2,2
	LDB	T1,[POINT 8,EB.TRN(T1),7
		POINT 8,EB.TRN(T1),15
		POINT 8,EB.TRN(T1),23
		POINT 8,EB.TRN(T1),31](T2)
	PUSHJ	P,DUMP6
	PUSHJ	P,COMTYP
	LDB	T1,[POINT 8,DATA,27]
	ANDI	T1,377
	MOVE	T3,T1
	SETZ	T2,
	LSHC	T1,-2
	ROT	T2,2
	LDB	T1,[POINT 8,EB.TRN(T1),7
		POINT 8,EB.TRN(T1),15
		POINT 8,EB.TRN(T1),23
		POINT 8,EB.TRN(T1),31](T2)
	PUSHJ	P,DUMP6
	PUSHJ	P,TABTYP
	SETZ	T5,		;ONLY ONE INSTRUCTION
	SETZ	DOTFOO,
	MOVE	T1,DATA
	SKIPN	DUMPF		;IF $1D, DON'T PRINT INSTRUCTION
	PUSHJ	P,DATINS
	ADDI	DOT,2
	CAMG	DOT,S..END
	  JRST	DUMP3		;DUMP NEXT WORD
DUMP8:	PUSHJ	P,CRLTYP
	PUSHJ	P,DONE.W
	OUTSTR	[ASCIZ \
Dump done
\]
	JRST	LEVEL0
;
; SUBROUTINE TO PRINT A CHARACTER, OR ITS OCTAL IF THIS IS
;  NOT PRINTABLE
;
DUMP6:	CAIL	T1,40
	CAILE	T1,175		;LOWER CASE PRINTER ASSUMED
	SKIPA
	PJRST	TYPCHR		;CHAR OK, PRINT IT.
	MOVEI	T1,[ASCIZ \??\]
	PUSHJ	P,TYPSTR
	POPJ	P,
;
; HERE ON ERROR.
;
DUMP9:	OUTSTR	[ASCIZ	\error writing \]
	JRST	FILERR
	JRST	LEVEL0

DUMPL:	BLOCK	1		;LINES TO GO ON THIS PAGE

DUMPF:	BLOCK	1		;ARG TO $D COMMAND
;
; SUBROUTINE TO PRINT DUMP PAGE HEADER
;
DUMP7:	MOVEI	T1,14		;FORM FEED
	PUSHJ	P,TYPCHR
	MOVEI	T1,[ASCIZ \Dump of \]
	PUSHJ	P,TYPSTR
	SKIPE	MEMORY
	  JRST	[	MOVEI	T1,DMPDEV
			PUSHJ	P,FILTYP	;TYPE FILE ID
			JRST	DUMP0 ]
	MOVE	T1,[SIXBIT \/PORT:\]
	SKIPE	NODE
	  MOVE	T1,[SIXBIT \/NODE:\]
	PUSHJ	P,SIXTYP
	SKIPN	T1,NODE
	  HRRZ	T1,PORT
	MOVEI	T2,OCTYPE
	TLNE	T1,-1
	  MOVEI	T2,SIXTYP
	PUSHJ	P,(T2)
DUMP0:	MOVEI	T1,[ASCIZ \ by \]
	PUSHJ	P,TYPSTR
	PUSHJ	P,IDTYPE
	PUSHJ	P,DATETY	;TYPE DATE AND TIME
	PUSHJ	P,CRLTYP
	PUSHJ	P,CRLTYP
	MOVEI	T1,[ASCIZ \Location			Octal		Decimal		Address		ASCII	EBCDIC	Instruction\]
	PUSHJ	P,TYPSTR
	PUSHJ	P,CRLTYP
	MOVEI	T1,[ASCIZ \value	symbol			word	byte	word	byte\]
	PUSHJ	P,TYPSTR
	PUSHJ	P,CRLTYP
	MOVEI	T2,^D132
	MOVEI	T1,"-"
	PUSHJ	P,TYPCHR
	SOJG	T2,.-1
	PUSHJ	P,CRLTYP
	PUSHJ	P,CRLTYP
	MOVEI	T1,^D60-7	;REMAINING PAGE LENGTH
	MOVEM	T1,DUMPL
	POPJ	P,
SUBTTL	DUMP TO A BINARY FILE

ESC..P:	TRO	FLG,F.WRIT	;REMEMBER WE ARE WRITING
	MOVE	T1,[SIXBIT /KRUFT/]	;DEFAULT FILE NAME
	MOVSI	T2,'BIN'	;DEFAULT EXTENSION
	PUSHJ	P,OPNFIL	;OPEN FILE
	HALT
	MOVEI	T1,1
	PUSHJ	P,WRTWRD	;WRITE BINARY WORD
	HALT

WRTWRD:	SOSGE	OHD+2		;IS THERE ROOM IN BUFFER ?
	  JRST	WRTBN9		;NO ROOM
	IDPB	T1,OHD+1	;PUT BYTE INTO BUFFER
	POPJ	P,
WRTBN9:	OUT
	CAIA
	  JRST	FILERR		;COMPLAIN
	PUSH	P,T1		;SAVE DATA
	LDB	T1,[POINT 6,OHD+1,11]	;GET S FROM BYTE POINTER
	TRNE	FLG,F..ESC	;PUNCHING TAPE ?
	  JRST	WRTWD6		;YES
WRTWD6:
WRTWD7:	POP	P,T1		;GET DATA BACK
	JRST	WRTWRD
IFN FTPROM <
PROM:	INIT	10
	SIXBIT	/PTP/
	OHD,,0
	  JRST	DUMP9
	OUTBUF	1		;GET ONE BUFFER
	PUSHJ	P,PROM.7
	  JFCL
	PUSHJ	P,PROM.7
	  LSH	T1,-^D4
IFN	ROMTYP	<		;IF M9301
	PUSHJ	P,PROM.7
	  LSH	T1,-^D8
	PUSHJ	P,PROM.7
	  LSH	T1,-^D12
>;END OF IFN ROMTYP
	PJRST	DUMP8+1

PROM.7:	MOVEI	T1,377
	PUSHJ	P,TYPCHR
	MOVE	DOT,SBEGIN
IFE	ROMTYP	<		;ONLY BM873
	MOVEI	T4,^D128
>;END OF IFE ROMTYP
IFN	ROMTYP	<		;ONLY M9301
	MOVEI	T4,^D256
>;END OF IFN ROMTYP
PROM.8:	MOVE	T1,DOT
IFN	ROMTYP	<		;M9301 ONLY
	MOVEI	T2,2		;REQUEST 2 BYTES
>;END OF IFN ROMTYP
	PUSHJ	P,GETWRD
	  SETZ	T1,
	XCT	@(P)
IFE	ROMTYP	<		;ONLY BM873
	PUSH	P,T1
>;END OF IFE ROMTYP
	ANDI	T1,17
	PUSHJ	P,TYPCHR
IFE	ROMTYP	<		;ONLY BM873
	POP	P,T1
	LSH	T1,-^D8
	ANDI	T1,17
	PUSHJ	P,TYPCHR
>;END OF IFE ROMTYP
	ADDI	DOT,2
	SOJG	T4,PROM.8
IFN	ROMTYP	<		;ONLY M9301
	MOVE	DOT,S..END
	MOVEI	T4,^D256
PROM.9:	MOVE	T1,DOT
	MOVEI	T2,2
	PUSHJ	P,GETWRD
	  SETZ	T1,
	XCT	@(P)
	ANDI	T1,17
	PUSHJ	P,TYPCHR
	ADDI	DOT,2
	SOJG	T4,PROM.9
>;END OF IFN ROMTYP

	MOVEI	T4,^D256
	SETZ	T1,
	PUSHJ	P,TYPCHR
	SOJGE	T4,.-1
	AOS	(P)
	POPJ	P,
>;END OF IFN FTPROM
RDCHAR:	INCHWL	T1		;GET THE NEXT CHAR
	PUSHJ	P,GETCH0
	  JRST	RDCHAR
	POPJ	P,
;HERE TO GET A CHARACTER FROM THE TTY
GETCHR:	INCHRW	T1		;GET THE NEXT CHAR
	PUSHJ	P,GETCH0
	  JRST	GETCHR
	POPJ	P,
GETCH0:	JUMPE	T1,CPOPJ	;FLUSH NULLS
	CAIN	T1,15		;IS THIS A CARRIAGE RETURN ?
	  JRST	[	PUSHJ	P,GETCHR	;GET LF
			MOVEI	T1,15	;MAKE LF
			JRST	.+1	]
	CAIL	T1,40+"A"	;CHECK FOR LOWER CASE
	CAILE	T1,40+"Z"
	  CAIA
	TRZ	T1,40		;CONVERT TO UPPER CASE
	MOVEM	T1,LASCAR#	;REMEMBER LAST CHARACTER INPUT
	JRST	CPOPJ1
SUBTTL	/BIN: AND /DUMP: FILE HANDLING

;HERE BECAUSE WE FOUND /BIN OR /DUMP IN INITIAL DIALOG
; READ EITHER A BOOT11 OR NETLDR DUMP OR A BINARY FILE

RDDUMP:	MOVE	T1,[SIXBIT \PDPXI0\]	;DEFAULT FILE NAME
	MOVSI	T2,'LSD'	;DEFAULT EXTENSION
	TRNE	FLG,F.FLOP	;READING BINARY FILE ?
	  MOVSI	T2,'BIN'	;DEFAULT EXTENSION FOR BIN FILES
	PUSHJ	P,OPNFL0
	  JRST	DDT60		;BEGIN ALL OVER AGAIN
	MOVE	T1,[FILDEV,,DMPDEV]
	BLT	T1,DMPDEV+3	;COPY FILDEV, FILNAM, FILEXT, FILPPN
	HLRZ	T1,FILEXT	;GET FILE EXTENSION
	HRRZ	T1,.JBFF##	;GET FIRST FREE LOCATION
	MOVEM	T1,MEMORY	;SAVE ADDRESS OF SIMULATED MEMORY
	SETZM	MEMLIM		;FIRST NONEXISTENT ADDRESS IN DUMP MEMORY
	AOS	.JBFF##
	PUSHJ	P,GETCOR
	TRZN	FLG,F.FLOP	;READING A BINARY FILE ?
	  JRST	RDUMP0		;NO READING A DUMP

	SETZB	T5,T4		;ACCUMULATE CHECKSUM HERE
	LDB	T1,[POINT 6,IHD+1,11]	;GET S FIELD FROM INPUT POINTER
	CAIN	T1,^D36		;WORD POINTER ?
	  JRST	RDBN10		;YEH
	CAIE	T1,^D7		;ASCII POINTER ?
	  EXIT
	MOVEI	T1,^D36
	DPB	T1,[POINT 6,IHD+1,11]	;CHANGE POINTER
	MOVE	T1,IHD+2	;GET COUNT
	IDIVI	T1,5		;CONVERT TO WORD COUNT
	MOVEM	T1,IHD+2
;HERE TO LOOK FOR INITIAL 1
RDBN10:	PUSHJ	P,RDBN70	;GET NEXT CHAR
	  JRST	RDUMP9		;ALL DONE
	JUMPE	T1,RDBN10	;LOOP ON HEADER
	CAIE	T1,1		;IS THIS LEADING 1 ?
	  JRST	[OUTSTR	[ASCIZ	\improper format in input tape\]
		EXIT ]
	PUSHJ	P,RDBN70	;GET NEXT WORD = 0
	  EXIT
	JUMPN	T1,[	EXIT ]
	PUSHJ	P,RDBN60	;GET 16BIT WORD = COUNT
	MOVEI	T3,-6(T1)	;MAKE BYTE COUNT
	PUSHJ	P,RDBN60	;GET 16BIT WORD = ADR
	MOVE	T2,T1		;COPY ADDRESS
	JUMPE	T3,RDBN30
RDBN20:	PUSHJ	P,RDBN70	;GET NEXT BYTE TO STUFF
	  EXIT
	PUSHJ	P,PUTBYT	;PUT BYTE INTO MEMORY
	AOS	T2		;ADVANCE LOCATION COUNTER
	SOJG	T3,RDBN20
RDBN30:	PUSHJ	P,RDBN60	;INCLUDE CHECKSUM IN CALC
	TRNE	T5,377		;TEST CHECKSUM
	  JRST	[	OUTSTR	[ASCIZ \CHECKSUM ERROR\]
			EXIT ]
	JRST	RDBN10

;HERE TO GET SIXTEEN BITS
RDBN60:	PUSHJ	P,RDBN70	;GET LOW ORDER BITS
	  EXIT
	PUSH	P,T2
	LSHC	T1,-^D8		;SHOVE EM INTO T2
	PUSHJ	P,RDBN70	;GET HIGH ORDER BITS
	  EXIT
	ROTC	T1,^D8		;ADD LOW ORDER BITS
	POP	P,T2
	POPJ	P,		;RETURN TO CALLER
;HERE TO GET NEXT BYTE FROM BINARY FILE
RDBN70:	JUMPE	T4,RDBN74	;HALF OF PREVIOUS WORD LEFT ?
	LDB	T1,[POINT 8,T4,27]	;LOW ORDER BITS FROM PREV HLF WRD
	SETZ	T4,		;DONE WITH HALF WORD
	JRST	RDBN79
RDBN74:	SOSGE	IHD+2		;MORE DATA IN BUFFER ?
	  JRST	RDBN80		;NO SO READ MORE
	ILDB	T1,IHD+1
	TRNN	FLG,F.FLOP	;IS THIS PACKED FILE ?
	  JRST	RDBN79		;NO
	HRRO	T4,T1		;COPY HALF WORD
	LDB	T1,[POINT 8,T4,35]	;GET HIGH ORDER BITS
RDBN79:	ANDI	T1,377		;STRIP EXTRA BITS
	ADDI	T5,(T1)		;INCLUDE IN CHECKSUM
	JRST	CPOPJ1
RDBN80:	IN			;GET NEXT BUFFER
	  JRST	RDBN85		;GOT NEXT BUFFER
	POPJ	P,
RDBN85:	HRRZ	T1,IHD		;GET ADDRES OF CURRENT BUFFER
	HLRE	T1,2(T1)	;GET FIRST WORD IN BUFFER
	JUMPL	T1,RDIMAG	;THIS IS A DTELDR BINARY FILE
	JUMPE	T1,RDBN70	;PROCEED
	TRO	FLG,F.FLOP	;IS PACKED FILE
	LDB	T1,[POINT 6,IHD+1,11]	;GET S FIELD FROM INPUT POINTER
	CAIN	T1,^D18		;HALF WORD POINTER
	  JRST	RDBN70		;YES
	MOVEI	T1,^D18
	DPB	T1,[POINT 6,IHD+1,11]	;CHANGE POINTER
	MOVE	T1,IHD+2	;GET WORD COUNT
	LSH	T1,1		;MULTIPLY BY 2
	MOVEM	T1,IHD+2
	JRST	RDBN70

DMPDEV:	EXP	0
	EXP	0
	EXP	0
	EXP	0
;
; COME HERE IF WE HAVE A DTELDR BINARY FILE
;
;HERE IF WE HAVE A DTELDR DUMP (A .BIN FILE WITH THE SIGN BIT ON IN
;THE FIRST WORD). READ ALL THE DATA AND STORE IN CONTIGUOUS MEMORY

RDIMAG:	SETO	T2,		;THIS WILL INCREMENT TO 0 FOR FIRST BYTE
RDIMA1:	SOSL	IHD+2		;ANY DATA LEFT IN BUFFER?
	JRST	RDIMA2		;YES, USE IT
	IN			;NO, GET A NEW BUFFER
	  JRST	RDIMA1		;OK. TRY AGAIN
	POPJ	P,		;ERROR - ASSUME EOF

RDIMA2:	ILDB	T1,IHD+1	;GET NEXT WORD
	MOVS	T1,T1		;GET BYTES IN REVERSE ORDER (3,2,,1,0)
	PUSHJ	P,PUTBYI	;STUFF 0 IN NEXT LOCATION
	ROT	T1,-^D8		;POSITION TO NEXT BYTE
	PUSHJ	P,PUTBYI	;STUFF
	ROT	T1,-^D10	;THIRD, ACCOUNT FOR 2 EXTRA BITS
	PUSHJ	P,PUTBYI
	ROT	T1,-^D8		;FOURTH AND LAST
	PUSHJ	P,PUTBYI
	JRST	RDIMA1		;NEXT WORD
; COME HERE IF WE HAVE A DUMP IMAGE FILE.  SUCH A FILE HAS EACH 16-BIT
;  WORD FROM THE PDP-11 IN A HALF-WORD OF THE FILE.
;  DUMPS OF THIS KIND ARE PRODUCED BY DTELDR AND BY DASLOD.
;
; THE /BIN SWITCH WILL READ DTELDR DUMPS BY RECOGNIZING A SPECIAL FLAG
;  IN THE FIRST WORD OF THE FILE.  THIS SUBROUTINE WILL READ EITHER
;  KIND OF FILE.
;
RDDIMG:	MOVE	T1,[SIXBIT /DTED01/] ;DEFAULT FILE NAME
	MOVSI	T2,'BIN'	;DEFAULT EXTENSION
	PUSHJ	P,OPNFL0	;OPEN THE FILE (NO DIALOG)
	 JRST	DDT60		;CAN'T, RESTART.
	HRRZ	T1,.JBFF##	;BUILD CORE IMAGE AT END OF MEMORY
	MOVEM	T1,MEMORY
	SETZM	MEMLIM		;AS YET, MEMORY IS EMPTY
	AOS	.JBFF##		;WE HAVE USED THAT WORD
	PUSHJ	P,GETCOR	;BE SURE MEMORY IS ALLOCATED
	MOVEI	T1,^D36		;SET BYTE POINTER TO 36-BIT MODE
	DPB	T1,[POINT 6,IHD+1,11]
	MOVE	T1,IHD+2	;RECOMPUTE FIRST BUFFER COUNT
	IDIVI	T1,5
	MOVEM	T1,IHD+2
	SETO	T2,		;WILL BE INCREMENTED TO 0 BY FIRST CALL TO PUTBYI
;
; PROCESS ANOTHER FILE WORD
;
RDDIM1:	SOSL	IHD+2		;ANY DATA LEFT IN BUFFER?
	JRST	RDDIM2		;YES, PROCESS IT.
	IN			;NO, GET A NEW BUFFER
	 JRST	RDDIM1		;GOT ONE, PROCESS IT.
	JRST	RDUMP9		;ASSUME EOF, PRINT MEMORY SIZE

RDDIM2:	ILDB	T1,IHD+1	;GET WORD FROM FILE
	MOVSS	T1		;PUT PDP-11 BYTES IN RATIONAL ORDER
	PUSHJ	P,PUTBYI	;STORE FIRST BYTE IN MEMORY
	ROT	T1,-10
	PUSHJ	P,PUTBYI	;SECOND BYTE
	ROT	T1,-12
	PUSHJ	P,PUTBYI	;THIRD BYTE
	ROT	T1,-10
	PUSHJ	P,PUTBYI	;FOURTH BYTE
	JRST	RDDIM1		;PROCESS REST OF FILE
;
;HERE TO PUT A BYTE INTO A CORE DUMP
; CALL	PUSHJ	P,PUTBYT	WITH DATA IN T1, ADR IN T2
;
PUTBYI:	ADDI	T2,1		;PUT IN NEXT LOCATION
PUTBYT:	PUSHJ	P,SAVE4
	SKIPE	MEMORY		;DO WE HAVE A BASE ADDRESS FOR DUMPS ?
	  JRST	PUTBY4
	PUSH	P,T1
	MOVE	T1,.JBFF##	;ADDRESS OF FIRST FREE WORD
	MOVEM	T1,MEMORY
	AOS	.JBFF
	PUSHJ	P,GETCOR
	SETZM	MEMLIM
	SETZM	@MEMORY
	POP	P,T1
PUTBY4:	CAMG	T2,MEMLIM	;IS ADDRESS LARGER THAN PREVIOUS LIMIT ?
	  JRST	PUTBY8		;NO
	PUSH	P,T1		;SAVE DATA
	PUSH	P,T2		;SAVE ADDRESS
	AOS	T2,MEMLIM	;INCREASE LIMIT
	TRNE	T2,3		;ADVANCING TO NEXT WORD ?
	  JRST	PUTBY6
	AOS	.JBFF##		;GET ANOTHER WORD FOR CORE
	PUSHJ	P,GETCOR
PUTBY6:	SETZ	T1,		;FOR MEMORY
	PUSHJ	P,PUTBY9	;PUT ZERO BYTE INTO SIMULATED MEMORY
	POP	P,T2
	POP	P,T1
	JRST	PUTBY4

PUTBY8:	IORI	T1,400
PUTBY9:	IDIVI	T2,^D4
	ADD	T2,MEMORY	;RELOCATE
	ADD	T2,[	POINT 9,0,8
			POINT 9,0,17
			POINT 9,0,26
			POINT 9,0,35 ](T3)
	DPB	T1,T2
	POPJ	P,

SAVE4:	PUSH	P,T1
	PUSH	P,T2
	PUSH	P,T3
	PUSH	P,T4
	PUSHJ	P,@-4(P)
	POP	P,T4
	POP	P,T3
	POP	P,T2
	POP	P,T1
	POP	P,(P)
	POPJ	P,
;ROUTINES TO READ BOOT11 OR NETLDR DUMPS

;HERE TO FLUSH REST OF INPUT LINE
RDUMP0:	PUSHJ	P,FILCHR	;GET NEXT CHAR FROM DUMP
	  JRST	RDUMP9		;END OF DUMP
	CAIE	T1,12		;WE ARE LOOKING FOR A LINE FEED
	  JRST	RDUMP0		;AND DIDN'T FIND ONE
RDUMP1:	PUSHJ	P,INPOCT	;GET ADR
	  JRST	RDUMP9
	CAIN	T2,12		;SKIP EXTRA LINE FEEDS
	JRST	RDUMP1		; GENERATED BY DTELDR
	CAIE	T2,":"		;FINISHED READING ADDRESS ?
	  JRST	RDUMP0		;FLUSH LINE
	MOVEM	T1,DOT		;SAVE ADDRESS
RDUMP3:	PUSHJ	P,INPOCT	;GET DATA FOR LINE
	  JRST	RDUMP9		;END OF DUMP
	CAIE	T2,15		;CHECK FOR CR
	CAIN	T2,11		;CHECK FOR HT
	  JRST	RDUMP6		;THAT WAS DATA
	JRST	RDUMP0		;FLUSH LINE
RDUMP6:	MOVE	T2,DOT		;GET ADDRESS
	PUSHJ	P,PUTBYT
	LSH	T1,-^D8
	AOS	T2,DOT
	PUSHJ	P,PUTBYT
	AOJA	DOT,RDUMP3		;BACK FOR MORE DATA

RDUMP9:	MOVE	T1,MEMLIM	;HIGHEST ADDRESS READ
	MOVEM	T1,S..END	;END OF SEARCH
	SUBI	T1,1
	OUTSTR	[ASCIZ \ highest location is \]
	MOVE	T1,MEMLIM
	PUSHJ	P,OCTYPE
	OUTSTR	[ASCIZ \
\]
	POPJ	P,
	SUBTTL	Routines to write/read the DN200

IFN FTJSYS,<
;
; The SINs and SOUTs are merely replaced by calls to the BOOT JSYS.
; JFN is in this case used for the line number over which we are talking
; to the DN200.  It may be 0 or 1.

.BTLEN=2
.BTMSG=1
MAXBYT==274				;cannot send more than this
RTRIES==10				;Number of times to try for response
BTSIZ==20				;size of BOOT JSYS argument block
BTARG:	BLOCK	BTSIZ			;The BOOT JSYS argument block
RETRY:	BLOCK 1
RDLIN:	BLOCK 1
RDMSG:	BLOCK 1
RDLEN:	BLOCK 1
MOPMSG:	BLOCK	MAXBYT_<-2>+1	;ADD ONE TIL KDPSRV BUG FIXED;!!;
APRNUM:	BLOCK	1			; Processor serial number
KSFLG:	BLOCK	1			; Flag for 2020 (non-zero)

;routine to clear the BOOT JSYS argument block



CLRBOT:
	HRRI	T4,1+BTARG		;address of arg block
	HRLI	T4,-1(T4)		;address,,address+1 for blt
	SETZM	BTARG			;zero 1st word
	BLT	T4,BTSIZ-1+BTARG	;clear rest
	POPJ	P,

WR200:
	PUSHJ	P,CLRBOT		;clear
	MOVEI	T4,BTARG		;address of
	MOVEM	T1,.BTDTE(T4)		;line # over which we are conversing
	MOVMM	T3,.BTLEN(T4)		;the number of bytes
	MOVE	T4,[POINT 8,MOPMSG] ;WHERE TO COPY MESSAGE
	SKIPN	T3			;ZERO LENGTH NO ALLOWED
	 POPJ	P,
WRLOP:	ILDB	T1,T2			;GET A BYTE FROM INPUT
	IDPB	T1,T4			;DEPOSIT IN BUFFER
	AOJL	T3,WRLOP		;LOOP OVER ALL BYTES
	MOVEI	T2,BTARG		;ADDRESS OF ARG BLOCK FOR BOOT JSYS
	MOVE	T1,[POINT 8,MOPMSG]
	MOVEM	T1,.BTMSG(T2)		;STORE IN BOOT ARG BLOCK
	MOVEI	T1,21			;function code for write
	BOOT
	 ERJMP	.+2
	AOS	(P)
	POPJ	P,			;success return

RD200:	MOVEM	T1,RDLIN
	MOVEM	T2,RDMSG
	MOVEM	T3,RDLEN
	MOVEI	T4,RTRIES			;RETRY COUNTER
	MOVEM	T4,RETRY
RD2RTY:	PUSHJ	P,CLRBOT		;clear
	MOVEI	T4,BTARG		;address of
	MOVEM	T1,.BTDTE(T4)		;line # over which we are conversing
	MOVE	T2,[POINT 8,MOPMSG]
	MOVEM	T2,.BTMSG(T4)		;pointer to data
	MOVMM	T3,.BTLEN(T4)		;the number of bytes
	MOVE	T2,T4			;where the BOOT jsys expects arg address
	MOVEI	T1,22			;function code for read
	BOOT
	 ERJMP	RD2ERR
	SKIPLE	T1,.BTLEN(T4)		;POSITIVE MEANS WE GOT DATA
	JRST	RD2OK			;RETURN OKAY
	SKIPE	T1			;NEGATIVE MEANS
	JRST	[HRRZS	T1	;
		 CAIN	T1,1			;LINE CAME UP
		 JRST	RD2AGN			;READ NEXT MESSAGE
		 CAIN	T1,3			;TRANSMISSION COMPLETE
		 JRST	RD2AGN			;READ NEXT MESSAGE
		 JRST	RD2ERR			;ERROR
			]
	SOSGE	RETRY			;HAVE WE ALREADY TRIED TWICE?
	JRST	RD2ERR			;YES
	MOVEI	T1,^D100		;WAIT 1/10 SECOND
	DISMS
RD2AGN:	MOVE	T1,RDLIN
	MOVE	T2,RDMSG
	MOVE	T3,RDLEN
	JRST	RD2RTY			;RETRY
RD2OK:	MOVN	T3,T1		;GET RECEIVED LENGTH
	MOVE	T4,[POINT 8,MOPMSG]
	MOVE	T2,RDMSG
	CAMN	T2,T4			;IF SOURCE AND DESTINATION SAME
	JRST	RD2RET			;NO NEED TO COPY
RDLOP:
	ILDB	T1,T4			;GET A BYTE FROM MESSAGE
	IDPB	T1,T2			;PUT WHERE USER WANTS IT
	AOJL	T3,RDLOP
RD2RET:	AOS	(P)
RD2ERR:	POPJ	P,			;success return

;ROUTINE TO FLUSH THE DDCMP BUFFERS

FLSHFE:
	MOVE	T1,D60JFN	;THE FE LINE
	MOVE	T2,[POINT 8,MOPMSG] ;WHERE TO PUT FLUSHD DATA
	MOVEI	T3,MAXBYT	;MAXIMUM SIZE OF MESSAGE
	CALL	RD200		;DO THE FLUSH
	 JFCL			;IGNORE ERRORS
	JUMPN	T1,FLSHFE	;IF MORE , FLUSH THAT TOO
	POPJ	P,		;RETURN WHEN DONE
	SUBTTL	PRCTYP -- Routine to type the processor

; Routine - PRCTYP
;
; Function -
;
;	This routine determines whether we are running on a KL or KS system.
;
; Parameters - none
;
; Returns - True always
;
;	APRNUM/	Contains the processor serial number
;	KSFLG/	0 if KL, non-zero if KS

PRCTYP:	PUSH	P,T1			; Save some registers
	PUSH	P,T2

	MOVE	T1,[SIXBIT \APRID\]	; Table in TOPS20 to check
	SYSGT				;  for the processor serial number
	MOVEM	T1,APRNUM		; Save the processor serial number
	SETZM	KSFLG			; Default to KL
	CAIL	T1,^d4096		; Test for a KS serial number
	 SETOM	KSFLG			;  Yes .. so set such an indicator
	POP	P,T2			; Restore registers
	POP	P,T1
	POPJ	P,
   > ;End if TOPS20 (FTJSYS)
;PDP11 WORDS ARE READ INTO PDP10 HALF WORDS WITH AN INCREMENTING BYTE POINTER
; IF PDP11 WORD WAS READ IN THE BIT 200000 OF THE HALF WORD WILL BE SET
; IF PDP11 WORD IS MODIFIED, BIT 400000 OF THE HALF WORD WILL BE SET
	IFN FT2SEG < RELOC >
MEMORY:	EXP	Z		;ADDRESS OF DUMP MEMORY
MEMLIM:	EXP	Z		;HIGHEST LOCATION IN DUMP
	IFN FT2SEG < RELOC >
;TRANSLATION TABLE FROM EBCDIC TO ASCII

EB.TRN:	BYTE	(8)000,001,002,003,000,011,000,177		;000-007
	BYTE	(8)000,000,000,013,014,015,000,000		;010-017
	BYTE	(8)000,021,022,000,000,000,000,000		;020-027
	BYTE	(8)000,000,000,000,000,000,000,000		;030-037
	BYTE	(8)000,000,000,000,000,000,000,000		;040-047
	BYTE	(8)000,000,000,000,000,000,000,000		;050-057
	BYTE	(8)000,000,000,000,000,000,000,000		;060-067
	BYTE	(8)000,000,000,000,000,000,000,000		;070-077
	BYTE	(8)040,000,000,000,000,000,000,000		;100-107
	BYTE	(8)000,000,133,056,074,050,053,041		;110-117
	BYTE	(8)046,000,000,000,000,000,000,000		;120-127
	BYTE	(8)000,000,135,044,052,051,073,136		;130-137
	BYTE	(8)055,057,000,000,000,000,000,000		;140-147
	BYTE	(8)000,000,174,054,045,137,076,077		;150-157
	BYTE	(8)000,000,000,000,000,000,000,000		;160-167
	BYTE	(8)000,140,072,043,100,047,075,042		;170-177
	BYTE	(8)000,141,142,143,144,145,146,147		;200-207
	BYTE	(8)150,151,000,000,000,000,000,000		;210-217
	BYTE	(8)000,152,153,154,155,156,157,160		;220-227
	BYTE	(8)161,162,000,000,000,000,000,000		;230-237
	BYTE	(8)000,176,163,164,165,166,167,170		;240-247
	BYTE	(8)171,172,000,000,000,000,000,000		;250-257
	BYTE	(8)000,000,000,000,000,000,000,000		;260-267
	BYTE	(8)000,000,000,000,000,000,000,000		;270-277
	BYTE	(8)173,101,102,103,104,105,106,107		;300-307
	BYTE	(8)110,111,000,000,000,000,000,000		;310-317
	BYTE	(8)175,112,113,114,115,116,117,120		;320-327
	BYTE	(8)121,122,000,000,000,000,000,000		;330-337
	BYTE	(8)134,000,123,124,125,126,127,130		;340-347
	BYTE	(8)131,132,000,000,000,000,000,000		;350-357
	BYTE	(8)060,061,062,063,064,065,066,067		;360-367
	BYTE	(8)070,071,000,000,000,000,000,000		;370-377
	SUBTTL	STATE TABLES
STATE0:	EXP LOOP  ,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;00-07
	EXP ILLCHR,COMHT ,COMLF ,ILLCHR,ILLCHR,LEVEL0,ILLCHR,ILLCHR	;10-17
	EXP ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;20-27
	EXP EXPXOR,ILLCHR,COMCZ ,ESCAPE,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;30-37
	EXP LOOP  ,ILLCHR,ILLCHR,ILLCHR,ASSYMB,ILLCHR,ILLCHR,ILLCHR	;40-47
	EXP ILLCHR,ILLCHR,ILLCHR,EXPLUS,ILLCHR,EXPMIN,ASSYMB,ILLCHR	;50-57
	EXP ASSNUM,ASSNUM,ASSNUM,ASSNUM,ASSNUM,ASSNUM,ASSNUM,ASSNUM	;60-67
	EXP ASSDEC,ASSDEC,ILLCHR,ILLCHR,ILLCHR,EQUALS,ILLCHR,ILLCHR	;70-77
	EXP ILLCHR,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB	;100-107
	EXP ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB	;110-117
	EXP ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB	;120-127
	EXP ASSYMB,ASSYMB,ASSYMB,ILLCHR,COMBSL,ILLCHR,COMARR,ILLCHR	;130-137
	EXP ILLCHR,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB	;140-147
	EXP ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB	;150-157
	EXP ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB	;160-167
	EXP ASSYMB,ASSYMB,ASSYMB,ILLCHR,ILLCHR,ILLCHR,ILLCHR,COMRUB	;170-177
;STATE TABLE WHEN BUILDING AN EXPRESSION

STATEE:	EXP LOOP  ,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;00-07
	EXP ILLCHR,STEHT ,STELF ,ILLCHR,ILLCHR,STECR ,ILLCHR,ILLCHR	;10-17
	EXP ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;20-27
	EXP EXPXOR,ILLCHR,COMCZ ,ESCEXP,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;30-37
	EXP EXPLUS,EXPIOR,ILLCHR,ILLCHR,ASSYMB,ILLCHR,EXPAND,EXPDIV	;40-47
	EXP ILLCHR,ILLCHR,EXPMUL,EXPLUS,ILLCHR,EXPMIN,ASSPER,OPNLOC	;50-57
	EXP ASSNUM,ASSNUM,ASSNUM,ASSNUM,ASSNUM,ASSNUM,ASSNUM,ASSNUM	;60-67
	EXP ASSDEC,ASSDEC,DEFSYM,ILLCHR,SLOWLM,EXPEQU,SUPLIM,ILLCHR	;70-77
	EXP ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB	;100-107
	EXP ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB	;110-117
	EXP ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB	;120-127
	EXP ASSYMB,ASSYMB,ASSYMB,ILLCHR,COMBSE,ILLCHR,STEARR,BKARRW	;130-137
	EXP ILLCHR,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB	;140-147
	EXP ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB	;150-157
	EXP ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB,ASSYMB	;160-167
	EXP ASSYMB,ASSYMB,ASSYMB,ILLCHR,ILLCHR,ILLCHR,ILLCHR,COMRUB	;170-177
;STATE TABLE WHEN USER TYPES ALTMODE

STATSC:	EXP LOOP,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;00-07
	EXP ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;10-17
	EXP ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;20-27
	EXP ILLCHR,ILLCHR,COMCZ ,ESCESC,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;30-37
	EXP ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;40-47
	EXP ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;50-57
	EXP ESC..0,ESC..0,ESC..0,ESC..0,ESC..0,ESC..0,ESC..0,ESC..0	;60-67
	EXP ESC..0,ESC..0,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;70-77
	EXP ILLCHR,ESC..A,ESC..B,ESC..C,ESC..D,ILLCHR,ILLCHR,ESC..G	;100-107
	EXP ILLCHR,ESC..I,ILLCHR,ESC..K,ILLCHR,ESC..M,ESC..N,ILLCHR	;110-117
	EXP ESC..P,ILLCHR,ESC..R,ESC..S,ESC..T,ILLCHR,ESC..V,ESC..W	;120-127
	EXP ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR	;130-137
	EXP ILLCHR,ESC..A,ESC..B,ESC..C,ESC..D,ILLCHR,ILLCHR,ESC..G	;140-147
	EXP ILLCHR,ESC..I,ILLCHR,ESC..K,ILLCHR,ESC..M,ESC..N,ILLCHR	;150-157
	EXP ESC..P,ILLCHR,ESC..R,ESC..S,ESC..T,ILLCHR,ESC..V,ESC..W	;160-167
	EXP ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,ILLCHR,COMRUB	;170-177
	IFN FT2SEG < RELOC >
GOTO:	EXP	0	;STARTING ADDRESS FOR PROGRAM
NODE:	Z		;NAME OR NODE NUMBER WE ARE WORKING WITH
LINE:	Z		;LINE NUMBER ON NODE WE ARE WORKING WITH
DATA:	BLOCK	^D20
SBEGIN:	EXP	0	;FIRST ADDRESS FOR SEARCH
S..END:	EXP	0	;LAST ADDRESS FOR SEACRH
S.WORD:	EXP	0	;WORD TO SEARCH FOR
SZMASK:	EXP	1	;NUMBER OF WORDS IN MASK
S.MASK:	EXP	177777		;MASK FOR WORD SEARCH
	EXP	177777		;MORE OF MASK
	EXP	177777		;MORE OF MASK
	EXP	177777		;MORE OF MASK
	EXP	177777		;MORE OF MASK
	EXP	177777		;MORE OF MASK
	EXP	177777		;MORE OF MASK
	EXP	177777		;MORE OF MASK
INPOPR:	EXP	0	;INPUT OPERATION (0=+,1=-,2=*,3=',4=!,5=&,6=^X)
BYTCNT:	XWD	1,1	;REPEITION COUNTS FOR OUPUT BYTES ETC.
O.MODE:	EXP	0	;OUTPUT MODE LH = PERMANENT, RH = CURRENT
			; (0=SYMBOLIC, 1=ADDRESS, 2=NUMERIC, 3=BYTES,
			;  4=ASCII TEXT, 5=EBCDIC TEXT)
ORADIX:	^D8,,^D8	;OUTPUT RADIX
			; LH IS PERMANENT SETTING, RH IS CURRENT
LSTADR:	Z		;LAST ADDRESS DISPLAYED
;THE CACHE IS SO WORK OVER SYNCHRONOUS LINE WILL BE FASTER
CACHEL:	0		;CACHE LIMIT, I.E. 1ST NONEXISTEN BYTE ADR IN CACHE
CACHEA:	0		;ADDRESS REPRESENTED BY FIRST ADR IN CACHE
	CACHSZ=400		;NUMBER OF WORDS IN CACHE
CACHE:	BLOCK	<CACHSZ/4>
IFNDEF PDLEN <PDLEN=40>
PDL:	BLOCK	PDLEN

	LIT
	VAR
	SUBTTL	SYMBOL TABLES

DEFINE	X	(VAL,BIT,NAME,FLAG) <
	EXP	.+1
	SIXBIT	\NAME\
	BYTE	(4)<<BIT>-1>(14)FLAG(18)VAL
>;END OF DEFINE X
SYMBEG:	X	000000,^D16,HALT,<SMF.IN>
	X	000001,^D16,WAIT,<SMF.IN>
	X	000002,^D16,RTI,<SMF.IN>
	X	000003,^D16,BPT,<SMF.IN>
	X	000004,^D16,IOT,<SMF.IN>
	X	000005,^D16,RESET,<SMF.IN>
	X	000006,^D16,RTT,<SMF.IN>
	X	000100,^D10,JMP,<SMF.IN!SMF.DD>
	X	000200,^D13,RTS,<SMF.IN!SMF.RT>
	X	000230,^D13,SPL,<SMF.IN!SMF.PL>
	X	000240,^D16,NOP,<SMF.IN>
	X	000241,^D16,CLC,<SMF.IN>
	X	000242,^D16,CLV,<SMF.IN>
	X	000244,^D16,CLZ,<SMF.IN>
	X	000250,^D16,CLN,<SMF.IN>
	X	000257,^D16,CCC,<SMF.IN>
	X	000261,^D16,SEC,<SMF.IN>
	X	000262,^D16,SEV,<SMF.IN>
	X	000264,^D16,SEZ,<SMF.IN>
	X	000270,^D16,SEN,<SMF.IN>
	X	000277,^D16,SCC,<SMF.IN>
	X	000300,^D10,SWAB,<SMF.IN!SMF.DD>
	X	000400,^D8,BR,<SMF.IN!SMF.XX>
	X	001000,^D8,BNE,<SMF.IN!SMF.XX>
	X	001400,^D8,BEQ,<SMF.IN!SMF.XX>
	X	002000,^D8,BGE,<SMF.IN!SMF.XX>
	X	002400,^D8,BLT,<SMF.IN!SMF.XX>
	X	003000,^D8,BGT,<SMF.IN!SMF.XX>
	X	003400,^D8,BLE,<SMF.IN!SMF.XX>
	X	004000,^D7,JSR,<SMF.IN!SMF.DD!SMF.JS>
	X	005000,^D10,CLR,<SMF.IN!SMF.DD>
	X	005100,^D10,COM,<SMF.IN!SMF.DD>
	X	005200,^D10,INC,<SMF.IN!SMF.DD>
	X	005300,^D10,DEC,<SMF.IN!SMF.DD>
	X	005400,^D10,NEG,<SMF.IN!SMF.DD>
	X	005500,^D10,ADC,<SMF.IN!SMF.DD>
	X	005600,^D10,SBC,<SMF.IN!SMF.DD>
	X	005700,^D10,TST,<SMF.IN!SMF.DD>
	X	006000,^D10,ROR,<SMF.IN!SMF.DD>
	X	006100,^D10,ROL,<SMF.IN!SMF.DD>
	X	006200,^D10,ASR,<SMF.IN!SMF.DD>
	X	006300,^D10,ASL,<SMF.IN!SMF.DD>
	X	006400,^D10,MARK,<SMF.IN!SMF.MK>
	X	006500,^D10,MFPI,<SMF.IN!SMF.DD>
	X	006600,^D10,MTPI,<SMF.IN!SMF.DD>
	X	006700,^D10,SXT,<SMF.IN!SMF.DD>
	X	010000,^D4,MOV,<SMF.IN!SMF.SS>
	X	020000,^D4,CMP,<SMF.IN!SMF.SS>
	X	030000,^D4,BIT,<SMF.IN!SMF.SS>
	X	040000,^D4,BIC,<SMF.IN!SMF.SS>
	X	050000,^D4,BIS,<SMF.IN!SMF.SS>
	X	060000,^D4,ADD,<SMF.IN!SMF.SS>
	X	070000,^D7,MUL,<SMF.IN!SMF.JS!SMF.DD>
	X	071000,^D7,DIV,<SMF.IN!SMF.JS!SMF.DD>
	X	072000,^D7,ASH,<SMF.IN!SMF.JS!SMF.DD>
	X	073000,^D7,ASHC,<SMF.IN!SMF.JS!SMF.DD>
	X	074000,^D7,XOR,<SMF.IN!SMF.JS!SMF.DD>
	X	075000,^D13,FADD,<SMF.IN!SMF.RT>
	X	075010,^D13,FSUB,<SMF.IN!SMF.RT>
	X	075020,^D13,FMUL,<SMF.IN!SMF.RT>
	X	075030,^D13,FDIV,<SMF.IN!SMF.RT>
	X	077000,^D7,SOB,<SMF.IN!SMF.SB>
	X	100000,^D8,BPL,<SMF.IN!SMF.XX>
	X	100400,^D8,BMI,<SMF.IN!SMF.XX>
	X	101000,^D8,BHI,<SMF.IN!SMF.XX>
	X	101400,^D8,BLOS,<SMF.IN!SMF.XX>
	X	102000,^D8,BVC,<SMF.IN!SMF.XX>
	X	102400,^D8,BVS,<SMF.IN!SMF.XX>
	X	103000,^D8,BCC,<SMF.IN!SMF.XX>
	X	103000,^D8,BHIS,<SMF.IN!SMF.XX>
	X	103400,^D8,BCS,<SMF.IN!SMF.XX>
	X	103400,^D8,BLO,<SMF.IN!SMF.XX>
	X	104000,^D8,EMT,<SMF.IN!SMF.EM>
	X	104400,^D8,TRAP,<SMF.IN!SMF.EM>
	X	105000,^D10,CLRB,<SMF.IN!SMF.DD>
	X	105100,^D10,COMB,<SMF.IN!SMF.DD>
	X	105200,^D10,INCB,<SMF.IN!SMF.DD>
	X	105300,^D10,DECB,<SMF.IN!SMF.DD>
	X	105400,^D10,NEGB,<SMF.IN!SMF.DD>
	X	105500,^D10,ADCB,<SMF.IN!SMF.DD>
	X	105600,^D10,SBCB,<SMF.IN!SMF.DD>
	X	105700,^D10,TSTB,<SMF.IN!SMF.DD>
	X	106000,^D10,RORB,<SMF.IN!SMF.DD>
	X	106100,^D10,ROLB,<SMF.IN!SMF.DD>
	X	106200,^D10,ASRB,<SMF.IN!SMF.DD>
	X	106300,^D10,ASLB,<SMF.IN!SMF.DD>
	X	106400,^D10,MTPS,<SMF.IN!SMF.DD>
	X	106500,^D10,MFPD,<SMF.IN!SMF.DD>
	X	106600,^D10,MTPI,<SMF.IN!SMF.DD>
	X	106700,^D10,MFPS,<SMF.IN!SMF.DD>
	X	110000,^D4,MOVB,<SMF.IN!SMF.SS>
	X	120000,^D4,CMPB,<SMF.IN!SMF.SS>
	X	130000,^D4,BITB,<SMF.IN!SMF.SS>
	X	140000,^D4,BICB,<SMF.IN!SMF.SS>
	X	150000,^D4,BISB,<SMF.IN!SMF.SS>
	X	160000,^D4,SUB,<SMF.IN!SMF.SS>
;
; FLOATING POINT (17XXXX) OMITTED IN THIS VERSION
;
	EXP	Z
SYMEND:	EXP	.-3

DDTEND:	END	DDT60