perm filename MIXASM.MAC[B,PMP] blob sn#056168 filedate 1973-07-27 generic text, type T, neo UTF8
	TITLE	MIXASM - MIXAL ASSEMBLER FOR THE MIX COMPUTER
	SUBTTL ALB 6/30/73
IF2,<	PRINTX	BEGINNING PASS 2>
;REGISTER DEFINITIONS
	F=0			;FLAGS
	T=1			;TEMPORARY
	T1=2
	T2=3
	T3=4
	T4=5
	E=6			;EXPRESSION VALUE
	N=7			;ATOMIC VALUE
	W=10			;W-VALUE
	FP=11			;FREE CORE POINTER
	C=12			;CHARACTER BEING PROCESSES
	CP=13			;BYTE POINTER TO CHARACTER STRING
	LC=14			;LOCATION COUNTER
	S=15			;SYMBOL TABLE POINTER
	IOL=16			;I/O LINK
	P=17			;PUSH DOWN POINTER
	SUBTTL	DEFINITIONS
;I/O CHANNEL DEFINITIONS
	SRC=1			;SOURCE
	SCR=2			;SCRATCH FOR TEMPORARY RESULTS
	LST=3			;LISTING
	MOB=4			;BINARY OUTPUT FOR LOADING BY SIMULATOR
;FLAG DEFINITIONS
	.AERR==1B18		;ADDR FIELD ERROR
	.EERR==1B19		;EXPRESSION ERROR
	.FERR==1B20		;F-PART ERROR
	.IERR==1B21		;I-PART ERROR
	.LERR==1B22		;LOC FIELD ERROR
	.OERR==1B23		;OP FIELD ERROR
	.RERR==1B24		;FUTURE REFERENCE ERROR
	.SERR==1B25		;LINE SIZE ERROR ( >132 CHARS)
	.TERR==1B26		;TRUNCATION ERROR (EXPR TOO BIG FOR PURPOSE)
	.WERR==1B27		;W-VALUE ERROR
	.ALPH==1B28		;1 => SYMBOL, 0 => NUMBER
	.SYMVC==1B29		;SYMBOL VACUOUS
	.EXPVC==1B30		;EXPRESSION VACUOUS
	.DNILC==1B31		;DO NOT INCREMENT LOCATION COUNTER
	.LITRL==1B32		;1 => LITERAL, 0 => UNDEF SYMBOL
	.DEFIN==1B18		;SYMBOL DEFINED MARK
	.SIGN==1B18		;SIGN BIT
	TMASK==370000		;TRUNCATION MASK TO 30 BITS
	NOTERS==-<-1B27+1>	;ALL NON-ERROR FLAGS
;LISTING CONTROL BITS, FROM VALUE OF OP TYPE ITSELF
	.MWFOR==1B33		;1 => LIST AS MOP, 0 => LIST AS CONSTANT
	.LCBNK==1B34		;1 => LOC FIELD NON-BLANK, 0 => BLANK
	.MWBNK==1B35		;1 => MIX WORD FIELD NON-BLANK, 0 => BLANK
IFNDEF	NMBKTS,<	NMBKTS=20	>
IFN	<1B<↑L<NMBKTS>>-NMBKTS>,<
	PRINTX	**NUMBER OF BUCKETS IN SYMBOL TABLE MUST BE A POWER OF TWO**>
;DEFAULT FEATURE SETTINGS
IFNDEF	BINOPS,<BINOPS=-1>	;SLB,SRB,JAE,JAO,JXE,JXO,OR,AND,XOR
IFNDEF	FLTOPS,<FLTOPS==-1>	;FADD,FCMP,FDIV,FIX,FLOT,FMUL,FSUB
IFNDEF	EXTMEM,<EXTMEM==0>	;INT
IFNDEF	INDADR,<INDADR=0>	;XCT
	EXTERN	.JBREL,.JBFF	;ISN'T THE LOADER SMART?
	OPDEF	POPJ1[	JRST	[AOS	(P)
	POPJ	P,]]		;SKIP RETURN
	SUBTTL	MACROS
	DEFINE	ERRORS(FLAG)<IRPC	FLAG<
	XWD	.'FLAG'ERR,"FLAG"	>>
	DEFINE	FPOINT<
	.XCREF
	L==N/10
	R==N-<L*10>
	N==N+1
IFGE	<R-L>,<
IFGE	<5-R>,<
	.CREF
	POINT	<<R-L+1>*6>,(T1),<<R*6>+5>	>>
IFL	<<R-L>!<5-R>>,<
	.CREF
	Z>	>
	DEFINE	ATOMIX(N)<IRP	N<
	EXP	↑D'N	>>
	DEFINE	MOP(OPNAME,OPCODE,DEFLTF<5>)<
	ASCII	/OPNAME/
	XWD	<DEFLTF>B29+OPCODE,	MACHOP
	.XCREF
	TNEW=<	ASCII	/OPNAME/>
IFGE	<TOLD-TNEW>,<	PRINTX	******OPCODES OUT OF ORDER******>
	TOLD=TNEW
	.CREF	>
	DEFINE	AOP(AOPNAM,TYPE)<
	ASCII	/AOPNAM/
	EXP	TYPE
	.XCREF
	TNEW=<	ASCII	/AOPNAM/>
IFGE	<TOLD-TNEW>,<	PRINTX	******OPCODES OUT OF ORDER******>
	EXP	TNEW,TYPE
	TOLD=TNEW
	.CREF	>
	SUBTTL	INITIALIZATION
MIXASM: 			;THE SHOW STARTS HERE
	RESET
	OPEN	SRC,[EXP 0
	SIXBIT	/DSK/
	XWD	0,IIB]
	HALT
	OPEN	SCR,[EXP 13
	SIXBIT	/DSK/
	XWD	SOB,0]
	HALT
	OPEN	LST,[EXP 0
	SIXBIT	/DSK/
	XWD	LOB,0]
	HALT
	OPEN	MOB,[EXP	13
	SIXBIT	/DSK/
	XWD	OOB,0]
	HALT
	LOOKUP	SRC,[SIXBIT	/TEST/
	SIXBIT	/MIX/
	EXP	0,0]
	HALT
	ENTER	SCR,[SIXBIT	/SCRTCH/
	SIXBIT	/MIX/
	EXP	0,0]
	HALT
	ENTER	LST,[SIXBIT	/TEST/
	SIXBIT	/LST/
	EXP	0,0]
	HALT
	ENTER	MOB,[SIXBIT	/TEST/
	SIXBIT	/MOB/
	EXP	0,0]
	HALT
	MOVE	FP,.JBFF	;SAVE BUFFER ADRESSES TO USE AGAIN
	MOVEM	FP,ABUF1
	INBUF	SRC,2
	MOVE	FP,.JBFF
	MOVEM	FP,ABUF2
	OUTBUF	SCR,2
	OUTBUF	MOB,2
	SETZ	LC,		;INITIALIZE
	MOVE	FP,.JBFF
	MOVE	P,[IOWD	40,PDLIST]
	JRST	.+12
	SUBTTL	PROCESS NEXT LINE
