Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0010/palx11.3
There are 2 other files named palx11.3 in the archive. Click here to see a list.
	TITLE	PALX11	V003	20-FEB-70

;	COPYRIGHT 1969,1970, DIGITAL EQUIPMENT CORPORATION.
;	Edited to redefine the JOBDAT symbols from JOBxxx to .JBxxx
;	by Paul T. Robinson, Wesleyan Univ. 
;	for DECUS conversion to DEC-20 library.
;	Edits in lower case.

	LOC	137
	003
	RELOC

TITLE:	SIXBIT	/PALX11/
SUBTTL:	SIXBIT	/V003  /

	ENTRY		PALX11

;	EXTERNAL	JOBREL,	JOBFF,	JOBDDT,	JOBSYM,	JOBAPR,	JOBTPC
	external	.jbrel, .jbff, .jbddt, .jbsym, .jbapr, .jbtpc
	jobrel==.jbrel
	jobff==.jbff
	jobddt==.jbddt
	jobsym==.jbsym
	jobapr==.jbapr
	jobtpc==.jbtpc

	INTERNAL	PATCH
	SUBTTL	VARIABLE PARAMETERS

	PAGSIZ=	^D54		; NUMBER OF LINES ON A PAGE

	NUMBUF=	2		; NUMBER OF BUFFERS PER DEVICE

	CORINC=	2000		; CORE INCREMENT

	SPL=	4		; SYMBOLS PER LINE (SYMBOL TABLE LISTING)

	SPLTTY=	3		; SYMBOLS PER LINE (TTY)

	RADIX=	^D8		; ASSEMBLER RADIX

	DATLEN=	^D350		; DATA BLOCK LENGTH

	CPW=	6		; CHARACTERS PER WORD

	WPB=	10		; MACRO BLOCK SIZE

	CPL=	^D120		; CHARACTERS PER LINE

	PDPLEN=	40		; INITIAL PUSH-DOWN POINTER LENGTH

	PDPINC=	10		; PUSH-DOWN POINTER INCREMENT
	SUBTTL	ACCUMULATOR ASSIGNMENTS

	%00=	0		; ACCUMULATION OF SIXBIT SYMBOL, SCRATCH
	%01=	1		; SYMBOL VALUE AND FLAGS SET BY SRCH.  SCRATCH
	%02=	2		; SCRATCH
	%03=	3		; SCRATCH
	%04=	4		; CODE TO BE GENERATED.  LH - TYPE,  RH - VALUE
	%05=	5		; LOCATION COUNTER
	%06=	6		; SCRATCH
	%07=	7		; SYMBOL TABLE SEARCH INDEX
	%10=	10		; EXPRESSION OR TERM VALUE, SCRATCH
	%11=	11		; SCRATCH
	%12=	12		; MACRO STORAGE BYTE POINTER
	%13=	13		; LINE BUFFER BYTE POINTER
	%14=	14		; CURRENT CHARACTER (ASCII)
	%15=	15		; LH - ASSEMBLER FLAGS,  RH - ERROR FLAGS
	%16=	16		; EXEC FLAGS
	%17=	17		; PUSH-DOWN POINTER
	SUBTTL	FLAG REGISTERS

				; %16 - LH

	LSTBIT=	000001		; 1- SUPRESS LISTING OUTPUT
	BINBIT=	000002		; 1- SUPRESS BINARY OUTPUT
	CSWBIT=	000004		; 1- SUPRESS CROSS REFERENCE
	ESWBIT=	000010		; 1- LIST OCTAL
	MSWBIT=	000020		; 1- SUPRESS MACRO LISTING
	NSWBIT=	000040		; 1- SUPRESS ERRORS ON TTY
	RSWBIT=	000100		; 1- REPRODUCE SOURCE
	TTYBIT=	000200		; 1- LISTING IS ON TTY


				; %16 - RH

	ARWBIT=	000001		; 1- LEFT ARROW SEEN
	EXTBIT=	000002		; 1- EXPLICIT EXTENSION SEEN
	SWTBIT=	000004		; 1- ENTER SWITCH MODE
	INFBIT=	000010		; 1- VALID INFORMATION SEEN
	FFBIT=	000020		; 1- FORM-FEED SEEN
	ENDBIT=	000400		; 1- END OF ALL INPUT FILES
	SLABIT=	001000		; 1- SWITCH MODE ENTERED WITH A </>
	NULBIT=	010000		; 1- NON-NULL COMMAND STRING
	HDRBIT=	040000		; 1- TIME FOR NEW LISTING PAGE
	SEQBIT=	100000		; 1- SEQUENCE NUMBER SEEN
	MODBIT=	200000		; 1- USER MODE AC'S SET


				; %15 - LH

	DECFLG= 000002		; DECIMAL NUMBER
	SRCFLG=	000004		; 1- SUPPRESS LISTING OF SOURCE TEXT
	LINFLG=	000010		; 1- SUPPRESS LISTING OF LINE
	ENDFLG=	000020		; 1- END OF SOURCE ENCOUNTERED
	RSWFLG=	000040		; 1- LINE TO BE SUPPRESSED IN REDUCTION
	TTYFLG=	000100		; 1- TTY MODE LISTING FORMAT
	CONFLG=	000200		; 1- CONCATENATION CHARACTER SEEN
	LPTFLG=	000400		; 1- NO LPT LISTING OF SOURCE
	ROKFLG=	001000		; 1- REGISTER "OK" FLAG
	REGFLG=	002000		; 1- REGISTER FLAG
	P1F=	400000		; 1- PASS 1 IN PROGRESS
	SUBTTL	MISCELLANEOUS PARAMETERS

	TTYDEV=	000010		; 1- DEVICE IS A TTY
	PTRDEV=	000200		; 1- DEVICE IS A PTR
	LPTDEV=	040000		; 1- DEVICE IS A LPT
	CDRDEV=	100000		; 1- DEVICE IS A CDR

	IODATA= 200000		; 1- IO DATA ERROR
	IODEV=  100000		; 1- IO PARITY ERROR
	IOWRLK= 400000		; 1- IO WRITE LOCK ERROR
	IOBKTL=	040000		; 1- IO BLOCK TOO LARGE
	IOEOF=	020000		; 1- END OF FILE ON IO DEVICE


				; DEVICE PARAMETERS

	TTO=	0
	BIN=	1
	LST=	2
	SRC=	3
	TTI=	4


				; CREF FLAG CHARACTERS

	CRFLIN=	35
	CRFSYM=	36
	CRFMAC=	34
	CRFOPC=	33


				; OPDEFS

	OPDEF	RESET	[CALLI	 0]
	OPDEF	DEVCHR	[CALLI	 4]
	OPDEF	CORE	[CALLI	11]
	OPDEF	DATE	[CALLI	14]
	OPDEF	APRENB	[CALLI	16]
	OPDEF	MSTIME	[CALLI	23]
	OPDEF	RUNTIM	[CALLI	27]
	OPDEF	ZBINK	[CLOSE BIN,]
	SUBTTL	EXEC

PALX11:				;MAIN ENTRY POINT
	RESET			;RESET ALL I/O
	MOVEI	%17,ARGLST-1	;USE ARGLST AS TEMPORARY PDP
	MOVE	%00,[XWD BZCOR,BZCOR+1]
	SETZB	%01,BZCOR
	MOVE	%02,JOBREL
	SKIPE	JOBDDT
	MOVE	%02,JOBSYM
	BLT	%00,-1(%02)
	RUNTIM	%01,
	MOVEM	%01,RUNTIM
	DATE	%00,
	MOVEM	%00,DATE	;SAVE DATE
	MSTIME	%00,
	MOVEM	%00,MSTIME	;  AND TIME
	MOVSI	%16,BINBIT!LSTBIT!CSWBIT
	HRRI	%16,HDRBIT
	SETZ	%15,		;CLEAR ASSEMBLER FLAG REGISTER

	MOVE	%00,[INIT TTI,1]
	MOVSI	%01,(SIXBIT /TTY/)
	MOVEI	%02,TTIBUF
	PUSHJ	%17,INISET	;INITIALIZE TTY FOR INPUT
	INBUF	TTI,1		;GIVE IT AN INPUT BUFFER
	MOVE	%00,[INIT TTO,1]
	MOVSI	%02,TTOBUF
	PUSHJ	%17,INISET
	OUTBUF	TTO,4

	MOVEI	%00,EZCOR-TITLE+204*NUMBUF*3+PDPLEN+200
	SKIPE	JOBDDT		;  UNLESS DDT IS LOADED
	JRST	.+3
	CORE	%00,
	 JRST	ERRNC
	MOVEI	%02,"*"		;TYPE AN ASTERISK AT THE USER
	PUSHJ	%17,TTYDMP	;...
	OUTPUT	TTO,		;REALLY OUTPUT IT
	INPUT	TTI,		;GET A COMMAND STRING
	MOVSI	%01,(SIXBIT /DSK/)
	PUSHJ	%17,GETBIN	;INITIALIZE THE BINARY FILE
	MOVSI	%01,(SIXBIT /DSK/)
	TRNN	%16,ARWBIT	;GO ON TO SOURCE IF _ HAS BEEN SEEN
	PUSHJ	%17,GETLST	;INITIALIZE THE LISTING FILE

	MOVE	%05,JOBFF
	MOVEM	%05,JOBFFI	;SAVE START OF SRC BUFFER
	MOVE	%05,TTIPNT
	MOVEM	%05,TTISAV	;SAVE TTI POINTER
	MOVSI	%01,(SIXBIT /DSK/)
	PUSHJ	%17,GETSRC	;INITIALIZE THE SOURCE FILE
	MOVEI	%05,204		;COMPUTE MAX BUFFER SIZE
	IMULI	%05,NUMBUF
	ADD	%05,JOBFFI
	TRNN	%16,ENDBIT	;MULTI-FILE?
	MOVEM	%05,JOBFF	;  YES, SAVE LARGEST BUFFER SIZE

	PUSHJ	%17,PDPSET	;SET EXPANDABLE PDP

	MOVEI	%10,[ASCIZ ./R REQUIRES LISTING FILE.]
	TLNE	%16,LSTBIT	;IF NO LISTING FILE
	TLNN	%16,RSWBIT	;  BUT /R SEEN,
	CAIA
	JRST	ERROR		;  ERROR

	PUSHJ	%17,ACEXCH	;SAVE EXEC AC'S
	PUSHJ	%17,ASSEMB	;CALL THE ASSEMBLER
	PUSHJ	%17,LSTCR	;SKIP ONE LINE
	PUSHJ	%17,ACEXCH	;SWAP AC'S
	TLZ	%16,NSWBIT	;BE SURE TO TYPE FINAL MESSAGE
	PUSHJ	%17,ERRCR	;SKIP A LINE
	MOVEI	%02,"?"		;ASSUME ERROR
	SKIPE	%11,ERRCNT	;TEST ERRORS, LOAD %11
	PUSHJ	%17,ERROUT
	MOVEI	%10,[ASCIZ / ERRORS DETECTED: 5/]
	PUSHJ	%17,LSTMSG
	PUSHJ	%17,ERR2CR
	SETZ	%11,
	RUNTIM	%11,		;GET RUNTIM
	SUB	%11,RUNTIM	;DEDUCT STARTING TIME
	IDIVI	%11,^D1000	;CONVERT TO SECONDS
	MOVEI	%10,[ASCIZ / RUN-TIME:  5 SECONDS/]
	PUSHJ	%17,LSTMSG
	PUSHJ	%17,ERR2CR
	HRRZ	%11,JOBREL	;GET TOP OF COR
	ASH	%11,-^D10	;CONVERT TO "K"
	ADDI	%11,1		;BE HONEST ABOUT IT
	MOVEI	%10,[ASCIZ / 5K CORE USED/]
	PUSHJ	%17,LSTMSG	;LIST MESSAGE
	PUSHJ	%17,ERR2CR
	JRST	EXIT		;CLOSE OUT
	SUBTTL	FILE INITIALIZATION

;INITIALIZE A BINARY FILE
;COLLECTS A DEVICE NAME IN AC %01, A FILE NAME IN XE, AND
;AN OPTIONAL FILE NAME EXTENSION, THE DEVICE IS INITIALIZED IN
;BINARY MODE ON CHANNEL ONE, WITH EITHER ONE OR TWO BUFFERS.

GETBIN:	MOVSI	%13,(Z BIN,)	;SET SWITCH AC
	PUSHJ	%17,GETNAM	;GET A DEVICE NAME AND FILE NAME
	POPJ	%17,		;NULL FILE EXIT
	MOVE	%00,%01		;GET AN EXTRA COPY OF THE DEVICE
	DEVCHR	%00,		;TEST ITS CHARACTERISTICS
	TLNE	%00,TTYDEV!PTRDEV!LPTDEV!CDRDEV
	JRST	ERRTB		;ILLEGAL FOR BINARY
	MOVE	%00,[INIT BIN,10]	;INIT IMAGE MODE
	MOVSI	%02,BINBUF	;GET BUFFER HEADER ADDRESS
	PUSHJ	%17,INISET	;INITIALIZE THE BINARY DEVICE
	OUTBUF	BIN,NUMBUF
	TLNE	%13,777000	;IS THERE A SWITCH TO PROCESS?
	XCT	%13		;EXECUTE THE ASSEMBLED UUO
	TRZN	%16,EXTBIT	;WAS THERE AN EXTENSION
	MOVSI	%14,(SIXBIT/BIN/)	;  NO, SET TO .BIN
	HLLZM	%14,XE1
	ENTER	BIN,XE		;ENTER FILE NAME IN DIRECTORY
	JRST	ERRNR		;DIRECTORY FULL
	TLZ	%16,BINBIT	;INDICATE GOOD BINARY FILE
	POPJ	%17,		;EXIT
;INITIALIZE A LISTING FILE
;COLLECTS A DEVICE NAME IN AC %01, A FILE NAME IN XE AND
;AN OPTIONAL FILENAME EXTENSION, THE DEVICE IS INITIALIZED IN
;ASCII LINE MODE ON CHANNEL 2, IF THE DEVICE IS A TTY, THE
;TTYLST FLAG IS SET TO 1, AND THE INBUF/OUTBUF INDEX IS INCREMENTED.

GETLST:	MOVSI	%13,(Z LST,)	;SET SWITCH AC
	SETZM	XE
	PUSHJ	%17,GETNAM	;GET A DEVICE AND FILE NAME
	TLNN	%16,CSWBIT
	CAIA
	POPJ	%17,
	TLNE	%16,CSWBIT
	JRST	GETLS2		;NORMAL
	MOVSI	%04,(SIXBIT /CRF/)
	SKIPE	XE
	JRST	GETLS1
	MOVE	%03,[SIXBIT /CREF/]
	MOVEM	%03,XE
	MOVSI	%04,(SIXBIT /TMP/)
GETLS1:	TRON	%16,EXTBIT
	MOVE	%14,%04
GETLS2:	MOVE	%00,[INIT LST,1]
	MOVSI	%02,LSTBUF	;GET BUFFER HEADER ADDRESS
	PUSHJ	%17,INISET	;INITIALIZE LISTING FILE
	MOVE	%00,%01
	DEVCHR	%00,		;GET DEVICE CHARACTERISTICS
	TLNE	%00,TTYDEV	;IS IT A TTY?
	TLO	%16,TTYBIT	;SET FLAG
	OUTBUF	LST,NUMBUF
	TLNE	%13,777000	;IS THERE A SWITCH TO PROCESS?
	XCT	%13		;EXECUTE THE ASSEMBLED UUO
	TRZN	%16,EXTBIT	;WAS THERE AN EXTENSION?
	MOVSI	%14,(SIXBIT /LST/)	;NO
	HLLZM	%14,XE1		;SAVE EXTENSION IN LOOKUP BLOCK
	ENTER	LST,XE		;ENTER FILE NAME IN DIR.
	JRST	ERRNR		;DIRECTORY FULL
	TLZ	%16,LSTBIT	;INDICATE A GOOD LISTING FILE
	POPJ	%17,		;EXIT
;INITIALIZE A SOURCE FILE
;COLLECTS A DEVICE NAME IN AC %01, A FILE NAME IN XE AND
;AN OPTIONAL FILE NAME EXTENSION. THE DEVICE IS INITIALIZED
;IN ASCII LINE MODE ON CHANNEL 3, AND THE FILE NAME ASSOCIATED
;WITH THE SOURCE FILE IS USED AS THE TITLE ON THE LISTING.

GETSRC:	MOVSI	%13,(Z SRC,)	;SET SWITCH AC
	SETZM	XE
	PUSHJ	%17,GETNAM	;GET A DEVICE NAME AND FILE NAME
	JRST	ERRSE		;COMMAND ERROR IF A NULL
	MOVE	%00,[INIT SRC,1]
	MOVEI	%02,SRCBUF	;GET BUFFER HEADER ADDRESS
	PUSHJ	%17,INISET	;INITIALIZE THE SOURCE DEVICE
	MOVE	%05,JOBFFI
	MOVEM	%05,JOBFF	;SET TO TOP OF INPUT BUFFER
	INBUF	SRC,NUMBUF
	TLNE	%13,777000	;IS THERE A SWITCH TO PROCESS?
	XCT	%13		;EXECUTE THE ASSEMBLED UUO
	TRZE	%16,EXTBIT	;WAS AN EXPLICIT EXTENSION SEEN?
	JRST	SRC3A		;YES, LOOK FOR IT
	MOVSI	%14,(SIXBIT /P11/)
	HLLZM	%14,XE1		;NO, TRY .SRC FIRST
	LOOKUP	SRC,XE
	TDZA	%14,%14		;NOT FOUND, TRY BLANK
	POPJ	%17,		;FOUND
SRC3A:	HLLZM	%14,XE1		;SAVE EXTENSION IN LOOKUP BLOCK
	HLLZM	%14,EXTSAV	;SAVE EXTENSION FOR HEADER
	LOOKUP	SRC,XE		;LOOKUP FILE NAME
	JRST	ERRCF		;FILE NOT FOUND
	POPJ	%17,		;EXIT


SETP2:				;SET FOR PASS 2
	PUSHJ	%17,ACEXCH	;GET EXEC AC'S
	TRZ	%16,ENDBIT!FFBIT
	MOVE	%05,TTISAV
	MOVEM	%05,TTIPNT	;RESTORE INPUT COMMANDS
	MOVSI	%01,(SIXBIT /DSK/)
	PUSHJ	%17,GETSRC	;GET A SOURCE FILE
	JRST	ACEXCH		;SWAP AC'S AND EXIT
	SUBTTL	COMMAND STRING DECODER

;EXEC COMMAND STRING DISPATCHING
;THIS ROUTINE PICKS UP CHARACTERS FROM THE EXEC TTY BUFFER AND
;DISPATCHES TO THE PROPER ROUTINE DEPENDING ON THE TYPE OF
;CHARACTER. A TABLE OF BYTES AND BYTE POINTERS ALLOWS EACH CHARAC-
;TER IN THE ASCII SET TO BE TREATED INDIVIDUALLY.


GETNAM:	SETZ	%14,		;CLEAR SYMBOL WORD
	MOVE	%06,[POINT 6,%14]


GETCMN:	PUSHJ	%17,GETTTI	;GET NEXT CHARACTER
	CAIN	%05,"["		;PROJECT-PROGRAMMER PAIR?
	JRST	LFTBRA		;YES
	CAIGE	%10,4		;MODIFY CODE IF .GE. 4
	TRNN	%16,SWTBIT	;MODIFY IF SWITCH IS ON
	ADDI	%10,4		;CHANGE DISPATCH BY ADDING 4
	HRRZ	%02,DSPTCH(%10)	;LOAD RIGHT HALF DISPATCH
	CAIL	%10,10		;SKIP IF CORRECT
	HLRZ	%02,DSPTCH-10(%10);OTHERWISE, GET LEFT HALF DSPTCH
	JRST	@%02		;GO TO CORRECT ROUTINE

GETTTI:	ILDB	%05,TTIPNT	;GET A CHARACTER FROM TTY BUFFER
	MOVE	%10,%05		;ANOTHER COPY OF IT IN AC %10
	IDIVI	%10,8		;TRANSLATE TO 4-BIT CODE
	ADD	%10,[POINT 4,BITE,]	;SET BYTE POINTER
	IBP	%10		;MOVE TO PROPER BYTE
	SOJGE	%11,.-1		;TEST FOR END
	LDB	%10,%10		;OK, FETCH BYTE
	CAIN	%10,4		;IS IT A NULL?
	JRST	GETTTI		;YES, TRY AGAIN
	POPJ	%17,		;NO, EXIT

