Google
 

Trailing-Edge - PDP-10 Archives - SRI_NIC_PERM_SRC_3_19910112 - utilities/crsref.mac
There are no other files named crsref.mac in the archive.
TITLE CRSREF - PRODUCE CROSS REFERENCED OUTPUT FILE
SUBTTL	A. K. OLSON	ILLIAC IV PROJECT - NASA AMES RES. CTR.

	IFNDEF GTJFN,<SEARCH MONSYM>

SUMEX==1

IFNDEF SUMEX,<SUMEX==0>
IFN SUMEX,<FULLW==1>		;!! MAH @ SUMEX 4/75 !! FULLWORD/LOCATION SW.
IFE SUMEX,<FULLW==0>

	CRVER==^D17		;VERSION #

;	COMMAND FORMAT:
;
;	RUN CRSREF
;	*<OUTPUT FILE>_<SWITCHES><INPUT FILE>


;	ACCUMULATORS:

	F=0		;FLAGS
	P=17		;PUSH DOWN STACK
	C=2		;CHARACTER REGISTER
	CC=16		;CHARACTER CLASS
	L=15		;LINE NUMBER
	CNT=14		;COUNTER
	SP=13		;SYMBOL POINTER
	SYM=12		;SYMBOL ACCUMULATOR
	T1=5		;TEMP #1
	T2=6
	T3=7		;TEMP #3
	CTXT=10
	S=11		;SYMBOL PACKET INDEX


	LOGSTL==^D10	;LOG2(SYMBOL TABLE LENGTH)
	STL==1_LOGSTL	;SYMBOL TABLE LENGTH
IFN FULLW,<PKTL==^D8>	;!! MAH @ SUMEX 4/75 !! FULLWORD/LOCATION
IFE FULLW,<PKTL==^D4>	;SYMBOL PACKET LENGTH
	LINWTH==^D80	;LINE WIDTH
	MAXL==^D55	;max lines/page
IFN FULLW,<MAXFIL==^D100> ;MAX # OF FILES

;	MACROS AND OPDEFS:

	OPDEF	.BIN[PUSHJ P,DOBIN]
	OPDEF	.BOUT[PUSHJ P,DOBOUT]

	DEFINE	STEST(SWITCH,FLAG)
<	CAIE	C,SWITCH
	CAIN	C,SWITCH+40
	TRC	F,FLAG>

	DEFINE	GETC
<	TLZE	F,.SVC
	SKIPA	2,SVC
	.BIN

IFN FULLW,<TRNE	F,.LST>
	.BOUT
	HLRZ	CC,CLASS(C)>

	DEFINE	ISYM
<	SETZ	SYM,
	MOVEI	CNT,6
	MOVE	SP,[POINT 6,SYM]>

	DEFINE	ACCUM
<	SOJL	CNT,.+3
	HRRZ	T1,CLASS(C)
	IDPB	T1,SP>
;	FLAG BITS:

;	LH(F):

	.NSMAC=(1B1)	;NEXT SYMBOL IS A MACRO NAME
	.INS=(1B2)	;INSIDE STRING (ASCII, ETC)
	.MULTF=(1B3)	;PROCESS MULTIPLE INPUT FILES
	.OFOPN==(1B4)	;OUTPUT FILE ALREADY OPEN
	.BEG==(1B5)	;BEGINNING OF OUTPUT FILE
	.SVC==(1B6)	;USE SAVED CHARACTER

;	RH(F):

	.OP=1B18	;PROCESS OPCODES
	.PSOP=1B19	;PROCESS PSEUDO-OPS
	.UUO=1B20	;PROCESS DEC UUO MNEMONICS
	.JSYS=1B21	;PROCESS BBN JSYS MNEMONICS
	.MAC=1B22	;PROCESS MACRO NAMES
	.COM=1B23	;PROCESS SYMBOLS INSIDE COMMENTS
	.STR=1B24	;PROCESS SYMBOLS INSIDE STRINGS
	.SYM=1B25	;PROCESS ORDINARY SYMBOLS
	.SPH=1B26	;SUPPRESS PAGE HEADINGS
IFN FULLW,<.LST=1B27>	;REQUEST LISTING

	.TYFLD==7B35	;BITS 33-35 CONTAIN PSEUDO-OP TYPE CODE
	.TYMAC==1B35	;DEFINE
	.TYASC==2B35	;ASCII, ASCIZ OR SIXBIT
	.TYTTL==3B35	;TITLE OR SUBTTL

	LOC	137
	CRVER
	RELOC
BEGIN:	MOVEI	1,400000	;WE NOW HAVE THE PRIMARY
	GPJFN			;JFNS FOR THIS FORK
	MOVEM	2,PJFNS		;SAVE THEM
	SETZM	CMDFIL		;CLEAN UP FIRST
START:	SETO	1,		;ALL JFNS
	SKIPE	CMDFIL		;DO WE HAVE A COMMAND FILE
	RLJFN			;YES THEN RELEASE ALL CLOSED FILES
	RESET			;ELSE CLEAR THE WORLD
	MOVE	1,[SIXBIT "CRSREF"]
	SETNM
	MOVE	P,[IOWD PSL,PS]	;INITIALIZE STACK
	SETZ	L,		;INITIALIZE LINE NUMBER
	MOVEI	1,FFREE-PKTL	;INITIALIZE FREE SPACE POINTER
	MOVEM	1,FREE
	SETZM	ST
	MOVE	1,[ST,,ST+1]	;CLEAR SYMBOL TABLE LIST HEADERS
	BLT	1,ST+STL-1
IFN FULLW,<			;!! MAH @ SUMEX 4/75 !! PAGE.LINE NUMBERS
	MOVE	1,[POINT 7,NAMBUF] ;INITIALIZE NAME BUFFER
	MOVEM	1,NAMBP
	SETZM	FILNO		;INIT FILE NUMBER 
>
	SETO	1,
	MOVE	2,[400000,,IPAGE/1000]
	setz	3,
	PMAP
	AOSE	VERSW
	JRST	ST0
	HRROI	1,[ASCIZ "Version #"]
	PSOUT
	MOVEI	1,100
	MOVE	2,137
	MOVEI	3,^D10
	NOUT
	JFCL
	hrroi	1,[asciz /
/]
	psout
	MOVEI	1,400000
	MOVE	2,[LEVTAB,,CHNTAB]
	SIR			;SETUP PSI SYSTEM TABLES
	EIR			;ENABLE PSI SYSTEM
	MOVSI	2,(1B10)
	AIC			;ENABLE EOF CHANNEL