NXTLIN: TLNE	F,.DNILC	;INCREMENT LC?
	JRST	.+6		;NO - SKIP IT
	SETZB	F,MIXWRD	;rnrcIAlriE&
	AOJ	LC,
	TDZE	LC,[-1B23]
	TLO	F,.LERR!.TERR
	JRST	.+2
	SETZB	F,MIXWRD
	MOVEM	LC,OUTLC
	SETZM	AFUTRF
	SETZM	INOPC
	AOS	STMTNO		;BUMP STATEMENT NO.
	PUSHJ	P,INLIN
	JRST	NXTLIN
	SUBTTL	PROCESS AN INPUT LINE
INLIN:	MOVSI	T,-↑D132	;SET UP FOR AOBJN
	MOVE	T1,PT.LBF	;POINTER TO-Lrnn BdFFEr-(IlmB\-
	SOSG	IIB+2		;GET A CHARACTER
	IN	SRC,
	JRST	.+2
	HALT			;SHOULD MAKE END CARD HERE
	ILDB	C,IIB+1
	CAIN	C,15		;CARRIAGE RncURN\
	JRST	IL.1		;YES - NEXT STEp-
	CAIL	C,141		;LOWER CASE LETTER?
	CAILE	C,172
	JRST	.+2		;NO - SKIP
	MOVEI	C,-" "(C)	;YES - CHANGE TO UPPER CASE
	IDPB	C,T1		;STORE IN LINE BUFFER
	AOBJN	T,INLIN+2	;LOOP FOR MORE
	TLO	F,.SERR 	;LINE TOO LONG - SIZE ERROR
IL.1:	SOSG	IIB+2		;PULL LINEFEED
	IN	SRC,
	JRST	.+2
	HALT
	IBP	IIB+1
	SETZ	C,		;PUT NULL AT END OF LINE
	IDPB	C,T1
	MOVEI	T,(T)
	MOVEM	T,LINSIZ	;STORE LENGTH OF LINE
	CAIG	T,17		;SHORT LINE?
	SETZM	OUTLIN+3	;YES - MAKE SURE ADDR FIELD IS NULL
	MOVE	CP,PT.LIN	;POINTER TO FIRST CHARACTER (LDB)
	LDB	C,CP		;GRAB IT
	CAIN	C,"*"		;COMMENT CARD
	JRST	COMCRD		;YES - GO PROCESS IT
	MOVSI	T,-4		;OPCODE FIELD
	MOVE	T1,PT.OPC	;POINTER TO OPCODE FIELD
	MOVE	T2,PT.IOC	; AND POINTER TO INOPC
	ILDB	C,T1		;STORE OPCODE FIELD
	CAIE	C," "		;IGNORE SPACES
	CAIN	C,		;  AND NULLS (FOR NOW)
	JRST	.+2
	IDPB	C,T2
	AOBJN	T,.-5		;LOOP FOR MORE
	ILDB	C,T1		;CHECK COLUMN 16
	CAIE	C," "		;ERROR IF NOT BLANK
	CAIN	C,		;  OR NULL (END OF LINE)
	JRST	.+2		;SKIP IF OKAY
	TLO	F,.OERR 	;OP FIELD ERROR
	LDB	C,CP		;GET FIRST CHAR IN ADDR FIELD (AGAIN)
	CAIN	C," "		;LOC FIELD BLANK?
	JRST	LOCBNK		;YES - SKIP AHEAD
	PUSHJ	P,GETSON	;COLLECT SYMBOL
	JRST	LOCERR		;ERROR IN LOC FIELD
	TLNN	F,.ALPH 	;SYMBOL COLLECTED?
	JRST	LOCERR		;ERROR IF NUMBER
	MOVNI	T,(T1)		;CHECK REST OF LOC FIELD FOR BLANKS
	MOVEI	T,13(T)
	LDB	C,CP
	CAIE	C," "
	TLO	F,.LERR 	;ANYTHING BUT SPACE IS ERROR
	IBP	CP
	SOJG	T,.-4		;LOOP THROUGH REST OF LOC FIELD
	MOVEM	LC,SYMVAL	;SET SYMBOL VALUE
	PUSHJ	P,DEFSYM	;DEFINE SYMBOL
	JRST	LOCERR		;ALREADY DEFINED - ERROR IN LOC FIELD
	MOVEI	T,3(S)		;SAVE A(SYMBOL VALUE) FOR EQU OP
	MOVEM	T,T.EQU
	MOVEM	LC,OUTLC	;LOCATION COUNTER FOR PRINTING
	SUBTTL	OPCODE TABLE SEARCH
OCSRCH: MOVE	T3,INOPC	;GET OP FIELD
	MOVEI	T1,1B↑L<OPTTOP-OPTBOT>
				;SET UP OFFSET FROM OP CODE TABLE BOTTOM
	MOVEI	T2,1B↑L<OPTTOP-OPTBOT>/2
				;  AND DELTA FOR FIRST CHANGE
OSCH.1: CAMN	T3,OPTBOT-2(T1) ;FOuNm Ic?
	JRST	OSCH.3		;YES
	CAML	T3,OPTBOT-2(T1) ;NO - WHICH WAY TO MOVE NEXT?
	TDOA	T1,T2		;MOVE DOWN (ADD)
OSCH.2: SUB	T1,T2		;MOVE UP (SUBTRACT)
	ASH	T2,-1		;HALVE DELTA
	JUMPE	T2,OPERR	;ERROR IF NOT FOUND
	CAILE	T1,OPTTOP-OPTBOT;OUT OF BOUNDS?
	JRST	OSCH.2		;YES - MOVE UP
	JRST	OSCH.1		;NO - KEEP LOOKING
OSCH.3: MOVE	T,OPTBOT-1(T1)	;GET INFORMATION WORD
	HLRZM	T,MIXWRD	;STORE INITIAL MIX WORD
	HRLM	T,STMTNO	;STORE OP TYPE FOR PRINTING
	MOVE	CP,PT.ADR	;POINTER TO ADDR FIELD (LDB)-
	JRST	@OPDISP(T)	;GO TO APPROPRIATE ROUTINE
LOCERR: TLO	F,.LERR 	;MARK LOC FIELD ERROR
	JRST	OCSRCH-1	;PROCESS OPlomE&FIElm&
LOCBNK: MOVE	CP,PT.LBF	;POINTER TO LINE BUFFER (ILDB)
	MOVEI	T,13		;lHECk-TO-SEE&AlL-Ib BljnK-
	ILDB	C,CP
	CAIE	C," "
	TLO	F,.LERR 	;  ERROR OTHERWISE
	SOJG	T,.-3
	JRST	OCSRCH-1	;PROCESS OP FIELD
OPERR:	TLO	F,.OERR 	;MARK OP FIELD ERROR
	SETZ	T,		;USE ZERO FOR INFO WORD
				;  AND GO PROCESS LIKE A MOP
	SUBTTL	PROCESS A MACHINE OP
PMCHOP: LDB	C,CP		;GRAB A CHArjCcEr-
	CAIE	C," "		;SKIP AHEAD IF ADDR FIELD BLANK
	CAIN	C,		;  OR NULL
	JRST	RSTLIN
	CAIN	C,"("		;SKIP AHEAD IF A- AND I-PARTS VACdOUS
	JRST	PMOP.3+2
	CAIN	C,","		;SKIP AHEAD IF A-PART VACUOUS
	JRST	PMOP.6+3
FUTREF: 			;HANDLE FUTURE REFERENCES
	CAIN	C,"="		;LITERAL?
	JRST	FR.1		;YES - GO PROCESS
	PUSHJ	P,GETSON	;COLLECT SYMBOL
	JRST	PMOP.7		;NOTHING THERE - TRY EXPEVL
	TLNN	F,.ALPH 	;SYMBOL COLLECTED?
	JRST	PMOP.7		;NO - TRY EXPEVL
	PUSHJ	P,FNDSYM	;SEE IF SYMBOL IS PRESENT
	JRST	FR.4		;NOT THERE - ENTER INTO TABLE
	SKIPGE	(S)		;DEFINED?
	JRST	PMOP.7		;YES - TRY EXPEVL
	MOVEI	T,3(S)		;NO - IS A FUTURE FEFERENCE
	MOVEM	T,AFUTRF	;  SO SAVE A(SYMBOL VALUE)
	JRST	PMOP.6		;SKIP AHEAD
FR.1:	SETZM	LITSYM		;INITIALIZE LITERAL SYMBOL
	SETZM	LITSYM+1
	MOVE	T1,PT.LSM	;POINTER TO LITERAL SYMBOL (ILDB)
	MOVEI	T,13		;SET LENGTH OF SYMBOL
	JRST	.+4		;ENTRY WITH FIRST "="
	ILDB	C,CP		;GET NEXT CHARACTER
	CAIN	C,"="		;CLOSING "="?
	JRST	FR.2		;YES - EXIT FROM LOOP
	IDPB	C,T1		;DEPOSIT CHAR IN SYMBOL
	SOJG	T,.-4		;LOOP FOR ANOTHER CHARACTER
	TLO	F,.AERR!.RERR	;NO "=" FOUND - MARK ERRORS
	JRST	PMOP.6		;SKIP AHEAD
FR.2:	IBP	C,CP		;BUMP OVER "="
	MOVEM	CP,T.FRCP	;SAVE CHARACTER POINTER
	MOVE	T2,[LITSYM,,SYM] ;SET UP TO
	BLT	T2,SYM+1
	PUSHJ	P,FNDSYM	;FIND SYMBOL
	SKIPA	T1,[Z]		;NOT THERE - ZERO, SKIP, AND ENTER
	JRST	FR.1-3		;ALREADY DEFINED - SET UP AFUTRF AND LEAVE
	PUSHJ	P,ENTSYM	;ENTER SYMBOL IN TABLE
	JFCL			;HARD TO GET HERE
	HRRM	S,.+4		;SAVE FUTREF SYMBOL POINTER
	MOVE	CP,PT.LS2	;POINTER TO 2ND CHAR OF LITSYM (LDB)
	PUSHJ	P,WEVAL 	;EVALUATE THE LITERAL W-VALUE
	JRST	FR.3		;HANDLE ERRORS
	MOVEI	S,		;RESTORE FUTREF SYMBOL POINTER
	MOVEM	W,3(S)		;STORE W-VALUE AS SYMBOL VALUE (TEMPORARILY)
	MOVE	CP,T.FRCP	;RESTORE CHAR POINTER
	JRST	FR.1-3		;SET UP AFUTRF AND LEAVE
FR.3:	TLO	F,.WERR!.RERR!.AERR
				;MARK ERRORS
	JRST	.-4		;CLEAN UP AND LEAVE
FR.4:	SETZ	T1,		;PREPARE TO
	PUSHJ	P,ENTSYM	;  ENTER SYMBOL IN TABLE
	JFCL			;HARD TO GET HERE
	JRST	FR.1-3		;SAVE A(SYMBOL VALUE) AND LEAVE
PMOP.7: MOVE	CP,PT.ADR	;RESET POINTER TO ADDR FIELD
	MOVE	CP,PT.ADR	;RESET POINTER TO ADDR FIELD
	PUSHJ	P,EXPEVL	;EVALUATE A-PART
	JRST	PMOP.1		;MARK ERRORS AND EXIT
	TDZE	E,[377777,,770000] ;TRUNCATE TO TWO BYTES AND SIGN
	TLO	F,.TERR
	ASH	E,22		;PUT IN POSITION
	IORM	E,MIXWRD	;STORE MIX WORD
PMOP.6: LDB	C,CP		;NEXT CHARACTER
	CAIE	C,","		;I-PART THERE?
	JRST	PMOP.3		;NO - SKIP AHEAD
	IBP	CP		;BUMP OVER ","
	PUSHJ	P,EXPEVL	;EVALUATE I-PART
	JRST	PMOP.2		;CHECK THINGS
	TDZE	E,[-1B29]	;TRUNCATE TO ONE BYTE (PLUS)
	TLO	F,.TERR
	ROT	E,14		;PUT IN POSITION
	IORM	E,MIXWRD	;STORE IN MIX WORD
	LDB	C,CP		;NEXT CHARACTER
PMOP.3: CAIE	C,"("		;F-PART THERE?
	JRST	PMOP.4		;NO - SKIP AHEAD
	PUSHJ	P,FPART 	;EVALUATE F|Pjrt
	JRST	PMOP.5		;CHECK THINGS
	TDZE	E,[-1B29]	;TRUNCATE TO ONE BYTE (PLUS)
	TLO	F,.TERR
	MOVEI	T1,MIXWRD	;STORE IN MIX WORD
	DPB	E,FP.TAB+44
	LDB	C,CP		;NEXT CHARACTER
PMOP.4: CAIE	C," "		;ADDR FIELD DELIMITER FOUND?
	CAIN	C,
	JRST	.+2		;YES - SKIP
	TLO	F,.AERR 	;NO - ADDR FIELD ERROR
	JRST	RSTLIN		;FINISH WITH THIS LINE
PMOP.1: TLO	F,.EERR!.AERR	;MARK ERRORS
	JRST	RSTLIN		;FINISH WITH THIS LINE
PMOP.2: TLNE	F,.EXPVC	;EXPRESSION VACUOUS?
	JRST	PMOP.3		;YES - OKAY
	TLO	F,.IERR 	;MARK ERROR
	JRST	RSTLIN		;FINISH WITH THIS LINE
PMOP.5: TLNE	F,.EXPVC	;F-PART VACUOUS (I.E. () )?
	JRST	PMOP.4-5	;YES - OKAY
	TLO	F,.FERR 	;MARK ERROR
	JRST	RSTLIN		;FINISH WITH THIS LINE
	SUBTTL	PSEUDO OP PROCESSORS
PALFOP: 			;PROCESS ALF OP
	SETZB	C,T1		;INITIALIZE
	MOVE	CP,PT.ALF	;POINTER TO ADDR FIELD (ILDB)
	MOVEI	T,5		;ALF FIELD LENGTH
ALF.1:	ROT	C,6		;PREPARE FOR NEXT BYTE
	ILDB	T1,CP		;NEXT CHARACTER
	JUMPE	T1,ALF.4		;EXIT IF NULL FOUND
	CAIL	T1," "		;DEFINED CHARACTER?
	CAILE	T1,136
	JRST	ALF.3		;UNDEFINED MIX CHARACTER - ERROR
	CAIN	T1,134		;"\" IS UNDEFINED
	TLO	F,.AERR
ALF.2:	IOR	C,ATMTAB-" "(T1) ;ADD CHARACTER TO MIX WORD
	SOJG	T,ALF.1 	;LOOP FOR MORE
	MOVEM	C,MIXWRD	;STORE MIX WORD
	JRST	RSTLIN		;FINISH WITH THIS LINE
ALF.3:	TLO	F,.AERR 	;MARK ERROR
	MOVEI	T1,"?"		;SET MIX CHARACTER TO "?"
	JRST	ALF.2		;BACK FOR MORE
	ROT	C,6		;PUT IN PROPER POSITION
ALF.4:	SOJG	T,.-1		;LOOP UNTIL FINISHED
	MOVEM	C,MIXWRD	;STORE MIX WORD
	JRST	RSTLIN		;FINISH WITH THIS LINE
PCONOP: 			;PROCESS CON OP
	PUSHJ	P,WEVAL 	;EVALUATE THE W-VALUE
	TLO	F,.WERR!.AERR	;MARK ERRORS
	MOVEM	W,MIXWRD	;STORE MIX WORD
	JRST	RSTLIN		;FINISH WITH THIS LINE
PORGOP: 			;PROCESS ORIG OP
	PUSHJ	P,WEVAL 	;EVALUATE THE W-VALUE
	TLO	F,.WERR!.AERR	;MARK THE ERRORS
	TDZE	W,[-1B23]	;TRUNCATE TO TWO BYTES (PLUS)
	TLO	F,.AERR!.TERR
	MOVEI	LC,(W)		;STORn&NNf0LOLAcZoN-3ouvtVr-
	TLO	F,.DNILC	;DON'T INCREMENT LC
	JRST	RSTLIN		;FINISH WIcH&THIb Lrnn&
PEQUOP: 			;PROCESS EQU OP
	PUSHJ	P,WEVAL 	;EVALUATE THE W-VALUE
	TLO	F,.WERR!.AERR	;MARK ERRORS
	MOVEM	W,@T.EQU	;STORE NEW SYMBOL-VALuE
	MOVEM	W,MIXWRD	;  AND SAVE FOR PRINTING
	TLO	F,.DNILC	;DON'T INCREMENT LC
	JRST	RSTLIN		;FINISH WITH THIS LINE
	SUBTTL	END OP PROCESSOR
PENDOP: PUSHJ	P,WEVAL 	;EVALUATE W-VALUE
	TLO	F,.WERR!.AERR	;MARK ERRORS
	TDZ	W,[-1B23]	;LOOK ONLY AT (4:5) BYTE
	MOVEM	W,OUTLC 	;STORE FOR PRINTING
	SOJ	LC,		;SINCE .DNILC WON'T WORK
	POP	P,T4		;POP OFF RETURN (SO RETURNS HERE)
	PUSHJ	P,RSTLIN	;OUTPUT SCRATCH BLOCK
	SUBTTL	SEARCH SYMBOL TABLE FOR LITERALS AND UNDEFINED SYMBOLS
SYMSRC: SETZM	AFUTRF		;CLEAR FUTURE REFERENCE ADDR
	SETZB	F,OUTERR	;  AND OUTPUT ERROR FLAGS
	MOVEI	T,NMBKTS	;SET NUMBER ITERATIONS
	SKIPN	T1,BUKETS-1(T)	;GET A BUCKET
	JRST	.+11		;LOOP IF ZERO
	MOVE	T2,1(T1)	;GET FIRST WORD OF SYMBOL
	XOR	T2,[BYTE (7) "="] ;IS FIRST CHAR "="?
	TLNN	T2,774000
	JRST	ENDLIT		;YES - PROCESS LITERAL
	SKIPL	T2,(T1) 	;NO - DEFINED?
	JRST	ENDUDS		;NO - PROCESS UNDEFINED SYMBOL
	MOVEI	T1,(T2) 	;SET NEXT LINK
	JUMPG	T1,.-7		;LOOP FOR NEXT SYMBOL
	SOJG	T,.-12		;LOOP FOR NEXT BUCKET
	JRST	PROSCR		;GO PROCESS SCRATCH FILE
ENDLIT: TLOA	F,.LITRL	;MARK PROCESSING LITERAL
ENDUDS: TLZ	F,.LITRL	;MARK PROCESSING UNDEF SYMBOL
	MOVE	T2,[
	XWD	[ASCIZ/           CON  0/],OUTLIN]
				;SETUP BLT POINTER
	BLT	T2,OUTLIN+3	;SETUP CON CARD FOR LITERAL
	TLNN	F,.LITRL	;SKIP AHEAD IF UDS
	JRST	.+11
	MOVE	T2,3(T1)	;STORE MIX WORD FROM SYMBOL VALUE
	MOVEM	T2,MIXWRD
	MOVE	T2,1(T1)	;CHANGE LEADING "=" TO " " AND STORE SYM
	TLZ	T2,<"="-" ">B24
	MOVEM	T2,OUTLIN+3
	MOVE	T2,2(T1)
	MOVEM	T2,OUTLIN+4
	JRST	.+2		;SKIP FOR UDS
	SETZM	MIXWRD		;CON 0 TO MIX WORD
	AOJ	LC,		;BUMP LOCATION COUNTER
	TDZE	LC,[-1B23]	;TRUNCATE TO TWO BYTES (PLUS)
	TLO	F,.TERR!.LERR
	MOVEM	LC,OUTLC	;  AND STORE FOR PRINTING
	MOVEM	LC,3(T1)	;DEFINE LITERAL/SYMBOL VALUE
	MOVEI	W,CONOP 	;STORE OP TYPE FOR PRINTING
	HRLM	W,STMTNO
	AOS	STMTNO		;INCREMENT STATEMENT NO.
	MOVEM	F,OUTERR	;ERROR FLAGS FOR PRINTING
	MOVE	CP,PT.STB	;POINTER TO SYMBOL TABLE (ILDB)
	MOVE	T2,PT.LBF	;POINTER TO LINE BUFFER (ILDB)
	ILDB	C,CP		;GRAB A CHARACTER
	CAIN	C,		;NULL?
	JRST	.+3		;YES - EXIT
	IDPB	C,T2		;NO - DEPOSIT AND LOOP
	JRST	.-4
	MOVE	T2,[-12,,SCRTCH] ;SET AOBJN SCRATCH BLOCK POINTER
	PUSHJ	P,RSTLIN+6	;OUTPUT SCRATCH BLOCK
	HRRZ	T1,(T1) 	;GET NEXT LINK
	JRST	ENDLIT-3	;LOOP FOR NEXT SYMBOL
	SUBTTL	PROCESS REST OF LINE
RSTLIN: MOVEM	F,OUTERR	;STORE ERROR FLAGS FOR PRINTING
	MOVE	T2,LINSIZ	;NUMBER OF CHARS IN LINE
	IDIVI	T2,5		;GET NUMBER OF WORDS TO SAVE IN SCRATCH BLOCK
	MOVNI	T2,6(T2)
	MOVSI	T2,(T2) 	;FORM AOBJN SCRATCH BLOCK POINTER
	HRRI	T2,SCRTCH
	SOSG	SOB+2
	OUT	SCR,
	AOSA	SOB+1
	HALT
	MOVEM	T2,@SOB+1	;  AND OUTPUT IT
	MOVE	C,(T2)
	SOSG	SOB+2
	OUT	SCR,
	AOSA	SOB+1
	HALT
	MOVEM	C,@SOB+1	;  ALONG WITH THE REST OF THE BLOCK
	AOBJN	T2,.-6
	POPJ	P,		;RETURN TO CALLER
	SUBTTL	PROCESS SCRATCH FILE - PRINT AND SAVE RESULTS
PROSCR: CLOSE	SRC,		;FINISHED WITH SOURCE FILE
	RELEAS	SRC,
	CLOSE	SCR,
	OPEN	SCR,[EXP 13
	SIXBIT	/DSK/
	XWD	0,SIB]
	HALT
	LOOKUP	SCR,[SIXBIT	/SCRTCH/
	SIXBIT	/MIX/
	EXP	0,0]
	HALT
	MOVE	T,ABUF1
	MOVEM	T,.JBFF
	OUTBUF	LST,2
	MOVE	T,ABUF2
	MOVEM	T,.JBFF
	INBUF	SCR,2
	MOVSI	FP,-7
PS.1:	SOSG	SIB+2
	IN	SCR,
	AOSA	SIB+1
	JRST	FINISH
	MOVE	T,@SIB+1
	SOSG	SIB+2
	IN	SCR,
	AOSA	SIB+1
	JFCL			;SHOULD NEVER GET HERE
	MOVE	C,@SIB+1
	MOVEM	C,(T)
	AOBJN	T,.-6
	SKIPE	S,AFUTRF
	JRST	LNKFR		;LINK UP FUTURE REFERENCE
PS.2:	MOVEI	C,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/O AND EXIT
FINISH:	JSP	IOL,OPUT
	HRRZ	T4,MIXSA
	SOSG	OOB+2
	OUT	MOB,
	AOSA	OOB+1
	HALT
	MOVEM	T4,@OOB+1
	RENAME	SCR,[Z] 	;SO WHO FILES THEIR SCRATCH PAPER?
	CLOSE	MOB,
	CLOSE	LST,
	RELEAS	SCR,
	RELEAS	LST,
	RELEAS	MOB,
	EXIT			;.....(!)......(!!).  . ...... ..
	SUBTTL	RANDOM
GETCOR: HRRZ	T3,.JBREL
	ADDI	T3,2000
	CORE	T3,
	HALT
	POPJ	P,
COMCRD: 			;PROCESS COMMENT CARD
	TLO	F,.DNILC	;DON'T INCREMENT LC
	MOVEI	T,COMOP 	;STORE COMMENT OP TYPE FOR PRINTING
	HRLM	T,STMTNO
	JRST	RSTLIN		;FINISH WITH THIS LINE
	SUBTTL	W-VALUE EVALUATOR (FULL-WORD MIX CONSTANT)
WEVAL:	SETZ	W,		;SET INITIAL W-VALUE TO +ZERO
	LDB	C,CP		;GET FIRST CHARACTER
	CAIE	C," "		;SPACE?
	CAIN	C,		;  OR NULL (END MARK)?
	POPJ1			;YES - NORMAL RETURN
	CAIN	C,","		;VACUOUS?
	JRST	WEVL.3		;YES - BUMP AND LOOK AGAIN
	CAIN	C,"("		;EXPRESSION PART VACUOUS?
	JRST	WEVL.1		;YES - SKIP AHEAD
	PUSHJ	P,EXPEVL	;EVALUATE EXPRESSION
	JRST	WEVL.4		;EXPRESSION ERROR (CAN'T BE VACUOUS)
	MOVEM	E,W.TEMP	;SAVE EXPRESSION
	LDB	C,CP		;GET NEXT CHARACTER
	CAIE	C,"("		;IS F-PART THERE?
	JRST	WEVL.7		;IF VACUOUS, USE (0:5)
WEVL.1: PUSHJ	P,FPART 	;GO EVALUATE F-PART
	JRST	WEVL.5		;CHECK ON THINGS
	CAIG	E,55		;TOO BIG?
	JUMPGE	E,.+2		;  OR TOO SMALL?
	JRST	WEVL.6		;YES - ERROR IN F-PART
WEVL.2: MOVEI	T1,W.TEMP	;SET A(TEMPORARY W-VALUE)
	SKIPN	T4,FP.TAB(E)	;SET FIELD POINTER - ZERO?
	JRST	WEVL.6		;YES - ERROR IN F-PART
	LDB	T3,T4		;GET BYTE FROM W.TEMP
	MOVEI	T1,W		;SET A(RECEIVER OF W-VALUE)
	DPB	T3,T4		;PUT W-VALUE IN W (NATURALLY...)
	JRST	WEVAL+1 	;LOOP FOR MORE PRIMITIVES
WEVL.3: IBP	CP		;BUMP OVER COMMA
	JRST	WEVAL+1 	;LOOK FOR MORE PRIMITIVES
WEVL.4: TLO	F,.EERR 	;EXPRESSION ERROR
	POPJ	P,		;  AND ERROR RETURN
WEVL.5: TLNE	F,.EXPVC	;EXPRESSION VACUOUS (I.E. () )?
	JRST	WEVL.2		;YES - USE F-PART OF ZERO
WEVL.6: TLO	F,.FERR 	;NO - F-PART ERROR
	POPJ	P,		;  AND ERROR RETURN
WEVL.7: MOVEI	E,5		;DEFAULT F-PART IS (0:5)
	JRST	WEVL.2		;PUT IT IN
	SUBTTL	EVALUATE AN F-PART ( <(><EXPRESSION><)> )
FPART:	IBP	CP		;SKIP OVER "(" (HAS TO BE THERE)
	PUSHJ	P,EXPEVL	;EVALUATE EXPRESSION
	JRST	FPRT.1		;CHECK ON CLOSING PAREN
	CAIE	C,")"		;CLOSING PAREN THERE?
	JRST	FPRT.2		;NO - F-PART ERROR BUT NORMAL RETURN
	IBP	CP		;YES - SKIP OVER
	POPJ1			;  AND NORMAL RETURN
FPRT.1: CAIN	C,")"		;CLOSING PAREN THERE?
	JRST	.+3		;YES - SKIP
	TLO	F,.FERR 	;NO - F-PART ERROR
	POPJ	P,		;ERROR RETURN
	IBP	CP		;BUMP OVER ")"
	POPJ	P,		;ERROR RETURN
FPRT.2: TLO	F,.FERR 	;F-PART ERROR
	POPJ1			;  BUT NORMAL RETURN (ONLY FORMAT ERROR)
	SUBTTL	COLLECT SYMBOL OR NUMBER
GETSON: TLZ	F,.SYMVC!.ALPH	;INITIALIZE
	SETZB	T1,SYM		;INITIALIZE SYMBOL TO NULLS
	SETZB	T2,SYM+1
	MOVSI	T1,-13		;(MAX NUMBER OF CHARS) + 1
	MOVE	T4,PT.SYM	;POINTER TO SYMBOL OUTPUT
	LDB	C,CP		;GET FIRST CHARACTER
GTSN.1: CAIL	C,"0"		;NUMBER?
	CAILE	C,"9"
	JRST	GTSN.3		;NO - TRY LETTER
	AOBJP	T1,GTSN.5	;EXIT IF TOO LONG
	IDPB	C,T4		;STORE AS PART OF SYMBOL
	TLNE	F,.ALPH 	;LETTER FOUND YET?
	JRST	GTSN.2		;YES - SKIP CUMULATIVE NUMBER
	IMULI	T2,12		;SUM ← SUM*10 + DIGIT
	ADDI	T2,-"0"(C)	;CONVERT ASCII TO DIGIT AND ADD IN
GTSN.2: ILDB	C,CP		;GET NEXT CHARACTER
	JRST	GTSN.1		;LOOP
GTSN.3: CAIL	C,"A"		;LETTER?
	CAILE	C,"Z"
	JRST	GTSN.4		;NO - EXIT
	AOBJP	T1,GTSN.5	;EXIT IF TOO LONG
	IDPB	C,T4		;STORE AS PART OF SYMBOL
	TLO	F,.ALPH 	;MARK AS SYMBOL
	ILDB	C,CP		;GET NEXT CHARACTER
	JRST	GTSN.1		;LOOP
GTSN.4: TRNE	T1,-1		;COLLECTED ANYTHING?
	POPJ1			;YES - NORMAL RETURN
	TLO	F,.SYMVC	;MARK AS VACUOUS
GTSN.5: POPJ	P,		;ERROR RETURN
	SUBTTL	ATOMIX EXPRESSION EVALUATOR
ATOMIC: SETZ	N,		;SET VALUE TO +ZERO
	LDB	C,CP		;GET THE FIRST CHARACTER
	CAIN	C,"*"		;LOCATION COUNTER?
	JRST	ATOM.2		;GO HANDLE IT
	PUSHJ	P,GETSON	;COLLECT SYMBOL OR NUMBER
	POPJ	P,		;ERROR RETURN TO CALLER
	TLNE	F,.ALPH 	;SYMBOL COLLECTED?
	JRST	ATOM.1		;YES - FIND ITS VALUE
	TLZE	T2,TMASK	;TRUNCATE TO 30 MAGNITUDE BITS
	TLO	F,.TERR 	;TRUNCATION ERROR
	MOVE	N,T2		;MAGNITUDE OF NUMBER TO N
	POPJ1			;NORMAL RETURN
ATOM.1: PUSHJ	P,FNDSYM	;FIND SYMBOL ENTRY
	POPJ	P,		;SYMBOL NOT FOUND - ERROR RETURN
	SKIPL	(S)		;SYMBOL DEFINED?
	POPJ	P,		;ERROR RETURN
	MOVE	N,3(S)		;VALUE TO N
	POPJ1			;NORMAL RETURN
ATOM.2: MOVE	N,LC		;LOCATION COUNTER TO N
	IBP	CP		;BUMP CHARACTER POINTER
	POPJ1			;NORMAL RETURN
	SUBTTL	DEFINE A SYMBOL (OR JUST ENTER INTO THE TABLE)
DEFSYM: PUSHJ	P,FNDSYM	;GO FIND SYMBOL OR END
	SKIPA	T1,[.DEFIN,,0]	;END FOUND - MARK AS DEFINED AND SKIP
	JRST	DFSM.1		;SYMBOL FOUND - GO CHECK IF DEFINED
;NEW SYMBOLS ARE STORED AT THE BEGINNING OF THE LIST FOR EACH BUCKET
;  SINCE THE OCCURRENCE OF A SYMBOL IS OFTEN NOT INDEPENDENT OF PREVIOUS
;  USAGE (I.E., USAGE OF SYMBOLS IS CLUSTERED)
ENTSYM: HRR	T1,(T)		;GET OLD LIST HEAD
	MOVEM	T1,(FP) 	;STORE HEADER OF NEW ENTRY
	MOVEM	FP,(T)		;STORE NEW HEAD POSITION
	MOVEI	S,(FP)		;A(NEW ENTRY) TO S
	MOVEI	FP,4(FP)	;BUMP FREE POINTER
	CAMLE	FP,.JBREL	;NEED MORE CORE?
	PUSHJ	P,GETCOR	;YES - GO GET SOME MORE
	MOVSI	T2,SYM		;ENTER SYMBOL
	HRRI	T2,-3(FP)
	BLT	T2,-2(FP)
	JUMPGE	T1,.+3		;EXIT IF DONE
ENTVAL: MOVE	T1,SYMVAL	;ENTER SYMBOL VALUE
	MOVEM	T1,3(S)
	POPJ1			;NORMAL RETURN
DFSM.1: SKIPGE	T1,(S)		;ALREADY DEFINED?
	POPJ	P,		;YES - ERROR RETURN
	HRLI	T1,.DEFIN	;NO - MARK AS DEFINED AND STORE
	MOVEM	T1,(S)
	JRST	ENTVAL		;  AND ENTER THE VALUE
	SUBTTL	FIND A SYMBOL
FNDSYM:  LCSMCK:!		;CHECK FOR LOCAL SYMBOLS
	MOVE	T2,SYM		;FIRST WORD OF SYMBOL
	TDNE	T2,[401437,,-1] 	;TEST FOR ZEROES IN (N)(H,F,B)
	JRST	HASHIT		;CAN'T BE LOCAL SYMBOL, SO GO ON
	SETZ	T1,		;PREPARE TO
	ROTC	T1,7
	CAIG	T1,"9"		;CHECK FOR DIGIT
	CAIGE	T1,"0"
	JRST	HASHIT		;NOT LOCAL, SO GO ON
	MOVEI	T3,-"0"(T1)		;MAKE IT A NUMBER & SAVE DIGIT
	MOVE	T4,LCSMNO(T3)	;GET LOCAL SYMBOL N SERIAL NUMBER
	SETZ	T1,		;PREPARE TO
	ROTC	T1,7
	CAIN	T1,"F"		;CHECK LETTER
	JRST	LCSM.F		;PROCESS (N)F
	CAIN	T1,"B"
	JRST	LCSM.B		;PROCESS (N)B
	CAIE	T1,"H"
	JRST	HASHIT		;NOT LOCAL, SO GO ON
LCSM.H: AOSA	T4,LCSMNO(T3)	;BUMP & STORE SERIAL NUMBER
LCSM.F: MOVEI	T4,1(T4)	;BUMP SERIAL NUMBER
;CONTRUCT A UNIQUE SYMBOL OF THE FORM "(N)HNNNN", WHERE NNNN IS UNIQUE
LCSM.B: MOVE	T1,PT.SYM	;GET POINTER TO SYMBOL
	MOVEI	T2,"0"(T3)	;GET ASCII DIGIT IN T2
	IDPB	T2,T1		;STORE (N)
	MOVEI	T2,"H"
	IDPB	T2,T1		;AND "H"
	MOVSI	T4,(T4) 	;PUT SERIAL NUMBER IN POSITION
	LSH	T4,6
	MOVSI	T2,-4		;SET UP AOBJN COUNTER
	SETZ	T3,		;SERIAL NUMBER INTO ASCII
	LSHC	T3,3
	MOVEI	T3,"0"(T3)
	IDPB	T3,T1
	AOBJN	T2,.-4
HASHIT: MOVE	T1,SYM		;FIGURE HASH CODE
	XOR	T1,SYM+1
	MUL	T1,[EXP 475026625661]
	SETZ	T1,
	ROTC	T1,<43-<↑L<NMBKTS>>>
	MOVEI	S,BUKETS(T1)	;GET A(BUCKET HASHED)
	MOVEI	T,(S)		;SAVE FOR PUTTING NEW ENTRY AT HEAD OF LIST
	SKIPN	(S)		;BUCKET INITIALIZED?
	POPJ	P,		;NO - ERROR RETURN
	MOVE	T1,SYM		;GET ASCII FOR CHECKING
	MOVE	T2,SYM+1
	JRST	.+4		;ENTER LOOP
FDSM.1: HRRZ	T3,(S)		;SYMBOL BLOCK HEADER
	JUMPN	T3,.+2		;SKIP IF NOT END
	POPJ	P,		;ERROR RETURN
	MOVE	S,(S)		;GET NEXT LINK
	CAMN	T1,1(S) 	;SYMBOL HERE?
	CAME	T2,2(S)
	JRST	FDSM.1		;NO - LOOP FOR ANOTHER BLOCK
	POPJ1			;SYMBOL FOUND - NORMAL RETURN
	SUBTTL	EXPRESSION EVALUATOR
EXPEVL: JRSTF	@[0,,.+1]	;CLEAR POSSIBLE CRAP IN FLAGS
	TLZ	F,.EERR!.EXPVC	;INITIALIZE
	SETZ	E,		;EXPRESSION VALUE TO +ZERO
	LDB	C,CP		;GET FIRST CHARACTER
	CAIE	C,"+"		;IS IT UNARY PLUS?
	 CAIN	 C,"-"		;   OR UNARY MINUS?
	JRST	EXP.1-1 	;YES - GO PROCESS IT
	PUSHJ	P,ATOMIC	;EVALUATE FIRST ATOMIC EXPRESSION
	JRST	EXPNFD		;EXPRESSION NOT FOUND
	MOVE	E,N		;PUT FIRST ATOMIC IN E
	JRST	.+6		;ENTER LOOP
EXP.OP: JUMPGE	E,.+3		;SKIP IF IN MAG-SIGN FORM
	MOVN	E,E		;IF NOT, CONVERT IT
	TLO	E,.SIGN
	TLZE	E,TMASK 	;TRUNCATE TO 30 MAGNITUDE BITS
	TLO	F,.TERR 	;TRUNCATION ERROR
	LDB	C,CP		;GET NEXT CHARACTER
	MOVSI	T1,-5		;SET UP FOR OPERATOR SEARCH
EXP.1:	CAMN	C,E.OPCH(T1)	;OPERATOR FOUND?
	JRST	EXP.2		;YES - GO PROCESS IT
	AOBJN	T1,EXP.1	;TEST OTHER OPERATORS
				;NEXT OPERATOR NOT FOUND - NORMAL EXIT
	JOV	.+2		;SKIP IF SOMETHING OVERFLOWED
				;ONLY POSSIBLE OVERFLOWS ARE IN THE DIVIDES
	POPJ1
	TLO	F,.TERR 	;TRUNCATION ERROR (DIVIDE BY ZERO)
	POPJ1
EXP.2:	IBP	CP		;BUMP OVER OPERATOR
	HRRM	C,ED.1		;SAVE OPERATOR FOR POSSIBLE "//" CHECK
	MOVEI	T1,@E.OPRT(T1)		;SAVE A(ROUTINE DESIRED)
	HRRM	T1,EXP.3
	PUSHJ	P,ATOMIC	;GET SECOND OPERAND
	JRST	E.DDIV		;CHECK IF "//"
	TLZE	E,.SIGN 	;PUT OPERANDS INTO TWOS COMPLEMENT FORM
	MOVN	E,E
	TLZE	N,.SIGN
	MOVN	N,N
EXP.3:	XCT	.		;PERFORM PROPER OPERATION
	JRST	EXP.OP
E.ADD:	ADD	E,N
E.SUB:	SUB	E,N
E.MUL:	IMUL	E,N
E.DIV:	IDIV	E,N
E.COL:	JRST	.+1
	ASH	E,3
	ADD	E,N
	JRST	EXP.OP
E.DDIV: TLNN	F,.SYMVC	;WAS ATOMIC VACUOUS?
	JRST	EXPERR		;NO - EXPRESSION ERROR
	CAIN	C,"/"		;IS IT A SECOND SLASH?
ED.1:	CAIE	C,
	JRST	EXPERR		;NO - ERROR RETURN
	SETZ	T2,		;PREPARE FOR DOUBLE LENGTH DIVISION
	MOVE	T1,E
	ASHC	T1,-5		;PUT IN POSITION AS E*(2**30)
	DIV	T1,N		;DIVIDE
	MOVE	E,T1
	JRST	EXP.OP
EXPNFD: TLNN	F,.SYMVC	;ATOMIC VACUOUS?
	JRST	.+2		;NO - EXPRESSION ERROR
	TLOA	F,.EXPVC	;YES, SO EXPRESSION IS VACUOUS
EXPERR: TLO	F,.EERR 	;EXPRESSION ERROR
	POPJ	P,		;ERROR RETURN
	SUBTTL	RANDOM GARBAGE
;BYTE POINTERS
PT.LBF: POINT	7,OUTLIN
PT.OPC: POINT	7,OUTLIN+2,6
PT.IOC: POINT	7,INOPC
PT.ADR: POINT	7,OUTLIN+3,13
PT.SYM: POINT	7,SYM
PT.STB: POINT	7,1(T1)
PT.LIN: POINT	7,OUTLIN,6
PT.ALF: POINT	7,OUTLIN+3,6
PT.LSM: POINT	7,LITSYM
PT.LS2: POINT	7,LITSYM,13
;RANDOM MEMORY LOCATIONS
;SCRATCH BLOCK
SCRTCH:
AFUTRF: Z
OUTLC:	Z
MIXWRD: Z
STMTNO: Z
OUTERR: Z
OUTLIN: BLOCK	33
;SYMBOL TABLE BUCKETS
BUKETS: BLOCK	NMBKTS
;LOCAL SYMBOL SERIAL NUMBER TABLE
LCSMNO: BLOCK	12
;MIX OBJECT OUTPUT BLOCK
MOBBLK: BLOCK	7
MOBLOC: Z
MIXSA:	Z
LINSIZ: Z
INOPC:	Z
T.EQU:	Z
W.TEMP: Z
SYMVAL: Z
IIB:	BLOCK	3
SIB:	BLOCK	3
SOB:	BLOCK	3
LOB:	BLOCK	3
OOB:	BLOCK	3
SYM:	BLOCK	3
LITSYM: BLOCK	3
PDLIST: BLOCK	40
T.FRCP: Z
ABUF1:	Z
ABUF2:	Z
	SUBTTL	TABLES
IF1,<	PRINTX TABLES ON PASS 1>
IF2,<	PRINTX TABLES ON PASS 2>
	OPDISP=.+1		;OPCODE TYPE DISPATCH TABLE
	PHASE	-1
ALFOP:	PALFOP
	Z
EQUOP:	PEQUOP
ENDOP:	PENDOP
CONOP:	PCONOP
COMOP:	Z
	Z
ORIGOP: PORGOP
MACHOP: PMCHOP
	DEPHASE
E.OPCH: EXP	":","+","-","*","/"	;TABLE OF OPERATORS
E.OPRT: EXP	E.COL,E.ADD,E.SUB,E.MUL,E.DIV	;OPERATOR PROCESSOR ADDRESSES
ERRTAB: ERRORS(AEFILORSTW)	;ERROR FLAG TABLE
;ASCII TO MIX CHARCTER CODE CONVERSION TABLE
ATMTAB: ATOMIX<0,20,21,56,49,57,58,55,42,43,46,44,41,45,40,47,30,31,32,33,34,∨
35,36,37,38,39,54,53,50,48,51,10,52,1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,18,∨
19,22,23,24,25,26,27,28,29,59,10,60,61>
	N==0
FP.TAB: 			;BYTE POINTER TABLE FOR MIX FIELDS
REPEAT	56,<	FPOINT	>
	SUBTTL	OPCODE TABLE
	RADIX	10		;FOR KNUTH'S SAKE..
	TOLD=1B0
OPTBOT:
	MOP(ADD,1)
	AOP(ALF,ALFOP)
IFN	BINOPS,<
	MOP(AND,5,3)
>
	MOP(CHAR,5,1)
	MOP(CMP1,57)
	MOP(CMP2,58)
	MOP(CMP3,59)
	MOP(CMP4,60)
	MOP(CMP5,61)
	MOP(CMP6,62)
	MOP(CMPA,56)
	MOP(CMPX,63)
	AOP(CON,CONOP)
	MOP(DEC1,49,1)
	MOP(DEC2,50,1)
	MOP(DEC3,51,1)
	MOP(DEC4,52,1)
	MOP(DEC5,53,1)
	MOP(DEC6,54,1)
	MOP(DECA,48,1)
	MOP(DECX,55,1)
	MOP(DIV,4)
	AOP(END,ENDOP)
	MOP(ENN1,49,3)
	MOP(ENN2,50,3)
	MOP(ENN3,51,3)
	MOP(ENN4,52,3)
	MOP(ENN5,53,3)
	MOP(ENN6,54,3)
	MOP(ENNA,48,3)
	MOP(ENNX,55,3)
	MOP(ENT1,49,2)
	MOP(ENT2,50,2)
	MOP(ENT3,51,2)
	MOP(ENT4,52,2)
	MOP(ENT5,53,2)
	MOP(ENT6,54,2)
	MOP(ENTA,48,2)
	MOP(ENTX,55,2)
	AOP(EQU,EQUOP)
IFN	FLTOPS,<
	MOP(FADD,1,6)
	MOP(FCMP,56,6)
	MOP(FDIV,4,6)
	MOP(FIX,5,8)
	MOP(FLOT,5,6)
	MOP(FMUL,3,6)
	MOP(FSUB,2,6)
>
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