;COMMAND DISPATCH TABLE AND BYTE POINTERS
DSPTCH:	XWD	GETCMN,	ERRBS	;IGNORED CHAR, BAD CHAR(SWITCH)
	XWD	SWTCH,	SWTCHA	;<(>, LETTER(SWITCH MODE)
	XWD	COLON,	ERRBS	;<:>, NUMBER(SWITCH MODE)
	XWD	PERIOD,	SWTCHE	;<.>,<)>ESCAPE SWITCH MODE
	XWD	LFTARW,	ERRIC	;<_> OR <=>, BAD CHAR (NORMAL MODE)
	XWD	COMMA,	STORE	;<,>,ALPHABETICH CHAR (NORMAL)
	XWD	CARRTN,	STORE	;<CR>,NUMERIC CHAR (NORMAL)
	XWD	SLASH,	ERRIC	;</>, <)> ILLEGAL ESCAPE
;BYTE TABLE FOR DISPATCHING
;CLASSIFICATION BYTE CODES


;	BYTE	DISP	CLASSIFICATION


;	00	00	ILLEGAL CHARACTER, SWITCH MODE
;	01	01	ALPHABETIC CHARACTER, SWITCH MODE
;	02	02	NUMERIC CHARACTER, SWTICH MODE
;	03	03	SWITCH MODE ESCAPE, SWITCH MODE


;	00	04	ILLEGAL CHARACTER, NORMAL MODE
;	01	05	ALPHABETIC CHARACTER, NORMAL MODE
;	02	06	NUMERIC CHARACTER, NORMAL MODE
;	03	07	SWITCH MODE ESCAPE, NORMAL MODE