ST0:	MOVE	F,ISTATE	;INITIALIZE STATE
	MOVEI	1,"*"		;TYPE PROMPT CHARACTER
	PBOUT
	MOVEI	1,100
	BIN
	CAIE	2,"@"		;INDIRECT COMMAND FILE?
	JRST ST00		;NO
	MOVSI	1,3		;SHORT GTJFN
	MOVE	2,[100,,101]
	GTJFN
	JRST [	PUSHJ P,TYERR	;RETURN TO COMMAND LEVEL
		JRST ST0]
	PUSH	P,1		;SAVE IT
	MOVE	2,[70000,,200000] ;READ 7BIT
	OPENF
	JRST [	POP P,1		;CANT OPEN
		RLJFN		;THEN RELEASE IT
		JFCL
		PUSHJ P,TYERR
		JRST ST0]
	SKIPE	CMDFIL		;ARE WE IN A COMMAND FILE NOW?
	JRST [	MOVEI	1,400000	;YES
		GPJFN
		HLRZ	1,2		;THEN GET OLD PRIMARY INPUT
		CLOSF			;AND CLOSE IT
		JFCL
		JRST .+1]
	SETOM	CMDFIL		;SAY WE HAVE A COMMAND FILE
	POP	P,1
	HRL	2,1		;THE NEW PRIMARY INPUT
	HRR	2,PJFNS		;THE OLD PRIMARY OUTPUT
	MOVEI	1,400000	;FOR THIS FORK
	SPJFN			;ARE NOW THE NEW PRIMARYS
	JRST ST01
ST00:	BKJFN
	JRST ERROR
ST01:	MOVEI	1,OJFNB
	SETZ	2,
	GTJFN
	JRST	[PUSH P,1
		 MOVEI	1,100
		 BKJFN
		 JRST ERROR
		 BIN
		 POP P,1
		CAIE 2,"="
		 CAIN 2,"_"
		 JRST [MOVEI 1,101
		       JRST ST1]
		 CAIN 1,GJFX33
		 JRST [CAIE 2,37
		       CAIN 2,15
		       JRST [HALTF
			     JRST START]
		       PUSHJ P,TYERR
		       JRST ST0]
		 CAIN 2,32
		 JRST [HALTF
		       JRST START]
		 PUSHJ P,TYERR
		 JRST ST0]
ST1:	HRRZM	1,OJFN		;SAVE OUTPUT JFN
	MOVEI	1,100
	BKJFN		;BACK UP TO DELIMITER
	JRST	ERROR
	BIN
	CAIN	C,33	;ALTMODE?
	BIN		;YES. IGNORE IT
	CAIE	C,"_"	;LEFT ARROW?
	CAIN	C,"="	;OR A = ?
	SKIPA
	JRST	[PUSHJ P,GOBBLE
		 HRROI 1,[ASCIZ /Illegal command!
/]
		 PSOUT
		 JRST START]



START1:	MOVE	P,[IOWD PSL,PS]
	MOVEI	1,100
L1:	BIN			;GET DELIMITER
	CAIE	C,"/"		;ANY MORE SWITCHES?
	JRST	[BKJFN		;NO. BACK UP INPUT STREAM
		 JRST ERROR
		 JRST L2]	;PROCESS INPUT FILE
	BIN			;GET SWITCH CHARACTER
	STEST	"O",.OP
IFN FULLW,<STEST "L",.LST>
	STEST	"P",.PSOP
;	STEST	"U",.UUO
;	STEST	"J",.JSYS
	STEST	"M",.MAC
	STEST	"C",.COM
	STEST	"S",.STR
	STEST	"N",.SYM
	STEST	"H",.SPH
	JRST	L1		;CHECK FOR MORE SWITCHES
L2:	MOVEI	1,IJFNB
	SETZ	2,
	GTJFN
	JRST	[PUSHJ P,TYERR
		 JRST L2]
	HRRZM	1,IJFN		;SAVE INPUT JFN
	PUSHJ	P,OPENI		;OPEN INPUT FILE
	MOVEI	1,100
	BKJFN			;BACKUP INPUT
	JRST	ERROR
	MOVEI	T1,1
	MOVEM	T1,PAGE		;INITIALIZE PAGE NUMBER
	SETOM	SPAGE		;INITIALIZE SUB-PAGE NUMBER
	MOVE	T1,[ASCII /     /]
	MOVEI	T2,PHEAD2-PHEAD1
	MOVEM	T1,PHEAD1(T2)	;INITIALIZE HEADER
	SOJGE	T2,.-1
	MOVEI	T1,MAXL
	MOVEM	T1,LINE		;INITIALIZE LINE NUMBER
	HRROI	1,PHEAD1
	MOVE	2,IJFN
	MOVE	3,[2B5+1B8+1B11+2B14+1B35]
	JFNS			;STORE FILE NAME IN HEADER
	MOVEI	T1," "
	IDPB	T1,1
	HRROI	1,PHEAD2
	SETO	2,
	MOVSI	3,(1B10)
	ODTIM			;STORE DATE AND TIME
	IDPB	T1,1
IFN FULLW,<			;!! MAH @ SUMEX 4/75 !! PAGE.LINE NUMBERS
	HRRZ	1,NAMBP		;STORE NAME IN NAME BUFFER
	CAIL	1,MAXNBP
	 JRST	[MOVEI 1,400000
		MOVE 2,PJFNS
		SPJFN
		HRROI 1,[ASCIZ /
Ran out of file name buffer space...sorry...restarting./]
		PSOUT
		JRST START]
	MOVE	T1,FILNO
	MOVE	1,NAMBP
	MOVEM	1,FILBP(T1)	;NOTE STRING START OF THIS FILES NAME
	MOVE	2,IJFN
	MOVE	3,[2B5+1B8+1B11+2B14+1B35]
	JFNS
	IBP	1
	MOVEM	1,NAMBP
	AOS	FILNO		;INC TO NEW FILE NUMBER
	SETZM	NLINE		;INIT REAL LINE NUMBER
> ;END IFN FULLW
	MOVEI	1,100
L2AA:	BIN			;INPUT DELIMITER
	CAIN	C,33		;ALTMODE?
	BIN			;YES. IGNORE IT
	CAIN	C,","		;MULTIPLE FILES?
	JRST	[TLO F,.MULTF	;YES. SET SWITCH
		 JRST L2AA]
	CAIE	C,15		;CR
	CAIN	C,37		;OR EOL?
	 JRST	L2A		;YES, GO AND PROCESS
	CAIG	C," "		;IS IT A PRINTABLE CHAR
	JRST L2AA		;NO, GET ANOTHER
	BKJFN			;BACKUP OVER PRINTABLE FOR GTJFN
	JRST ERROR


L2A:	TLOE	F,.OFOPN	;OUTPUT FILE ALREADY OPEN?
	JRST   [
IFN FULLW,<
		TRNN F,.LST	;LISTING?
		 JRST L2B	;NO
>
		MOVEI C,15	;YES. OUTPUT CRFF
		.BOUT
		MOVEI C,14
		.BOUT
		JRST L2B]
	PUSHJ	P,OPENO		;OPEN OUTPUT FILE
	PUSHJ	P,ISTAB		;INITIALIZE SYMBOL TABLES
	ISYM			;INITIALIZE SYMBOL
	MOVEI	C,12		;DUMMY UP AN INITIAL LINE FEED
L2B:	HLRZ	CC,CLASS(C)
	JRST	S1(CC)		;TAKE INITIAL ACTION
S0:	GETC			;GET NEXT CHARACTER
	JRST	.+1(CC)		;TAKE APPROPRIATE ACTION