;	04	10	IGNORED CHARACTER
;	05	11	ENTER SWITCH MODE WITH A <(>
;	06	12	DEVICE DELIMITER, <:>
;	07	13	FILE EXTENSION DELIMITER, <.>
;	10	14	OUTPUT SPEC. DELIMITER, <_> OR <=>
;	11	15	FILE DELIMITER, <,>
;	12	16	COMMAND TERMINATOR, <CR>
;	13	17	ENTER SWITCH MODE WITH </>


;BYTE TABLE:


BITE:
	BYTE	(4)	 4,  ,  ,  ,  ,  ,  ,  
	BYTE	(4)	  , 4,12, 4, 4,12,  ,  
	BYTE	(4)	  ,  ,  ,  ,  ,  ,  ,  
	BYTE	(4)	  ,  ,12,  ,  ,  ,  ,  

	BYTE	(4)	11,  , 4,  ,  ,  ,  ,  
	BYTE	(4)	 5, 3,  ,  ,11,  , 7,13 
	BYTE	(4)	 2, 2, 2, 2, 2, 2, 2, 2
	BYTE	(4)	 2, 2, 6,  ,  ,10,  ,  

	BYTE	(4)	  , 1, 1, 1, 1, 1, 1, 1
	BYTE	(4)	 1, 1, 1, 1, 1, 1, 1, 1
	BYTE	(4)	 1, 1, 1, 1, 1, 1, 1, 1
	BYTE	(4)	 1, 1, 1,  ,  ,  ,  ,10

	BYTE	(4)	  ,  ,  ,  ,  ,  ,  ,  
	BYTE	(4)	  ,  ,  ,  ,  ,  ,  ,  
	BYTE	(4)	  ,  ,  ,  ,  ,  ,  ,  
	BYTE	(4)	  ,  ,  ,  ,  ,12,  , 4
;LEFT ARROW PROCESSOR
LFTARW:	TRO	%16,ARWBIT	;SET APPROPIATE FLAGS
	TRNN	%16,EXTBIT	;IS THIS A FILE NAME EXTENSION?
	MOVEM	%14,XE		;NO, ITS A FILE NAME
	TRZE	%16,INFBIT	;IS THIS A NULL FILE?
CPOPJ1:	AOS	(%17)		;GOOD EXIT
CPOPJ:	POPJ	%17,		;...

;PERIOD PROCESSOR
PERIOD:	TRO	%16,EXTBIT	;SET FLAG FOR EXPLICIT EXTENSION
	MOVEM	%14,XE		;SAVE THE FILE NAME
	JRST	GETNAM		;RE-ENTER THE GETNAM ROUTINE

;COLON PROCESSOR
COLON:	MOVE	%01,%14		;SET UP NEW DEVICE NAME
	JRST	GETNAM		;RETURN FOR MORE COMMAND

;COMMA PROCESSOR
COMMA:	TRZN	%16,INFBIT	;IS THIS A NULL FILE?
	TRNE	%16,ARWBIT	;ONLY LOOK FOR THEM IF NO _
	SKIPA			;NOT A NULL FILE
	POPJ	%17,		;NULL FILE, EXIT
COMMA1:	TRNN	%16,EXTBIT	;DO WE HAVE A FILE NAME EXTENSION?
	MOVEM	%14,XE		;NO, IT WAS A FILE NAME
	JRST	CPOPJ1		;GOOD EXIT

;CARRIAGE RETURN PROCESSOR
CARRTN:	TRNN	%16,NULBIT	;IS THIS JUST A RANDOM CR?
	JRST	PALX11		;YES, RESTART COMPLETELY
	TRO	%16,ENDBIT	;IS THIS A NORMAL MODE COMMAND?
	TRNN	%16,ARWBIT	;YES, HAS A LEFT ARROW BEEN SEEN?
	JRST	ERRSE		;NO, SYNTAX ERROR
	JRST	COMMA1		;YES, TREAT IT LIKE A COMMA
;THE FOLLOWING TWO ROUTINES HANDLE ALPHANUMERIC CHARACTERS
;FOUND IN THE COMMAND STRING. IN NORMAL MODE, THE CHARACTER
;IS DEPOSITED TO FORM A SIXBIT SYMBOL. IN SWITCH MODE, THE
;PROPER INSTRUCTION IS EXECUTED WITH THE AID OF A DISPATCH
;TABLE. THEN, IF SWITCH MODE WAS ENTERED WITH A SLASH, THE
;EXEC EXITS FROM SWITCH MODE.


STORE:	TRO	%16,INFBIT!NULBIT;TURN ON BITS FOR CR ROUTINE
	SUBI	%05,40		;CONVERT SIXBIT TO ASCII
	TLNE	%06,770000	;DON'T STORE IF NO ROOM FOR CHAR
	IDPB	%05,%06		;PLOP THE CHARACTER INTO AC %14
	JRST	GETCMN		;RETURN

SWTCHA:	MOVEI	%11,-"A"(%05)
	MOVE	%10,[POINT 4,BYTAB]
	IBP	%10
	SOJGE	%11,.-1
	LDB	%11,%10
	JUMPE	%11,ERRBS
	CAIG	%11,SWTABA-SWTAB;THIS SWITCH LEGAL FOR INPUT?
	TRNN	%16,ARWBIT	;  NO, ERROR IF "_" SEEN
	CAIA			;OK
	JRST	ERRWF		;  ERROR, SWITCH IN WRONG FIELD
	XCT	SWTAB-1(%11)
	JRST	ERRBS
	TRZE	%16,SLABIT	;CALLED BY A SLASH?
	TRZ	%16,SWTBIT	;YES, EXIT FROM SWITCH MODE
	JRST	GETCMN		;NO, RETURN FOR MORE CHARACTERS


;THE FOLLOWING THREE ROUTINES HANDLE THE CONTROL CHARACTERS
;IN THE COMMAND STRING WHICH CAUSE THE EXEC TO ENTER INTO AND
;EXIT FROM SWITCH MODE. THERE ARE TWO TYPES OF SWITCH MODE,
;DEPENDING ON WHETHER IT IS ENTERED WITH A </> OR A <(>.


SLASH:	TRO	%16,SLABIT	;TURN ON THE SPECIAL SWITCH MODE
SWTCH:	TROA	%16,SWTBIT	;TURN ON NORMAL SWITCH MODE
SWTCHE:	TRZ	%16,SWTBIT	;TURN OFF THE NORMAL SWITCH MODE
	JRST	GETCMN		;RETURN FOR MORE CHARACTERS
;DISPATCH TABLE FOR SWITCHES


	DEFINE	SETSW	(LETTER, INSTRUCTION) <
	INSTRUCTION
	Y=<"LETTER"-"A">-^D9*<X=<"LETTER"-"A">/^D9>
	SETCOD	\X,Y>

	DEFINE	SETCOD	(X,Y)
	<BYTAB'X=BYTAB'X!<.-SWTAB>B<4*Y+3>>

BYTAB0=	0
BYTAB1=	0
BYTAB2=	0

SWTAB:

	SETSW	C,<TLZA  %16,CSWBIT>

	SETSW	R,<TLOA  %16,RSWBIT>

	SETSW	E,<TLOA  %16,ESWBIT>

	SETSW	T,<TLCA  %15,TTYFLG>

SWTABA:
	SETSW	W,<TDOE  %13, [MTAPE  1]>

	SETSW	M,<TLOA  %16,MSWBIT>

	SETSW	N,<TLOA  %16,NSWBIT>

BYTAB:	+BYTAB0
	+BYTAB1
	+BYTAB2

IF2,	<PURGE	X,	Y,	BYTAB0,	BYTAB1,	BYTAB2	>
LFTBRA:	SETZM	XE3		;CLEAR NUMBER
LFTBR1:	HRLZS	XE3		;COMMA, MOVE TO LEFT HALF
LFTBR2:	PUSHJ	%17,GETTTI	;GET NEXT CHAR
	CAIN	%05,"]"		;TERMINAL?
	JRST	GETCMN		;YES, EXIT
	CAIN	%05,","		;SEPARATOR?
	JRST	LFTBR1		;YES
	CAIL	%05,"0"		;TEST FOR OCTAL NUMBER
	CAILE	%05,"7"
	JRST	ERRIC		;IMPROPER CHARACTER
	HRRZ	%10,XE3		;OK, GET PREVIOUS VALUE
	IMULI	%10,8
	ADDI	%10,-"0"(%05)	;ACCUMULATE NEW NUMBER
	HRRM	%10,XE3
	JRST	LFTBR2
	SUBTTL	I/O ROUTINES

LSTCR:	TDZA	%02,%02
LSTTAB:	MOVEI	%02,11
LSTOUT:	TLNE	%16,LSTBIT!RSWBIT	;LISTING REQUESTED?
	POPJ	%17,		;  NO, EXIT
	TRZE	%16,HDRBIT
	PUSHJ	%17,HEADER
LSTSRC:	JUMPN	%02,LSTDMP

	MOVEI	%02,15		;CARRIAGE RETURN
	PUSHJ	%17,LSTDMP
	MOVEI	%02,12		;LINE FEED
	PUSHJ	%17,LSTDMP
	TLNE	%16,TTYBIT	;LISTING TO TTY?
	PUSHJ	%17,LIST1	;YES, DUMP THE LINE
	SOSG	LINCNT
	TRO	%16,HDRBIT
	POPJ	%17,

LSTDMP:	SOSG	LSTCNT		;DECREMENT ITEM COUNT
	PUSHJ	%17,LIST1	;EMPTY ENTIRE BUFFER
	IDPB	%02,LSTPNT	;STORE THE CHARACTER
	POPJ	%17,		;EXIT


LIST1:	OUTPUT	LST,		;EMPTY A BUFFER
LSTTST:	STATO	LST,IODATA!IODEV!IOWRLK	;CHECK FOR ERRORS
	POPJ	%17,		;NO, EXIT
	MOVEI	%10,[ASCIZ /LISTING OUTPUT ERROR/]
	JRST	ERROR		;TYPE MESSAGE


ERR2CR:	PUSHJ	%17,ERRCR
ERRCR:	TDZA	%02,%02
ERRSP:	MOVEI	%02," "
ERROUT:	HRLM	%02,0(%17)	;SAVE VIRGIN CHARACTER
	TLNN	%15,LPTFLG	;SKIP LISTING OF SOURCE IF CONTINUATION
	PUSHJ	%17,LSTOUT	;TRY THE LISTING FILE
	TLNE	%16,NSWBIT!TTYBIT	;CHAR TO TTY ALSO?
	POPJ	%17,		;NO, JUST EXIT
	HLRZ	%02,0(%17)	;YES, RESTORE CHARACTER
	JRST	TTYOUT		;TYPE AND EXIT
HEADER:	PUSHJ	%17,ACEXCH	;YES, SAVE THE ACCUMULATORS
	PUSH	%17,%16		;SAVE CURRENT FLAGS
	TLO	%16,NSWBIT	;DON'T OUTPUT TO TTY
	MOVEI	%02,15
	PUSHJ	%17,LSTDMP
	MOVEI	%02,14		;GET A FORM FEED
	PUSHJ	%17,LSTDMP	;OUTPUT IT
	MOVEI	%10,PAGSIZ+3	;RESET LINE COUNTER REGISTER
	MOVEM	%10,LINCNT	;...
	PUSHJ	%17,LSTTAB
	MOVE	%00,TITLE
	PUSHJ	%17,LSTSIX
	PUSHJ	%17,LSTTAB
	MOVE	%00,SUBTTL	;PRINT VERSION NO.
	PUSHJ	%17,LSTSIX
	PUSHJ	%17,LSTTAB

;THE FOLLOWING SECTION PRINTS THE DATE, WHICH IS FOUND IN
;REGISTER XDATE IN THE FORM
;	((Y-1964)*12 + (M-1))*31 + (D-1)
	MOVE	%10,DATE	;GET THE DATE IN %10
	IDIVI	%10,^D31	;DIVIDE BY 31 DECIMIAL
	ADDI	%11,1
	PUSHJ	%17,DNC		;OUTPUT DAY
	IDIVI	%10,^D12	;DIVIDE BY 12 DECIMAL
	MOVE	%00,MONTH(%11)
	PUSHJ	%17,LSTSIX	;OUTPUT THE MONTH, (M-1) IS IN %12
	MOVEI	%11,^D64(%10)	;GET THE YEAR
	PUSHJ	%17,DNC		;TYPE IT
	PUSHJ	%17,LSTTAB	;OUTPUT TAB
;THE FOLLOWING SECTION OF CODE PRINTS THE TIME, WHICH IS
;PICKED UP FROM THE MONITOR AS THE NUMBER OF MILLISECONDS
;SINCE MIDNIGHT. THE FORMAT OF THE TIME PRINTOUT IS HH:MM
	MOVE	%11,MSTIME	;GET THE CURRENT TIME
	IDIVI	%11,^D60*^D1000	;NUMBER OF MIN. SINCE MIDNITE
	IDIVI	%11,^D60	;NUMBER OF HOURS
	PUSH	%17,%12		;SAVE MINUTES
	PUSHJ	%17,DNC		;OUTPUT THE HOURS
	MOVEI	%02,":"		;OUTPUT A COLON AFTER THE HOURS
	PUSHJ	%17,LSTDMP	;OUTPUT IT
	POP	%17,%11		;PUT MINUTES IN OUTPUT AC
	MOVEI	%02,"0"		;GET AN ASCII ZERO
	CAIG	%11,^D9		;IS IT A ONE-DIGIT NUMBER?
	PUSHJ	%17,LSTDMP	;YES, OUTPUT A ZERO
	PUSHJ	%17,DNC		;OUTPUT THE MINUTES


;THE FINAL SECTION OF CODING PICKS UP THE WORD "PAGE " AND
;STORES IT IN THE PROPER PLACE IN THE TITLE BUFFER.
	PUSHJ	%17,LSTTAB
	MOVE	%00,[SIXBIT /PAGE/]
	PUSHJ	%17,LSTSIX	;PRINT "PAGE"
	MOVEI	%02," "
	PUSHJ	%17,LSTDMP	;SPACE
	MOVE	%11,PAGNUM	;GET PAGE NUMBER
	PUSHJ	%17,DNC		;CONVERT TO DECIMAL AND PRINT
	MOVEI	%10,[ASCIZ //]	;ASSUME NO EXTENSION
	AOSE	%11,PAGEXT	;INCREMENT, PICK UP, AND TEST
	MOVEI	%10,[ASCIZ /-5/]
	PUSHJ	%17,LSTMSG	;LIST IT
	PUSHJ	%17,ERR2CR
	POP	%17,%16		;RESTORE FLAGS
	JRST	ACEXCH		;RESTORE F4 REGS AND EXIT
DNC:	IDIVI	%11,^D10	;RECURSIVE SUBROUTINE
	HRLM	%12,0(%17)	;SAVE REMAINDER ON PUSHDOWN LIST
	SKIPE	%11		;ALL DONE?
	PUSHJ	%17,DNC		;NO, CALL DNC AGAIN
	HLRZ	%02,0(%17)	;RETRIEVE NUMBER FROM PD LIST
	ADDI	%02,"0"		;MAKE IT ASCII
	JRST	ERROUT		;GET NEXT NUMBER OR EXIT

LSTSIX:	MOVSI	%06,(POINT 6,%00,)
LSTSI1:	ILDB	%02,%06
	JUMPE	%02,CPOPJ
	ADDI	%02," "
	PUSHJ	%17,ERROUT
	TLNE	%06,770000
	JRST	LSTSI1
	POPJ	%17,

MONTH:	SIXBIT	/-JAN-/
	SIXBIT	/-FEB-/
	SIXBIT	/-MAR-/
	SIXBIT	/-APR-/
	SIXBIT	/-MAY-/
	SIXBIT	/-JUN-/
	SIXBIT	/-JUL-/
	SIXBIT	/-AUG-/
	SIXBIT	/-SEP-/
	SIXBIT	/-OCT-/
	SIXBIT	/-NOV-/
	SIXBIT	/-DEC-/
TTYOUT:	JUMPN	%02,TTYDMP
TTYCR:	MOVEI	%02,15
	PUSHJ	%17,TTYDMP
	MOVEI	%02,12
TTYDMP:	SOSG	TTOCNT		;IS THE BUFFER EMPTY?
	OUTPUT	TTO,		;YES, GO EMPTY IT
	IDPB	%02,TTOPNT	;STORE THE CHARACTER
	CAIN	%02,12		;WAS IT A LINE FEED?
	OUTPUT	TTO,		;YES, OUTPUT THE LINE
	POPJ	%17,		;EXIT

INISET:	MOVE	%03,[JRST ERRNA];ERROR EXIT FOR INIT
	MOVSI	%04,(POPJ %17,)
	JRST	%00
CHARB:	MOVEM	%14,SEQNUM	;SAVE SEQUENCE NUMBER
	AOS	SRCPNT		;INCREMENT POINTER PAST WORD
	MOVNI	%14,5		;GET -5
	ADDM	%14,SRCCNT	;SUBTRACT 5 FROM WORD COUNT
	TRO	%16,SEQBIT
CHAR:	SOSGE	SRCCNT		;DECREMENT ITEM COUNT
	JRST	CHAR4		;GET ANOTHER BUFFER IF NECESSARY
	IBP	SRCPNT		;INCREMENT THE BYTE POINTER
	MOVE	%14,@SRCPNT	;PICK UP AN ENTIRE WORD FROM BUFFER
	TRZE	%14,1		;IS THE SEQUENCE NUMBER BIT ON?
	JRST	CHARB		;YES, SKIP AROUND IT
	LDB	%14,SRCPNT	;NO, PICK UP A GOOD CHARACTER
	JUMPE	%14,CHAR	;GET ANOTHER IF NULL
	CAIE	%14,FF		;FORM FEED?
	JRST	CPOPJ1		;  NO, EXIT
	AOS	PAGNUM		;YES, INCREMENT PAGE
	SETOM	PAGEXT		;INITIALIZE EXTENSION
	TRO	%16,HDRBIT!FFBIT
	JRST	CPOPJ1

CHAR4:	INPUT	SRC,		;CALL MONITIOR FOR A BUFFER
	STATZ	SRC, IODATA+IODEV+IOBKTL+IOWRLK
	JRST	ERRID		;INPUT TRANSMISSION ERROR
	STATO	SRC, IOEOF	;WAS AN END OF FILE REACHED?
	JRST	CHAR		;GET NEXT CHAR
	CLOSE	SRC,
	TRNE	%16,ENDBIT	;CRR SEEN BY COMMAND SCANNER?
	POPJ	%17,

	PUSHJ	%17,ACEXCH	;GET EXEC AC'S
	PUSHJ	%17,GETSRC	;GET THE NEXT SOURCE FILE
	TRO	%16,HDRBIT	;START NEW FILE
	PUSHJ	%17,ACEXCH	;SAVE EXEC AC'S AND RETURN
	JRST	CHAR
;ROUTINES TO SAVE AND RESTORE THE COMPILER ACCUMULATORS

ACEXCH:				;SWAP AC'S
	TRC	%16,MODBIT	;TOGGLE MODE BIT
	EXCH	%00,AC00
	EXCH	%01,AC01
	EXCH	%02,AC02
	EXCH	%03,AC03
	EXCH	%04,AC04
	EXCH	%05,AC05
	EXCH	%06,AC06
	EXCH	%07,AC07
	EXCH	%10,AC10
	EXCH	%11,AC11
	EXCH	%12,AC12
	EXCH	%13,AC13
	EXCH	%14,AC14
	POPJ	%17,
;ROUTINE TO OUTPUT RELOCATABLE BINARY


BINOUT:				;BINARY OUTPUT
	ANDI	%02,377		;MASK TO 8 BITS
	TLNN	%16,ESWBIT	;EXPANDED LISTING (OCTAL) REQUESTED?
	JRST	BINOU2		;  NO
	PUSH	%17,%03		;  YES, STACK WORKING REGISTERS
	PUSH	%17,%02
	MOVSI	%03,(POINT 3,0(%17),26)	;POINT TO STACKED CODE
BINOU1:	ILDB	%02,%03		;GET THE NEXT BYTE
	ADDI	%02,"0"		;CONVERT TO ASCII
	PUSHJ	%17,LSTOUT	;LIST IT
	TLNE	%03,770000	;END?
	JRST	BINOU1		;  NO
	PUSHJ	%17,LSTCR	;YES, LIST CR/LF
	POP	%17,%02		;RESTORE REGISTERS
	POP	%17,%03
BINOU2:	TLNE	%16,BINBIT	;BINARY REQUESTED?
	POPJ	%17,		;  NO, EXIT
	SOSG	BINCNT
	PUSHJ	%17,BINDMP
	IDPB	%02,BINPNT
	POPJ	%17,

BINDMP:	OUTPUT	BIN,
BINTST:	STATO	BIN,IODATA!IODEV!IOWRLK
	POPJ	%17,
	MOVEI	%10,[ASCIZ /BINARY OUTPUT ERROR/]
	JRST	ERROR		;TYPE ERROR MESSAGE
	SUBTTL	EXEC ERROR ROUTINES

ERRCF:	MOVEI	%10,[ASCIZ /CANNOT FIND 234/]
	JRST	ERROR

ERRID:	MOVEI	%10,[ASCIZ /INPUT DATA ERROR 234/]
	JRST	ERROR

ERRBS:	MOVEI	%10,[ASCIZ /1 IS A BAD SWITCH/]
	JRST	ERROR

ERRIC:	MOVEI	%10,[ASCIZ /1 IS AN ILLEGAL CHARACTER/]
	JRST	ERROR

ERRNA:	MOVEI	%10,[ASCIZ /2 IS NOT AVAILABLE/]
	JRST	ERROR

ERRNR:	MOVEI	%10,[ASCIZ /NO ROOM FOR 234/]
	JRST	ERROR

ERRSE:	MOVEI	%10,[ASCIZ /SYNTAX ERROR IN COMMAND STRING/]
	JRST	ERROR

ERRNC:	MOVEI	%10,[ASCIZ /INSUFFICIENT CORE/]
	JRST	ERROR

ERRWF:	MOVEI	%10,[ASCIZ /1 ILLEGAL SWITCH FOR INPUT/]
	JRST	ERROR

ERRTF:	MOVEI	%10,[ASCIZ /TOO MANY INPUT FILES/]
	JRST	ERROR

ERRTB:	MOVEI	%10,[ASCIZ /2 ILLEGAL FOR BINARY OUTPUT/]
	JRST	ERROR
ERROR:				;NON-RECOVERABLE ERROR MESSAGE
	PUSH	%17,%10		;STACK MESSAGE ADDRESS
	TRNE	%16,MODBIT	;HAVE WE EXEC AC'S?
	PUSHJ	%17,ACEXCH	;  NO, GET THEM
	POP	%17,%10		;RESTORE MESSAGE POINTER
	MOVE	%16,[XWD LSTBIT!BINBIT,ENDBIT]
	PUSHJ	%17,ERRCR
	MOVEI	%02,"?"
	PUSHJ	%17,ERROUT
	PUSHJ	%17,ERRSP	;TYPE SPACE
	PUSHJ	%17,LSTMSG
	PUSHJ	%17,ERR2CR
	JRST	EXIT

LSTMSG:	TLOA	%10,(POINT 7,,)	;SET BYTE POINTER AND SKIP
LSTMS4:	PUSHJ	%17,ERROUT	;TYPE CHARACTER
LSTMS5:	ILDB	%02,%10		;GET CHARACTER
	JUMPE	%02,CPOPJ	;TEST FOR END
	CAIL	%02,"1"		;TEST FOR SWITCH
	CAILE	%02,"5"
	JRST	LSTMS4		;NO, TYPE THE CHARACTER
	PUSHJ	%17,@[EXP ERR1,ERR2,ERR3,ERR4,DNC]-"1"(%02)
	JRST	LSTMS5		;GET NEXT CHARACTER

ERR1:	MOVE	%02,%05		;GET IMPROPER CHARACTER
	JRST	TTYDMP		;DUMP IT

ERR2:	MOVE	%00,%01		;GET DEVICE NAME
	PUSHJ	%17,LSTSIX	;TYPE IT
	MOVEI	%02,":"
	JRST	TTYDMP		;TYPE ":"

ERR3:	MOVE	%00,XE		;GET FILE NAME
	JRST	LSTSIX		;TYPE IT

ERR4:	HLLZ	%00,XE1		;GET EXTENSION
	JUMPE	%00,CPOPJ	;EXIT IF NULL
	MOVEI	%02,"."
	PUSHJ	%17,TTYDMP	;TYPE "."
	JRST	LSTSIX
EXIT:	CLOSE	SRC,		;CLOSE THE SOURCE DEVICE
	CLOSE	LST,		;CLOSE THE LISTING FILE
	CLOSE	BIN,		;CLOSE THE BINARY FILE
	TLON	%16,LSTBIT	;WAS THERE A LISTING FILE?
	PUSHJ	%17,LSTTST	;YES, TEST FOR FINAL ERROR
	TLON	%16,BINBIT	;IS THERE A BINARY FILE?
	PUSHJ	%17,BINTST	;YES, TEST FOR FINAL ERROR
	TRNN	%16,ENDBIT	;END OF COMMAND STRING?
	JRST	ERRTF		;  NO, MARK ERROR
	CLOSE	TTO,		;BE SURE MESSAGES ARE COMPLETE
	JRST	PALX11		;GET A NEW COMMAND STRING
	SUBTTL	ASSEMBLER PROPER
;	THESE ARE THE LISTING ERROR FLAGS.

ERRA=	400000
ERRB=	200000
ERRD=	100000
ERRE=	040000
ERRI=	020000
ERRL=	010000
ERRM=	004000
ERRO=	002000
ERRP=	001000
ERRQ=	000400
ERRR=	000200
ERRT=	000100
ERRU=	000040
ERRN=	000020

ERRP1=	000001

LBLSYM=	001000		;LABEL
MDLSYM=	002000		;MULTIPLY DEFINED LABEL FLAG
REGSYM=	004000		;REGISTER
UNDSYM=	010000		;UNDEFINED SYMBOL FLAG
ASSEMB:				;ASSEMBLER PROPER
	TLO	%15,P1F		;SET FOR PASS 1
	TLNE	%16,TTYBIT	;TELETYPE?
	TLC	%15,TTYFLG	;  YES, TOGGLE BIT FOR LISTING
	PUSHJ	%17,INIPAS	;INITIALIZE PASS ONE
	PUSHJ	%17,LINE	;GO DO PASS ONE.
	TLZ	%15,P1F		;RESET TO PASS 2
	PUSHJ	%17,SETP2	;RESET INPUT COMMAND STRING
	PUSHJ	%17,INIPAS
	PUSHJ	%17,BLKINI	;INITIALIZE BINARY BLOCK
	PUSHJ	%17,LINE	;CALL THE ASSEMBLER (PASS TWO)
	TLNN	%16,LSTBIT!MSWBIT!RSWBIT	;LISTING?
	PUSHJ	%17,SYMTB	;  YES, OUTPUT THE SYMBOL TABLE
	POPJ	%17,


INIPAS:
	SETZB	%05,SEQNUM	;CLEAR LOCATION COUNTER
	SETZB	%04,%12
	MOVEI	%00,1
	MOVEM	%00,PAGNUM	;INITIALIZE PAGE NUMBER
	SETOM	PAGEXT		;  AND EXTENSION
	TLZ	%15,SRCFLG!LINFLG!RSWFLG
	POPJ	%17,


LINE:				;PROCESS ONE LINE
	PUSHJ	%17,GETLIN	;GET A SOURCE LINE
	PUSHJ	%17,STMNT	;PROCESS ONE STATEMENT
	TLZN	%15,ENDFLG	;TEST FOR END STATEMENT
	JRST	LINE		;GET THE NEXT LINE
	POPJ	%17,		;END OF PASS
GETLIN:				;GET THE NEXT SOURCE LINE
	MOVEI	%06,CPL		;TEST FOR OVERFLOW
	SKIPA	%13,LINPNT	;SET POINTER
GETLI1:	TRO	%15,ERRL	;LINE OVERFLOW
GETLI2:	JUMPN	%12,GETLI4	;BRANCH IF READING FROM MACRO TREE
	PUSHJ	%17,CHAR	;GET AN INPUT CHARACTER
	 TDO	%15,[XWD ENDFLG,ERRE]	;END OF FILE, NO END STATEMENT
GETLI3:	LDB	%02,C7PNTR	;SET INDEX
	XCT	GLTBL(%02)
	SOJL	%06,GETLI1	;DON'T STORE IF TOO MANY
	IDPB	%14,%13		;STORE IN BUFFER
	JUMPN	%14,GETLI2	;RECYCLE IF NOT END
	MOVE	%13,LINPNT	;SET FOR READ
	JRST	GETNB		;RETURN WITH FIRST NON-BLANK

GETLI4:	PUSHJ	%17,READMC	;GET A CHARACTER FROM THE TREE
	 JRST	GETLI2		;  NOTHING WORTHWHILE, TRY AGAIN
	JRST	GETLI3		;OK, PROCESS

GETLI5:	TRO	%15,ERRI	;ILLEGAL CHARACTER
	MOVEI	%14,RUBOUT	;REPLACE WITH RUBOUT
	POPJ	%17,


GLTBL:				;GET LINE TABLE
	PHASE	0
	PUSHJ	%17,GETLI5	;ILLEGAL
QJNU:	JRST	GETLI2		;NULL
QJCR:	TDZA	%14,%14		;CARRIAGE RETURN
QJSP:	JFCL
QJPC:	JFCL
	DEPHASE

LINPNT:	POINT	7,LINBUF,	;POINTER TO START OF LINE
TYPPNT:	POINT	9,%01,17	;OP TYPE POINTER
ENDLR:				;SUPPRESS IF /R
	TLO	%15,RSWFLG	;SET LOCAL FLAG

ENDL:				;END OF LINE PROCESSOR
	TLNE	%15,P1F
	JRST	ENDLF		;BYPASS IF PASS 1
	LDB	%02,C1PNTR	;MAP CHARACTER
	XCT	ENDLT1(%02)	;EXECUTE TABLE
	JRST	.-2		;CYCLE IF BLANK
	TLNE	%16,RSWBIT	;TEST FOR REPRODUCTION OF SOURCE LINE
	TLNE	%15,RSWFLG
	JRST	ENDLF		;  NO
	MOVEI	%02,FF
	TRZE	%16,FFBIT	;FORM FEED SEEN?
	PUSHJ	%17,LSTSRC	;  YES, LIST ONE
	SKIPA	%03,LINPNT	;SET TO LIST SOURCE
	PUSHJ	%17,LSTSRC	;LIST A CHARACTER
	ILDB	%02,%03		;GET THE NEXT CHARACTER
	JUMPN	%02,.-2		;BRANCH IF NOT CR
	PUSHJ	%17,LSTSRC	;CR, LIST IT

ENDLF:				;ENDL FIN
	HLRZ	%02,%04		;GET TYPE
	XCT	ENDLT2(%02)	;EVEN LOCATION TEST
	TRO	%15,ERRB	;FAILED
	TRZN	%15,ERRP1	;PASS 1 ERROR?
	TLNN	%15,P1F		;  NO, ARE WE IN PASS2?
	CAIA			;  YES, LIST THIS LINE
	JRST	ENDL11		;PASS 1, NO ERRORS, DON'T LIST
	MOVEI	%01,LSTOUT
	TLNE	%15,LINFLG	;LINE-SUPPRESS IN EFFECT?
	MOVEI	%01,CPOPJ	;  YES, CAUSE A NOP
	MOVEI	%02,CRFLIN
	TLNN	%16,CSWBIT	;SHOULD WE MARK?
	PUSHJ	%17,0(%01)	;  YES

	TRNN	%15,-1		;ANY ERRORS?
	JRST	ENDL6		;  NO
	AOS	ERRCNT		;  YES, TALLY ERROR COUNT
	MOVE	%00,XE		;GET FILE NAME
	TLNN	%16,NSWBIT
	CAMN	%00,XESAVE
	JRST	ENDL4
	JUMPE	%00,ENDL4
	MOVEM	%00,XESAVE
	MOVSI	%01,(POINT 6,%00,)
ENDL2:	ILDB	%02,%01
	JUMPE	%02,ENDL3
	ADDI	%02,40
	PUSHJ	%17,TTYOUT
	TLNE	%01,770000
	JRST	ENDL2
ENDL3:	MOVEI	%02,":"
	PUSHJ	%17,TTYOUT
	PUSHJ	%17,TTYCR
ENDL4:	HRLZ	%00,%15		;PUT FLAGS IN AC0 LEFT
	MOVE	%01,[POINT 7,[ASCII /ABDEILMOPQRTUN/],]
ENDL5:	ILDB	%02,%01		;FETCH CHARACTER
	JUMPGE	%00,.+3		;THIS CHARACTER
	PUSHJ	%17,ERROUT	;  YES
	AOS	ESPCNT		;MARK FOR LISTING
	LSH	%00,1
	JUMPN	%00,ENDL5	;TEST FOR END
	MOVEI	%01,ERROUT	;END, SET TO ERROR-LIST

ENDL6:	MOVE	%02,LINPNT	;TEST FOR NO MORE LISTING
	ILDB	%02,%02
	TDO	%02,%04
	TDO	%02,SEQNUM
	JUMPE	%02,ENDL10	;BRANCH IF NOTHING TO LIST
	PUSHJ	%17,PRNTA	;LIST THE OCTAL
	TRNN	%15,-1		;ANY ERRORS?
	JRST	ENDL6A		;  NO, BRANCH
	TLZE	%15,SRCFLG	;YES, LIST SOURCE.  HOW ABOUT LPT?
	TLO	%15,LPTFLG	;  NO, TELETYPE ONLY
ENDL6A:	TLNE	%15,SRCFLG	;SHOULD WE BYPASS SOURCE?
	JRST	ENDL10		;  YES
	TRNN	%16,SEQBIT	;ANY SEQUENCE NUMBERS ENCOUNTERED?
	JRST	ENDL8		;  NO
	PUSHJ	%17,LOTAB	;OUTPUT A TAB
	MOVE	%00,[POINT 7,SEQNUM,]
ENDL7:	ILDB	%02,%00		;GET A CHARACTER
	JUMPE	%02,ENDL8	;BYPASS IF NULL
	PUSHJ	%17,0(%01)	;OUTPUT THE NUMBER
	TLNE	%00,760000	;END OF WORD?
	JRST	ENDL7		;  NO, TRY FOR MORE
ENDL8:	PUSHJ	%17,LOTAB
	SKIPA	%03,LINPNT	;GET SET TO PRINT LINE
ENDL9:	PUSHJ	%17,0(%01)	;LIST A CHARACTER
	ILDB	%02,%03		;GET ANOTHER CHARACTER
	CAIN	%02,RUBOUT	;RUBOUT?
	MOVEI	%02,"?"		;  YES, REPLACE WITH QM
	JUMPN	%02,ENDL9	;TEST FOR END
ENDL10:	TLZ	%15,LPTFLG	;BE SURE TO LIST CR ON LPT
	SETZB	%02,SEQNUM
	PUSHJ	%17,0(%01)	;END,LIST CR/LF
	PUSHJ	%17,PRNTB	;LIST EXTENSION LINE, IF ANY

ENDL11:	HLRZ	%02,%04		;GET TYPE
	XCT	ENDLT3(%02)	;UPDATE LOCATION COUNTER
	ANDI	%05,177777
	SETZB	%04,CEXT1	;ZERO ARGUMENT
	SETZM	CEXT2		;  AND EXTENSIONS
	SETZM	ESPCNT		;CLEAR ERROR FLAG COUNT
	TRZ	%15,-1
	TLZ	%15,SRCFLG!LINFLG!RSWFLG!LPTFLG
	POPJ	%17,


ENDLT1:
	PHASE	0
	TROA	%15,ERRQ	; ILLEGAL TERMINATION OF LINE
MASP:	PUSHJ	%17,GETCHR		; BLANK, GET NEXT CHARACTER
MACM:	TROA	%15,ERRQ
MASC:	CAIA
MACR:	CAIA
	DEPHASE


ENDLT2:
	PHASE	0
	CAIA
CL1:	CAIA			; ASSIGNMENT
CL2:	CAIA			; .=
CL3:	TRNE	%05,1		; XXXXXX
CL4:	CAIA			;    XXX
CL5:	CAIA			; .END
CL6:	TRNE	%05,1		; XXXXXX XXXXXX
CL7:	TRNE	%05,1		; XXXXXX XXXXXX XXXXXX
	DEPHASE


ENDLT3:
	PHASE	0
	JFCL
CL1:	JFCL			; ASSIGNMENT
CL2:	MOVEI	%05,0(%04)	; .=
CL3:	PUSHJ	%17,DUMP		; XXXXXX
CL4:	PUSHJ	%17,DUMP		;    XXX
CL5:	PUSHJ	%17,DUMP		; .END
CL6:	PUSHJ	%17,DUMP		; XXXXXX XXXXXX
CL7:	PUSHJ	%17,DUMP		; XXXXXX XXXXXX XXXXXX
	DEPHASE
STMNT:				;STATEMENT PROCESSOR
	SETZM	OFFSET		;CLEAR ADDRESS OFFSET
	PUSHJ	%17,GETSYM	;TRY FOR SYMBOL
	 JRST	STMNT2		;  NO
	CAIN	%14,":"		;LABEL?
	JRST	LABEL		;  YES
	CAIN	%14,"="		;ASSIGNMENT?
	JRST	ASGMT		;  YES
	PUSHJ	%17,MSRCH	;TEST FOR MACRO
	 CAIA
	JRST	CALLM		;YES
	TRZ	%15,ERRD	;CLEAR ANY D ERROR RESULTING
				;  FROM MACRO SEARCH.
	PUSHJ	%17,OSRCH	;NO, TRY OP TABLE
	 JRST	STMNT2		;TREAT AS EXPRESSION
	LDB	%02,TYPPNT	;FOUND, GET TYPE
	XCT	STMNJT(%02)	;EXECUTE TABLE
	PUSH	%17,%01		;OP, STACK BASIC VALUE
	JRST	0(%10)		;BRANCH TO PROPER ROUTINE

STMNJT:				;STATEMENT JUMP TABLE
	PHASE	0
	0			;SHOULD NEVER HAPPEN
PSOP:	JRST	0(%01)		;PSEUDO-OP, GO TO ROUTINE
BGOP:	MOVEI	%10,PBGOP	;BASIC GROUP
OPOP:	MOVEI	%10,POPOP	;OPERATE GROUP
SCOP:	MOVEI	%10,PSCOP	;SUBROUTINE CALL
UNOP:	MOVEI	%10,PUNOP	;UNARY OP
SHOP:	MOVEI	%10,PUNOP	;SHIFT OP
BCOP:	MOVEI	%10,PBCOP	;BRANCH ON CONDITION OP
TROP:	MOVEI	%10,PTROP	;TRAP OP
RTOP:	MOVEI	%10,PRTOP	;RETURN JUMP
MAOP:	JRST	CALLM
	DEPHASE

STMNT2:	MOVE	%13,SYMBEG	;NON-OP SYMBOL, RESET CHAR POINTER
	PUSHJ	%17,SETCHR	;SET CURRENT CHAR
	CAIE	%14,"."		;LOC TYPE STATEMENT?
	JRST	STMNT4		;  NO
	PUSHJ	%17,GETNB	;POSSIBLY, GET NEXT NON-BLANK
	CAIE	%14,"="
	JRST	STMNT3		;  NO
	PUSHJ	%17,GETCHR	;YES, BYPASS CHAR
	PUSHJ	%17,EXPRF	;EVALUATE THE EXPRESSION
	 TRO	%15,ERRU	;  ERROR, NULL
	TRNE	%15,-1		;ANY ERRORS?
	TRO	%15,ERRP1	;  YES, LIST ON PASS 1
	LDB	%04,[POINT 16,%10,35]	;GET VALUE
	HRLI	%04,CL2		;SET CLASS
	JRST	ENDL		;LIST AND EXIT

STMNT3:	MOVE	%13,SYMBEG
	PUSHJ	%17,SETCHR	;RESET CHARACTER
STMNT4:	PUSHJ	%17,EXPRF	;GET AN EXPRESSION
	SKIPA			;  NO SOAP
	JRST	WORDF		;  YES, EXIT THROUGH "WORD"
	CAIN	%14,","		;IS THERE A COMMA?
	JRST	WORDD		;YES, PROCESS A WORD OF ZERO.
	TLNN	%15,ENDFLG	;END OF EOF SEEN?
	JRST	ENDL		;NO-EXIT NULL
	JRST	END2		;YES-FORCE AN END
LABEL:				;LABEL PROCESSOR
	PUSHJ	%17,SSRCH	;SEARCH USER TABLE
	 JRST	 LABEL1		;NOT FOUND
	TRZ	%15,ERRD	;CLEAR POSSIBLE D ERROR.
	TLNN	%01,REGSYM	;REGISTER ALREADY?
	JRST	 LABEL2		; NO
	TRO	%15,ERRR	; YES - SET R
	TLO	%01,MDLSYM	;     AND MULTIPLE DEF
LABEL2:	TLNN	%15,P1F		;WHICH PASS?
	JRST	 LABEL3		; NOT 1
				;PASS1 - IS IT A LABEL OR
	TLNE	%01,LBLSYM!MDLSYM; MULT DEFINED?

LABEL5:	JRST	LABEL8		; YES - ERROR
LABEL4:	HRR	%01,%05		;GET CURRENT VALUE
	TLO	%01,LBLSYM	;SET LABEL FLAG.
	TLZ	%01,UNDSYM	;MAKE IT DEFINED.
	PUSHJ	%17,INSRT	;INSERT IT.
LABEL7:	PUSHJ	%17,GETCHR	;BYPASS ":"
	JRST	STMNT		;EXIT.

LABEL1:	SETZ	%01,		;CLEAR VAL AND FLAGS.
	TLNE	%15,P1F		;PASS?
	JRST	LABEL4		;  PASS1.
LABEL6:	TRO	%15,ERRP	;  PASS2 - PHASE ERROR. DON'T ENTER IT.
	JRST	LABEL7		; GET OUT

LABEL3:	TLNN	%01,LBLSYM	;ALREADY A LABEL
	JRST	LABEL6		;  NO - ERROR
	TLNE	%01,MDLSYM	;IS IT MULTIPLY DEFINED?
	JRST	LABEL5		;  YES - ERROR
	CAIE	%05,0(%01)	;OUT OF PHASE?
	JRST	LABEL6		;  YES, ERROR
	JRST	LABEL7		;  NO, EXIT
LABEL8:	TRO	%15,ERRM	;M ERROR
	TLO	%01,MDLSYM	;MULT DEFINED.
	JRST	LABEL4+1
ASGMT:				;ASSIGNMENT PROCESSOR

	PUSH	%17,%00		;STACK SYMBOL
	PUSHJ	%17,GETCHR	;BYPASS "="
	PUSHJ	%17,EXPR	;  EVAL EXPRESSION.
	TRO	%15,ERRU!ERRQ	;ERROR IF NULL.
	LDB	%04,[POINT 16,%10,35]	;GET EXPRESSION VALUE.
	HRLI	%04,CL1			;SET CLASS.
	POP	%17,%00		;GET SYMBOL
	PUSHJ	%17,SSRCH	;SEARCH USER TABLE.
	SETZ	%01,		;NOT THERE. VALUE IS 0.
	TLNN	%15,REGFLG	;  REGISTER?
	JRST	ASGMT1		;   NO
	TLNN	%01,LBLSYM	;  LABEL?
	JRST	ASGMT1		;   NO
	TLO	%01,MDLSYM	;  SET MUL DEF.
	TRO	%15,ERRR	;  SET R ERROR.
ASGMT1:	TLNN	%01,MDLSYM	;MUL DEF?
	JRST	ASGMT2		; NO
	TRO	%15,ERRM	; YES - SET M
	TLZ	%01,UNDSYM	;   AND MAKE IT DEFINED
ASGMT4:	PUSHJ	%17,INSRT	;INSERT IT AND
	JRST	ENDL		;   EXIT.

ASGMT2:	TLNE	%15,REGFLG	;REGISTER EXPRESSION?
	TLOA	%01,REGSYM	;YES--FLAG AND TEST MAGNITUDE.
	TLZA	%01,REGSYM	;NO--RESET AND SKIP TEST.
	CAIG	%10,7		;YES--OUT OF RANGE?
	JRST	ASGMT3		;NO.
	TRO	%15,ERRR	;YES--R ERROR AND
	SETZ	%10,		;CLEAR VALUE
ASGMT3:	TRNE	%15,ERRU	;ANY UNDEFINED ERRORS?
	TLOA	%01,UNDSYM	;YES, SET FLAG
	TLZ	%01,UNDSYM	;NO-SET DEFINED
	HRR	%01,%10		;GET FAVLUE
	JRST	ASGMT4		;GO INSERT IT.
PBGOP:				;PROCESS BASIC GROUP OPS
	PUSHJ	%17,AEXP	;GET FIRST ARGUMENT
	LSH	%00,6		;ADJUST SOURCE
	ORM	%00,0(%17)	;MERGE INTO BASIC
	SKIPE	CEXT1		;SKIP IF REGISTER TYPE
	AOS	OFFSET		;FLAG SECOND FIELD
PRADDR:	CAIE	%14,","		;COMMA?
	TROA	%15,ERRQ	;  NO, FLAG ERROR AND SKIP
	PUSHJ	%17,GETCHR	;  YES, BYPASS
PUNOP:				;PROCESS UNARY OP
	PUSHJ	%17,AEXP	;GET SECOND ARGUMENT
	ORM	%00,0(%17)	;MERGE INTO BASIC CODE
POPOP:				;PROCESS OPERATE OP
OPXIT:	POP	%17,%04		;SET VALUE
	HRLI	%04,CL3		;ASSUME 1 WORD
	SKIPN	CEXT1		;TRUE?
	JRST	ENDL		;  YES, LIST AND EXIT
	HRLI	%04,CL6		;NO, ASSUME TWO
	SKIPE	CEXT2		;TRUE?
	HRLI	%04,CL7		;NO, SET FOR THREE
	JRST	ENDL		;LIST AND EXIT

PSCOP:				;PROCESS SUBROUTINE CALL OP
	PUSHJ	%17,REGEXP	;PROCESS REGISTER EXPRESSION
	LSH	%10,6		;MOVE INTO PLACE
	ORM	%10,0(%17)	;MERGE WITH BASIC
	JRST	PRADDR		;PROCESS ADDRESS FIELD
PTROP:				;PROCESS TRAP/EMT OPS
	PUSHJ	%17,EXPRF	;GET EXPRESSION
	SETZ	%10,		;NULL RETURN. ASSUME ZERO.
	TRZE	%10,777400	;VALUE TOO BIG?
	TRO	%15,ERRA	;YES-SET ERROR.
	ORM	%10,0(%17)	;MERGE WITH BASIC VALUE.
	JRST	OPXIT		;EXIT THEM OP EXIT.
PBCOP:				;PROCESS BRANCH ON CONDITION
	PUSHJ	%17,EXPRF	;EVALUATE EXPRESSION
	JRST	PBCOP2		;  NULL, ERROR
	SUBI	%10,2(%05)	;COMPUTE E-.-2
	ROT	%10,-1		;/2, ODD BIT TO SIGN
	TRNE	%10,040000	;WAS IT NEG?
	TRO	%10,100000	;   YES-PROPOGATE SIGN.
	TRNE	%10,000200	;NEGATIVE?
	TRC	%10,177400	;  YES, TOGGLE HIGH BITS
	TRNN	%10,177400	;ANY OVERFLOW?
	JUMPGE	%10,PBCOP1	;  NO, BRANCH IF EVEN
PBCOP2:	MOVNI	%10,1		;  YES, SET TO JMP .
	TRO	%15,ERRA	;FLAG ERROR
PBCOP1:	ANDI	%10,377		;MASK
	ORM	%10,0(%17)	;MERGE WITH BASIC
	JRST	OPXIT		;EXIT THROUGH OP EXIT

PRTOP:				;PROCESS RETURN JUMP
PRTOP1:	PUSHJ	%17,REGEXP	;GET A REGISTER EXPRESSION
	ORM	%10,0(%17)	;MERGE INTO BASIC
	JRST	OPXIT		;EXIT
	SUBTTL	EXPRESSION HANDLERS

AEXP:				;"A" EXPRESSION EVALUATOR
	PUSH	%17,[0]		;STACK INITIAL VALUE
AEXP01:	PUSHJ	%17,SETNB	;GET A NON-BLANK
	CAIN	%14,"#"
	JRST	AEXP02
	CAIN	%14,"%"
	JRST	AEXP04
	CAIN	%14,"("
	JRST	AEXP06
	CAIN	%14,"-"
	JRST	AEXP07
	CAIN	%14,"@"
	JRST	AEXP08
	JRST	AEXP10		;NO UNARIES, PROCESS BASIC EXPRESSION



AEXP02:				; #
	PUSHJ	%17,GETCHR	;BYPASS UNARY OP
	PUSHJ	%17,EXPRF	;EVALUATE EXPRESSION
	 TRO	%15,ERRQ	;  NULL, ERROR
	POP	%17,%00		;RETRIEVE PRESET VALUE
AEXP03:	TRO	%00,27		;SET BITS
	MOVE	%02,OFFSET	;GET OFFSET
	HRROM	%10,CEXT(%02)	;STORE ADDRESS
	POPJ	%17,		;EXIT

AEXP04:				; %
	PUSHJ	%17,REGEXP	;EVALUATE REG EXPRESSION
	POP	%17,%00		;RETRIEVE CODE
AEXP05:	CAILE	%10,7		;ANY OVERFLOW?
	TROA	%15,ERRR	;  YES, FLAG ERROR AND SKIP
	TRO	%00,00(%10)	;SET BITS
	POPJ	%17,		;EXIT

AEXP06:				; (
	PUSHJ	%17,AEXP20	;EVALUATE PARENTHESES
	SETZ	%01,		;ZERO IN CASE OF INDEX
	CAIE	%14,"+"		;FINAL "+" SEEN?
	JRST	AEXP13		;  NO, GO SEE IF (R) OR @(R)?
	POP	%17,%00		;YES, RETRIEVE CODE
	TRO	%00,20(%10)	;SET BITS
	JRST	GETNB		;BYPASS DELIMITER AND EXIT
AEXP13:	POP	%17,%00	;GET CODE
	TRON	%00,10	;IS "@" SET?
	JRST	AEXP05	;NO-REGISTER MODE
	PUSH	%17,%00	;YES-INDEX MODE
	JRST	AEXP12

AEXP07:				; -(
	MOVEM	%13,SYMBEG	;SAVE POINTER IN CASE OF FAILURE
	PUSHJ	%17,GETNB	;GET THE NEXT NON-BLANK
	CAIE	%14,"("		;PARENTHESIS?
	JRST	AEXP09		;  NO, TREAT AS EXPRESSION
	PUSHJ	%17,AEXP20	;YES, EVALUATE
	POP	%17,%00		;RETRIEVE CODE
	TRO	%00,40(%10)	;SET BITS
	POPJ	%17,		;EXIT

AEXP08:				; @
	POP	%17,%00		;RETRIEVE BASIC CODE
	TROE	%00,10		;SET INDIRECT BIT, WAS IT BEFORE?
	TRO	%15,ERRQ	;  YES, FLAG ERROR
	PUSH	%17,%00		;RE-STACK CODE
	PUSHJ	%17,GETCHR	;BYPASS CHARACTER
	JRST	AEXP01		;GO BACK TO BEGINNING

AEXP09:				; -( FAILURE
	MOVE	%13,SYMBEG	;GET POINTER TO "-"
	PUSHJ	%17,SETCHR	;RESTORE CHARACTER
AEXP10:				; NO UNARIES
	PUSHJ	%17,EXPR	;EVALUATE EXPRESSION
	 TRO	%15,ERRQ	;  NULL, ERROR
	CAIN	%14,"("		;ANOTHER EXPRESSION?
	JRST	AEXP11		;  YES, BRANCH
	POP	%17,%00		;RETRIEVE CODE
	TLNE	%15,REGFLG	;REGISTER EXPRESSION?
	JRST	AEXP05		;  YES, TREAT AS %
	TRO	%00,67		;SET BITS FOR INDEXED BY PC.
	SUBI	%10,0(%05)	;DECREMENT BY CLC
	HRROI	%01,-4(%10)	;ASSUME FIRST ADDRESS FIELD
	SKIPE	%02,OFFSET	;TRUE?
	HRROI	%01,-6(%10)	;  NO, TREAT AS SECOND FIELD
	MOVEM	%01,CEXT(%02)		;SET VALUE
	POPJ	%17,		;EXIT

AEXP11:				; E1(E2)
	TLNE	%15,REGFLG	;REGISTER EXPRESSION?
	TRO	%15,ERRR	;  YES, ERROR
	PUSH	%17,%10		;STACK E1
	PUSHJ	%17,AEXP20	;PROCESS EXPRESSION
	POP	%17,%01		;RETRIEVE E1
AEXP12:	MOVE	%02,OFFSET
	HRROM	%01,CEXT(%02)	;STORE ADDRESS
	POP	%17,%00		;RETRIEVE CODE BITS
	TRO	%00,60(%10)	;COMPLETE CODE
	POPJ	%17,		;EXIT


AEXP20:				;()
	PUSHJ	%17,GETCHR	;BYPASS PAREN
	PUSHJ	%17,REGEXP	;EVALUATE REGISTER EXPRESSION
	CAIE	%14,")"		;PROPER DELIMITER
	TROA	%15,ERRQ	;  NO, FLAG ERROR AND SKIP
	PUSHJ	%17,GETCHR	;  YES, BYPASS CHARACTER
	JRST	SETNB		;RETURN WITH NON-BLANK DELIMITER
REGEXP:				;EVALUATE REGISTER EXPRESSION
	PUSHJ	%17,EXPR	;EVALUATE EXPRESSION
	 TRO	%15,ERRR	;  NULL, ERROR
	CAIG	%10,7		;ARE WE WITHIN BOUNDS?
	POPJ	%17,		;  YES, EXIT
	TRO	%15,ERRR	;NO, FLAG ERROR
	SETZ	%10,		;SET VALUE TO ZERO
	POPJ	%17,		;EXIT
EXPR:				;EXPRESSION PROCESSOR, REGISTER ALLOWED
	TLOA	%15,ROKFLG	;ALLOW REGISTER TYPE SYMBOLS

EXPRF:				;EXPRESSION FIN, NO REGISTERS ALLOWED
	TLZ	%15,ROKFLG	;PRECLUDE REGISTER
	TLZ	%15,REGFLG	;RESET ACTUAL FLAG
	PUSHJ	%17,EXPRT	;GET THE FIRST TERM
	 POPJ	%17,		;  NULL, EXIT
EXPRF1:	LDB	%02,C4PNTR	;MAP CHARACTER USING COLUMN 4
EXPRF2:	XCT	EXPRJT(%02)	;EXECUTE TABLE
	PUSHJ	%17,GETNB	;GET THE NEXT NON-BLANK
	LDB	%02,C4PNTR	;MAP
	JUMPE	%02,EXPRF3	;BRANCH IF NOT OPERATOR
	TRO	%15,ERRQ	;OPERATOR, FLAG ERROR
	JRST	EXPRF2		;USE LAST OP

EXPRF3:	PUSH	%17,%01		;STACK INSTRUCTION
	PUSH	%17,%10		;STACK CURRENT VALUE
	PUSHJ	%17,EXPRT	;GET THE NEXT EXPRESSION TERM
	 TRO	%15,ERRQ	;  NULL, FLAG ERROR
	POP	%17,%00		;GET PREVIOUS VALUE
	POP	%17,%01		;  AND OPERATOR
	XCT	%01		;EXECUTE INSTRUCTION
	LDB	%10,[POINT 16,%00,35]	;RETURN TRIMMED RESULT IN %10
	JRST	EXPRF1		;RECYCLE


EXPRJT:				;EXPRESSION JUMP TABLE
	PHASE	0
	JRST	CPOPJ1			; NOT AN OP, EXIT +1
EXPL:	MOVSI	%01,(ADDI %00,0(%10))	; +
EXMI:	MOVSI	%01,(SUBI %00,0(%10))	; -
EXOR:	MOVSI	%01,(IORI %00,0(%10))	; !
EXAN:	MOVSI	%01,(ANDI %00,0(%10))	; &
	DEPHASE
EXPRT:				;EXPRESSION TERM PROCESSOR
	PUSHJ	%17,TERM	;TRY FOR A NORMAL TERM
	 POPJ	%17,		;  NOT FOUND, NORMAL EXIT
	  JRST	CPOPJ1		;    NUMERIC, SKIP-EXIT
	AOS	0(%17)		;SYMBOLIC, SET SKIP-EXIT

	PUSHJ	%17,SSRCH	;SEARCH THE SYMBOL TABLE
	 JRST	EXPRT1		;  NOT FOUND
	TLNE	%01,UNDSYM	;UNDEFINED?
	TRO	%15,ERRU	;  YES, FLAG ERROR
	LDB	%10,[POINT 16,%01,35]	;TRIMMED VALUE TO %10
	TLNE	%01,REGSYM	;REGISTER SYMBOL?
	JRST	ROKTST		;  YES, EXIT THROUGH "OK" TEST
	POPJ	%17,		;EXIT

EXPRT1:	PUSHJ	%17,OSRCH	;PERHAPS AN OP
	 JRST	EXPRT2		;  NO
	LDB	%02,TYPPNT	;YES, GET TYPE
	XCT	EXPRTT(%02)	;DISPATCH ON TABLE
	LDB	%10,[POINT 16,%01,35]	;OK, GET VALUE
	POPJ	%17,		;EXIT

EXPRT2:	MOVSI	%01,UNDSYM	;NOT IN SYMBOL TABLE, FLAG AS UNDEFINED
	TRO	%15,ERRU	;FLAG FOR LISTING
	JRST	INSRT		;INSERT IN TABLE AND EXIT


EXPRTT:				;EXPRESSION TERM TABLE
	PHASE	0
	0			;SHOULD NEVER HAPPEN
PSOP:	JRST	EXPRT2		;PSEUDO-OPS ARE ILLEGAL
BGOP:	JFCL			;BASIC GROUP
OPOP:	JFCL			;OPERATE GROUP
SCOP:	JFCL
UNOP:	JFCL			;UNARY OP
SHOP:	JFCL			;SHIFT OP
BCOP:	JFCL			;BRANCH ON CONDITION OP
TROP:	JFCL			;TRAP OP
RTOP:	JFCL
MAOP:	JRST	EXPRT2
	DEPHASE
				;PUSHJ	%17,TERM
				; 	NULL
				; 	NUMERIC
				; 	SYMBOLIC


TERM:				;TERM PROCESSOR
	SETZB	%10,%01		;RETURN VALUE IN %10
	SETZ	%11,		;DECIMAL NUMBER ACCUM.
	TLZ	%15,DECFLG	;NO DECIMAL NUM.
	PUSHJ	%17,GETSYM	;TRY FOR SYMBOL
	 JRST	TERM1		;  NOT A SYMBOL
	AOS	0(%17)		;SYMBOL, SET DOUBLE-SKIP EXIT
	AOS	0(%17)
	POPJ	%17,

TERM1:	CAIE	%14,"+"		;IF UNARY PLUS
	CAIN	%14,"-"		;  OR UNARY MINUS,
	JRST	NUMXIT		;  EXIT NUMERIC
	CAIE	%14,"&"		;IF LEADING .AND.
	CAIN	%14,"!"		;  OR INCLUSIVE .OR.,
	JRST	NUMXIT		;  EXIT NUMERIC.
	CAIN	%14,"."		;CURRENT LOCATION?
	JRST	TERMPE		;  YES
	CAIN	%14,"'"		;QUOTE?
	JRST	TERMQ		;  YES
	CAIN	%14,""""	;DOUBLE QUOTE?
	JRST	TERMDQ		;  YES
	CAIN	%14,"%"		;REGISTER EXPRESSION?
	JRST	TERM3		;  YES
	CAIL	%14,"0"		;IF NOT BETWEEN 0
	CAIL	%14,"0"+RADIX+2	;  AND 9
	POPJ	%17,		;  EXIT NULL
TERM2:	CAIL	%14,"0"+RADIX	;IS CHAR DECIMAL?
	TLO	%15,DECFLG	;YES-SET FLAG.
	IMULI	%10,RADIX	;ACCUMULATE OCTAL
	ADDI	%10,-"0"(%14)	;ADD IN ABSOLUTE VALUE
	IMULI	%11,RADIX+2	;ACCUMULATE
	ADDI	%11,-"0"(%14)	;DECIMAL
	PUSHJ	%17,GETCHR	;GET NEXT CHARACTER
	CAIL	%14,"0"		;IS IT IN
	CAIL	%14,"0"+RADIX+2	;  RANGE?
	JRST	NUMXA		;NO, TEST FOR END OF NUM.
	JRST	TERM2		;DO IT AGAIN.

NUMXA:	CAIE	%14,"."		;IS CHAR A "."?
	JRST	NUMXB		;NO, GO SEE IF DECIMAL.
	PUSHJ	%17,GETCHR	;YES, GET PAST CHAR.
	JRST	NUMXC		;  TREAT AS DECIMAL
NUMXB:	TLZN	%15,DECFLG	;8 OR 9 SEEN?
	JRST	NUMXIT		;  NO, EXIT.
	TRO	%15,ERRN	;SET N ERROR
NUMXC:	MOVE	%10,%11		;GET DECIMAL NUMBER.
	TLZ	%15,DECFLG	;CLEAR DEC FLAG.
	JRST	NUMXIT

TERM3:	PUSHJ	%17,GETNB	;BYPASS UNARY %
	PUSHJ	%17,EXPRT	;EVALUATE TERM
	 TRO	%15,ERRR	;  NULL, ERROR
	PUSHJ	%17,ROKTST	;TEST MAGNITUDE

NUMXIT:	TDZE	%10,[-1B19]	;MASK TO 16 BITS, ANY OVERFLOW?
	TRO	%15,ERRT	;  YES,FLAG IT
	AOS	0(%17)		;SET FOR SKIP-EXIT
	JRST	SETNB		;RETURN NON-BLANK

ROKTST:				;REGISTER "OK" TEST
	TLNN	%15,ROKFLG	;REGISTER ALLOWED?
	TRO	%15,ERRR	;  NO, FLAG ERROR
	TLO	%15,REGFLG	;SET FLAG
	POPJ	%17,		;EXIT
TERMPE:				;"."
	MOVE	%10,%05		;GET CURRENT LOCATION COUNTER
	PUSHJ	%17,GETCHR	;MOVE PAST CHARACTER
	JRST	NUMXIT		;EXIT NUMERIC


TERMDQ:				; """
	PUSHJ	%17,GETCHR	;GET THE NEXT CHARACTER
	MOVE	%10,%14		;MOVE TO EXPRESSION AC
	CAIE	%10,0		;ERROR IF CR
	PUSHJ	%17,GETCHR	;GET THE NEXT CHAR
	LSH	%14,8		;MOVE OVER ONE
	CAIA			;SKIP AND FALL THROUGH
TERMQ:				;"'"
	PUSHJ	%17,GETCHR	;GET THE NEXT CHARACTER
	TRO	%10,0(%14)	;MERGE/PLACE CHARACTER IN 10
	CAIN	%10,0		;PERCHANCE CARRIAGE RETURN?
	TROA	%15,ERRQ	;  YES, FLAG ERROR AND SKIP
	PUSHJ	%17,GETCHR	;  NO, BYPASS
	JRST	NUMXIT		;EXIT NUMERIC
	SUBTTL	SYMBOL/CHARACTER HANDLERS

GETSYM:				;GET A SYMBOL
	MOVSI	%03,(POINT 6,%00,)	;SET POINTER
	TDZA	%00,%00		;CLEAR AC AND SKIP
GETSY1:	PUSHJ	%17,GETCHR	;GET NEXT CHARACTER
	MOVEM	%13,SYMBEG	;SAVE START IN CASE OF FAIL
	LDB	%02,ANPNTR	;MAP CHARACTER TYPE
	XCT	GETSY3(%02)	;EXECUTE TABLE
GETSY2:	SUBI	%14,40		;VALID, CONVERT TO SIXBIT
	CAME	%03,[POINT 6,%00,<CPW*6-1>]	;ARE WE FULL?
	IDPB	%14,%03		;  NO, STORE CHARACTER
GETSY5:	PUSHJ	%17,GETCHR	;GET THE NEXT INPUT CHARACTER
	LDB	%02,ANPNTR	;MAPE CHARACTER TYPE
	XCT	GETSY4(%02)	;EXECUTE TABLE
	CAME	%00,[SIXBIT /./];FINISHED, WAS IT A DOT?
	JRST	CPOPJ1		;  NO, VALID.  EXIT +1
	MOVE	%13,SYMBEG	;  YES, RESET CHARACTER POINTER
	PUSHJ	%17,SETCHR	;  AND CHARACTER
	SETZ	%00,		;CLEAR AC
	POPJ	%17,		;EXIT NULL
GETSY6:	TRO	%15,ERRI	;SET I ERROR
	JRST	GETSY5		;GET NEXT CHAR



GETSY3:				;FIRST CHARACTER TABLE
	PHASE	0
	POPJ	%17,		;NOTHING CHARACTER, EXIT NULL
.TAB:	JRST	GETSY1		;SPACE OR TAB, BYPASS
.ALP:	JFCL			;ALPHA, FALL THROUGH
.NUM:	POPJ	%17,		;NUMERIC, EXIT NULL
.DOT:	JFCL			;DOT, FALL THROUGH, TEST LATER
.TRM:	POPJ	%17,		;TERMINATOR, EXIT NULL
	DEPHASE


GETSY4:				;SUCCEEDING CHARACTERS
	PHASE	0
	JRST	GETSY6		;NOTHING CHAR, SET I AND IGNORE
.TAB:	PUSHJ	%17,GETNB	;SPACE OR TAB, BYPASS AND FALL THROUGH
.ALP:	JRST	GETSY2		;ALPHA, RECYCLE
.NUM:	JRST	GETSY2		;NUMERIC, DITTO
.DOT:	JRST	GETSY2		;DOT, DITTO
.TRM:	JFCL			;TERMINATOR, FALL THROUGH
	DEPHASE
GETNB:				;GET NON-BLANK CHARACTER
	IBP	%13		;INDEX BYTE POINTER
SETNB:				;SET TO NON-BLANK CHARACTER
	PUSHJ	%17,SETCHR	;SET CHARACTER IN %14
	CAIE	%14,SPACE	;IF SPACE
	CAIN	%14,TAB		;  OR TAB;
	JRST	GETNB		;  BYPASS
	POPJ	%17,		;OTHERWISE EXIT


GETCHR:				;GET THE NEXT CHARACTER
	IBP	%13		;INDEX BYTE POINTER
SETCHR:				;SET THE CURRENT CHAR IN %14
	LDB	%14,%13		;PICK IT UP
	CAIN	%14,RUBOUT	;RUBOUT (ILLEGAL CHAR)?
	JRST	GETCHR		;  YES, BYPASS
	POPJ	%17,		;NO, EXIT
	SUBTTL	PSEUDO-OPS

END:				;"END" PSEUDO-OP
	TLO	%15,ENDFLG	;FLAG "END SEEN"
	PUSHJ	%17,EXPRF	;EVALUATE THE ADDRESS
END2:	MOVEI	%10,1		;  NULL, FORCE ODD VECTOR
	MOVEM	%10,CEXT1	;STORE VECTOR
	MOVEI	%04,6		;SET INSTRUCTION (DUMMY. USED AS BYTE CT.)
END1:	HRLI	%04,CL5		;FLAG AS .END
	JRST	ENDL		;LIST AND EXIT

OPCERR:				;ILLEGAL OP CODE
	TRO	%15,ERRO
	JRST	ENDL		;FLAG ERROR, LIST, AND EXIT
EVEN:				;"EVEN" PSEUDO OP
	MOVEI	%10,2
	MOVE	%04,%05		;GET CURRENT ADDRESS
	TRZE	%04,-1(%10)	;CLEAR LOW BITS, ANY THERE?
	ADDI	%04,0(%10)	;  YES, INCREMENT
	HRLI	%04,CL2		;SET CLASS
	JRST	ENDL		;LIST AND EXIT
ASC:				;"ASC" PSEUDO-OP
	PUSHJ	%17,SETNB	;GET FIRST NON-BLANK
	PUSH	%17,%14		;STACK TERMINATOR
	JUMPE	%14,ASC3	;ERROR IF CR
ASC1:	PUSHJ	%17,GETCHR	;GET NEXT CHARACTER
	JUMPE	%14,ASC3	;ERROR IF CARRIAGE RETURN
	CAMN	%14,0(%17)	;TERMINATOR?
	JRST	ASC4		;  YES
	MOVEI	%04,0(%14)	;PLACE IN AC4
	HRLI	%04,CL4		;SET CLASS
	PUSHJ	%17,ENDLF	;PRINT AND DUMP IT
	TLO	%15,SRCFLG
	JRST	ASC1		;RECYCLE

ASC3:	TROA	%15,ERRQ	;ERROR, FLAG AND SKIP
ASC4:	PUSHJ	%17,GETCHR	;NORMAL TERMINATION, BYPASS TERMINATOR
	POP	%17,%00		;FLUSH TERMINATOR FROM STACK
	JRST	ENDL		;EXIT

BYT:				;"BYT" PSEUDO-OP
	PUSHJ	%17,EXPRF	;EVALUATE EXPRESSION
	SETZ	%10,		;NULL, ASSUME 0
	TDCN	%10,[177400]	;OVERFLOW?
	JRST	.+3		;  NO.
				;HIGH BITS ARE NOW COMPLEMENTED.
	TDZE	%10,[-1B27]	;MASK TO 8 BITS.
				;ANY OVERFLOW
	TRO	%15,ERRT	;YES, FLAG IT
	LDB	%04,[POINT 8,%10,35]	;SET CODE
	HRLI	%04,CL4		;SET CLASS
	CAIE	%14,","		;ANY MORE
	JRST	ENDL		;  NO, EXIT
	PUSHJ	%17,ENDLF	;YES, DUMP THIS ITEM
	TLO	%15,SRCFLG
	PUSHJ	%17,GETCHR	;BYPASS COMMA
	JRST	BYT		;GET ANOTHER ITEM


WORD:				;"WORD" PSEUDO-OP
	PUSHJ	%17,EXPRF	;EVALUATE EXPRESSION
WORDD:	SETZ	%10,		;  NULL, ASSUME 0
WORDF:	MOVE	%04,%10		;GET VALUE
	HRLI	%04,CL3		;SET CLASS
	CAIE	%14,","		;END OF STRING?
	JRST	ENDL		;  YES, LIST AND EXIT
	PUSHJ	%17,ENDLF	;NO, LIST THIS WORD
	TLO	%15,SRCFLG	;DON'T RE-LIST SOURCE
	PUSHJ	%17,GETCHR	;BYPASS COMMA
	JRST	WORD		;RE-CYCLE
	SUBTTL	REPEAT HANDLER

REPEA0:				;"REPEAT" PSEUDO-OP
	PUSHJ	%17,EXPRF	;EVALUATE EXPRESSION
	 TRO	%15,ERRU!ERRP1	;PASS 1 ERROR IF NULL
	LDB	%04,[POINT 16,%10,35]
	HRLI	%04,CL1		;LIST VALUE
	TRNN	%10,1B20
	CAIN	%10,0		;IF LESS THAN OR EQUAL TO ZERO,
	JRST	UNSCON		;  JUST LIST
	CAIN	%10,1		;IF SINGLE,
	JRST	SATCON		;  JUS@ PROCESS
	PUSH	%17,%10		;STACK EXPRESSION
	PUSHJ	%17,ENDLR	;LIST LINE
	PUSHJ	%17,GETBLK	;MULTIPLE, SDT FOR STORAGE
	PUSH	%17,MWPNTR	;SAVE STARTING BLOCK ADDRESS
	MOVEI	%11,3
	ADDM	%11,MWPNTR	;POINT PAST POINTER STORAGE
	SETZ	%07,		;ZERO LEVEL COUNT
REPEA1:	PUSHJ	%17,GETLIN	;GET THE NEXT SOURCE LINE
	PUSHJ	%17,GETSYM	;TEST THE FIRST SYMBOL
	 JRST	REPEA2		;  NON-SYMBOLIC
	CAMN	%00,.REPTX
	AOJA	%07,REPEA2	;  INCREMENT AND BRANCH
	CAMN	%00,.ENDRX
	SOJL	%07,REPEA3	;  DECREMENT AND BRANCH IF END
REPEA2:	SKIPA	%13,LINPNT	;POINT TO START OF LINE
	PUSHJ	%17,WCIMT	;WRITE CHAR IN MACRO TREE
	PUSHJ	%17,GETCHR	;GET THE NEXT CHARACTER
	JUMPN	%14,.-2		;TEST FOR CR
	MOVEI	%14,CRR
	PUSHJ	%17,WCIMT	;WRITE CR
	SETZ	%14,
	PUSHJ	%17,ENDLR	;LIST THE LINE
	TLNN	%15,ENDFLG	;SKIP IF EOF SEEN
	JRST	REPEA1		;TRY THE NEXT LINE

REPEA3:	PUSHJ	%17,ENDLR	;TERMINATION, LIST LINE
	MOVEI	%14,QUEREP	;END, SET TO CLOSE
	PUSHJ	%17,WTIMT	;WRITE FLAG AND "REPEAT END"
	POP	%17,%11		;RETRIEVE STARTING POINTER
	MOVEI	%10,-1(%11)	;SET FOR PUSH
	PUSH	%10,%12		;STORE READ POINTER
	PUSH	%10,REPPNT	;  REPEAT POINTER
	PUSH	%10,REPEXP	;  AND REPEAT EXPRESSION
	MOVEM	%11,REPPNT	;SET NEW REPEAT POINTER
	POP	%17,REPEXP	;  AND REPEAT COUNT
;	JRST	REPEND
REPEND:				;REPEAT END
	MOVE	%12,REPPNT	;ASSUME ANOTHER ITERATION
	ADDI	%12,3		;POINT PAST POINTERS
	SOSL	REPEXP		;END?
	POPJ	%17,		;  NO
	MOVE	%01,REPPNT	;  YES, GET SET TO CLEAN UP
	HRROI	%10,2(%01)	;POINT TO TOP POINTER
	POP	%10,REPEXP	;REPLACE STORED ITEMS
	POP	%10,REPPNT
	POP	%10,%12
	PUSHJ	%17,REMMAC	;GARBAGE COLLECT
	POPJ	%17,		;EXIT
	SUBTTL	REPEAT/CONDITIONAL ROUTINES

SATCON:	PUSHJ	%17,ENDLR	;LIST THE LINE
SATCO1:	PUSHJ	%17,GETLIN	;GET THE NEXT LINE
	PUSHJ	%17,GETSYM	;CHECK THE FIRST SYMBOL
	 TLNN	%15,ENDFLG	;  NON-SYMBOLIC, TEST FOR EOF
	CAMN	%00,.ENDRX	;"ENDR"?
	JRST	ENDLR		;  YES, LIST AND EXIT
	MOVE	%13,SYMBEG	;NO, RESTORE LINE
	PUSHJ	%17,SETCHR	;  AND CHARACTER
	PUSHJ	%17,STMNT	;PROCESS IT
	JRST	SATCO1		;TRY AGAIN


UNSCON:	PUSHJ	%17,ENDLR	;LIST THE LINE
UNSCO1:	PUSHJ	%17,GETLIN	;GET THE NEXT LINE
	PUSHJ	%17,GETSYM	;CHECK THE FIRST SYMBOL
	 JRST	UNSCO2		;  NON-SYMBOLIC, LIST
	CAMN	%00,.ENDRX	;"ENDR"?
	JRST	ENDLR		;  YES, LIST AND EXIT
	CAME	%00,.REPTX	;NESTED?
	JRST	UNSCO2		;  NO
	PUSHJ	%17,UNSCO2	;YES, RECURSE
	JRST	UNSCO1		;BACK TO NORMAL

UNSCO2:	SETZ	%14,
	TLNE	%15,ENDFLG	;EOF SEEN?
	JRST	ENDL		;  YES, EXIT
	PUSHJ	%17,ENDLR	;NO, LIST THE LINE
	JRST	UNSCO1		;TRY AGAIN
	SUBTTL	MACRO HANDLERS

DEFIN0:				;"DEFINE" PSEUDO-OP
	PUSHJ	%17,GETSYM	;GET ITS NAME
	 JRST	DEFERR		;  ERROR, EXIT
	PUSHJ	%17,GETBLK	;OK, GET A BLOCK FROM STORAGE
	PUSHJ	%17,MSRCH	;SEE IF ALREADY DEFINED
	 SETZ	%01,		;  NOT IN TABLE
	LDB	%02,TYPPNT	;GET OP TYPE
	CAIN	%02,MAOP	;MACRO?
	PUSHJ	%17,DECMAC	;  YES, DECREMENT REFERENCE
	HRRZ	%01,MWPNTR	;GET POINTER TO START OF BLOCK
	HRLI	%01,MAOP	;FLAG MACRO
	PUSHJ	%17,INSRT	;INSERT/DELETE IN SYMBOL TABLE
	PUSH	%17,MWPNTR	;STACK POINTER TO START OF BLOCK
	MOVEI	%01,2
	ADDM	%01,MWPNTR	;MOVE PAST REFERENCE LEVEL AND ARG COUNT
	TDZA	%07,%07		;INIT ARG COUNT
DEF01:	PUSHJ	%17,GETCHR	;MOVE PAST COMMA
	PUSHJ	%17,GETSYM	;GET AN ARG
	 JRST	DEF02		;  NOT THERE
	MOVEM	%00,ARGLST(%07)	;STORE IN LIST
	ADDI	%07,1		;BUMP POINTER
	CAIN	%14,","		;ANY MORE?
	JRST	DEF01		;  YES

DEF02:	PUSH	%17,%07		;STACK ARG COUNT
	SETZM	ARGLST(%07)	;MARK END
	PUSHJ	%17,ENDLR	;LIST THE LINE
	SETZ	%07,		;INIT LEVEL COUNT

DEF03:	PUSHJ	%17,GETLIN	;GET THE NEXT LINE
	PUSHJ	%17,GETSYM	;TEST THE FIRST SYMBOL
	 JRST	DEF04		;NON-SYMBOLIC
	CAMN	%00,.MACRX
	AOJA	%07,DEF04	;INCREMENT
	CAMN	%00,.ENDMX
	SOJL	%07,DEF13	;END IF MINUS

DEF04:	MOVE	%13,LINPNT	;SET TO START OF LINE
DEF05:	PUSHJ	%17,GETCHR	;GET THE NEXT CHARACTER
DEF06:	CAIE	%14,"'"		;CONCATENATION CHARACTER?
	JRST	DEF06C		;  NO, BRANCH AROUND
DEF06A:	PUSHJ	%17,GETCHR	;YES, GET THE NEXT CHARACTER
	CAIE	%14,"'"		;MULTIPLE?
	JRST	DEF06B		;  NO
	PUSHJ	%17,WCIMT	;YES, SAVE ONLY ONE
	JRST	DEF06A		;TEST FOR MORE

DEF06B:	TLO	%15,CONFLG	;FLAG THE CONCATENATION CHARACTER
DEF06C:	LDB	%02,ANPNTR	;MAP
	XCT	DEFT1(%02)	;EXECUTE TABLE
	PUSHJ	%17,WCIMT	;WRITE IN TREE
	JRST	DEF05		;TRY FOR ANOTHER
DEF07:	SETZ	%00,		;POSSIBLE ARGUMENT
	MOVSI	%03,(POINT 6,%00,)
	MOVEM	%13,SYMBEG	;SAVE START JUST IN CASE
DEF08:	SUBI	%14,40		;CONVERT TO SIXBIT
	CAME	%03,[POINT 6,%00,<CPW*6-1>]	;ROOM TO STORE?
	IDPB	%14,%03		;  YES, DO SO
	PUSHJ	%17,GETCHR	;GET THE NEXT CHARACTER
	LDB	%02,ANPNTR	;MAP
	XCT	DEFT2(%02)	;EXECUTE TABLE
	SETZ	%02,		;INIT SEARCH INDEX
DEF09:	SKIPN	ARGLST(%02)	;TEST FOR END
	JRST	DEF10		;  YES
	CAME	%00,ARGLST(%02)	;NO, HAVE WE A MATCH?
	AOJA	%02,DEF09	;  NO,TRY THE NEXT SLOT
	TLZ	%15,CONFLG	;REMOVE POSSIBLE CONCATENATION CHARACTER
	MOVEI	%14,101(%02)	;SET DUMMY SYMBOL POINTER
	PUSHJ	%17,WTIMT	;WRITE IN TREE
	PUSHJ	%17,SETCHR	;SET CHARACTER
	CAIN	%14,"'"		;CONCATENATION CHARACTER?
	JRST	DEF05		;  YES, BYPASS IT
	JRST	DEF06		;  NO, PROCESS IT

DEF10:	MOVE	%13,SYMBEG	;MISSED, RESET POINTER
	PUSHJ	%17,SETCHR	;RESET CHARACTER
DEF11:	LDB	%02,ANPNTR	;MAP
	XCT	DEFT3(%02)	;EXECUTE TABLE
	PUSHJ	%17,WCIMT	;OK, WRITE IN TREE
	PUSHJ	%17,GETCHR	;GET NEXT CHAR
	JRST	DEF11		;TEST IT

DEF12:	MOVEI	%14,CRR		;END OF LINE, SET CR
	PUSHJ	%17,WCIMT	;WRITE IT OUT
	SETZ	%14,
	PUSHJ	%17,ENDLR	;LIST IT
	TLNN	%15,ENDFLG	;SKIP IF EOF SEEN
	JRST	DEF03		;GET THE NEXT LINE

DEF13:	MOVEI	%14,QUEMAC	;FINISHED, SET "END OF MACRO DEFINITION"
	PUSHJ	%17,WTIMT	;WRITE IT, WITH QUE, IN TREE
	POP	%17,%02		;RETRIEVE COUNT
	POP	%17,%01		;  AND POINTER TO START OF BLOCK
	SETZM	0(%01)		;ZERO LEVEL COUNT
	HRRZM	%02,1(%01)	;STORE ARG COUNT IN SECOND RUNG
	PUSHJ	%17,SETCHR	;RESTORE LAST CHARACTER
	JRST	ENDLR		;LIST AND EXIT


DEFERR:
	TRO	%15,ERRQ
	SETZ	%14,
	JRST	ENDLR
DEFT1:
	PHASE	0
	JUMPE	%14,DEF12
.TAB:	JFCL
.ALP:	JRST	DEF07
.NUM:	JRST	DEF07
.DOT:	JRST	DEF07
.TRM:	JUMPE	%14,DEF12
	DEPHASE


DEFT2:
	PHASE	0
	JFCL
.TAB:	JFCL
.ALP:	JRST	DEF08
.NUM:	JRST	DEF08
.DOT:	JRST	DEF08
.TRM:	JFCL
	DEPHASE


DEFT3:
	PHASE	0
	JRST	DEF06
.TAB:	JRST	DEF06
.ALP:	JFCL
.NUM:	JFCL
.DOT:	JFCL
.TRM:	JRST	DEF06
	DEPHASE
CALLM:	PUSH	%17,%01		;SAVE POINTER
	PUSHJ	%17,INCMAC	;INCREMENT THE REFERENCE COUNT
	MOVE	%07,1(%01)	;GET ARGUMENT COUNT
	PUSHJ	%17,GETBLK	;GET A BLOCK FROM FREE STORAGE
	PUSH	%17,MWPNTR	;SAVE THE STARTING ADDRESS
	MOVEI	%00,5
	ADDM	%00,MWPNTR	;MOVE BYTE POINTER PAST WORD STORAGE
	MOVEI	%14,QUEARG
	PUSHJ	%17,WTIMT	;INITIALIZE ARGUMENT LIST
	JUMPE	%07,MAC50	;TEST FOR NO ARGS
	PUSHJ	%17,SETCHR	;RESTORE LAST CHARACTER

MAC10:	LDB	%02,C1PNTR	;MAP USING COLUMN 1
	XCT	CALMT1(%02)
	PUSHJ	%17,GETCHR	;IGNORE LEADING BLANKS
	JRST	MAC10

MAC20:	CAIN	%14,"^"		;FIRST CHAR, TEST UNARY OPS
	JRST	MAC60		;  DELIMITED STRING
	CAIN	%14,"\"
	JRST	MAC70		;EXPRESSION TO ASCII CONVERSION
MAC21:	PUSHJ	%17,WCIMT	;NOTHING SPECIAL, WRITE IN TREE
	PUSHJ	%17,GETCHR	;GET THE NEXT CHARACTER
	LDB	%02,C1PNTR	;MAP
	XCT	CALMT2(%02)

MAC30:	PUSHJ	%17,GETCHR	;TEST ARG DELIMITER
MAC31:	LDB	%02,C1PNTR	;MAP
	XCT	CALMT3(%02)
	JRST	MAC30		;NON-DELIMITER, TRY THE NEXT ONE
MAC40:				;COMMA PROCESSOR
	MOVEI	%14,QUEARG
	PUSHJ	%17,WTIMT	;MARK END OR ARGUMENT
	PUSHJ	%17,GETCHR	;BYPASS COMMA
	SOJG	%07,MAC10	;BRANCH IF MORE ARGS

MAC50:				;END OF LINE PROCESSOR
	MOVEI	%14,QUEARG
	PUSHJ	%17,WTIMT	;PAD MISSING ARGS
	SOJGE	%07,.-1
	POP	%17,%10		;GET CALL BLOCK POINTER
	MOVEM	%12,0(%10)	;SAVE CURRENT READ POINTER
	MOVE	%01,CALPNT
	MOVEM	%01,1(%10)	;SAVE CURRENT CALL BLOCK POINTER
	MOVEM	%10,CALPNT	;SET NEW POINTER
	POP	%17,%12		;GET POINTER TO BASIC BLOCK
	HRLI	%12,(POINT 7,,)	;FORM A BYTE POINTER
	MOVEM	%12,2(%10)	;SAVE IT FOR DECMAC
	MOVEM	%14,3(%10)	;SAVE LAST CHARACTER READ
	ADDI	%12,2		;POINT PAST WORD STORAGE
	AOS	MACLVL
	PUSHJ	%17,SETCHR	;RESTORE LAST CHARACTER
	JRST	ENDLR		;LIST AND EXIT
MAC60:				;"^" PROCESSOR
	PUSHJ	%17,GETCHR	;BYPASS UNARY OP
	LDB	%02,C1PNTR	;MAP
	XCT	CALMT4(%02)
	MOVE	%00,%14		;SAVE ARBITRARY DELIMITER
MAC61:	PUSHJ	%17,GETCHR	;PROCESS BODY
	LDB	%02,C1PNTR	;MAP
	XCT	CALMT5(%02)
	CAMN	%14,%00		;TEST FOR DELIMITER
	JRST	MAC30		;  YES, TEST FOR COMMA
	PUSHJ	%17,WCIMT	;NO, WRITE CHARACTER IN TREE
	JRST	MAC61		;TRY ANOTHER

MAC62:	TRO	%15,ERRQ	;CARRIAGE RETURN IN TEXT, ERROR
	JRST	MAC50


MAC70:				;"\"
	PUSHJ	%17,GETCHR	;BYPASS UNARY OP
	PUSH	%17,%07		;PROTECT ARG COUNT
	PUSHJ	%17,EXPRF	;EVALUATE THE EXPRESSION
	 TRO	%15,ERRQ	;  NULL, ERROR
	PUSHJ	%17,MAC71	;CONVERT TO ASCII
	POP	%17,%07		;RESTORE ARG COUNT
	PUSHJ	%17,SETCHR	;  AND LAST CHARACTER
	JRST	MAC31		;TEST FOR COMMA

MAC71:	IDIVI	%10,RADIX
	HRLM	%11,0(%17)
	SKIPE	%10		;TEST FOR END
	PUSHJ	%17,MAC71
	HLRZ	%14,0(%17)
	ADDI	%14,"0"		;FORM TEXT
	JRST	WCIMT		;WRITE INTO SKELETON
CALMT1:
	PHASE	0
	JRST	MAC20
MASP:	JFCL			; SPACE OR TAB
MACM:	JRST	MAC40		; COMMA
MASC:	JRST	MAC50		; SEMI-COLON
MACR:	JRST	MAC50		; CARRIAGE RETURN
	DEPHASE


CALMT2:
	PHASE	0
	JRST	MAC21
MASP:	JFCL			; SPACE OR TAB
MACM:	JRST	MAC40		; COMMA
MASC:	JRST	MAC50		; SEMI-COLON
MACR:	JRST	MAC50		; CARRIAGE RETURN
	DEPHASE


CALMT3:
	PHASE	0
	TRO	%15,ERRQ
MASP:	JFCL			; SPACE OR TAB
MACM:	JRST	MAC40		; COMMA
MASC:	JRST	MAC50		; SEMI-COLON
MACR:	JRST	MAC50		; CARRIAGE RETURN
	DEPHASE


CALMT4:
	PHASE	0
	JFCL
MASP:	TRO	%15,ERRQ	; SPACE OR TAB
MACM:	JFCL			; COMMA
MASC:	JFCL			; SEMI-COLON
MACR:	JRST	MAC62		; CARRIAGE RETURN
	DEPHASE


CALMT5:
	PHASE	0
	JFCL
MASP:	JFCL			; SPACE OR TAB
MACM:	JFCL			; COMMA
MASC:	JFCL			; SEMI-COLON
MACR:	JRST	MAC62		; CARRIAGE RETURN
	DEPHASE
MACEND:				;END OF MACRO CALL
	MOVE	%10,CALPNT	;IN CASE WE GOT WIPED
	MOVE	%12,0(%10)	;RESET PREVIOUS READ POINTER
	MOVE	%01,1(%10)
	MOVEM	%01,CALPNT	;LIKEWISE
	MOVE	%01,2(%10)	;GET POINTER TO BASIC BLOCK
	PUSHJ	%17,DECMAC	;DECREMENT THE REFERENCE
	MOVE	%14,3(%10)	;RESTORE LAST CHARACTER
	MOVE	%01,%10
	PUSHJ	%17,REMMAC	;RETURN THIS BLOCK FOR DEPOSIT
	SOS	MACLVL		;DECREMENT MACRO LEVEL COUNT
	POPJ	%17,		;FINIS
	SUBTTL	MACRO STORAGE HANDLERS

WTIMT:				;WRITE TWO CHARACTERS IN MACRO TREE
	PUSH	%17,%14		;STACK CURRENT CHARACTER
	MOVEI	%14,RUBOUT	;SET FLAG CHARACTER
	PUSHJ	%17,WCIMT	;WRITE IT
	POP	%17,%14		;RESTORE CHARCTER AND FALL THROUGH

WCIMT:				;WRITE CHARACTER IN MACRO TREE
	TLZE	%15,CONFLG	;CONCATENATION CHARACTER PENDING?
	JRST	WCIMT2		;  YES, WRITE IT OUT
	IBP	MWPNTR		;POINT TO ACTUAL WORD
	SKIPN	@MWPNTR		;END OF BLOCK?
	JRST	WCIMT1		;  YES, GET ANOTHER
	DPB	%14,MWPNTR	;NO, STORE BYTE
	POPJ	%17,		;EXIT

WCIMT1:	PUSH	%17,MWPNTR	;NEAD A NEW BLOCK, SAVE CURRENT POINTER
	PUSHJ	%17,GETBLK	;GET IT
	HRRZ	%11,MWPNTR	;GET START OF NEW BLOCK
	EXCH	%11,0(%17)	;EXCHANGE WITH POINTER TO LAST
	POP	%17,0(%11)	;STORE VECTOR
	JRST	WCIMT		;TRY AGAIN

WCIMT2:	PUSH	%17,%14		;STACK CURRENT CHARACTER
	MOVEI	%14,"'"
	PUSHJ	%17,WCIMT	;WRITE CONCATENATION CHARACTER
	POP	%17,%14		;RESTORE CHARACTER
	JRST	WCIMT		;CONTINUE
GETBLK:				;GET A BLOCK FOR MACRO STORAGE
	SKIPE	%11,NEXT	;ANY REMNANTS OF GARBAGE COLLECTION?
	JRST	GETBL1		;  YES, RE-USE
	PUSH	%17,%07		;  NO, SAVE REGISTER
	MOVEI	%07,WPB
	ADDB	%07,MACTOP	;UPDATE FREE LOCATION POINTER
	CAML	%07,SYMBOT	;ANY ROOM?
	PUSHJ	%17,GETCOR	;  NO, GET MORE CORE
	MOVEI	%11,-<WPB-1>(%07)	;POINT TO START OF BLOCK
	POP	%17,%07		;RESTORE
	SETZM	WPB-1(%11)	;CLEAR VECTOR
GETBL1:	HRLI	%11,(POINT 7,,)	;FORM BYTE POINTER
	MOVEM	%11,MWPNTR	;SET NEW BYTE POINTER
	HRLI	%11,-<WPB-1>	;GET SET TO INITIALIZE BLOCK
	SETOM	0(%11)		;CLEAR ENTRY
	AOBJN	%11,.-1		;SET ALL EXCEPT LAST TO -1
	PUSH	%17,0(%11)	;GET TOP
	POP	%17,NEXT	;SET FOR NEXT BLOCK
	SETZM	0(%11)		;CLEAR LAST WORD
	POPJ	%17,		;EXIT
READMC:				;READ MACRO CHARACTER
	PUSHJ	%17,READMB	;GET A MACRO BYTE
	CAIE	%14,RUBOUT	;SPECIAL?
	 JRST	CPOPJ1		;  NO, JUST EXIT
	PUSHJ	%17,READMB	;YES, GET TYPE
	TRZE	%14,100		;SYMBOLIC?
	JRST	GETDS		;  YES
	JRST	.(%14)		;  NO, TRANSFER ON TYPE

	PHASE	1
QUEMAC:	JRST	MACEND		;END OF MACRO
QUEARG:	JRST	DSEND		;END OF MACRO ARGUMENT
QUEREP:	JRST	REPEND		;END OF REPEAT
	DEPHASE


READMB:				;READ MACRO BYTE
	ILDB	%14,%12		;GET CHARACTER
	JUMPN	%14,CPOPJ	;EXIT IF NON-NULL
	MOVE	%12,0(%12)	;END OF BLOCK, GET LINK
	HRLI	%12,(POINT 7,,)	;SET ASCII BYTE POINTER
	JRST	READMB		;TRY AGAIN
GETDS:				;GET DUMMY SYMBOL
	MOVE	%11,CALPNT	;GET POINTER TO CALL BLOCK
	MOVEM	%12,4(%11)	;SAVE CURRENT READ POINTER
	MOVE	%12,%11		;SET NEW READ POINTER
	ADDI	%12,5		;MOVE PAST WORDS
	MOVE	%11,%14		;GET ARG NUMBER
	ANDI	%11,37
GETDS1:	PUSH	%17,%11		;STACK WORKING REGISTER
GETDS2:	PUSHJ	%17,READMB	;GET A MACRO BYTE
	CAIE	%14,RUBOUT	;FLAGGED?
	JRST	GETDS2		;  NO, TRY AGAIN
	PUSHJ	%17,READMB	;YES, BYPASS END CODE
	POP	%17,%11		;RESTORE WORKING REGISTER
	SOJG	%11,GETDS1	;TEST FOR COMPLETION
	POPJ	%17,		;  YES, EXIT


DSEND:				;DUMMY SYMBOL END
	MOVE	%12,CALPNT	;GET POINTER TO CALL BLOCK
	MOVE	%12,4(%12)	;RESTORE PREVIOUS READ POINTER
	POPJ	%17,		;EXIT
INCMAC:				;INCREMENT MACRO STORAGE
	AOS	0(%01)
	POPJ	%17,

DECMAC:				;DECREMENT MACRO STORAGE
	SOSL	0(%01)		;TEST FOR END
	POPJ	%17,		;  NO, EXIT

REMMAC:				;REMOVE MACRO STORAGE
	PUSH	%17,%01		;SAVE POINTER
	HRLS	%01		;SAVE CURRENT POINTER
	HRR	%01,WPB-1(%01)	;GET NEXT LINK
	TRNE	%01,-1		;TEST FOR END (NULL)
	JRST	.-3		;  NO
	HLRZS	%01		;YES, GET RETURN POINTER
	HRL	%01,NEXT	;GET CURRENT START OF CHAIN
	HLRM	%01,WPB-1(%01)	;STORE AT TOP
	POP	%17,%01		;RESTORE BORROWED REGISTER
	HRRZM	%01,NEXT	;SET NEW START
	POPJ	%17,		;EXIT
	SUBTTL	LISTING ROUTINES

PRNTA:				;PRINT BASIC LINE OCTAL
	HLRZ	%06,%04		;GET CLASS TYPE
	TLNE	%15,TTYFLG	;TELETYPE (DOUBLE LINE)?
	JRST	PRNTA1		;  YES, BRANCH
	PUSHJ	%17,LOTAB	;LIST A TAB
	HLRZ	%03,PRNTAT(%06)	;TEST FOR LEFT HALF
	PUSHJ	%17,0(%03)	;PROCESS
	PUSHJ	%17,LOTAB	;OUTPUT TAB
	HRRZ	%03,PRNTAT(%06)	;GET RIGHT HALF
	PUSHJ	%17,0(%03)	;PROCESS
	PUSHJ	%17,LOTAB
	HLRZ	%03,PRNTBT(%06)	;GET NEXT ITEM
	SKIPE	%03		;SKIP IF NULL
	PUSHJ	%17,0(%03)
	PUSHJ	%17,LOTAB
	HRRZ	%03,PRNTBT(%06)
	SKIPE	%03		;SKIP IF NULL
	PUSHJ	%17,0(%03)	;PROCESS
	POPJ	%17,		;EXIT

PRNTA1:				;TELETYPE LINE 1
	SOSGE	ESPCNT		;LIST TWO SPACES (LESS ERROR FLAGS)
	PUSHJ	%17,LOSP
	SOSGE	ESPCNT
	PUSHJ	%17,LOSP
	HLRZ	%03,PRNTAT(%06)
	PUSHJ	%17,PRNTA2
	PUSHJ	%17,LOSP
	HRRZ	%03,PRNTAT(%06)
PRNTA2:	CAIE	%03,CPOPJ
	JRST	0(%03)
	MOVEI	%03,6
	PUSHJ	%17,LOSP	;OUTPUT 6 SPACES
	SOJG	%03,.-1
	POPJ	%17,


PRNTAT:
	PHASE	0
	XWD	CPOPJ,	CPOPJ
CL1:	XWD	CPOPJ,	LOBAS	; ASSIGNMENT
CL2:	XWD	CPOPJ,	LOBAS	; .=
CL3:	XWD	LOLOC,	LOBAS	; XXXXXX
CL4:	XWD	LOLOC,	LOLOB	;    XXX
CL5:	XWD	CPOPJ,	LOHOW	; .END
CL6:	XWD	LOLOC,	LOBAS	; XXXXXX XXXXXX
CL7:	XWD	LOLOC,	LOBAS	; XXXXXX XXXXXX XXXXXX
	DEPHASE
PRNTB:				;PRINT EXTENSION LINE OCTAL
	HLRZ	%06,%04		;GET CLASS
	TLNE	%15,TTYFLG	;IF NON-TELETYPE
	SKIPN	PRNTBT(%06)	;  OR NON-MULTIPLE WORD
	POPJ	%17,		;  EXIT
	MOVEI	%03,5		;SET FOR 5 SPACES
	PUSHJ	%17,LOSP	;LIST THEM
	SOJG	%03,.-1
	HLRZ	%03,PRNTBT(%06)	;GET OP
	PUSHJ	%17,0(%03)	;LIST FIRST WORD
	HRRZ	%03,PRNTBT(%06)	;GET RIGHT HALF
	JUMPE	%03,PRNTB1	;BRANCH IF NULL
	PUSHJ	%17,LOSP	;LIST ANOTHER SPACE
	PUSHJ	%17,0(%03)	;PROCESS CODE
PRNTB1:	MOVEI	%02,0
	JRST	0(%01)		;LIST CR AND EXIT

PRNTBT:
	PHASE	0
	0
CL1:	0			; ASSIGNMENT
CL2:	0			; .=
CL3:	0			; XXXXXX
CL4:	0			;    XXX
CL5:	0			; .END
CL6:	XWD	LOHOW,	0	; XXXXXX XXXXXX
CL7:	XWD	LOHOW,	LOLOW	; XXXXXX XXXXXX XXXXXX
	DEPHASE
LOTAB:	MOVEI	%02,TAB
	JRST	0(%01)

LOSP:	MOVEI	%02,SPACE
	JRST	0(%01)

LOLOC:	LDB	%10,[POINT 16,%05,35]
	JRST	PRNTWD			;PRINT LOCATION

LOBAS:	LDB	%10,[POINT 16,%04,35]
	JRST	PRNTWD			;PRINT BASIC

LOHOW:	LDB	%10,[POINT 16,CEXT1,35]
	JRST	PRNTWD			;PRINT HIGH ORDER WORD

LOHOB:	LDB	%10,[POINT  8,CEXT1,35]
	JRST	PRNTBY			;PRINT HIGH ORDER BYTE

LOLOW:	LDB	%10,[POINT 16,CEXT2,35]
	JRST	PRNTWD			;PRINT LOW ORDER WORD

LOLOB:	LDB	%10,[POINT  8,%04,35]
	JRST	PRNTBY			;PRINT LOW ORDER BYTE


PRNTBY:				;PRINT BYTE
	MOVEI	%02,SPACE
	PUSHJ	%17,0(%01)	;LIST THREE SPACES
	PUSHJ	%17,0(%01)
	PUSHJ	%17,0(%01)
	SKIPA	%03,[POINT 3,%10,26]
PRNTWD:	MOVE	%03,[POINT 3,%10,17]
	ILDB	%02,%03
	ADDI	%02,"0"		;CONVERT TO ASCII
	PUSHJ	%17,0(%01)	;LIST
	TLNE	%03,770000
	JRST	PRNTWD+1
	POPJ	%17,
	SUBTTL	OCTAL OUTPUT ROUTINES

DUMP:				;DUMP A WORD OF CODE
	TLNE	%15,ENDFLG	;"END" STATEMENT SEEN?
	JRST	DUMP2		;  YES, BRANCH
	HLRZ	%06,%04		;NO, GET OP TYPE
	XCT	DMPTBL(%06)	;EXECUTE THE TABLE
DUMP1:	HLLZS	%06		;NORMAL, CODES FOUND IN %06, LEFT-JUSTIFIED
	JUMPE	%06,CPOPJ	;EXIT ON NULL
	ROT	%06,3		;BRING NEXT BYTE INTO RIGHT HALF
	LDB	%02,DUMPT(%06)	;GET THE PROPER BYTE
	PUSHJ	%17,BYTOUT	;OUTPUT IT
	JRST	DUMP1		;TRY FOR MORE

DUMP2:	TLNE	%15,P1F		;"END", PASS 1?
	POPJ	%17,		;  YES, EXIT
	PUSHJ	%17,BLKDMP	;NO, DUMP CURRENT BUFFER
	MOVEI	%02,01
	MOVEM	%02,CHKSUM	;INIT CHKSUM
	PUSHJ	%17,BINOUT	;OUTPUT BLOCK FLAG
	SETZ	%02,		;PUNCH A ZERO
	PUSHJ	%17,BINOUT
	MOVSI	%06,-4		;SET TO DUMP CODE
	LDB	%02,DUMPT+1(%06)	;GET BYTE
	ADDM	%02,CHKSUM	;UPDATE CHKSUM
	PUSHJ	%17,BINOUT	;OUTPUT IT
	AOBJN	%06,.-3		;TEST FOR END
	MOVN	%02,CHKSUM	;GET -CHKSUM
	PUSHJ	%17,BINOUT	; PUNCH IT.
	ZBINK			;KEEP THE OPERATOR HAPPY
	POPJ	%17,		; YES, EXIT


DUMPT:
	0			;NOT USED
	POINT	8,%04,35	
	POINT	8,%04,27	
	POINT	8,CEXT1,35	
	POINT	8,CEXT1,27	
	POINT	8,CEXT2,35
	POINT	8,CEXT2,27


DMPTBL:				;DUMP TABLE
	PHASE	0
	POPJ	%17,		;EXIT IF CLASS 0
CL1:	POPJ	%17,
CL2:	POPJ	%17,
CL3:	MOVSI	%06,(BYTE (3) 1, 2            )
CL4:	MOVSI	%06,(BYTE (3) 1               )
CL5:	POPJ	%17,
CL6:	MOVSI	%06,(BYTE (3) 1, 2, 3, 4      )
CL7:	MOVSI	%06,(BYTE (3) 1, 2, 3, 4, 5, 6)
	DEPHASE
BYTOUT:				;OUTPUT A BYTE OF CODE
	TLNE	%15,P1F		;PASS 1
	AOJA	%05,CPOPJ	;  YES, JUST INCREMENT AND EXIT
	PUSH	%17,%01		;GET A WORKING REGISTER
	MOVE	%01,BYTCNT	;GET THE BYTE COUNT
	CAIGE	%01,DATLEN	;IS THE BUFFER FULL?
	CAME	%05,CURADR	;  OR WAS THERE A PROGRAM BREAK?
	PUSHJ	%17,BLKDMP	;  YES, DUMP IT
	AOS	%01,BYTCNT	;INCREMENT AND FETCH THE BYTE COUNT
	MOVEM	%02,DATBLK-1(%01)	;STORE CURRENT BYTE IN BUFFER
	POP	%17,%01		;RESTORE REGISTER
	AOS	CURADR		;UPDATE CURRENT ADDRESS
	AOJA	%05,CPOPJ	;INCREMENT CLC AND EXIT
BLKDMP:				;DUMP THE CURRENT BLOCK
	SKIPN	BYTCNT		;IS IT EMPTY?
	JRST	BLKINI		;  YES, INITIALIZE FOR GOOD MEASURE
	PUSH	%17,%01		;GET A COUPLE OF SCRATCH REGISTERS
	PUSH	%17,%02
	MOVEI	%02,01		;BLOCK TYPE ONE
	MOVEM	%02,CHKSUM
	PUSHJ	%17,BINOUT
	SETZ	%02,		;OUTPUT A ZERO
	PUSHJ	%17,BINOUT
	MOVEI	%01,6		;FUDGE BYTE COUNT
	ADDM	%01,BYTCNT
	MOVSI	%01,-4		;SET COUNT
	LDB	%02,BLKDMT(%01)	;GET PROPER BYTE
	ADDM	%02,CHKSUM	;UPDATE CHECKSUM
	PUSHJ	%17,BINOUT	;DUMP IT.
	AOBJN	%01,.-3		;COUNT.
	MOVNI	%02,6		;UNFUDGE
	ADD	%02,BYTCNT	;  BYTE CT.
	MOVNS	%02		;NEGATE BYTE CT
	HRLZ	%01,%02		;PUT INTO %01,LH.
	MOVE	%02,DATBLK(%01)	;GET AN ITEM FROM THE DATA BLOCK
	ADDM	%02,CHKSUM	;UPDATE CHECKSUM.
	PUSHJ	%17,BINOUT	;DUMP IT
	AOBJN	%01,.-3		;RECYCLE IF NOT DONE
	MOVN	%02,CHKSUM	;GET NEG OF CHECKSUM.
	PUSHJ	%17,BINOUT	;DUMP IT
	SETZ	%02,		;FINISHED WITH BLOCK
	MOVEI	%01,^D6
	PUSHJ	%17,BINOUT	;DUMP SOME BLANK TAPE
	SOJG	%01,.-1
	POP	%17,%02		;RESTORE REGISTERS
	POP	%17,%01
				;FALL THROUGH TO BLKINI

BLKINI:				;CODE BLOCK INITIALIZATION
	MOVEM	%05,LODADR	;SET STARTING ADDRESS
	MOVEM	%05,CURADR	;SAVE CURRENT ADDRESS
	SETZM	BYTCNT		;CLEAR BYTE COUNT
	SETZM	CHKSUM		;  AND CHECK-SUM
	POPJ	%17,		;EXIT


BLKDMT:				;BLOCK DUMP TABLE
	POINT	8,BYTCNT,35
	POINT	8,BYTCNT,27
	POINT	8,LODADR,35
	POINT	8,LODADR,27
	SUBTTL	MEMORY MANAGEMENT

PDPSET:				;INIT PDP AND DYNAMIC MEMORY
	POP	%17,%03		;SAVE RETURN ADDRESS
	MOVEI	%00,PDPOVF
	HRRM	%00,JOBAPR	;SET TRAP LOCATION
	MOVEI	%00,1B19	;SET FOR PUSH-DOWN OVERFLOW
	APRENB	%00,		;INFORM THE MONITOR

	HRRZ	%00,JOBFF
	MOVEM	%00,MACTOP	;ESTABLISH START OF GARBAGE PIT
	HRRZ	%17,JOBREL	;GET TOP OF CORE
	SKIPE	JOBDDT		;DDT LOADED?
	HRRZ	%17,JOBSYM	;  YES, DON'T CLOBBER ITS SYMBOL TABLE
	SUBI	%17,PDPLEN+10	;COMPUTE BASE OF PDP PLUS SLOP AREA
	HRLI	%17,-PDPLEN	;SET INITIAL COUNT
	HRRZM	%17,SYMTOP
	MOVEI	%02,-2(%17)	;GET POINTER TO BOTTOM OF TABLE
	HRRZM	%02,SYMBOT	;STORE IT
	MOVSI	%00,(1B0)
	MOVEM	%00,@SYMBOT	;STORE LOWER BUMPER
	SETCAM	%00,@SYMTOP	;  AND UPPER BUMPER
	PUSH	%17,%03		;STACK RETURN ADDRESS
	JRST	SRCHI		;INITIALIZE THE SYMBOL TABLE AND RETURN
PDPOVF:				;PDP OVERFLOW TRAP LOCATION
	HRLI	%17,-PDPINC	;PREVENT FUTHER TRAPS FOR A WHILE
	PUSH	%17,%01		;GET A COUPLE OF WORKING CELLS
	PUSH	%17,%02
PDPOV1:	MOVE	%01,SYMBOT	;GET BASE OF SYMBOL TABLE
	SUBI	%01,PDPINC	;GET ITS DESTINATION ADDRESS
	CAMLE	%01,MACTOP	;HAVE WE ROOM?
	JRST	PDPOV2		;  YES
	PUSHJ	%17,GETCOR	;NO, GET MORE CORE
	JRST	PDPOV1		;RE-ESTABLISH REGISTERS

PDPOV2:	HRL	%01,SYMBOT	;SET UP BLT
	MOVE	%02,JOBREL	;MOVE ALL OF UPPER CORE
	SKIPE	JOBDDT
	MOVE	%02,JOBSYM	;  UNLESS DDT IS LOADED
	BLT	%01,-PDPINC(%02)
	SUBI	%17,PDPINC	;ADJUST FOR NEW BASE
	MOVNI	%01,PDPINC	;UPDATE POINTERS
	ADDM	%01,SYMBOT
	ADDM	%01,SYMPNT
	ADDM	%01,VALPNT
	ADDM	%01,SYMTOP
	POP	%17,%02		;RESTORE REGISTERS
	MOVEI	%01,1B19
	APRENB	%01,		;RE-ENABLE FOR NEW MONITORS
	POP	%17,%01
	JRST	2,@JOBTPC	;RETURN TO NORMAL
GETCOR:				;GET CORE
	PUSH	%17,%00		;GET A COULPLE OF WORKING REGISTERS
	PUSH	%17,%01
	HRRO	%01,JOBREL	;GET TOP OF CURRENT CORE
	MOVEI	%00,CORINC(%01)	;COMPUTE NEXT K
	CORE	%00,		;MAKE A REQUEST
	 JRST	ERRNC		;FORGET IT!
	MOVEI	%00,1(%01)
	SUB	%00,SYMBOT	;COMPUTE NUMBER OF ITEMS TO BE MOVED
	POP	%01,CORINC(%01)	;POP ITEM UP ONE K
	SOJG	%00,.-1		;TEST FOR COMPLETION
	ADDI	%17,CORINC	;ALL MOVED, UPDATE PDP
	MOVEI	%01,CORINC	;UPDATE POINTERS
	ADDM	%01,SYMBOT
	ADDM	%01,SYMPNT
	ADDM	%01,VALPNT
	ADDM	%01,SYMTOP
	ADDM	%01,JOBSYM
	POP	%17,%01		;RESTORE REGISTERS
	POP	%17,%00
	POPJ	%17,		;EXIT
	SUBTTL	SYMBOL TABLE HANDLERS

MSRCH:				;MACRO SEARCH
	PUSHJ	%17,SRCH	;SEARCH BASIC TABLE
	 POPJ	%17,		;  NOT FOUND, EXIT
	LDB	%02,TYPPNT
	CAIE	%02,MAOP	;MACRO?
	POPJ	%17,		;  NO
	PUSHJ	%17,CRFOUT	;YES, CREF IT
	JRST	CPOPJ1		;EXIT +1


SSRCH:				;NORMAL SYMBOL
	PUSHJ	%17,SRCH	;SEARCH BASIC TABLE
	 POPJ	%17,		;  NOT FOUND, EXIT
	LDB	%02,TYPPNT
	CAIE	%02,0		;NORMAL TYPE?
	POPJ	%17,		;  NO
	PUSHJ	%17,CRFOUT	;YES, CREF IT
	JRST	CPOPJ1		;EXIT +1


SRCH:				;SYMBOL SEARCH
	MOVE	%07,DELTA	;SET OFFSET FOR INDEX
	MOVE	%06,%07
	ASH	%06,-1		;SET INCREMENT
SRCH1:	CAMGE	%00,@SYMPNT	;ARE WE LOOKING ABOVE SYMBOL?
	JRST	SRCH2		;  YES, MOVE DOWN
	CAMG	%00,@SYMPNT	;NO, POSSIBLY AT IT?
	JRST	SRCH3		;  YES
	TDOA	%07,%06		;  NO, INCREMENT INDEX
SRCH2:	SUB	%07,%06		;DECREMENT INDEX
	ASH	%06,-1		;DECREMENT DELTA
	CAMG	%07,SYMLEN	;ARE WE OUT OF BOUNDS?
	JUMPN	%06,SRCH1	;  NO, BRANCH IF NOT THROUGH
	JUMPN	%06,SRCH2	;  YES, MOVE DOWN IF NOT THROUGH
	SOJA	%07,CPOPJ	;NOT FOUND, SET INDEX AND EXIT NORMAL

SRCH3:	MOVE	%01,@VALPNT	;FOUND, FETCH VALUE
	TLNE	%01,MDLSYM	;MULTIPLE DEFINITION LABEL?
	TRO	%15,ERRD	;  YES, FLAG ERROR
	JRST	CPOPJ1		;EXIT +1
CRFOUT:				;OUTPUT WORD TO CREF
	TLNN	%15,P1F		;IF PASS 1
	TLNE	%16,CSWBIT!LSTBIT	;  OR NOT REQUESTED,
	POPJ	%17,		;  EXIT
	LDB	%02,TYPPNT
	XCT	CRFTBL(%02)	;GET PROPER FLAG
	PUSHJ	%17,LSTDMP	;LIST CREF TYPE
	MOVSI	%03,(POINT 6,%00,)
CRFOU1:	ILDB	%02,%03		;GET A SIXBIT CHARACTER
	JUMPE	%02,CRFOU2	;BRANCH IF END
	ADDI	%02,40		;CONVERT TO SIXBIT
	PUSHJ	%17,LSTDMP	;LIST IT
	TLNE	%03,770000	;END OF WORD?
	JRST	CRFOU1		;  NO, GET ANOTHER
CRFOU2:	MOVEI	%02,CRFSYM
	JRST	LSTDMP		;FLAG END AND EXIT


CRFTBL:
	PHASE	0
	MOVEI	%02,CRFSYM
PSOP:	MOVEI	%02,CRFOPC
BGOP:	MOVEI	%02,CRFOPC	;BASIC GROUP
OPOP:	MOVEI	%02,CRFOPC	;OPERATE GROUP
SCOP:	MOVEI	%02,CRFOPC
UNOP:	MOVEI	%02,CRFOPC	;UNARY OP
SHOP:	MOVEI	%02,CRFOPC	;SHIFT OP
BCOP:	MOVEI	%02,CRFOPC	;BRANCH ON CONDITION OP
TROP:	MOVEI	%02,CRFOPC	;TRAP OP
RTOP:	MOVEI	%02,CRFOPC
MAOP:	MOVEI	%02,CRFMAC
	DEPHASE
INSRT:				;INSERT ITEM IN SYMBOL TABLE
	CAMN	%00,@SYMPNT	;IS IT HERE ALREADY?
	JRST	INSRT1		;  YES
	MOVNI	%06,2		;NO, PREPARE TI INSERT
	ADDB	%06,SYMBOT	;DECREMENT POINTER TO BOTTOM OF TABLE
	CAMG	%06,MACTOP	;ARE WE INTRUDING ON THE MACROS?
	PUSHJ	%17,GETCOR	;  YES, GET MORE CORE
	MOVE	%06,SYMBOT
	HRLI	%06,2(%06)	;SET UP BLT
	BLT	%06,@SYMPNT	;MOVE LOWER SYMBOLS DOWN
	PUSHJ	%17,SRCHI	;RE-INITIALIZE THE POINTERS
	ADDI	%07,2		;COMPENSATE FOR SHIFT
	MOVEM	%00,@SYMPNT	;STORE SYMBOL
INSRT1:	MOVEM	%01,@VALPNT	;STORE VALUE
	JRST	CRFOUT		;CREF AND EXIT
	REPEAT	0,
<

REMOVE:				;REMOVE A SYMBOL FROM THE TABLE
	HRROI	%06,@SYMPNT	;GET POINTER TO THE ENTRY
	SUBI	%06,2		;SET TO NEXT ENTRY DOWN
	POP	%06,2(%06)	;MOVE A RUNG UP
	SOJG	%07,.-1		;TEST FOR END
	MOVEI	%06,2
	ADDM	%06,SYMBOT	;UPDATE BASE
	JRST	SRCHI		;INITIALIZE FOR SEARCH AND EXIT

>
SRCHI:				;INITIALIZE FOR SEARCH
	PUSH	%17,%01		;STACK WORKING REGISTERS
	PUSH	%17,%02
	MOVE	%01,SYMTOP	;GET THE TOP LOCATION
	SUB	%01,SYMBOT	;COMPUTE THE DIFFERENCE
	MOVEM	%01,SYMLEN	;SAVE IT
	MOVEI	%02,1		;SET LOW BIT
	LSH	%02,1		;SHIFT OVER ONE
	TDZ	%01,%02		;CLEAR CORRESPONDING ONE
	JUMPN	%01,.-2		;TEST FOR ALL BITS CLEARED
	MOVEM	%02,DELTA	;END, SAVE LEADING BIT FOR SEARCH OFFSET
	MOVE	%01,SYMBOT	;GET THE BASE
	HRRM	%01,SYMPNT	;SET SYMBOL POINTER
	SUBI	%01,1
	HRRM	%01,VALPNT	;SET VALUE POINTER
	POP	%17,%02		;RESTORE REGISTERS
	POP	%17,%01
	POPJ	%17,		;EXIT
SYMTB:				;LIST THE SYMBOL TABLE
	SETZ	%07,		;INITIALIZE POINTER

SYMTB1:	TRO	%16,HDRBIT	;FLAG NEW PAGE
	MOVEI	%03,PAGSIZ-2	;SET LINE COUNT

SYMTB2:	MOVEI	%06,2(%07)
	CAML	%06,SYMLEN	;END REACHED?
	POPJ	%17,		;  YES, EXIT
	MOVE	%06,%07		;SAVE CURRENT POINTER
	MOVEI	%10,SPL		;SET "SYMBOLS PER LINE"
	TLNE	%16,TTYBIT	;TTY?
	MOVEI	%10,SPLTTY	;  YES, REDUCE
	SETZ	%05,

SYMTB3:	PUSHJ	%17,GETSTE	;GET THE NEXT SYMBOL TABLE ENTRY
	 JRST	SYMTB4		;FINIS
	SOJG	%05,SYMTB3	;TEST FOR ITEMS TO SKIP
	PUSHJ	%17,LSTSTE	;LIST SYMBOL TABLE ENTRY
	MOVEI	%05,PAGSIZ-2
	SOJG	%10,SYMTB3	;TEST FOR MORE ITEMS ON LINE

SYMTB4:	PUSHJ	%17,LSTCR	;END OF LINE, LIST CR/LF
	SOJLE	%03,SYMTB1	;BRANCH IF END OF PAGE
	MOVE	%07,%06		;RETRIEVE POINTER
	PUSHJ	%17,GETSTE	;MOVE ONE PAST
	 POPJ	%17,		;END, EXIT
	JRST	SYMTB2		;OK, PROCESS ANOTHER
GETSTE:				;GET SYMBOL TABLE ENTRY
	ADDI	%07,2		;MOVE UP TWO
	CAML	%07,SYMLEN	;TEST FOR END
	POPJ	%17,		;  YES, EXIT
	LDB	%02,[POINT 9,@VALPNT,17]	;GET SYMBOL TYPE
	JUMPN	%02,GETSTE	;BYPASS IF OP
	JRST	CPOPJ1		;OK, PERFORM SKIP-RETURN

LSTSTE:				;LIST SYMBOL TABLE ENTRY
	PUSHJ	%17,LSTTAB	;LEAD OFF WITH TAB
	MOVE	%01,[POINT 6,@SYMPNT,]	;SIXBIT POINTER TO SYMBOL
LSTST1:	ILDB	%02,%01		;GET A CHARACTER
	JUMPE	%02,LSTST2	;DON'T LIST TRAILING BLANKS
	ADDI	%02,40		;CONVERT TO ASCII
	PUSHJ	%17,LSTOUT	;LIST CHARACTER
	TLNE	%01,770000	;ANY MORE CHARACTERS?
	JRST	LSTST1		;  YES
LSTST2:	PUSHJ	%17,LSTTAB
	MOVE	%01,[POINT 3,@VALPNT,17]	;SET HEX POINTER
LSTST3:	ILDB	%02,%01		;GET OCTAL CHARACTER
	ADDI	%02,"0"		;CONVERT TO ASCII
	PUSHJ	%17,LSTOUT	;LIST IT
	TLNE	%01,770000	;ANY MORE BYTES?
	JRST	LSTST3		;  YES
	MOVE	%01,@VALPNT	;PICK UP VALUE POINTER
	MOVEI	%02,"R"
	TLNE	%01,REGSYM	;REGISTER SYMBOL?
	PUSHJ	%17,LSTOUT	;YES, LIST IT
	MOVEI	%02,"U"
	TLNE	%01,UNDSYM	;UNDEFINED?
	PUSHJ	%17,LSTOUT	;YES, LIST IT
	JRST	LSTTAB		;OUTPUT A TAB AND EXIT
OSRCH:				;OP TABLE SEARCH
	MOVEI	%02,1B^L<OPTTOP-OPTBOT>	;SET UP OFFSET AND DELTA
	MOVEI	%06,1B^L<OPTTOP-OPTBOT>/2
OSRCH1:	CAMN	%00,OPTBOT-2(%02)	;ARE WE LOOKING AT IT?
	JRST	OSRCH3		;  YES
	CAML	%00,OPTBOT-2(%02)	;TEST FOR DIRECTION OF NEXT MOVE
	TDOA	%02,%06		;ADD
OSRCH2:	SUB	%02,%06		;SUBTRACT
	ASH	%06,-1		;HALVE DELTA
	JUMPE	%06,CPOPJ	;EXIT IF END
	CAILE	%02,OPTTOP-OPTBOT	;YES, ARE WE OUTOF BOUNDS?
	JRST	OSRCH2		;YES, MOVE DOWN
	JRST	OSRCH1		;NO, TRY AGAIN

OSRCH3:	MOVE	%01,OPTBOT-1(%02)	;FOUND, PLACE VALUE IN %02
	PUSHJ	%17,CRFOUT	;CREF IT
	JRST	CPOPJ1		;EXIT +1
	SUBTTL	PERMANENT SYMBOL TABLE

OPTBOT:				;OP TABLE BOTTOM

	SIXBIT	/ADC/
	XWD	UNOP,	005500

	SIXBIT	/ADCB/
	XWD	UNOP,	105500

	SIXBIT	/ADD/
	XWD	BGOP,	060000

	SIXBIT	/ASL/
	XWD	SHOP,	006300

	SIXBIT	/ASLB/
	XWD	SHOP,	106300

	SIXBIT	/ASR/
	XWD	SHOP,	006200

	SIXBIT	/ASRB/
	XWD	SHOP,	106200


	SIXBIT	/BCC/
	XWD	BCOP,	103000

	SIXBIT	/BCS/
	XWD	BCOP,	103400
	SIXBIT	/BEQ/
	XWD	BCOP,	001400


	SIXBIT	/BGE/
	XWD	BCOP,	002000


	SIXBIT	/BGT/
	XWD	BCOP,	003000

	SIXBIT	/BHI/
	XWD	BCOP,	101000

	SIXBIT	/BHIS/
	XWD	BCOP,	103000
	SIXBIT	/BIC/
	XWD	BGOP,	040000

	SIXBIT	/BICB/
	XWD	BGOP,	140000

	SIXBIT	/BIS/
	XWD	BGOP,	050000

	SIXBIT	/BISB/
	XWD	BGOP,	150000

	SIXBIT	/BIT/
	XWD	BGOP,	030000

	SIXBIT	/BITB/
	XWD	BGOP,	130000

	SIXBIT	/BLE/
	XWD	BCOP,	003400

	SIXBIT	/BLO/
	XWD	BCOP,	103400
	SIXBIT	/BLOS/
	XWD	BCOP,	101400

	SIXBIT	/BLT/
	XWD	BCOP,	002400

	SIXBIT	/BMI/
	XWD	BCOP,	100400
	SIXBIT	/BNE/
	XWD	BCOP,	001000

	SIXBIT	/BPL/
	XWD	BCOP,	100000
	SIXBIT	/BR/
	XWD	BCOP,	000400

	SIXBIT	/BVC/
	XWD	BCOP,	102000

	SIXBIT	/BVS/
	XWD	BCOP,	102400

	SIXBIT	/CCC/
	XWD	OPOP,	000257

	SIXBIT	/CLC/
	XWD	OPOP,	000241

	SIXBIT	/CLN/
	XWD	OPOP,	000250

	SIXBIT	/CLR/
	XWD	UNOP,	005000

	SIXBIT	/CLRB/
	XWD	UNOP,	105000

	SIXBIT	/CLV/
	XWD	OPOP,	000242

	SIXBIT	/CLZ/
	XWD	OPOP,	000244

	SIXBIT	/CMP/
	XWD	BGOP,	020000

	SIXBIT	/CMPB/
	XWD	BGOP,	120000

	SIXBIT	/CNZ/
	XWD	OPOP,	000254

	SIXBIT	/COM/
	XWD	UNOP,	005100

	SIXBIT	/COMB/
	XWD	UNOP,	105100


	SIXBIT	/DEC/
	XWD	UNOP,	005300

	SIXBIT	/DECB/
	XWD	UNOP,	105300

	SIXBIT	/EMT/
	XWD	TROP,	104000

	SIXBIT	/HALT/
	XWD	OPOP,	000000

	SIXBIT	/INC/
	XWD	UNOP,	005200

	SIXBIT	/INCB/
	XWD	UNOP,	105200

	SIXBIT	/IOT/
	XWD	OPOP,	000004

	SIXBIT	/JMP/
	XWD	UNOP,	000100

	SIXBIT	/JSR/
	XWD	SCOP,	004000

	SIXBIT	/MOV/
	XWD	BGOP,	010000

	SIXBIT	/MOVB/
	XWD	BGOP,	110000

	SIXBIT	/NEG/
	XWD	UNOP,	005400

	SIXBIT	/NEGB/
	XWD	UNOP,	105400

	SIXBIT	/RESET/
	XWD	OPOP,	000005

	SIXBIT	/ROL/
	XWD	SHOP,	006100

	SIXBIT	/ROLB/
	XWD	SHOP,	106100

	SIXBIT	/ROR/
	XWD	SHOP,	006000

	SIXBIT	/RORB/
	XWD	SHOP,	106000

	SIXBIT	/RTI/
	XWD	OPOP,	000002

	SIXBIT	/RTS/
	XWD	RTOP,	000200

	SIXBIT	/SBC/
	XWD	UNOP,	005600

	SIXBIT	/SBCB/
	XWD	UNOP,	105600

	SIXBIT	/SCC/
	XWD	OPOP,	000277

	SIXBIT	/SEC/
	XWD	OPOP,	000261

	SIXBIT	/SEN/
	XWD	OPOP,	000270

	SIXBIT	/SEV/
	XWD	OPOP,	000262

	SIXBIT	/SEZ/
	XWD	OPOP,	000264

	SIXBIT	/SUB/
	XWD	BGOP,	160000

	SIXBIT	/SWAB/
	XWD	UNOP,	000300

	SIXBIT	/TRAP/
	XWD	TROP,	104400

	SIXBIT	/TST/
	XWD	UNOP,	005700

	SIXBIT	/TSTB/
	XWD	UNOP,	105700

	SIXBIT	/WAIT/
	XWD	OPOP,	000001

	SIXBIT	/.ASCII/
	XWD	PSOP,	ASC

	SIXBIT	/.BYTE/
	XWD	PSOP,	BYT

	SIXBIT	/.END/
	XWD	PSOP,	END

.ENDMX:	SIXBIT	/.ENDM/
	XWD	PSOP,	OPCERR

.ENDRX:	SIXBIT	/.ENDR/
	XWD	PSOP,	OPCERR

	SIXBIT	/.EOT/
	XWD	PSOP,	ENDL

	SIXBIT	/.EVEN/
	XWD	PSOP,	EVEN

.MACRX:	SIXBIT	/.MACR/
	XWD	PSOP,	DEFIN0

.REPTX:	SIXBIT	/.REPT/
	XWD	PSOP,	REPEA0

	SIXBIT	/.WORD/
	XWD	PSOP,	WORD

OPTTOP:	-1B36			;OP TABLE TOP
	SUBTTL	CHARACTER DISPATCH ROUTINES

C1PNTR:	POINT	4,CHJTBL(%14), 3
C2PNTR:	POINT	4,CHJTBL(%14), 7
C3PNTR:	POINT	4,CHJTBL(%14),11
C4PNTR:	POINT	4,CHJTBL(%14),15
C5PNTR:	POINT	4,CHJTBL(%14),19
C6PNTR:	POINT	4,CHJTBL(%14),23
C7PNTR:	POINT	4,CHJTBL(%14),27
C8PNTR:	POINT	4,CHJTBL(%14),31
C9PNTR:	POINT	4,CHJTBL(%14),35

ANPNTR=	C8PNTR
CHJTBL:				;CHARACTER JUMP TABLE
	PHASE	0


	BYTE	(4)	MACR,    ,    ,    ,    ,    ,QJCR,.TRM,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;

	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
TAB:	BYTE	(4)	MASP,    ,    ,    ,    ,    ,QJSP,.TAB,    	; TAB
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJNU,    ,    	; LF
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJNU,    ,    	;
FF:	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJNU,    ,    	; FF
CRR:	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJCR,    ,    	; CR
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;

	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;

	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJNU,    ,    	; EOF
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
SPACE:	BYTE	(4)	MASP,    ,    ,    ,    ,    ,QJSP,.TAB,    	; SPACE
	BYTE	(4)	    ,    ,    ,EXOR,    ,    ,QJPC,.TRM,    	; !
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.TRM,    	; "
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.TRM,    	; #
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; $
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.TRM,    	; %
	BYTE	(4)	    ,    ,    ,EXAN,    ,    ,QJPC,.TRM,    	; &
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.TRM,    	; '

	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.TRM,    	; (
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.TRM,    	; )
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,    ,    	; *
	BYTE	(4)	    ,    ,    ,EXPL,    ,    ,QJPC,.TRM,    	; +
	BYTE	(4)	MACM,    ,    ,    ,    ,    ,QJPC,.TRM,    	; ,
	BYTE	(4)	    ,    ,    ,EXMI,    ,    ,QJPC,.TRM,    	; -
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.DOT,    	; .
	BYTE	(4)    	    ,    ,    ,    ,    ,    ,QJPC,    ,    	; /

	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.NUM,    	; 0
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.NUM,    	; 1
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.NUM,    	; 2
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.NUM,    	; 3
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.NUM,    	; 4
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.NUM,    	; 5
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.NUM,    	; 6
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.NUM,    	; 7

	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.NUM,    	; 8
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.NUM,    	; 9
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.TRM,    	; :
	BYTE	(4)	MASC,    ,    ,    ,    ,    ,QJPC,.TRM,    	; ;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,    ,    	; <
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.TRM,    	; =
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,    ,    	; >
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,    ,    	; ?
INDBIT:	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.TRM,    	; @
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; A
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; B
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; C
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; D
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; E
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; F
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; G

	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; H
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; I
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; J
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; K
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; L
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; M
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; N
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; O

	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; P
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; Q
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; R
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; S
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; T
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; U
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; V
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; W

	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; X
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; Y
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,.ALP,    	; Z
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,    ,    	; [
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,    ,    	; \
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,    ,    	; ]
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,    ,    	; ^
	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJPC,    ,    	; _
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;

	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;

	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;

	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
	BYTE	(4)	    ,    ,    ,    ,    ,    ,    ,    ,    	;
RUBOUT:	BYTE	(4)	    ,    ,    ,    ,    ,    ,QJNU,    ,    	;

	DEPHASE
	LIT		;REMOVE WHEN SEGMENTING
	SUBTTL	IMPURE AREA

PATCH:	BLOCK	20

SYMPNT:	Z	-1(%07)		;POINTER TO SYMBOL TABLE MNEMONIC
VALPNT:	Z	-1(%07)		;POINTER TO SYMBOL TABLE VALUE


BZCOR:				;BEGINNING OF CORE TO BE INITIALIZED TO ZERO

SYMBOT:	BLOCK	1		;BASE OF SYMBOL TABLE
SYMTOP:	BLOCK	1		;TOP OF SYMBOL TABLE
SYMLEN:	BLOCK	1		;LENGTH OF SYMBOL TABLE
DELTA:	BLOCK	1		;BINARY SEARCH OFFSET
MACTOP:	BLOCK	1		;TOP OF MACRO STORAGE

MWPNTR:	BLOCK	1		;MACRO WRITE POINTER
NEXT:	BLOCK	1		;GARBAGE COLLECTION CHAIN
REPEXP:	BLOCK	1		;REPEAT EXPRESSION
REPPNT:	BLOCK	1		;REPEAT POINTER

SYMBEG:	BLOCK	1		;POINTER TO START OF SYMBOL FOR RESCAN PURPOSES

RUNTIM:	BLOCK	1		;RUN TIME

LINBUF:	BLOCK	CPL/5+1		;SOURCE LINE BUFFER


LODADR:	BLOCK	1		;LOAD ADDRESS
CURADR:	BLOCK	1		;CURRENT DATA BLOCK ADDRESS
BYTCNT:	BLOCK	1		;BYTE COUNT
CHKSUM:	BLOCK	1		;CHECK SUM
DATBLK:	BLOCK	DATLEN		;DATA BLOCK
SEQNUM:	BLOCK	1		;SEQUENCE NUMBER

AC00:	BLOCK	1		;AC EXCHANGE BLOCK
AC01:	BLOCK	1
AC02:	BLOCK	1
AC03:	BLOCK	1
AC04:	BLOCK	1
AC05:	BLOCK	1
AC06:	BLOCK	1
AC07:	BLOCK	1
AC10:	BLOCK	1
AC11:	BLOCK	1
AC12:	BLOCK	1
AC13:	BLOCK	1
AC14:	BLOCK	1

DATE:	BLOCK	1		;DATE FOR HEADER
MSTIME:	BLOCK	1		;CURRENT TIME IN MILLISECONDS
PAGNUM:	BLOCK	1		;PAGE NUMBER
PAGEXT:	BLOCK	1		;PAGE EXTENSION
ERRCNT:	BLOCK	1		;ERROR COUNT
EXTSAV:	BLOCK	1		;FILNAM EXTENSION FOR HEADER (EXEC)


CALPNT:	BLOCK	1		;POINTER TO CURRENT MACRO CALL BLOCK
MACLVL:	BLOCK	1		;MACRO NESTING LEVEL
ARGLST:	BLOCK	^D65		;TEMP STORAGE FOR MACRO ARGUMENTS

CEXT:				;CODE EXTENSION BLOCK
CEXT1:	BLOCK	1		;   BYTES 3&4 OF CODE
CEXT2:	BLOCK	1		;   BYTES 5&6 OF CODE

OFFSET:	BLOCK	1		;0 OF 1, FOR CEXT1 OR CEXT2
ESPCNT:	BLOCK	1		;SPACE COUNT FOR LISTING
JOBFFI:	BLOCK	1		;JOBFF SAVE
TTISAV:	BLOCK	1		;TTI POINTER SAVE
XESAVE:	BLOCK	1		;FILE NAME STORAGE FOR TTY ERROR MESSAGES

XE:	BLOCK	1		;EXEC LOOKUP BLOCK
XE1:	BLOCK	1
XE2:	BLOCK	1
XE3:	BLOCK	1

				;BUFFER HEADER BLOCKS

TTIBUF:	BLOCK	1
TTIPNT:	BLOCK	1
TTICNT:	BLOCK	1

TTOBUF:	BLOCK	1
TTOPNT:	BLOCK	1
TTOCNT:	BLOCK	1

BINBUF:	BLOCK	1
BINPNT:	BLOCK	1
BINCNT:	BLOCK	1

LSTBUF:	BLOCK	1
LSTPNT:	BLOCK	1
LSTCNT:	BLOCK	1

SRCBUF:	BLOCK	1
SRCPNT:	BLOCK	1
SRCCNT:	BLOCK	1

LINCNT:	BLOCK	1		;EXEC LINE COUNTER

EZCOR:
	END	PALX11		;....PALX11