S1:	JRST	S0		;IGNORE CHARACTER
	JRST	S20		;";" OR """ OR "'"
	JRST	S4		;LETTER, PROCESS IT
	JRST	S3		;DIGIT, IGNORE IT
	JRST	S4		;"$" OR "%", PROCESS IT
	JRST	S6		;".", CONSIDER IT
	JRST	S2		;")" OR "^" OR RIGHT ANGLE BRACKET
	JRST	S25		;LF OR EOL, PROCESS IT
S2:	GETC			;GET NEXT CHARACTER
	JRST	.+1(CC)		;TAKE ACTION
	JRST	S0
	JRST	S20
	JRST	S2
	JRST	S2
	JRST	S4
	JRST	S6
	JRST	S2
	JRST	S25
S3:	GETC			;GET NEXT CHARACTER
	JRST	.+1(CC)		;TAKE ACTION
	JRST	S0
	JRST	S20
	JRST	S3
	JRST	S3
	JRST	S3
	JRST	S3
	JRST	S2
	JRST	S25
S4:	ACCUM			;ACCUMULATE SYMBOL CHARACTER
S5:	GETC			;GET NEXT CHARACTER
	JRST	.+1(CC)		;TAKE ACTION
	JRST	S9		;END OF SYMBOL
	JRST	S9		;END OF SYMBOL
	JRST	S4		;ACCUMULATE LETTER
	JRST	S4		;ACCUMULATE DIGIT
	JRST	S4		;ACCUMULATE "$" OR "%"
	JRST	S4		;ACCUMULATE "."
	JRST	S9		;END OF SYMBOL
	JRST	S9		;EOL, END OF SYMBOL
S6:	ACCUM			;ACCUMULATE CHARACTER
	GETC			;GET NEXT CHARACTER
	JRST	.+1(CC)		;TAKE ACTION
	JRST	S7		;NO GOOD
	JRST	S7		;NO GOOD
	JRST	S8		;OKAY WE'VE GOT "."LETTER
	JRST	S7		;NO GOOD
	JRST	S8		;OKAY WE'VE GOT "."("$"/"%")
	JRST	S8		;OKAY WE'VE GOT ".."
	JRST	S7		;NO GOOD
;	JRST	S7		;EOL, NO GOOD
S7:	ISYM			;SCRUB THE SYMBOL
	JRST	S1(CC)		;TAKE APPROPRIATE ACTION
S8:	ACCUM			;ACCUMULATE SYMBOL
	GETC			;GET NEXT CHARACTER
	JRST	.+1(CC)		;TAKE APPROPRIATE ACTION
	JRST	S9		;END OF SYMBOL
	JRST	S9		;END OF SYMBOL
	JRST	S8		;ACCUMULATE LETTER
	JRST	S8		;ACCUMULATE DIGIT
	JRST	S8		;ACCUMULATE "$" OR "%"
	JRST	S8		;ACCUMULATE "."
	JRST	S9		;END OF SYMBOL
;	JRST	S9		;END OF SYMBOL
S9:	MOVE	CTXT,L		;CLEAR SYMBOL CONTEXT
	CAIE	C,":"		;CHECK FOR VALUE ASSIGNMENT
	CAIN	C,"="
	MOVN	CTXT,L
	CAIN	C,"#"
	JRST	[.BIN		;DISTINGUISH VARS FROM EXTERNS
		 CAIN C,"#"
		 JRST [.BOUT
		       JRST .+1]
		 TLO F,.SVC
		 MOVEM C,SVC
		 MOVN CTXT,L
		 JRST .+1]
IFN FULLW,<			;!! MAH @ SUMEX 4/75 !! PAGE.LINE NUMBERING
	SETZ	T1,
	MOVE	T2,FILNO
	DPB	T2,PFILN
	MOVE	T2,PAGE
	DPB	T2,PPAGE
	MOVE	T2,NLINE
	DPB	T2,PLINE
	SKIPGE	CTXT
	MOVNS	T1
	MOVE	CTXT,T1
> ;END IFN FULLW
	PUSHJ	P,FNDSYM	;S = SYMBOL PACKET ADDRESS
	HLRZ	T1,(S)		;T1 = TYPE OF SYMBOL
	TDNN	T1,F		;PROCESSING THIS TYPE?
	JRST	S11		;NO. CONTINUE
S10:	
IFN FULLW,<			;!! MAH @ SUMEX 4/75 !! FULLWORD/LOCATION
	SKIPE	PKTL-2(S)	;ANY ROOM LEFT IN THIS PACKET?
	JRST 	S16		;NO
	MOVEI	T1,2(S)
	SKIPE	(T1)
	 AOJA	T1,.-1
	MOVEM	CTXT,(T1)
>
IFE FULLW,<
	SKIPE	PKTL-1(S)	;ANY ROOM LEFT IN THIS PACKET?
	JRST	S16		;NO
	MOVE	SP,[POINT 18,2(S)]
	ILDB	T1,SP		;FIND AN OPEN SLOT
	JUMPN	T1,.-1
	DPB	CTXT,SP		;STORE CTXT
>
S11:	ISYM			;INITIALIZE SYMBOL
	HLRZ	T1,(S)		;GET SYMBOL TYPE BITS
S12:	ANDI	T1,.TYFLD	;GET TYPE DISPATCH CODE
	JRST	.+1(T1)
	JRST	S1(CC)		;NOTHING SPECIAL
	JRST	[TLO F,.NSMAC	;DEFINE ENCOUNTERED
		 JRST S1(CC)]
	JRST	S13		;ASCII, ASCIZ OR SIXBIT
	JRST	S22		;TITLE OR SUBTTL
				;OTHER TYPES DISPATCH FROM HERE
S13:	TRNE	F,.STR		;PROCESS SYMBOLS INSIDE STRINGS?
	JRST	S1(CC)		;YES.
	CAIE	C," "		;SPACE OR TAB?
	CAIN	C,11
	JRST	[GETC		;YES. KEEP LOOKING FOR DELIMITER
		 JRST S13]
	MOVE	CTXT,C		;NO. FOUND IT. SAVE IT
S14:	GETC			;GET NEXT CHARACTER
	CAIN	CC,.CCEOL	;END OF LINE?
	JRST	S24		;YES. EDIT LINE NUMBER
S15:	CAME	CTXT,C		;END OF STRING?
	JRST	S14		;NO. KEEP GOING
	JRST	S1(CC)		;YES.
S16:	MOVE	T3,S		;FIND/CREATE A FREE PACKET
S17:	
IFN FULLW,<			;!! MAH @ SUMEX 4/75 !! FULLWORD/LOCATION
	MOVE	T1,PKTL-1(T3)
	JUMPN	T1,S19
	MOVEI	T2,PKTL
	ADDB	T2,FREE
	MOVEM	T2,PKTL-1(T3)
	MOVEM	CTXT,(T2)
>
IFE FULLW,<
	HRRZ	T1,PKTL-1(T3)
	JUMPN	T1,S19
	MOVEI	T2,PKTL
	ADDB	T2,FREE
	HRRM	T2,PKTL-1(T3)
	HRLZM	CTXT,(T2)
>
S18:
	REPEAT PKTL-1,<	SETZM	.-S18+1(T2)>
	JRST	S11
S19:	
IFN FULLW,<			;!! MAH @ SUMEX 4/75 !! FULLWORD/LOCATION
	SKIPE	PKTL-2(T1)
	JRST	[MOVE T3,T1
		JRST S17]
	MOVEI	T2,(T1)
	SKIPE	(T2)
	 AOJA	T2,.-1
	MOVEM	CTXT,(T2)
>
IFE FULLW,<
	SKIPE	PKTL-1(T1)
	JRST	[MOVE T3,T1
		 JRST S17]
	MOVE	SP,[POINT 18,(T1)]
	ILDB	T2,SP
	JUMPN	T2,.-1
	DPB	CTXT,SP
>
	JRST	S11
S20:	CAIN	C,";"		;COMMENT?
	JRST	S22		;YES. JUMP
	TRNE	F,.STR		;PROCESSING SYMBOLS WITHIN STRINGS?
	JRST	S0		;YES.
	MOVE	CTXT,C		;SAVE C
S21:	GETC			;GET CHARACTER
	CAIN	CC,.CCEOL	;END OF LINE?
	JRST	S25		;YES. RESUME NORMAL PROCESSING
	CAMN	C,CTXT		;NO. END OF STRING YET?
	JRST	S0		;YES. RESUME NORMAL PROCESSING
	JRST	S21		;NO. CONTINUE SCANNING
S22:	TRNE	F,.COM		;PROCESS COMMENTS?
	JRST	S1(CC)		;YES. DON'T IGNORE SYMBOLS
S23:	GETC			;GET NEXT CHARACTER
	CAIE	CC,.CCEOL	;END OF LINE YET?
	JRST	S23		;NO. CONTINUE SCANNING
	JRST	S1(CC)		;YES. RESUME END OF LINE PROCESSING
S24:	TLO	F,.INS		;SET INSIDE STRING SWITCH
S25:	CAIN	C,14		;FORM FEED IN FUNNY PLACE?
	JRST	[MOVEI C,15	;YES
		 JRST S26]
	TLZE	F,.SVC		;SAVED CHARACTER?
	SKIPA	C,SVC		;YES. USE IT
	.BIN			;GET NEXT CHARACTER
	CAIE	C,14		;FORM FEED?
	JRST	[TLO F,.SVC	;NO
		 MOVEM C,SVC
		 JRST S27]
S26:	
IFN FULLW,<
	TRNE	F,.LST		;LISTING?
>
	.BOUT			;YES. PASS IT ON
	AOS	PAGE		;BUMP PAGE NUMBER
	SETOM	SPAGE		;INITIALIZE SUBPAGE NUMBER
	MOVEI	1,MAXL
	MOVEM	1,LINE		;INITIALIZE LINE COUNTER
IFN FULLW,<SETZM NLINE>		;!! MAH @ SUMEX 4/75 !! PAGE.LINE NUMBERING
S27:	
	ADDI	L,1		;BUMP LINE NUMBER
IFN FULLW,<
	AOS	NLINE		;!! MAH @ SUMEX 4/75 !! PAGE.LINE NUMBERING
	TRNN	F,.LST		;LISTING?
	 JRST	S27A
>
	PUSHJ	P,NEWLIN	;CHECK FOR PAGE OVERFLOW
	MOVEI	1,6		;OUTPUT LINE NUMBER
	MOVE	3,L
	PUSHJ	P,DNOUTF
	MOVEI	C,11
	.BOUT			;FOLLOWED BY A TAB
IFN FULLW,<S27A:>
	TLZN	F,.INS		;INSIDE STRING?
	JRST	S0		;NO. RESUME PROCESSING
	JRST	S15		;YES. DO SPECIAL RETURN
FNDSYM:	HLRZ	T1,SYM
	LSH	T1,LOGSTL-^D18	;T1 = SYMBOL TABLE LIST HEADER INDEX
	MOVEI	T2,ST(T1)
FNDS1:	HRRZ	S,(T2)		;S = NEXT PACKET ADDRESS
	JUMPE	S,FNDS2		;NONE LEFT, ADD A NEW ONE
	CAMLE	SYM,1(S)	;HAVE WE GONE FAR ENOUGH?
	JRST	[MOVE T2,S	;NO.
		 JRST FNDS1]
	CAME	SYM,1(S)	;YES. IS (SYM) = SYMBOL?
	JRST	FNDS2		;NO. ADD NEW PACKET
	TLZN	F,.NSMAC
	POPJ	P,
	MOVSI	T1,.MAC
	HLLM	T1,(S)
	MOVNS	CTXT
	POPJ	P,
FNDS2:	TLO	S,.SYM		;ASSUME IT'S AN ORDINARY SYMBOL
	TLZE	F,.NSMAC	;THIS SYMBOL A MACRO NAME?
	JRST	[MOVNS CTXT	;YES. INDICATE DEFINITION LINE
		 TLC S,.SYM+.MAC
		 JRST .+1]
	TRNN	F,.SYM		;ARE WE PROCESSING ORDINARY SYMBOLS?
	JRST	[MOVEI S,[0]	;NO. IGNORE THIS SYMBOL
		 POPJ P,]
	MOVEI	T1,PKTL		;GET NEW PACKET
	ADDB	T1,FREE		;T1 = NEW PACKET ADDRESS
	MOVEM	S,(T1)		;PUT NEW PACKET IN LIST
	HRRM	T1,(T2)
	MOVE	S,T1
	MOVEM	SYM,1(S)	;STORE SYMBOL
FNDS6:
	REPEAT PKTL-2,<	SETZM	.-FNDS6+2(S)>
	POPJ	P,		;EXIT
	DEFINE	SPOT(SYMBOL,TYPE)
<	MOVSI	CTXT,TYPE
	MOVE	SYM,[SIXBIT /SYMBOL/]
	PUSHJ	P,FNDSYM
	IORM	CTXT,(S)>

	DEFINE	IT(TYPE)
<	TRNE	F,TYPE		;PROCESS THIS TYPE?
	JRST	.+7		;YES.
	MOVSI	CNT,-N'TYPE	;NO. MUST PUT SYMBOLS IN TABLE
	MOVE	SYM,T'TYPE(CNT)	;GET SYMBOL NAME
	PUSHJ	P,FNDSYM	;GET PACKET FOR SYMBOL
	MOVSI	CTXT,TYPE!.SYM	;GET SYMBOL TYPE
	XORM	CTXT,(S)	;SET SYMBOL TYPE BITS
	AOBJN	CNT,.-4		;PROCESS NEXT SYMBOL
>

	DEFINE	SX(SYMBOL)
<IRP SYMBOL,<	SIXBIT /SYMBOL/>>



ISTAB:	SPOT(DE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	SX(<IF1,IF2,IFB,IFDEF,IFDIF,IFE,IFG,IFGE>)
	SX(<IFIDN,IFL,IFLE,IFN,IFNB,IFNDEF>)
N.PSOP==.-T.PSOP
;	CHARACTER CLASS TABLE

	.CCIGN==0	;CLASS 0: IGNORE CHARACTER
	.CCCS==1	;CLASS 1: ";" OR """ OR "'"
	.CCLET==2	;CLASS 2: LETTERS
	.CCDIG==3	;CLASS 3: DIGITS
	.CCDP==4	;CLASS 4: "$" OR "%"
	.CCDOT==5	;CLASS 5: "."
	.CCSP1==6	;CLASS 6: ")" OR "^" OR RIGHT ANGLE BRACKET
	.CCEOL==7	;CLASS 7: LF OR EOL

CLASS:

REPEAT 12,<	.CCIGN,,0>
	.CCEOL,,0		;LINE FEED
	.CCIGN,,0		;TAB
	.CCEOL,,0		;FORM FEED
REPEAT 36-14,<	.CCIGN,,0>
	.CCEOL,,0		;TENEX END OF LINE
REPEAT 41-37,<	.CCIGN,,0>
	.CCCS,,0		;"""
	.CCIGN,,0		;"#"
	.CCDP,,'$'		;"$"
	.CCDP,,'%'		;"%"
	.CCIGN,,0
	.CCCS,,0		;"'"
	.CCIGN,,0
	.CCSP1,,0		;")"
REPEAT 4,<	.CCIGN,,0>
	.CCDOT,,'.'		;"."
	.CCIGN,,0		;"/"
REPEAT 71-57,<	.CCDIG,,.-CLASS-40>
	.CCIGN,,0		;":"
	.CCCS,,0		;";"
REPEAT 2,<	.CCIGN,,0>
	.CCSP1,,0		;RIGHT ANGLE BRACKET
REPEAT 100-76,<	.CCIGN,,0>
REPEAT ^D26,<	.CCLET,,.-CLASS-40>	;LETTERS
REPEAT 3,<	.CCIGN,,0>
	.CCSP1,,0		;"^"
REPEAT 2,<	.CCIGN,,0>
REPEAT ^D26,<	.CCLET,,.-CLASS-100>	;LETTERS
REPEAT 5,<	.CCIGN,,0>
ISTATE:	.BEG,,.MAC+.SYM
LEVTAB:	PC1
	PC2
	PC3
CHNTAB:
	REPEAT ^D10,<	2,,IGNORE>
	1,,EOF
	REPEAT ^D25,<	2,,IGNORE>

EOF:	SKIPN	INPFIL		;ON INPUT FILE
	JRST EOF1
	SETZM	INPFIL		;TURN OFF SWITCH
	MOVEI	1,FINISH
	HRRM	1,PC1
IGNORE:	DEBRK

EOF1:	SKIPN	CMDFIL		;IS IT ON COMMAND FILE
	JRST EOF2		;NO GO TO START
	SETZM	CMDFIL		;NO MORE COMMAND FILE
	MOVEI	1,400000
	GPJFN			;GET CURRENT PRIMARIES
	HLRZ	1,2		;AND THE INPUT FROM IT
	CLOSF			;CLOSE AND RELEASE IT
	JFCL
	MOVEI	1,400000
	MOVE 	2,PJFNS
	SPJFN			;RESET ORIGINAL PRIMARIES
	DEBRK

EOF2:	MOVEI	1,START
	HRRM	1,PC1		;DEBREAK TO THE TOP
	DEBRK

FINISH:	seto	1,
	move	2,[400000,,ipage/1000]
	setz	3,
	pmap
	HRRZ	1,IJFN		;CLOSE INPUT FILE
	CLOSF
	JRST	ERROR
	TLZE	F,.MULTF	;ANOTHER INPUT FILE?
	 JRST	START1		;YES
REPEAT 0,<
	JRST   [HRROI 1,[ASCIZ / Next: /]
		SKIPN	CMDFIL	;BUT DONT PRINT FOR COMMAND FILE
		PSOUT
		JRST START1]	;YES. GO PROCESS IT
>
	MOVEI	T1,2
	CAILE	L,^D10
	AOS	T1
	CAILE	L,^D100
	AOS	T1
	CAILE	L,^D1000
	AOS	T1
	CAILE	L,^D10000
	AOS	T1
	CAILE	L,^D100000
	AOS	T1
IFN FULLW,<MOVEI T1,^D8>	;!! MAH @ SUMEX 4/75 !! LATER PERHAPS CALC
				;THE LARGEST OF PAGE # AND LINE #
	MOVEI	T2,LINWTH-^D8
	IDIVI	T2,1(T1)
	MOVEM	T1,SYMWTH	;SAVE SYMBOL WIDTH
	MOVEM	T2,SYMSPL	;SAVE SYMBOLS/LINE
IFN FULLW,<
	TRZN	F,.LST		;LISTING?
	 JRST	[MOVEI 1,1
		MOVEM 1,PAGE
		JRST F0]
>
	PUSHJ	P,CRLF
	MOVEI	C,14
	.BOUT			;OUTPUT A FORM FEED
	AOS	PAGE		;BUMP PAGE NUMBER
IFN FULLW,<F0:>
	TRZ	F,.SPH		;RESET SUPPRESS HEADING SWITCH
	SETOM	SPAGE		;INITIALIZE SUB-PAGE NUMBER
	MOVEI	1,MAXL
	MOVEM	1,LINE		;INITIALIZE LINE COUNTER
	PUSHJ	P,NEWLIN	;FUDGE OUT THE PAGE HEADING
	SETZ	CNT,		;INITIALIZE ST INDEX
F1:	SKIPN	S,ST(CNT)	;GET STARTING PACKET ON THIS LIST
	JRST	F4		;NONE ON THIS LIST
F1A:	
IFN FULLW,<MOVE	T1,2(S)>	;!! MAH @ SUMEX 4/75 !! FULLWORD/LOCATION
IFE FULLW,<HLLZ	T1,2(S)>	;GET FIRST LINE #
	JUMPE	T1,F3A		;JUMP IF NO REFERENCES
	MOVEI	T3,6
	MOVE	SP,[POINT 6,1(S)]
F1B:	ILDB	C,SP		;OUTPUT SYMBOL NAME
	ADDI	C,40
	.BOUT
	SOJG	T3,F1B
	MOVEI	C,11		;OUTPUT A TAB
	.BOUT
	MOVE	SYM,SYMSPL	;GET NUMBER OF SYMBOLS/LINE
IFN FULLW,<			;!! MAH @ SUMEX 4/75 !! FULLWORD/LOCATION 
	SETOM	OFILN		;FORCE A FILE NAME PRINT
	MOVE	CC,FILNO
	CAIN	CC,1		;IF MORE THAN ONE FILE, ELSE SUPPRESS
	MOVEM	CC,OFILN	;FILE NAME
	MOVEI	CC,PKTL-3     
	MOVEI	SP,2(S)
>
IFE FULLW,<
	MOVEI 	CC,<2*PKTL>-5
	MOVE	SP,[POINT 18,2(S)]
>
	MOVE	CTXT,S
F2:	
IFN FULLW,<MOVE	L,(SP)		;!! MAH @ SUMEX 4/75 !! FULLWORD/LOCATION
	AOJ	SP,>
IFE FULLW,<ILDB	L,SP>		;GET NEXT LINE REFERENCE
	JUMPE	L,F3		;END OF REFERENCES
	JUMPGE	SYM,F2A		;ANY ROOM LEFT ON THIS LINE? IF SO, JUMP
	MOVE	SYM,SYMSPL	;RESET REFERENCE COUNTER
	PUSHJ	P,CRLF		;NO. OUTPUT A CRLF
	MOVEI	C,11		;OUTPUT A TAB
	.BOUT
F2A:	
IFN FULLW,<			;!! MAH @ SUMEX 4/75 !! PAGE.LINE NUMBERING
	MOVM	T1,L
	LDB	T2,PFILN	;GET FILE NUMBER
	CAMN	T2,OFILN	;SAME AS LAST PAGE.LINE NUMBER
	 JRST	F2AA		;YES
	PUSH	P,T1
	CAME	SYM,SYMSPL	;BEGINING OF LINE?
	 JRST	[PUSHJ P,CRLF	;NO, CRLF TO BEGINNING OF LINE
		MOVEI C,11
		.BOUT
		MOVE SYM,SYMSPL
		JRST .+1]
	MOVEM	T2,OFILN	;REMEMBER LAST FILE PRINTED
	SETZM	OCOUNT
	MOVE	T2,FILBP-1(T2)	;PRINT OUT FILE NAME
	ILDB	C,T2
	JUMPE	C,.+3
	.BOUT
	JRST	.-3
	MOVEI	C," "		;SEPARATE WITH AT LEAST TWO SPACES
	.BOUT
	.BOUT
F2AB:	MOVE	1,OCOUNT	;SPACE OUT TO MULTIPLE OF SYMWTH TO PUT
	IDIV 	1,SYMWTH	;SYMBOLS IN RIGHT SPACE
	JUMPN	2,[MOVEI C," "
		.BOUT
		JRST F2AB]
	SUB	SYM,1		;ACCOUNT FOR SPACE TAKEN BY NAME
	POP	P,T1
F2AA:	SETZM	OCOUNT
	LDB	3,PPAGE		;GET PAGE NUMBER
	MOVEI	1,3		;WIDTH OF 3
	PUSHJ	P,DNOUT
	MOVEI	C,"."
	.BOUT
	LDB	3,PLINE		;LINE NUMBER
	MOVEI	1,3		
	PUSHJ	P,DNOUT
> ;END IFN FULLW

IFE FULLW,<
	HRRES	L
	MOVM	3,L		;OUTPUT THE REFERENCE LINE NUMBER
	MOVE	1,SYMWTH
	PUSHJ	P,DNOUTF
>
	MOVEI	C," "
	SKIPG	L
	MOVEI	C,"#"		;IF REFERENCE ASSIGNED A VALUE, FLAG IT
	.BOUT
IFN FULLW,<
	MOVEI	C," "		;FILL OUTWITH SPACES
	MOVE	1,SYMWTH
	CAMLE	1,OCOUNT
	 JRST	[.BOUT
		JRST .-2]
>
	SOJ	SYM,		;COUNT # OF SYMBOLS ON LINE
	SOJG	CC,F2		;JUMP IF MORE SLOTS IN THIS PACKET
	HRRZ	CTXT,PKTL-1(CTXT) ;NO MORE. GET LINK TO NEXT PACKET
	JUMPE	CTXT,F3		;JUMP IF NO MORE PACKETS FOR THIS SYMBOL
IFN FULLW,<			;!! MAH @ SUMEX 4/75 !! FULLWORD/LOCATION
	MOVEI	CC,PKTL-1
	MOVEI	SP,(CTXT)
>
IFE FULLW,<
	MOVEI	CC,<2*PKTL>-1
	MOVE	SP,[POINT 18,(CTXT)]
>
	JRST	F2		;PROCESS NEXT PACKET OF SYMBOL
F3:	PUSHJ	P,CRLF		;OUTPUT A CRLF
F3A:	HRRZ	S,(S)		;GET LINK TO NEXT SYMBOL PACKET
	JUMPN	S,F1A		;IF ANOTHER SYMBOL PACKET EXISTS, JUMP
F4:	CAIE	CNT,STL-1	;ANY LISTS LEFT?
	AOJA	CNT,F1		;YES. PROCESS NEXT SYMBOL LIST
	PUSHJ	P,OCLOSE	;NO. CLOSE OUTPUT FILE
	JRST	START
ERROR:	HRROI	1,[ASCIZ /
/]
	PSOUT
	MOVEI	1,101		;SELECT PRIMARY OUTPUT
	HRLOI	2,400000	;SELECT CURRENT FORK
	SETZ	3,
	ERSTR
	JRST	ERROR1
	JRST	ERROR1
ERROR1:	HRROI	1,[ASCIZ /
/]
	PSOUT
	JRST	START

CRLF:	MOVEI	C,15
	.BOUT
	MOVEI	C,12
	.BOUT
;	JRST	NEWLIN		;FALL INTO NEWLIN

NEWLIN:	MOVEM	T1,SAVT1	;SAVE T1
	AOS	T1,LINE		;BUMP LINE COUNTER
	TRNN	F,.SPH		;SKIP IF SUPPRESS HEADING
	CAIG	T1,MAXL		;ANOTHER SUBPAGE?
NEWL1:	JRST	[MOVE T1,SAVT1	;NO. EX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E	2,[7B5+1B19]
	OPENF
	JRST	ERROR
	SETOM	INPFIL		;EOF WILL BE FOR INPUT FILE
	SETOM	IPG
	SETZM	ICNT
	POPJ	P,



;	SEQUENCE TO SIMULATE BIN VIA PMAPS

BIN1:	SOSGE	ICNT
	JRST	DOBIN+5
	ILDB	C,IPNT
	JUMPE	C,DOBIN
	POPJ	P,
	AOS	1,IPG
	HRL	1,IJFN
	RPACS
	TLNN	2,(1B5)
	JRST	FINISH
	MOVE	2,[400000,,IPAGE/1000]
	MOVSI	3,(1B2)
	PMAP
	MOVEI	3,5000
	MOVEM	3,ICNT
	MOVE	3,IPOINT
	MOVEM	3,IPNT
	JRST	DOBIN
BIN1L==.-BIN1

;	SEQUENCE TO DO JUST BINS

BIN2:	HRRZ	1,IJFN
	BIN
	POPJ	P,
BIN2L==.-BIN2
;	ROUTINE TO OPEN OUTPUT FILE

OPENO:	HRRZ	1,OJFN
	SETOM	PMAPO
	DVCHR
	MOVE	1,[-BOUT1L,,BOUT1]
	TLNE	2,(777B17)
	JRST	[MOVE 1,[-BOUT2L,,BOUT2]
		 SETZM PMAPO
		 JRST .+1]
	SETZ	4,
OPENO1:	MOVE	3,(1)
	MOVEM	3,DOBOUT(4)
	AOJ	4,
	AOBJN	1,OPENO1
	HRRZ	1,OJFN
	MOVE	2,[7B5+1B19+1B20]
	SKIPN	PMAPO
	TRZ	2,1B19
	OPENF
	JRST	ERROR
	SETOM	OPG
	SETZM	OCNT
	POPJ	P,

;	SEQUENCE TO SIMULATE BOUT VIA PMAPS

BOUT1:	SOSGE	OCNT
IFN FULLW,<JRST	DOBOUT+5>	;!! MAH @ SUMEX 4/75 !!
IFE FULLW,<JRST	DOBOUT+4>
	IDPB	C,OPNT
IFN FULLW,<AOS	OCOUNT>
	POPJ	P,
	PUSH	P,C
	PUSH	P,3
	SETO	1,
	MOVE	2,[400000,,OPAGE/1000]
	setz	3,
	PMAP
	AOS	1,OPG
	HRL	1,OJFN
	MOVE	2,[400000,,OPAGE/1000]
	MOVSI	3,(1B2+1B3)
	PMAP
	MOVEI	3,5000
	MOVEM	3,OCNT
	MOVE	3,[POINT 7,OPAGE]
	MOVEM	3,OPNT
	POP	P,3
	POP	P,C
	JRST	DOBOUT
BOUT1L==.-BOUT1


;	SEQUENCE TO MERELY DO BOUTS

BOUT2:	HRRZ	1,OJFN
IFN FULLW<AOS	OCOUNT>		;!! MAH @ SUMEX 4/75 !!
	BOUT
	POPJ	P,
BOUT2L==.-BOUT2



;	ROUTINE TO CLOSE OUTPUT FILE AND CLEAN UP

OCLOSE:	SETO	1,
	MOVE	2,[400000,,OPAGE/1000]
	setz	3,
	PMAP
	MOVE	2,[400000,,IPAGE/1000]
	PMAP
	HRRZ	4,FREE
	ADDI	4,PKTL-1
	LSH	4,-^D9
OCLOS1:	CAILE	4,<FFREE+777+140-START>/1000
	JRST	OCLOS2
	MOVSI	2,400000
	ADD	2,4
	PMAP
	SOJA	4,OCLOS1
OCLOS2:	SKIPN	PMAPO
	JRST	OCLOS6
	HRRZ	1,OJFN
	HRLI	1,11
	MOVSI	2,(77B11)
	MOVSI	3,(7B11)
	CHFDB
	HRLI	1,12
	SETO	2,
	MOVEI	3,5000
	IMUL	3,OPG
	ADDI	3,5001
	SUB	3,OCNT
	CHFDB
OCLOS6:	HRRZ	1,OJFN
	CLOSF
	JRST	ERROR
	POPJ	P,
;	ROUTINE TO SIMULATE NOUT

DNOUTF:	SETOM	FILLSW
	CAIA
DNOUT:	SETZM	FILLSW
	SETZM	DIGSW
	JRST	.+1(1)
	JRST	ERROR
	JRST	DNO1
	JRST	DNO2
	JRST	DNO3
	JRST	DNO4
	JRST	DNO5
DNO6:	CAIGE	3,^D100000
	JRST	DNO6B
	IDIVI	3,^D100000
	PUSHJ	P,DNDIG
DNO6B:	PUSHJ	P,DNFILL
DNO5:	CAIGE	3,^D10000
	JRST	DNO5B
	IDIVI	3,^D10000
	PUSHJ	P,DNDIG
DNO5B:	PUSHJ	P,DNFILL
DNO4:	CAIGE	3,^D1000
	JRST	DNO4B
	IDIVI	3,^D1000
	PUSHJ	P,DNDIG
DNO4B:	PUSHJ	P,DNFILL
DNO3:	CAIGE	3,^D100
	JRST	DNO3B
	IDIVI	3,^D100
	PUSHJ	P,DNDIG
DNO3B:	PUSHJ	P,DNFILL
DNO2:	CAIGE	3,^D10
	JRST	DNO2B
	IDIVI	3,^D10
	PUSHJ	P,DNDIG
DNO2B:	PUSHJ	P,DNFILL
DNO1:	MOVEI	C,"0"(3)
	JRST	DOBOUT


DNDIG:	MOVEI	C,"0"(3)
	.BOUT
	SETOM	DIGSW
	SETOM	FILLSW
	MOVE	3,4
	AOS	(P)
	POPJ	P,

DNFILL:	SKIPN	FILLSW
	POPJ	P,
	MOVEI	C," "
	SKIPE	DIGSW
	MOVEI	C,"0"
	JRST	DOBOUT




OJFNB:	1B0
	100,,101
	EXP	0,0,0
	-1,,[ASCIZ /CRF/]
	EXP	0,0,0

IJFNB:	1B2
	100,,101
	EXP	0,0,0
	-1,,[ASCIZ /MAC/]
	EXP	0,0,0



	LIT

;	DATA AREAS

VERSW:	-1
IPOINT:	POINT	7,IPAGE
BSIZE:	0
OJFN:	0
IJFN:	0
INPFIL:	0			; 0=READING INPUT FILE , -1=NOT
CMDFIL:	0			;0=NO CMD FILE,-1=CMD FILE
PJFNS:	0			;PRIMARY JFNS FOR COMMAND INPUT
DOBIN:	BLOCK	BIN1L
DOBOUT:	BLOCK	BOUT1L
SYMSPL:	0
SYMWTH:	0
PC1:	0
PC2:	0
PC3:	0
FREE:	0

PHEAD:
PHEAD1:	ASCII	"     "
	REPEAT 6,<ASCII "     ">
PHEAD2:	REPEAT 4,<ASCII "     ">
	ASCIZ	"Page "

PAGE:	0
SPAGE:	0
LINE:	0
SAVT1:	0
SVC:	0
FILLSW:	0
DIGSW:	0
IPG:	0
ICNT:	0
OPG:	0
OCNT:	0
IPNT:	0
OPNT:	0
PMAPO:	0

IFN FULLW,<			;!! MAH @ SUMEX 4/75 !! PAGE.LINE NUMBERING
FILNO:	0			;CURRENT FILE NUMBER
OFILN:	0			;LAST PRINTED FILE NAME ON CRSREF OUTPUT
NLINE:	0			;REAL LINE NUMBER OF INPUT FILE
NAMBP:	0			;NAME BUFFER BYTE POINTER
OCOUNT:	0			;OUTPUT CHARACTER COUNTER
PLINE:	POINT 12,T1,35		;POINTER TO LINE NO BYTE OF LOCATION WORD
PPAGE:	POINT 9,T1,23		;POINTER TO PAGE NO BYTE OF LOCATION WORD
PFILN:	POINT 9,T1,14		;POINTER TO FILE NO BYTE OF LOCATION WORD
FILBP:	BLOCK MAXFIL		;FILE NAME POINTER ARRAY
NAMBUF: BLOCK MAXFIL*10		;FILE NAME BUFFER
MAXNBP==.-45			;ALLOW OVERFLOW SPACE
>

PS:	BLOCK	20
PSL=.-PS

ST:	BLOCK	STL


IPAGE=766000
OPAGE=767000

FFREE=.

	END	BEGIN