 NAM STRUBAL+ COMPILER
* COPYRIGHT 1978
*
DELCHR EQU $AC01
ESCRTN EQU $AC16
LPTSW EQU $AC22
FLXSIZ EQU $AC2B
WARMS EQU $AD03
FCRLF EQU $AD24
RSTRIO EQU $AD2A
FMSCLS EQU $B403
*
 LDX #FLXCAL
 STX ESCRTN
 STS STACK INIT STACK POINTER
 LDX TABLES+1
 LDX 0,X GET START OF TABLES
 STX MACTBL MACRO TABLE ADDRESS
*
 STX PSTNG1
 LDX #$1000 4K MACRO TABLE SPACE
 STX PSTNG2
 LDX #PSTNG1
 JSR ADD16
 LDX PSTNG1
 STX MACEND END OF MACRO TABLE
*
 LDX #$0100 256 BYTES MACRO STACK
 STX PSTNG2
 LDX #PSTNG1
 JSR ADD16
 LDX PSTNG1
 STX MACSTK START OF MACRO STACK
*
 INX
 STX SYMTAB SYMBOL TABLE ADDRESS
*
 STX PSTNG2
 LDX FLXSIZ  SPACE ?
 STX PSTNG1
 LDX #PSTNG1
 JSR SUB16
 LDAA PSTNG1
 LDAB PSTNG1+1
 LDX #9 9 BYTES PER SYMBOL
 STX PSTNG2
 LDX #PSTNG2
 JSR DIV16
 STAA NSYM NSYM=(32K-SYMTAB)/9
 STAB NSYM+1
*
 LDX #9
 STX PSTNG1
 LDX #PSTNG1
 JSR MPY16
 STAA PSTNG1
 STAB PSTNG1+1
 LDX SYMTAB
 STX PSTNG2
 LDX #PSTNG1
 JSR ADD16
 LDX PSTNG1
 STX SYMEND SYMEND=9*NSYM+SYMTAB
 JMP OPC1
*
* MACRO TABLE PARA'S
*
MACTBL RMB 2 MACRO TABLE START
MACEND RMB 2 TABLE END
MACSTK RMB 2 MACRO STACK START
*
* SYMBOL TABLE PARA'S
*
SYMTAB RMB 2 START OF TABLE
SYMEND RMB 2 END OF TABLE
NSYM RMB 2 NUMBER OF SYMBOLS
*
* KEYWORD AND MNEMONIC TABLE
*
MNTAB FCC '.ABS' ABSOLUTE VALUE FUNCTION
 FDB ABSPR
 FCB $3B
 FCC '.ACO' ARC-COSINE FUNC.
 FDB ACOSPR
 FCB $B0
 FCC '.AND' AND FUNC.
 FDB ANDPR
 FCB $3F
 FCC '.ASI' ARC-SINUS FUNC.
 FDB ASINPR
 FCB $B1
 FCC '.ATA' ARC-TANGENT FUNC.
 FDB ATANPR
 FCB $B2
 FCC '.COS' COSINE FUNC.
 FDB COSPR
 FCB $B3
 FCC '.EOF' END-FILE FUNC.
 FDB EOFPR
 FCB $39
 FCC '.EQ.' EQ COMPARISON
 FDB EQPR
 FCB $41
 FCC '.ERR' ERROR FUNC.
 FDB EOFPR
 FCB $39
 FCC '.EXP' EXPONENT FUNC.
 FDB EXPR
 FCB $2C
 FCC '.FIX' FIX FUNC.
 FDB FIXPR
 FCB $36
 FCC '.FLO' FLOAT FUNC.
 FDB FLOTPR
 FCB $B7
 FCC '.GE.' GE COMPARISON
 FDB GEPR
 FCB $42
 FCC '.GT.' GT COMPARISON
 FDB GTPR
 FCB $43
 FCC '.LE.' LE COMPARISON
 FDB LEPR
 FCB $44
 FCC '.LOG' LOG10 FUNC.
 FDB LOGPR
 FCB $B8
 FCC '.LT.' LT COMPARISON
 FDB LTPR
 FCB $45
 FCC '.MOD' MODULUS FUNC.
 FDB MODPR
 FCB $2E
 FCC '.NAT' NATURAL-LOG FUNC.
 FDB NATPR
 FCB $B9
 FCC '.NE.' NE COMPARISON
 FDB NEPR
 FCB $46
 FCC '.NOT' NOT FUNC.
 FDB NOTPR
 FCB $3A
 FCC '.OR.' OR FUNCTION
 FDB ORPR
 FCB $3E
 FCC '.PEE' PEEK FUNC.
 FDB PEEKPR
 FCB $38
 FCC '.RAN' RANDOM FUNC.
 FDB RANPR
 FCB $3C
 FCC '.SGN' S(I)GNUM FUNC.
 FDB SIGPR
 FCB $3D
 FCC '.SIN' SINE FUNC.
 FDB SINPR
 FCB $B4
 FCC '.TAN' TANGENT FUNC.
 FDB TANPR
 FCB $B5
 FCC '.TEN' BASE10 EXPONENT
 FDB TENPR
 FCB $AE
 FCC '.XOR' EXCLUSIVE OR
 FDB EXOPR
 FCB $40
 FCC '.XTO' X-TO-Y POWER
 FDB XTOYPR
 FCB $BC
 FCC 'ABA '
 FDB ADDR9
 FCB $1B
 FCC 'ADC '
 FDB ADDR1
 FCB $09
 FCC 'ADD '
 FDB ADDR1
 FCB $0B
 FCC 'AND '
 FDB ADDR1
 FCB $04
 FCC 'ASL '
 FDB ADDR3
 FCB $08
 FCC 'ASR '
 FDB ADDR3
 FCB $07
 FCC 'BCC '
 FDB ADDR8
 FCB $24
 FCC 'BCS '
 FDB ADDR8
 FCB $25
 FCC 'BEQ '
 FDB ADDR8
 FCB $27
 FCC 'BGE '
 FDB ADDR8
 FCB $2C
 FCC 'BGT '
 FDB ADDR8
 FCB $2E
 FCC 'BHI '
 FDB ADDR8
 FCB $22
 FCC 'BIT '
 FDB ADDR1
 FCB $05
 FCC 'BLE '
 FDB ADDR8
 FCB $2F
 FCC 'BLOC' BLOCK KEYWORD
 FDB BLOKPR
 FCB $F0
 FCC 'BLS '
 FDB ADDR8
 FCB $23
 FCC 'BLT '
 FDB ADDR8
 FCB $2D
 FCC 'BMI '
 FDB ADDR8
 FCB $2B
 FCC 'BNE '
 FDB ADDR8
 FCB $26
 FCC 'BPL '
 FDB ADDR8
 FCB $2A
 FCC 'BRA '
 FDB ADDR8
 FCB $20
 FCC 'BSR '
 FDB ADDR8
 FCB $8D
 FCC 'BVC '
 FDB ADDR8
 FCB $28
 FCC 'BVS '
 FDB ADDR8
 FCB $29
 FCC 'BYTE' BYTE KEYWORD
 FDB BYTEPR
 FCB $F0
 FCC 'CALL' CALL KEYWORD
 FDB CALLPR
 FCB $F0
 FCC 'CBA '
 FDB ADDR9
 FCB $11
 FCC 'CEND' C(OMMON) END KEY.
 FDB CENDPR
 FCB $F0
 FCC 'CLC '
 FDB ADDR9
 FCB $0C
 FCC 'CLI '
 FDB ADDR9
 FCB $0E
 FCC 'CLOS' CLOSE FILES
 FDB CLOSPR
 FCB $F0
 FCC 'CLR '
 FDB ADDR3
 FCB $0F
 FCC 'CLV '
 FDB ADDR9
 FCB $0A
 FCC 'CMN '
 FDB POCMN
 FCB $FF
 FCC 'CMP '
 FDB ADDR1
 FCB $01
 FCC 'COM '
 FDB ADDR3
 FCB $03
 FCC 'COMM'
 FDB POCMN
 FCB $FF
 FCC 'CONV' CONVERT KEYWORD
 FDB CONVPR
 FCB $F0
 FCC 'CPX '
 FDB ADDR5
 FCB $8C
 FCC 'CSEC'
 FDB CSECPR
 FCB $F0
 FCC 'DAA '
 FDB ADDR9
 FCB $19
 FCC 'DEC '
 FDB ADDR3
 FCB $0A
 FCC 'DEFI' DEFINE FLOATING KEYWORD
 FDB DEFPR
 FCB $F0
 FCC 'DELA'
 FDB DELAY
 FCB $F0
 FCC 'DEND' DATA SECTION KEYWORD
 FDB DENDPR
 FCB $F0
 FCC 'DES '
 FDB ADDR9
 FCB $34
 FCC 'DEX '
 FDB ADDR9
 FCB $09
 FCC 'DIGI'
 FDB PRNTPR
 FCB $F0
 FCC 'DIGS'
 FDB DIGSPR
 FCB $F0
 FCC 'DSEC' DATA SECTION KEYWORD
 FDB DSECPR
 FCB $F0
 FCC 'DSTR' DECLARE STRING
 FDB DSTPR
 FCB $F0
 FCC 'ELSE'
 FDB IFPR3
 FCB $F0
 FCC 'END '
 FDB POEND
 FCB $FF
 FCC 'ENT '
 FDB POENT
 FCB $FF
 FCC 'ENTR'
 FDB POENT
 FCB $FF
 FCC 'EOR '
 FDB ADDR1
 FCB $08
 FCC 'EQU '
 FDB POEQU
 FCB $FF
 FCC 'EQUA'
 FDB POEQU
 FCB $FF
 FCC 'EXT '
 FDB POEXT
 FCB $FF
 FCC 'EXTE'
 FDB POEXT
 FCB $FF
 FCC 'FCB '
 FDB POFCB
 FCB $FF
 FCC 'FCC '
 FDB POFCC
 FCB $FF
 FCC 'FDB '
 FDB POFDB
 FCB $FF
 FCC 'FFP '
 FDB POFFP
 FCB $FF
 FCC 'FOR '
 FDB FORPR
 FCB $F0
 FCC 'FUNC'
 FDB POFUNC
 FCB $F0
 FCC 'GETA'
 FDB GETAD
 FCB $F0
 FCC 'GOSU'
 FDB GOSBPR
 FCB $F0
 FCC 'GOTO'
 FDB GOTOPR
 FCB $F0
 FCC 'IF  '
 FDB IFPR
 FCB $F0
 FCC 'IFC '
 FDB POIFC
 FCB $FF
 FCC 'INC '
 FDB ADDR3
 FCB $0C
 FCC 'INPU'
 FDB INPPR
 FCB $F0
 FCC 'INS '
 FDB ADDR9
 FCB $31
 FCC 'INTE'
 FDB INTPR
 FCB $F0
 FCC 'INX '
 FDB ADDR9
 FCB $08
 FCC 'JMP '
 FDB ADDR7
 FCB $6E
 FCC 'JSR '
 FDB ADDR7
 FCB $AD
 FCC 'LDA '
 FDB ADDR1
 FCB $06
 FCC 'LDS '
 FDB ADDR5
 FCB $8E
 FCC 'LDX '
 FDB ADDR5
 FCB $CE
 FCC 'LENG'
 FDB LENGPR
 FCB $F0
 FCC 'LET '
 FDB LETPR
 FCB $F0
 FCC 'LSR '
 FDB ADDR3
 FCB $04
 FCC 'MACR'
 FDB POMAC
 FCB $FF
 FCC 'NAM '
 FDB PONAM
 FCB $FF
 FCC 'NAME'
 FDB PONAM
 FCB $FF
 FCC 'NEG '
 FDB ADDR3
 FCB $00
 FCC 'NEXT'
 FDB NEXTPR
 FCB $F0
 FCC 'NIFC'
 FDB PONIF
 FCB $FF
 FCC 'NOP '
 FDB ADDR9
 FCB $01
 FCC 'ON  '
 FDB ONPR
 FCB $F0
 FCC 'OPEN'
 FDB OPENPR
 FCB $F0
 FCC 'ORA '
 FDB ADDR1
 FCB $0A
 FCC 'PAG '
 FDB POPAG
 FCB $FF
 FCC 'PAGE'
 FDB POPAG
 FCB $FF
 FCC 'POKE'
 FDB POKEPR
 FCB $F0
 FCC 'POP '
 FDB POPPR
 FCB $F0
 FCC 'PRIN'
 FDB PRNTPR
 FCB $F0
 FCC 'PROC'
 FDB PROCPR
 FCB $F0
 FCC 'PSH '
 FDB ADDR4
 FCB $36
 FCC 'PUL '
 FDB ADDR4
 FCB $32
 FCC 'PUSH'
 FDB PUSHPR
 FCB $F0
 FCC 'READ'
 FDB READPR
 FCB $F0
 FCC 'RETU'
 FDB RETPR
 FCB $F0
 FCC 'REWI'
 FDB REWPR
 FCB $F0
RMBZ FCC 'RMB '
 FDB PORMB
 FCB $FF
 FCC 'ROL '
 FDB ADDR3
 FCB $09
 FCC 'ROR '
 FDB ADDR3
 FCB $06
 FCC 'RTI '
 FDB ADDR9
 FCB $3B
 FCC 'RTS '
 FDB ADDR9
 FCB $39
 FCC 'SBA '
 FDB ADDR9
 FCB $10
 FCC 'SBC '
 FDB ADDR1
 FCB $02
 FCC 'SEC '
 FDB ADDR9
 FCB $0D
 FCC 'SEI '
 FDB ADDR9
 FCB $0F
 FCC 'SET '
 FDB POSET
 FCB $FF
 FCC 'SEV '
 FDB ADDR9
 FCB $0B
 FCC 'STA '
 FDB ADDR2
 FCB $07
 FCC 'STEP'
 FDB $FFFF
 FCB $F0
 FCC 'STOP'
 FDB STOPPR
 FCB $F0
 FCC 'STRI'
 FDB STRPR
 FCB $F0
 FCC 'STS '
 FDB ADDR6
 FCB $8F
 FCC 'STX '
 FDB ADDR6
 FCB $CF
 FCC 'SUB '
 FDB ADDR1
 FCB $00
 FCC 'SWI '
 FDB ADDR9
 FCB $3F
 FCC 'TAB '
 FDB ADDR9
 FCB $16
 FCC 'TAP '
 FDB ADDR9
 FCB $06
 FCC 'TBA '
 FDB ADDR9
 FCB $17
 FCC 'THEN'
 FDB IFPR2
 FCB $F0
 FCC 'TO  '
 FDB $FFFF
 FCB $F0
 FCC 'TPA '
 FDB ADDR9
 FCB $09
 FCC 'TST '
 FDB ADDR3
 FCB $0D
 FCC 'TSX '
 FDB ADDR9
 FCB $30
 FCC 'TXS '
 FDB ADDR9
 FCB $35
 FCC 'VALU'
 FDB VALUPR
 FCB $F0
 FCC 'WAI '
 FDB ADDR9
 FCB $3E
 FCC 'WHIL'
 FDB WHILPR
 FCB $F0
 FCC 'WRIT'
 FDB WRITPR
 FCB $F0
 FCC 'XTRA'
 FDB XTRPR
 FCB $F0
*
* CHAR.TABLE
*
* BIT $80 ALPHABETIC CHAR.
* BIT $40 DECIMAL DIGIT
* BIT $20 ARITHMETIC OPERATION
* BIT $10 PARENTHESIS,EQUALS
* BIT $08 NOT USED
* BIT $04 DELIMITER CHAR.
* BIT $02 HEXADECIMAL CHAR.
* BIT $01 REGISTER NAME (A,B,X)
*
CHRTAB FCB $00
 FCB $00
 FCB $00
 FCB $04
 FCB $04
 FCB $04
 FCB $00
 FCB $04
 FCB $10
 FCB $10
 FCB $24
 FCB $24
 FCB $04
 FCB $24
 FCB $80
 FCB $24
 FCB $42
 FCB $42
 FCB $42
 FCB $42
 FCB $42
 FCB $42
 FCB $42
 FCB $42
 FCB $42
 FCB $42
 FCB $00
 FCB $00
 FCB $00
 FCB $10
 FCB $04
 FCB $00
 FCB $04
 FCB $83
 FCB $83
 FCB $82
 FCB $82
 FCB $82
 FCB $82
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $80
 FCB $81
 FCB $80
 FCB $80
 FCB $04
 FCB $00
 FCB $04
 FCB $00
 FCB $00
*
LNUM RMB 2 LINE NUMBER
TSTPH RMB 2 PHASING ERROR LOC.
LC RMB 2 LOCATION COUNTER
PASS RMB 1 PASS 0=1,FF=2
COMFLG RMB 1 CSECTION FLAG
LBFLG RMB 1 0=NO LABEL
FLPFLG RMB 1 FLOATING SWITCH 00=INTEGER
RELFLG RMB 1 RELOCATION FLAG 0=NO,FF=YES
CMNFLG RMB 1 COMMON FLAG
EXTFLG RMB 1
ENTFLG RMB 1
MSTKPT RMB 2 MACRO STACK POINTER
STKSAV RMB 2 TEMP STACK POINTER
MXSAV1 RMB 2 TEMP ,,
MXSAV2 RMB 2 
MACLIN RMB 80 MACRO LINE EXPANSION SPACE
MACPAR RMB 80 MACRO PARAMETER SPACE
MACFLG RMB 1 MACRO MODE FLAG
MACPTR RMB 2 POINTER TO MACRO TABLE
MACSAV RMB 2
MCLPTR RMB 2 MACRO LINE POINTER
LABEL RMB 2 AUTO-GEN.
PARNUM RMB 1 NO. OF PARAMETERS
 RMB 16
IFSTK EQU * COND. STACK
@IFSTK RMB 2 COND. STACK POINTER
CIFFLG RMB 1 COND. FLAG
DESCRA RMB 2 DESCRIPTOR ADDRESS
DESCRC RMB 1 DESCRIPTOR COUNT
MYSAV RMB 2 POINTER STORAGE
MYSAV2 RMB 2
OPTLN RMB 10 BUFFER SPACE
CONSW RMB 1
*
CMPLNG FDB $0D0A CR,LF
 FCC 'STRUBAL+ COMPILER....VERSION 1.2'
 FCB $D
*
OPTPMT FDB $0D0A
 FCC 'ENTER OPTIONS: '
 FCB $04
*
CMPCNT RMB 1 COMPILER CHAR COUNTER
CUCHAR RMB 2 CURRENT CHAR ADDRESS
CFLAG RMB 1 COMPILING FLAG
CULINE RMB 2 CURRENT LINE ADDRESS
SYMPTR RMB 2 SYMTAB POINTER
OPTNS RMB 1 ASSEMBLER OPTIONS
LCN RMB 1 BYTES IN AN INSTRUCTION
LSAVE RMB 2 LC SAVE LOCATION
LCOUNT RMB 1 LINES ON A PAGE
IFFLG RMB 1 IF PROCESS FLAG
IFLBL RMB 2 IF BRANCH LABEL
FORFLG RMB 1 FOR PROCESS FLAG
PFLAG RMB 1 PARAMETER FLAG
PARFLG RMB 1
ECOUNT RMB 2 ERROR COUNT
CMNLC RMB 2 COMMON LC
NXTFLG RMB 1 NEXT TOKEN FLAG
LBLCNT RMB 2 COUNT OF COMPILER LABELS
*
 EXT INEEE INPUT A CHAR.
 EXT OUTEEE OUTPUT A CHAR.
 EXT OUTLPT OUTPUT TO LINEPRINTER
STACK RMB 2
*
OPC1 JSR INITIO
 CLR CONSW
 INC LPTSW
 INC CONSW OUTPUT TO CONSOLE
 LDX #CMPLNG
 JSR PDATA1
 JSR ADRINT CLEAR AND INIT.
 CLR COMFLG
 CLR IFFLG
 LDX #BLKEND
 STX BLKCNT
*
*SET PROCESSING OPTIONS
*(L) LIST
*(M) LIST MACRO EXPANSION
*(S) SYMBOL TABLE
*(O) OBJECT FILE
*(X) CROSS REFERENCE OUTPUT
*(I) INTERMEDIATE CODE (COMPILE ONLY)
*(Q) QUIT---RETURN TO OPERATING SYSTEM.
*
OPC1A CLR OPTNS
 COM OPTNS ALL OPTIONS OFF
OPC2 JSR INEEE
 BITA #$40 ALPHABETIC ?
 BEQ *+4
 ANDA #$DF FORCE UPPER CASE
 CMPA DELCHR ESCAPE ?
 BNE OPC2B
OPC2A LDX #OPTPMT
 INC LPTSW
 CLR CONSW
 INC CONSW
 JSR PDATA1
 BRA OPC1A
OPC2B CMPA #$D CR.?
 BEQ OPC3
 CMPA #'Q QUIT ?
 BNE OPYE9
FLXCAL JSR FMSCLS
 JSR RSTRIO
 JMP WARMS
OPYE9 CMPA #'L LIST ?
 BNE *+6
 LDAA #$7F
 BRA OPYES
 CMPA #'M MACRO EXP ?
 BNE *+6
 LDAA #$FB
 BRA OPYES
 CMPA #'O OBJECT FILE ?
 BNE *+6
 LDAA #$BF
 BRA OPYES
 CMPA #'S SYMBOL TABLE ?
 BNE *+6
 LDAA #$DF
 BRA OPYES
 CMPA #'X CROSS REFERENCE ?
 BNE *+6
 LDAA #$F7
 BRA OPYES
 CMPA #'I INTERMEDIATE CODE ?
 BNE OPC2
 LDAA #$EF
OPYES ANDA OPTNS
 STAA OPTNS TURN ON OPTION
 BRA OPC2 CONTINUE
OPC3 JSR CRLF
 FDB $0101
 FCB 1
 FDB $0101
 FDB $0101
 LDAA OPTNS TEST OPTIONS
 COMA
 BITA #$48 XREF OR OBJECT
 BEQ OPC3A
 FDB $0101
 FCB 1
 FDB $0101
 FDB $0101
OPC3A LDX #CORASM
 JSR PDATA1
 CLR OPTLN
OPC3B JSR INEEE
 CMPA DELCHR
 BEQ OPC3A
 CMPA #$D CR ?
 BEQ OPC3C
 STAA OPTLN SAVE CHAR.
 BRA OPC3B LOOP BACK
OPC3C JSR CRLF
 LDAA OPTLN
 ANDA #$DF FORCE UPPER CASE
 CMPA #'A ASSEMBLE ?
 BNE *+5
 JMP PASS1
 CMPA #'C COMPILE ?
 BNE OPC3A
 BRA OPC4
*
CORASM FDB $0D0A
 FCC '(C)OMPILE OR (A)SSEMBLE? '
 FCB $04
*
OPC4 LDX #RTMSG RUN TIME NAME PROMPT
 JSR PDATA1
 LDX #RTL1+5 GET NAME
OPC5 JSR INEEE GET A CHAR.
 STAA 0,X STORE IT
 CMPA #$D
 BEQ OPC6
 CMPA DELCHR
 BEQ OPC4
 INX
 CPX #RTL1+15 TOO LONG ?
 BNE OPC5
OPC6 JSR CRLF
 LDAA #$FF
 STAA PASS
 STAA CFLAG SET COMPILE FLAG
 JMP PASS1A
*
* OUTPUT RUNTIME LINKS
*
OUTRTL LDX #RTL1
 JSR STR1
 LDX #RTL2
 JSR STR1
 LDX #RTL3
 JSR STR1
 LDX #RTL4
 JSR STR1
 LDX #RTL5
 JSR STR1
 LDX #RTL6
 JSR STR1
 LDX #RTL7
 JSR STR1
 LDX #RTL8
 JMP STR1
*
RTL1 FCC ' NAM '
 RMB 10
 FCB $D
RTL2 FCC ' CMN .RNSTK,80'
 FCB $D
RTL3 FCC ' CMN .ACCUM,21'
 FCB $D
RTL4 FCC ' CMN .EOF,2'
 FCB $D
RTL5 FCC ' CMN .ERR,2'
 FCB $D
RTL6 FCC ' CMN .CURIO,2'
 FCB $D
RTL7 FCC ' BRA *+5'
 FCB $D
RTL8 FCC ' EXT .RTBL'
 FCB $D
*
RTMSG FDB $0D0A
 FCC 'ENTER PROGRAM NAME: '
 FCB $04
*
PASS1 CLR PASS PASS:=1
 CLR CFLAG ASSEMBLY
PASS1A JSR SPACER
 LDAA #$20
 LDX SYMTAB
 STAA 0,X
 INX
 CPX SYMEND BLANK SYMBOL TABLE
 BNE *-6
 LDX #$0
 STX TSTPH
 STX ECOUNT
 STX CMNLC
 STX RUNCNT
 STX LBLCNT
 STX GAFLG
PASS2 CLR LCOUNT
 LDX #$0
 STX LC
 STX LNUM
 LDX MACTBL
 STX MACPTR
 CLR MACFLG
 LDX MACSTK
 STX MSTKPT
 LDAA #$FF
 STAA CIFFLG
 LDX #IFSTK
 STX @IFSTK
 LDAA OPTNS
 ANDA #$94 LIST/MACRO/INTERM ?
 EORA #$94 ANY BITS ZERO ?
 BEQ MAIBI1
 CLR CONSW
 CLR LPTSW
MAIBI1 TST CFLAG
 BEQ MAIN1
 JSR OUTRTL
*
MAIN1 JSR RDLINE GET A LINE OF SOURCE.
 CLR NXTFLG
 CLR DSTFLG
 CLR LBFLG
 CLR FLPFLG
 CLR OVFLG
 CLR GAFLG2
 CLR ERNUM
 CLR FORFLG
 JSR ADRINT
MAIN2 LDX LNUM
 INX
 STX LNUM BUMP LNUM
 LDX CULINE
 LDAA 0,X GET COL 1
 CMPA #'* COMMENT ?
 BNE MAIN3
 JSR PRINTL
 TST CFLAG COMPILING /
 BEQ MAIN1
 LDX CULINE RESTORE LINE POINTER
 JSR STR1
 BRA MAIN1
MAIN3 TST CFLAG
 BNE *+5
 JMP MAIN3A
*
* PROCESSING FOR COMPILER HERE
*
 JSR PRINTL
 TST IFFLG
 BEQ COMPO
 CLR IFFLG
 LDAA IFLBL
 LDAB IFLBL+1 SET UP FOR CVBTD
 LDX #LABL+1
 JSR CVBTD
*
* PUT OUT BRANCH LABEL HERE
* IF A PENDING "IF" STATEMENT
*
 LDX #LABL
 JSR STR1
COMPO LDX CULINE
 LDAA 0,X RESET POINTERS
 CMPA #$20 A LABEL ?
 BEQ COMP1
 JSR NXTOK
 CMPB #$01 A VALID LABEL ?
 BEQ *+5
 JMP MAIN3E
 INC LBFLG
 JSR OUTNAM
 JSR XREF
COMP1 LDAB #$20 BLANK OBJECT
 JSR TPCHAR
 LDAA #$20
 JSR WRTCHR BLANK TO LIST
 JSR NXTOK GET MNEMONIC
 CMPB #1 A VALID TOKEN ?
 BNE COMP2E
COMP2 JSR MNLKP
 TSTA FOUND MNEM.?
 BEQ COMP2D
*
* LOOK FOR USER DEFINED FUNCTION
*
 JSR LKPSYM NAME IN SYMTAB ?
 CMPB #$FF
 BEQ COMP2C
 BITB #$20 NAME OF FUNCTION ?
 BEQ COMP2C
 STX SAVEX
 LDX #LABL+6
 JSR STR1
 LDX SAVEX
 TST MACFLG
 BEQ COMP2A
*
* PUSH PRESENT FUNCTION ON STACK
*
 JSR MACPSH
 TST MACFLG ERRORS ?
 BNE COMP2A
 JMP MAIN1
COMP2A STX MACPTR
 LDX LBLCNT
 INX
 STX LBLCNT
 STX LABEL
 CLR PARNUM
 INC MACFLG SET FUNCTION FLAG
 JSR NXTOK
 CMPB #$D EOL ?
 BNE COMP2B
 STAB MACPAR
 JMP MAIN1
COMP2B JSR PARMVE GET LIST
 JMP MAIN1
COMP2C JMP LETPR2
COMP2D CPX #$FFFF SPECIAL NAME (STEP,TO) ?
 BEQ COMP2E
 CPX #IFPR2 "THEN" ?
 BEQ COMP2E
 CPX #IFPR3 "ELSE" ?
 BNE COMP2F
COMP2E LDX #$0202 ERROR !
 JSR PRINTE
 JMP MAIN1
COMP2F CMPB #$F0 COMPILER OP.?
 BEQ COMP3
 CPX #POPAG PAGE DIRECTIVE ?
 BNE COMP2H
 LDAB LCOUNT
 BEQ COMP2G TOP OP PAGE
 CLR LCOUNT
 JSR SPACER
 BRA COMP2G
COMP2H CPX #POEND END STMNT ?
 BEQ COMP3
 CPX #PONAM
 BNE COMP2G
 LDX #$0201 ERROR !
 JSR PRINTE
 JMP MAIN1
*
* ASSEMBLER LINES ARE PASSED ACROSS
*
COMP2G LDX DESCRA
 JSR STR1
 JMP MAIN1
*
* COMPILER LINE PROCESSED HERE
*
COMP3 JMP 0,X
*
* PROCESSING FOR ASSEMBLER HERE
*
MAIN3A TST CIFFLG ASSEMBLING ?
 BNE MAIN3C
 CMPA #$20 LINE HAS LABEL ?
 BEQ MAIN3B
 JSR NXTOK
MAIN3B JSR NXTOK
 JSR MNLKP
 CPX #POIFC
 BEQ COMP3
 CPX #PONIF
 BEQ COMP3
 JSR ADRINT
 JSR PRINTL
 JMP MAIN1
MAIN3C CMPA #$20
  BEQ MAIN3D
 JSR NXTOK
MAIN3D JSR NXTOK
 JSR MNLKP
 CPX #POSET
 BEQ COMP3
 LDX CULINE
 STX CUCHAR
 LDAA 0,X
 CMPA #$20
 BEQ MAIN5
 JSR NXTOK
 CMPB #$01
 BEQ MAIN4
 CMPA #$01
 BEQ MAIN4
MAIN3E LDX #$0205 ERROR !
 BRA MAIN8
MAIN4 INC LBFLG
 TST PASS
 BNE MAIN4A
 JSR STOSYM
MAIN4A JSR XREF HANDLE CROSS REFERENCE
MAIN5 JSR NXTOK
 CMPB #$01
 BEQ MAIN6A
MAIN6 LDX #$0202 ERROR !
 BRA MAIN8
MAIN6A JSR MNLKP
 TSTA
 BEQ MAIN6D
*
* LOOK FOR USER MACRO NAME
 JSR LKPSYM
 CMPB #$FF
 BEQ MAIN7
 BITB #$20
 BEQ MAIN7
 TST MACFLG
 BEQ MAIN6B
* PUSH MACRO ON STACK
 JSR MACPSH
 TST MACFLG
 BNE MAIN6B
 JMP MAIN1
MAIN6B STX MACPTR
 LDX LBLCNT
 INX
 STX LBLCNT
 STX LABEL
 CLR PARNUM
 INC MACFLG
 JSR PRINTL
 JSR NXTOK
 CMPB #$D EOL ?
 BNE MAIN6C
 STAB MACPAR
 JMP MAIN1
MAIN6C JSR PARMVE
 JMP MAIN1
MAIN6D JMP 0,X GOTO ROUTINE
MAIN7 LDX #$0207 ERROR !
MAIN8 JSR PRINTE
 JSR PRINTL
 JMP MAIN1
*
* GET A LINE OF SOURCE FROM INBUF
*
RDLINE TST MACFLG
 BEQ RDLINA
 JSR RDMAC
 TST MACFLG
 BEQ RDLINA
 RTS
RDLINA LDX #INBUF
 STX CUCHAR
 STX CULINE
RDL1 JSR GETB GET A BYTE
 BCC RDL1A
 JSR CLOSI CLOSE FILE
 LDS STACK
 JMP POEND0
RDL1A CMPA #$0A LF ?
 BEQ RDL1
 CMPA #$00 NULLS ?
 BEQ RDL1
 CPX #INBUF+79 LINE TOO LONG ?
 BEQ RDL2
 STAA 0,X
 INX
 BRA RDL3
RDL2 LDAB #$0D TRUNCATE LINE
 STAB 0,X
RDL3 CMPA #$0D CR ?
 BNE RDL1
 RTS
INBUF RMB 80 INPUT BUFFER FOR LINE
*
* EXPAND MACRO OR FUNCTION CALL
*
RDMAC LDX MACPTR
 LDAA 0,X
 CMPA #$17
 BNE RDMAC1
 DEC MACFLG
 BEQ RDMACO
* PULL UP LAST STACKED MACRO
 JSR MACPUL
 BRA RDMAC
RDMACO RTS
RDMAC1 LDX #MACLIN
 STX CULINE
 STX CUCHAR
 STX MCLPTR
RDMAC2 LDX MACPTR POINT TO MACRO DEF.
 LDAA 0,X
 INX
 STX MACPTR
 CMPA #'& PARAMETERS ?
 BEQ RDMAC3
 CMPA #'! AUTO-DEF LABEL ?
 BNE RDM2
 LDAA #'. FORM NEW LABEL
 LDX MCLPTR
 STAA 0,X
 INX
 LDAA LABEL
 LDAB LABEL+1
 JSR CVBTD MAKE "LABEL" INTO ASCI
 LDX MACPTR
 LDAA 0,X
 JSR GCHRTB CHECK FOR ALPHABETIC ?
 BITA #$80
 BNE *+5 
 JMP RDMERR
 LDX MACPTR
 LDAA 0,X
 INX
 STX MACPTR
 LDX MCLPTR
 STAA 1,X PUT CHAR IN LABEL
 LDAB #6 SIX-CHAR LABEL
RDM1 INX
 STX MCLPTR
 CPX #MACLIN+74 OVERFLOW ?
 BNE *+5
 JMP RDMERR
 DECB
 BNE RDM1
 BRA RDMAC2
RDM2 LDX MCLPTR
 STAA 0,X
 INX
 STX MCLPTR MOVE POINTER
 CPX #MACLIN+74 OVERFLOW ?
 BNE *+5
 JMP RDMERR
 CMPA #$0D EOL ?
 BNE RDMAC2
 RTS
*
* SUBSTITUTE POSITIONAL PARA'S
*
RDMAC3 JSR CVHBS
 CMPA PARNUM POS.NUMBER TOO BIG ?
 BLE *+5
 LDAA PARNUM
 TAB
 INX
 STX MACPTR
 TSTB
 BNE RDM3
 LDAA #'$ OUTPUT HEX CONSTANT
 LDX MCLPTR
 STAA 0,X
 LDAA PARNUM
 JSR OUTHL
 STAA 1,X
 LDAA PARNUM
 JSR OUTHR
 STAA 2,X
 LDAB #3 3 CHAR IN NUMBER
 BRA RDM1
RDM3 LDX #MACPAR POINT TO PARA'S FROM CALL
RDMAC6 STX MACSAV
RDMAC4 LDAA 0,X
 INX
 CMPA #', END OF PARA'S
 BEQ RDMAC7
 CMPA #$0D
 BNE RDMAC4
RDMAC7 DECB
 BNE RDMAC6
 LDX MACSAV
 LDAA 0,X
 INX
 STX MACSAV
RDMAC5 LDX MCLPTR
 STAA 0,X
 INX
 STX MCLPTR
 CPX #MACLIN+74
 BEQ RDMERR
 LDX MACSAV
 LDAA 0,X
 INX
 STX MACSAV
 CMPA #',
 BNE *+5
 JMP RDMAC2
 CMPA #$0D
 BNE RDMAC5
 JMP RDMAC2
RDMERR LDAA #$0D
 LDX MCLPTR
 STX CUCHAR
 STAA 0,X
 LDX #$0230 ERROR !
 JSR PRINTE
 LDX CULINE
 STX CUCHAR
 JMP RDMAC2
* PUSH A MACRO ONTO MACRO STACK
MACPSH STX MXSAV1
 TPA
 PSHA
 SEI
 STS STKSAV
 LDS MSTKPT MACRO STACKPOINTER
 LDX #PARNUM
 LDAB #9 NINE BYTES TO PUSH
MPSH1 LDAA 0,X
 DEX
 STX MXSAV2
 TSX
 DEX
 CPX MACEND
 BEQ MPSH5 STACK FULL ?
 LDX MXSAV2
 PSHA
 DECB
 BNE MPSH1
 LDX #MACPAR
MPSH2 LDAA 0,X
 CMPA #$0D
 BEQ MPSH3
 INX
 BRA MPSH2
MPSH3 LDAA 0,X
 STX MXSAV2
 TSX
 DEX
 CPX MACEND
 BEQ MPSH5
 LDX MXSAV2
 PSHA
 DEX
 CPX #MACPAR-1
 BNE MPSH3
 STS MSTKPT
 LDS STKSAV
 PULA
 TAP
 LDX MXSAV1
 RTS
* MACRO NESTING OVERFLOW
MPSH5 LDS MACSTK
 STS MSTKPT
 LDS STKSAV
 PULA
 TAP
 LDX #$0251
 JSR PRINTE
 LDX MXSAV1
 RTS
* PULL A MACRO FROM THE STACK
MACPUL STX MXSAV1
 TPA
 PSHA
 SEI
 STS STKSAV
 LDS MSTKPT
 LDX #MACPAR
MPUL1 PULA
 STAA 0,X
 INX
 CMPA #$0D
 BNE MPUL1
 LDX #MACPTR
 LDAB #9
MPUL2 PULA
 STAA 0,X
 INX
 DECB
 BNE MPUL2
 STS MSTKPT
 LDS STKSAV
 PULA
 TAP
 LDX MXSAV1
 RTS
* MOVE FUNCTION/MACRO PARA'S
PARMVE LDX #MACPAR
 INC PARNUM COUNT PARA'S
 STX MACSAV
PARMV2 LDX DESCRA
 LDAA 0,X
 INX
 STX DESCRA
 LDX MACSAV
 STAA 0,X
 INX
 STX MACSAV
 CMPA #$0D
 BEQ PARMV3
 CMPA #',
 BNE PARMV2
 INC PARNUM
 BRA PARMV2
PARMV3 RTS
*
* WRITE A CHAR. TO LIST FROM 'A' DURING COMPILING
*
WRTCHR LDAB OPTNS
 BITB #$10 INTERMEDIATE ?
 BNE *+5
 JSR OUTCHR
 RTS
TPCHAR JMP OUTBNR
OUTNAM LDX DESCRA
 LDAA DESCRC
 STAA CMPCNT
* WRITE CHAR STRING
OUTCMP LDAA 0,X
OTCMP1 CMPA #$D
 BEQ OUTCR
 PSHA
 BSR WRTCHR
 PULB
 BSR TPCHAR
OTCMP2 INX
 DEC CMPCNT
 BNE OUTCMP
 LDAA #$20
 BSR WRTCHR
 LDAB #$20
 BRA TPCHAR
* WRITE CR ON OBJECT
OUTCR JSR CRLF
 LDAB #$D
 BSR TPCHAR
 LDAB #$A
 BRA TPCHAR
*
* COMPARE TWO STRINGS
*
COMPAR PSHA
 PSHB
 LDAB 4,X
 STX XSAV
CMP1 LDX XSAV
 LDX 0,X
 LDAA 0,X
 LDX XSAV
 INC 1,X
 BNE *+4
 INC 0,X
 LDX 2,X
 CMPA 0,X
 BNE CDONE
 LDX XSAV
 INC 3,X
 BNE CMP2
 INC 2,X
CMP2 DECB
 BNE CMP1
CDONE PULB
 PULA
 RTS
XSAV RMB 2
*
* PROCESS "LET" OPCODE
*
LETPR JSR NXTOK
 CMPB #1
 BEQ LETPR2
LETERR LDX #$0302
 TST GAFLG2
 BEQ *+5
 LDX #$0313
 JSR PRINTE
 JMP MAIN1
LETPR2 JSR LKPSYM
 CLR PFLAG
 CLR STRFLG
 CMPB #$FF
 BNE LET1
 JSR DEFS2
 BRA LET2
LET1 BITB #3 DIMENSIONED ?
 BEQ LET2
 COM STRFLG
 TST FORFLG
 BNE LETERR
LET2 LDX DESCRA
 STX MYSAV
 LDAA DESCRC
 STAA OPTLN
 BITB #$80
 BEQ *+5
 COM PFLAG
 ANDB #$08 IF FLOAT
 STAB FLPFLG
 BEQ LET3
 TST FORFLG
 BNE LETERR
 TST GAFLG2
 BNE LETERR
LET3 JSR NXTOK
 LDX DESCRA
 STX MYSAV2
 CMPB #'=
 BEQ LET3C
 CMPB #$0D
 BEQ LETERR
 LDX DESCRA
LET3A INX
 LDAA 0,X
 CMPA #'=
 BEQ LET3B
 CMPA #$0D
 BEQ LETERR
 BRA LET3A
LET3B INX
 STX CUCHAR
LET3C TST GAFLG2
 BEQ LET3D
 JSR GETADR
 BRA *+5
LET3D JSR EVALS
 TST STRFLG
 BEQ LET3F
 LDX MYSAV
 STX DESCRA
 LDX MYSAV2
 STX CUCHAR
 LDAA OPTLN
 STAA DESCRC
 TST FLPFLG
 BEQ LET3E
*
* GENERATE FLOAT CODE FOR ARRAY
*
 LDX #SAVEL
 JSR STR1
 LDX #UNOPL2
 JSR STR1
 LDAB #165
 JSR FUNOP
 JSR EVADIM
 LDX #UNOPL2
 JSR STR1
 LDX #SAVEL
 JSR STR1
 LDAB #165
 JSR RTBL
 JMP MAIN1
* GENERATE INTEGER ARRAY
LET3E JSR STRDIM
 JMP MAIN1
STRFLG RMB 1
LET3F TST FLPFLG
 BEQ LET4
* GENERATE FLOATING CODE HERE
 LDAA #4
 STAA CMPCNT
 LDX #UNOPL1
 JSR OUTCMP
 TST PFLAG
 BNE LET3G
 LDAA #'#
 JSR WRTCHR
 LDAB #'#
 JSR TPCHAR
LET3G LDX MYSAV
 LDAA OPTLN
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTCR
 LDX #UNOPL2
 JSR STR1
 LDAB #165
 JSR FUNOP
 JMP MAIN1
* GENERATE INTEGER CODE HERE
LET4 TST PFLAG
 BEQ LET5
 LDX #STRL1
 JSR STR1
 LDAA #$FF
 STAA GAFLG
 LDX MYSAV
 STX DESCRA
 LDX MYSAV2
 STX CUCHAR
 LDAA OPTLN
 STAA DESCRC
 JSR EVADIM+3
 BSR STRD2
 JMP MAIN1
LET5 LDX #UNOPL2
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 LDX MYSAV
 LDAA OPTLN
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTCR
 TST FORFLG
 BEQ *+3
 RTS
 JMP MAIN1
*GENERATE ARRAY ELEMENT STORE CODE
STRDIM LDX #STRL1
 JSR STR1
 JSR EVADIM
STRD2 LDX #STRL2
 JSR STR1
 LDX #STRL3
 JSR STR1
 LDX #STRL4
 JSR STR1
 LDX #STRL5
 JSR STR1
STRL1 FCC ' STX .ACCUM+4'
 FCB $D
STRL2 FCC ' LDA A .ACCUM+4'
 FCB $D
STRL3 FCC ' LDA B .ACCUM+5'
 FCB $D
STRL4 FCC ' STA A 0,X'
 FCB $D
STRL5 FCC ' STA B 1,X'
 FCB $D
SAVEL FCC ' LDX #.ACCUM+8'
 FCB $D
*
* PROCESS "FOR" OPCODE
*
FORPR COM FORFLG
 CLR FLPFLG
 JSR LETPR
 LDX LBLCNT
 INX
 STX LBLCNT
 STX BLKTOP
 CLR FLPFLG
 JSR EVALS
 TST ERNUM
 BNE FORPR5
 LDAA BLKTOP
 LDAB BLKTOP+1
 LDX #FORL1+6
 JSR CVBTD
 LDX #FORL1
 JSR STR1
 LDX DESCRA
 LDAA 0,X
 CMPA #$0D
 BNE FORPR2
* DEFAULT STEP SIZE IS 1
 LDX #COMPL4
 JSR STR1
 BRA FORPR3
FORPR2 CLR FLPFLG
 JSR EVALS
FORPR3 LDX #FORL3+6
 LDAA BLKTOP
 LDAB BLKTOP+1
 JSR CVBTD
 LDX #FORL3
 JSR STR1
 TPA
 PSHA
 SEI
 STS STKTOP
 LDS BLKCNT
 LDAA BLKTOP
 PSHA
 LDAA BLKTOP+1
 PSHA
 TSX
 DEX
 LDS STKTOP
 PULA
 TAP
 CPX #BLKSTR
 BNE FORPR5+3
 LDX #$0305 ERROR !
 JSR PRINTE
FORPR5 JMP MAIN1
 STX BLKCNT
 LDX #FORL4
 JSR STR1
 LDX #FORL5+1
 LDAA BLKTOP
 LDAB BLKTOP+1
 JSR CVBTD
 LDX #FORL5
 JSR STR1
 BRA FORPR5
FORL1 FCC ' STX .'
 RMB 5
 FCC '+2'
 FCB $D
FORL3 FCC ' STX .'
 RMB 5
 FCB $D
FORL4 FCC ' BRA *+6'
 FCB $D
FORL5 FCC '.'
 RMB 5
 FCC ' RMB 4'
 FCB $D
*
* PROCESS "NEXT" OPCODE
*
NEXTPR TPA
 PSHA
 SEI
 STS STKTOP
 LDS BLKCNT
 PULA
 STAA BLKTOP+1
 PULA
 STAA BLKTOP
 TSX
 DEX
 LDS STKTOP
 PULA
 TAP
 CPX #BLKEND
 BGE NXTPR2+3
NXTERR LDX #$0307 ERROR !
 JSR PRINTE
NXTPR2 JMP MAIN1
 STX BLKCNT
 JSR NXTOK
 CMPB #1
 BNE NXTERR
 JSR LKPSYM
 CMPB #$FF
 BEQ NXTERR
 BITB #$8B
 BNE NXTERR
* GENERATE CODE AS FOLLOWS
 LDX #UNOPL1
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTNAM
 JSR OUTCR
 LDX #NXTL5+6
 LDAA BLKTOP
 LDAB BLKTOP+1
 JSR CVBTD
 LDX #NXTL5
 JSR STR1
 LDX #NXTL6
 JSR STR1
 LDX #UNOPL2
 JSR STR1
 LDX #NXTL1+6
 LDAA BLKTOP
 LDAB BLKTOP+1
 JSR CVBTD
 LDX #NXTL1
 JSR STR1
 LDAB #12
 JSR RTBL
 LDX #UNOPL2
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTNAM
 JSR OUTCR
 LDX #JMPZ
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 LDX #NXTL4+1
 LDAA BLKTOP
 LDAB BLKTOP+1
 JSR CVBTD
 LDX #NXTL4
 JSR STR1
 JMP MAIN1
NXTL1 FCC ' LDX .'
 RMB 5
 FCB $D
NXTL2 FCC ' LDX .'
 RMB 5
 FCC '+2'
 FCB $D
NXTL3 FCC ' BGT *+5'
 FCB $D
NXTL4 FCC '.'
 RMB 5
 FCC '+4'
 FCB $D
NXTL5 FCC ' CPX .'
 RMB 5
 FCC '+2'
 FCB $D
NXTL6 FCC ' BEQ *+18'
 FCB $D
*
* HANDLE "PUSH" OPCODE
*
PUSHPR JSR PRESCN
 JSR GETADR
 LDAB #216
 TST FLPFLG
 BEQ *+4
 LDAB #219
 TST DSTFLG
 BEQ *+4
 LDAB #222
 JSR RTBL
 JMP MAIN1
*
* HANDLE "POP" OPCODE
*
POPPR JSR PRESCN
 JSR GETADR
 LDAB #225
 TST FLPFLG
 BEQ *+4
 LDAB #228
 TST DSTFLG
 BEQ *+4
 LDAB #231
 JSR RTBL
 JMP MAIN1
*
* UNARY FUNCTION HANDLER
*
NOTPR LDAB #0
EVAL20 STAB TMPVAL
 JMP UNOP
ABSPR LDAB #27
 BRA EVAL20
RANPR LDAB #39
 BRA EVAL20
SIGPR LDAB #30
 BRA EVAL20
PEEKPR LDAB #81
 BRA EVAL20
FABS LDAB #99
 BRA FUNOP
ACOSPR LDAB #144
 BRA FUNOP
ASINPR LDAB #141
 BRA FUNOP
ATANPR LDAB #147
 BRA FUNOP
COSPR LDAB #135
 BRA FUNOP
FEXP LDAB #159
 BRA FUNOP
FIXPR CLR FLPFLG
 LDAB #93
 BRA FUNOP
LOGPR LDAB #150
 BRA FUNOP
NATPR LDAB #153
 BRA FUNOP
FNEG LDAB #105
 BRA FUNOP
FSIGN LDAB #102
 BRA FUNOP
SINPR LDAB #132
 BRA FUNOP
TANPR LDAB #138
 BRA FUNOP
TENPR LDAB #156
FUNOP STAB TMPVAL
 LDAA NUMBER
 LDAB NUMBER+1
 LDX #FCLN1+13
 JSR CVBTD
 LDX #FCLN1
 JSR STR1
 LDAB TMPVAL
 JMP RTBL
FUNOP2 LDAA NUMBER
 LDAB NUMBER+1
 LDX #FCLN1+13
 JSR CVBTD
 LDX #FCLN1
 JSR STR1
 LDX #UNOPL2
 JMP STR1
FCLN1 FCC ' LDX #.RNSTK+'
 RMB 5
 FCB $D
FCLN2 FCC ' STX #.RNSTK+'
 RMB 5
 FCB $D
FCLN3 FCC ' LDX .RNSTK+'
 RMB 5
 FCB $D
FCLN4 FCC ' STX .RNSTK+'
 RMB 5
 FCB $D
*
* UNARY OPERATION CODE GENERATOR
*
UNOP CLR UBFLAG
 CLR COMPL
UNOP2 LDAA NUMBER
 LDAB NUMBER+1
 LDX #FCLN3+12
 JSR CVBTD
 LDX #FCLN3
 JSR STR1
 TST UBFLAG
 BEQ UNOP3
 LDX #UNOPL2
 JMP STR1
UNOP3 LDAB TMPVAL
 JSR RTBL
 TST COMPL
 BEQ *+3
 RTS
UNOP4 LDAA NUMBER
 LDAB NUMBER+1
 LDX #FCLN4+12
 JSR CVBTD
 LDX #FCLN4
 JMP STR1
UBFLAG RMB 1
UNOPL1 FCC ' LDX '
 RMB 5
 FCB $D
UNOPL2 FCC ' STX .ACCUM'
 FCB $D
*
* BINARY OPERATION CODE GENERATOR
*
BINOP CLR COMPL
BINOP2 JSR STAKDN
 CLR UBFLAG
 COM UBFLAG
 BSR UNOP2
 LDAA AX
 LDAB AX+1
 LDX #FCLN3+12
 JSR CVBTD
 LDX #FCLN3
 JSR STR1
 BRA UNOP3
*
* CHECK BINARY OPERATIONS
*
CHKBIN TST STKCNT
 BGE *+14
 STX XSAV
 LDX #$0301
 JSR PRINTE
 LDX XSAV
 RTS
*
* ARITHMETIC AND BINARY FUNCTION ROUTINES
*
MULT LDAB #18
EVAL19 STAB TMPVAL
 BSR CHKBIN
 BRA BINOP
ADDZ LDAB #12
 BRA EVAL19
SUBTR LDAB #15
 BRA EVAL19
DIV LDAB #21
 BRA EVAL19
ORPR LDAB #9
 BRA EVAL19
ANDPR LDAB #3
 BRA EVAL19
EXOPR LDAB #6
 BRA EVAL19
EXPR LDAB #36
 BRA EVAL19
MODPR LDAB #33
 BRA EVAL19
FLOTPR LDAA #$FF
 STAA FLPFLG
 STAA UBFLAG
 STAA COMPL
 JSR UNOP2
 LDX RUNCNT
 INX
 INX
 INX
 INX
 INX
 INX
 INX
 STX RUNCNT
 LDAB #96
 JMP FUNOP
XTOYPR BSR CHKBIN
 JSR FUNOP2
 JSR STAKDN
 LDAB #162
 JMP FUNOP
*
* GET ADDRESS COMPILER OPERATION
*
GETAD COM GAFLG2
 JMP LETPR
GETADR CLR GAFLG
 COM GAFLG
 JSR NXTOK
 JSR EVADIM+3
 TST ERNUM
 RTS
GAFLG RMB 1
GAFLG2 RMB 1
*
* OUTPUT RUNTIME CALL
*
RTBL CLRA
 LDX #RTBL2+5
 JSR CVBTD
 LDX #RTBL1
 BSR STR1
 LDX #RTBL2
STR1 LDAA #100
 STAA CMPCNT
 JMP OUTCMP
RTBL1 FCC ' JSR .RTBL'
 FCB $D
RTBL2 FCC ' FCB '
 RMB 5
 FCB $D
FADD LDAA #120
 STAA UBFLAG
 LDAA #111
 STAA TMPVAL
 LDAA #114
 STAA TMPVAL+1
 BRA FBINOP
FSUB LDAA #123
 BRA FADD+2
FMUL LDAA #126
 BRA FADD+2
FDIV LDAA #129
 STAA UBFLAG
 LDAA #114
 STAA TMPVAL
 LDAA #111
 STAA TMPVAL+1
FBINOP JSR CHKBIN
 JSR STAKDN
*
* GENERATE FLOATING OP CODE
*
 LDAA NUMBER
 LDAB NUMBER+1
 LDX #FCLN1+13
 JSR CVBTD
 LDX #FCLN1
 JSR STR1
 LDAB TMPVAL
 JSR RTBL
 LDAA AX
 LDAB AX+1
 LDX #FCLN1+13
 JSR CVBTD
 LDX #FCLN1
 JSR STR1
 LDAB TMPVAL+1
 JSR RTBL
 LDAB UBFLAG
 JSR RTBL
 LDAA NUMBER
 LDAB NUMBER+1
 LDX #FCLN1+13
 JSR CVBTD
 LDX #FCLN1
 JSR STR1
 LDAB #117
 JMP RTBL
*
* PROCESS BYTE OPCODE
*
BYTEPR BSR SSETUP
 LDX #STRP1
 JSR STR1
 CLR FLPFLG
 JSR EVALS
 LDX #STRL1
 JSR STR1
 LDX #STRP2
 JSR STR1
 LDAB #84
 JSR RTBL
 JMP MAIN1
*
* PROCESS STRING OPCODE
*
STRPR LDX CUCHAR
 STX AX
 JSR NXTOK
 JSR MNLKP
 CPX #IFPR
 BNE *+5
 JMP STRCMP
 LDX AX
 STX CUCHAR
 BSR SSETUP
 BEQ STR2
STRBAD LDX #$0312
 JSR PRINTE
 JMP MAIN1
STR2 JSR NXTOK
 LDX DESCRA
 STX CUCHAR
 CMPB #$27
 BNE STRP
 JMP STRQ
*
* SET UP FOR STRING FUNCTIONS
*
SSETUP JSR PRESCN
 JSR GETADR
 BNE SSTERR
 LDX DESCRA
 LDAA 0,X
 CMPA #')
 BNE *+6
 JSR NXTOK
 TBA
 CMPA #'=
 BEQ SSTUP
SSTERR INS
 INS
 BRA STRBAD
SSTUP RTS
*
* CONVERT OPCODE
*
CONVPR BSR SSETUP
 LDX #STRP1
 JSR STR1
 JSR PRESCN
 JSR EVALS
 TST ERNUM
 BNE STRBAD
 TST FLPFLG
 BEQ STRN
 CLRA
 CLRB
 LDX #FCLN1+13
 JSR CVBTD
 LDX #FCLN1
 JSR STR1
STRN LDX #STRL1
 JSR STR1
 LDX #STRP2
 JSR OUTCMP
 TST FLPFLG
 BEQ STRO
*
* FLOATING POINT CODE
*
 LDAB #171
 BRA *+4
STRO LDAB #66
 JSR RTBL
 JMP MAIN1
STRP LDX #STRP1
 JSR STR1
 JSR GETADR
 BEQ *+5
 JSR STRBAD
 LDX #STRL1
 JSR STR1
 LDX #STRP2
 JSR STR1
 LDX #UNOPL2
 JSR STR1
 LDX #STRP4
 JSR STR1
 LDAB #72
 JSR RTBL
MERGE LDX DESCRA
 LDAA 0,X
 CMPA #',
 BNE *+5
 JMP STR2
 CMPA #$D
 BNE *+5
 JMP MAIN1
 JSR NXTOK
 BRA MERGE
STRQ JSR NXTOK
 LDX #UNOPL2
 JSR STR1
 LDX #QL1
 JSR OUTCMP
 LDAB #72
 JSR RTBL
 JSR QUOT2
 BRA MERGE
*
* VALUE OPCODE
*
VALUPR JSR SSETUP
 LDX #STRP1
 JSR STR1
 JSR GETADR
 BEQ *+5
 JMP STRBAD
 TST FLPFLG
 BEQ STRV1
 LDAB #168
 JSR RTBL
 JMP MAIN1
STRV1 LDAB #63
 JSR RTBL
STRV2 LDX #STRL1
 JSR OUTCMP
 LDX #STRP2
 JSR OUTCMP
 JSR STRD2
 JMP MAIN1
*
* LENGHT OPCODE
*
LENGPR JSR SSETUP
 TST FLPFLG
 BEQ STRLN2
STRLN1 LDX #$0333
 JSR PRINTE
 JMP MAIN1
STRLN2 LDX #STRP1
 JSR STR1
 JSR GETADR
 BEQ *+5
 JMP STRBAD
 LDAB #60
 JSR RTBL
 BRA STRV2
*
* EXTRACT OPCODE
*
XTRPR JSR SSETUP
 TST FLPFLG
 BNE STRLN1
 LDX #STRP1
 JSR STR1
 CLR FLPFLG
 JSR EVALS
 TST ERNUM
 BEQ *+5
 JMP STRBAD
 LDX #STRL1
 JSR STR1
 LDX DESCRA
 LDAA 0,X
 CMPA #$D
 BNE *+5
 JMP STRBAD
 JSR GETADR
 BEQ *+5
 JMP STRBAD
 LDAB #69
 JSR RTBL
 JMP MAIN1
STRP1 FCC ' STX .ACCUM+6'
 FCB $D
STRP2 FCC ' LDX .ACCUM+6'
 FCB $D
STRP3 FCC ' LDX .ACCUM+8'
 FCB $D
STRP4 FCC ' LDX .ACCUM+4'
 FCB $D
STRP5 FCC ' STX .ACCUM+8'
 FCB $D
STRP6 FCC ' STX .ACCUM+2'
 FCB $D
STRP7 FCC ' LDX .ACCUM+2'
 FCB $D
*
* PROCESS STRING COMPARE
*
STRCMP LDX CUCHAR
 STX AX
 JSR NXTOK
 CMPB #$27
 BEQ STRC3
 CMPB #1
 BEQ *+5
STRCER JMP STRBAD
 LDX AX
 STX CUCHAR
 JSR GETADR
 BNE STRCER
 LDX #STRP1
 JSR STR1
 LDX DESCRA
 LDAA 0,X
 CMPA #')
 BEQ STRC4
 STX CUCHAR
 BRA STRC4
STRC3 LDX #STRCL2
 JSR STR1
 LDX #STRP1
 JSR STR1
 JSR QUOT2
STRC4 JSR NXTOK
 CMPB #1
 BNE STRCER
 JSR MNLKP
 TSTA
 BNE STRCER
 BITB #$40
 BEQ STRCER
 SUBB #$41
 BMI STRCER
 PSHB
 LDX CUCHAR
 STX AX
 JSR NXTOK
 CMPB #$27
 BEQ STRC5
 CMPB #1
 BNE STRCER
 LDX AX
 STX CUCHAR
 JSR GETADR
 BEQ STRC6
 PULB
 JMP STRBAD
STRC5 LDX #STRCL1
 JSR STR1
 JSR QUOT2
 BRA STRC6A
STRCL1 FCC ' LDX #*+5'
 FCB $D
STRCL2 FCC ' LDX #*+8'
 FCB $D
STRC6 LDX DESCRA
 LDAA 0,X
 CMPA #')
 BNE *+5
STRC6A JSR NXTOK
 LDAB #78
 JSR RTBL
 LDX #CTBL
 PULB
 TSTB
STRC6B BEQ STRC7
 INX
 INX
 DECB
 BRA STRC6B
CTBL FDB EQLN
 FDB GELN
 FDB GTLN
 FDB LELN
 FDB LTLN
 FDB NELN
STRC7 LDX 0,X
 JSR STR1
 LDX #COMPL2
 JSR STR1
 LDX #COMPL3
 JSR STR1
 LDX #COMPL5
 JSR STR1
 JMP IFPR0
*
* NEXT TOKEN ROUTINE
*
NXTOK CLR DESCRC
 INC DESCRC
NXTO LDX CUCHAR
 STX DESCRA
 LDAA 0,X
 INX
 STX CUCHAR
 CMPA #$20
 BEQ NXTO
 BHI NXT1
 CMPA #$D
 BEQ *+5
 JMP NXTER
 TAB
 RTS
NXT1 CMPA #$5F
 BLS NXT3
 JMP NXTER
NXT3 JSR GCHRTB
 BITA #$01
 BEQ NXT4
 TST CFLAG
 BNE NXT4
 LDX CUCHAR
 LDAA #$1
 LDAB 0,X
 CMPB #$20
 BEQ NXT3A
 LDAA #$D
 CMPB #$D
 BNE NXT4A
NXT3A LDX DESCRA
 LDAB 0,X
 RTS
NXT4 BITA #$80
 BEQ NXT5
 TST CFLAG
 BEQ NXT4A
 LDX DESCRA
 LDAA 0,X
 CMPA #'.
 BNE NXT4A
 LDAA 1,X
 JSR GCHRTB
 BITA #$40
 BEQ NXT4A
 TST FLPFLG
 BEQ NXTER
 JMP FSCAN
NXT4A BRA NSCAN
NXT5 BITA #$40
 BEQ NXT6
 TST FLPFLG
 BEQ *+5
 JMP FSCAN
 BRA DSCAN
NXT6 BITA #$20
 BNE NXT3A
 BITA #$4
 BEQ NXT7
 LDX DESCRA
 LDAB 0,X
 CMPB #'$
 BNE NXT3A
 BRA HSCAN
NXT7 BITA #$10
 BEQ NXTER
 LDX DESCRA
 LDAB 0,X
 CMPB #'(
 BNE NXT9
NXT8 LDAA #8
 RTS
NXT9 CMPB #')
 BEQ NXT8
NXT10 CMPB #'=
 BNE NXTER
 LDAA #$40
 RTS
NXTER CLRA
 CLRB
 RTS
DSCAN LDX CUCHAR
 LDAA 0,X
 INC DESCRC
 INX
 STX CUCHAR
 JSR GCHRTB
 BITA #$40
 BNE DSCAN
 LDAB #9
 BRA ENDSCN
NSCAN LDX CUCHAR
 LDAA 0,X
 CMPA #'.
 BNE NSCAN3
 LDX DESCRA
 LDAA 0,X
 CMPA #'.
 BNE NSCAN2
 LDX CUCHAR
 INX
 STX CUCHAR
 INC DESCRC
NSCAN2 LDAB #1
 LDAA #2
 RTS
NSCAN3 INC DESCRC
 INX
 STX CUCHAR
 JSR GCHRTB
 BITA #$C0
 BNE NSCAN
 LDAB #7
 CMPB DESCRC
 BCC NSCANA
 STAB DESCRC
NSCANA LDAB #1
 BRA ENDSCN
HSCAN CLR DESCRC
 LDX CUCHAR
 STX DESCRA
HSCAN1 LDX CUCHAR
 LDAA 0,X
 INC DESCRC
 INX
 STX CUCHAR
 JSR GCHRTB
 BITA #2
 BNE HSCAN1
 LDAB #3
ENDSCN DEC DESCRC
 LDX CUCHAR
 DEX
 STX CUCHAR
 LDAA #2
 RTS
*
* FLOATING POINT SCANNER
*
FSCAN LDX #FTEMP
 LDAB #9
FR1 CLR 0,X
 INX
 DECB
 BNE FR1
 CLR DECFLG
 CLR SIGDIG
 CLR EXPTMP
 LDX #FTEMP
 LDAB #14
 STAB TEMP
 LDAB #$20
 STAB 0,X
 LDAB #$FF
 STAB NIBBLE
 JSR SCNCHR
 CMPA #'.
 BNE CRCHK
 COM DECFLG
GETIN JSR SCNCHR
CRCHK CMPA #$D
 BNE *+5
 JMP SETEXP
 SUBA #$30
 BEQ GOTZER
 BMI NOTDON
 CMPA #9
 BHI NOTDON
 TST SIGDIG
 BNE GOTZER
 CLR 0,X
 INC SIGDIG
GOTZER TST TEMP
 BEQ GETIN
 TST SIGDIG
 BNE TSTNXT
 TST DECFLG
 BEQ GETIN
 DEC EXPTMP
 BRA GETIN
TSTNXT TST DECFLG
 BNE *+5
 INC EXPTMP
 TST NIBBLE
 BEQ LEFTH
 ASLA
 ASLA
 ASLA
 ASLA
LEFTH ORAA 2,X
 STAA 2,X
 COM NIBBLE
 BEQ *+3
 INX
 DEC TEMP
 BRA GETIN
NOTDON ADDA #$30
 CMPA #'E
 BEQ EXPIN
 CMPA #'.
 BNE SETEXP
 TST DECFLG
 BNE SETEXP
 COM DECFLG
 BRA GETIN
EXPIN BSR SCNCHR
 LDX #FTEMP
 CLR CNTR
 CLR SIGDIG
 CMPA #'+
 BEQ EXPIN2
 CMPA #'-
 BNE EXPIN2+2
 LDAB #$40
 ORAB 0,X
 STAB 0,X
EXPIN2 BSR SCNCHR
 SUBA #$30
 BMI SETEXP
 CMPA #9
 BLS EXPOK
 BRA SETEXP
EXPOK LDAB 1,X
 ASLB
 ASLB
 ASLB
 ASLB
 ABA
 STAA 1,X
 TST CNTR
 BNE SETEXP
 COM CNTR
 BRA EXPIN2
SETEXP LDX #FTEMP
 LDAA 1,X
 ANDA #$F
 PSHA
 LDAA 1,X
 ANDA #$F0
 LSRA
 TAB
 LSRA
 LSRA
 ABA
 PULB
 ABA
 LDAB 0,X
 BITB #$40
 BEQ *+3
 NEGA
 ADDA EXPTMP
 BPL SETX2
 NEGA
 LDAB #$40
 ORAB 0,X
 STAB 0,X
SETX2 CLRB
SETX3 CMPA #10
 BCS SETX4
 SUBA #10
 ADDB #$10
 BRA SETX3
SETX4 ABA
 DAA
 BCC *+4
 INC 0,X
 STAA 1,X
 LDAB #$F
 LDAA #2
 LDX CUCHAR
 DEX
 STX CUCHAR
 RTS
*
* GET A CHAR. FROM LINE
SCNCHR STX DVAL
 LDX DESCRA
 LDAA 0,X
 INX
 STX DESCRA
 STX CUCHAR
 LDX DVAL
 RTS
DECFLG RMB 1
NIBBLE RMB 1
SIGDIG RMB 1
EXPTMP RMB 1
CNTR RMB 1
TEMP RMB 1
FTEMP RMB 9
 FCB 0
*
* PUT OUT CROSS REFERENCE BLOCK
*
XREF LDAA OPTNS
 BITA #8
 BNE XREF2
 TST PASS
 BEQ XREF2
 PSHA
 ANDA #$BF
 STAA OPTNS
 LDAB LNUM
 JSR OUTBIN
 LDAB LNUM+1
 JSR OUTBIN
 JSR HASH
 LDAA #6
 LDX #HSMBL
 JSR PBLK2
 LDAB #$D
 JSR OUTBNR
 PULA
 STAA OPTNS
XREF2 RTS
*
* GET BYTE IN CHRTAB
*
GCHRTB CMPA #$20
 BCS GCHRTR
 CMPA #$5F
 BHI GCHRTR
 CLR CHPTR
 STAA CHPTR+1
 LDX #CHPTR
 JSR ADD16
 LDX CHPTR
 LDAA 0,X
 RTS
GCHRTR CLRA
 RTS
CHPTR RMB 2
 FDB CHRTAB-$20
*
* TABLE MANIPULATION ROUTINES
*
PSTNG1 RMB 2
PSTNG2 RMB 2
PCOUNT RMB 1
TBADD RMB 2
HSMBL RMB 6
HKEYA RMB 2
HKEYB RMB 2
HSAV1 RMB 2
HSAV2 RMB 2
STOSYM JSR HASH
 STX SYMPTR
SYMA LDAA 0,X
 CMPA #$20
 BNE SYMB
 STX HSAV2
 LDX #HSMBL
 STX HSAV1
 LDAB #6
SYM1 LDX HSAV1
 LDAA 0,X
 INX
 STX HSAV1
 LDX HSAV2
 STAA 0,X
 INX
 STX HSAV2
 DECB
 BNE SYM1
 LDAA LC
 STAA 0,X
 LDAA LC+1
 STAA 1,X
 CLRA
 TST CFLAG
 BNE *+4
 LDAA #$40
 STAA 2,X
 RTS
SYMB BSR SYMCMP
 BNE SYMC
 LDX SYMPTR
 LDAA #$80
 ORAA 8,X
 STAA 8,X
 LDX #$0206
SYMB1 JMP PRINTE
SYMC BSR SYMMOD
 CPX HKEYA
 BEQ *+4
 BRA SYMA
 LDX #$0221
 BRA SYMB1
*
* LOOK UP SYMBOL IN SYMTAB
*
LKPSYM BSR HASH
 STX SYMPTR
 JSR XREF
 LDX SYMPTR
LKPSM1 LDAA 0,X
 CMPA #$20
 BNE LKPSM3
LKPSM2 LDAB #$FF
 RTS
LKPSM3 BSR SYMCMP
 BNE LKPSM4
 LDX SYMPTR
 LDAB 8,X
 LDX 6,X
 RTS
LKPSM4 BSR SYMMOD
 CPX HKEYA
 BNE LKPSM1
 BRA LKPSM2
SYMCMP STX PSTNG1
 LDAA #6
 STAA PCOUNT
 LDX #HSMBL
 STX PSTNG2
 LDX #PSTNG1
 JMP COMPAR
SYMMOD LDX SYMPTR
 INX
 INX
 INX
 INX
 INX
 INX
 INX
 INX
 INX
 CPX SYMEND
 BNE *+5
 LDX SYMTAB
 STX SYMPTR
 RTS
*
* DELETE LAST SYMBOL
*
DELSYM LDX SYMPTR
 LDAA #$20
 LDAB #9
DEL1 STAA 0,X
 INX
 DECB
 BNE DEL1
 RTS
*
* HASH SYMBOL 
*
HASH LDX #$2020
 STX HSMBL
 STX HSMBL+2
 STX HSMBL+4
 LDX #HSMBL
 STX HSAV2
 LDX DESCRA
 STX HSAV1
 LDAB DESCRC
 CMPB #7
 BLT HASH1
 LDAB #6
HASH1 LDX HSAV1
 LDAA 0,X
 INX
 STX HSAV1
 LDX HSAV2
 STAA 0,X
 INX
 STX HSAV2
 DECB
 BNE HASH1
 COM OVFLG
 LDX HSMBL
 STX HKEYA
 LDX HSMBL+2
 STX HKEYB
 LDX #HKEYA
 JSR ADD16
 LDX HSMBL+4
 STX HKEYB
 LDX #HKEYA
 JSR ADD16
 LDAA HKEYA
 LDAB HKEYA+1
 LDX NSYM
 STX HKEYB
 LDX #HKEYB
 JSR DIV16
 STX HKEYA
 CLRA
 LDAB #9
 LDX #HKEYA
 JSR MPY16
 STAA HKEYA
 STAB HKEYA+1
 LDX SYMTAB
 STX HKEYB
 LDX #HKEYA
 JSR ADD16
 LDX HKEYA
 CLR OVFLG
 RTS
*
* LOOKUP MNEMONIC IN MNTAB
*
LP RMB 1
MP RMB 1
IP RMB 1
ENSIZ FDB 7
MNLKP JSR HASH
 COM OVFLG
 LDAA #4
 STAA PCOUNT
 LDAA #CHRTAB-MNTAB/7+1
 STAA MP
 CLRA
 STAA LP
MNLKPA LDAA LP
 INCA
 CMPA MP
 BNE MNLKPB
 CLR OVFLG
 LDAA #$FF
 RTS
MNLKPB LDAB LP
 ADDB MP
 RORB 
 STAB IP
 CLRA
 LDX #ENSIZ
 DECB
 JSR MPY16
 STAA PSTNG1
 STAB PSTNG1+1
  LDX #MNTAB
 STX PSTNG2
 LDX #PSTNG1
 JSR ADD16
 LDX PSTNG1
 STX TBADD
 LDX #HSMBL
 STX PSTNG2
 LDX #PSTNG1
 JSR COMPAR
 BCS MNLI
 BNE MNMI
 CLRA
 LDX TBADD
 LDAB 6,X
 LDX 4,X
 CLR OVFLG
 RTS
MNLI LDAA IP
 STAA LP
 JMP MNLKPA
MNMI LDAA IP
 STAA MP
 JMP MNLKPA
*
* EVALUATE NUMBERS,SYMBOLS AND EXPRESSIONS
*
RUNCNT RMB 2
DMSAV RMB 2
DMDATA RMB 1
DIMFLG RMB 1
STKCNT RMB 1
STKTOP RMB 2
STPSTK RMB 2
UNFLG RMB 1
OPSTAK RMB 40
AC RMB 2
NUMBER RMB 2
AX RMB 2
UPSCLR BSR STAKUP
 CLR NUMBER
 CLR NUMBER+1
 RTS
STAKUP LDX #OPSTAK
STAKU1 LDAB 2,X
 STAB 0,X
 INX
 CPX #NUMBER
 BNE STAKU1
 LDAA STKCNT
 CMPA #20
 BGT EXPERR
 INC STKCNT
 RTS
STAKDN LDX #AX-1
STAKD1 LDAB 0,X
 STAB 2,X
 DEX
 CPX #OPSTAK-1
 BNE STAKD1
 DEC STKCNT
 RTS
*
* COMPILER EXPRESSION EVALUATOR
*
MSMTCH LDX #$0333
 BRA *+5
EXPERR LDX #$0300
 LDS STKTOP
 JMP PRINTE
EVALS STS STKTOP
 LDS #EXSTK
 STS STPSTK
 CLR STKCNT
 CLR RUNCNT
 CLR RUNCNT+1
 CLR GAFLG
 CLR PARFLG
 CLR DIMFLG
EXPR1 TST NXTFLG
 BNE *+5
 JSR NXTOK
 CLR ERNUM
 CLR NXTFLG
 CLR UNFLG
 CMPB #'+
 BEQ EXPR2
 CMPB #'-
 BNE EXPR2A
UNEXP TST FLPFLG
 BEQ UNEXP2
 LDAB #$47
 PSHB
 BRA EXPR2
UNEXP2 PSHB
 LDX #COMPL2
 JSR STR1
 JSR UPSCLR
 COM UNFLG
 JMP EVAL7D
EXPR2 JSR NXTOK
 CLR UNFLG
EXPR2A TSTB
 BEQ EXPERR
 CLR PARFLG
 CMPB #',
 BEQ EVAL4
 CMPB #'=
 BEQ EVAL4
 CMPB #$D
 BEQ EVAL4
 CMPB #']
 BEQ EVAL4
 CMPB #1
 BNE *+5
 JMP EVAL8
 CMPA #2
 BEQ EVAL7
 CMPB #')
 BEQ EVAL3
 CMPA #$24
 BEQ EVAL2A
 CMPB #'(
 BNE EVAL2
 PSHB
 JMP EXPR1
EVAL2 JMP EXPERR
EVAL2A PSHB
 BRA EXPR2
EVAL3 TSX
 DEX
 LDAB DIMFLG
 CPX STPSTK
 BEQ EVAL3A
 PULA
 CLRB
 CMPA #'(
 BNE EVAL3A
 JMP EVAL12
EVAL3A TSTB
 BEQ EVAL2
EVAL4 LDAB STKCNT
 DECB
 BNE EVAL2
EVAL5 TSX
 DEX
 CPX STPSTK
 BNE EVAL2
 TST DIMFLG
 BNE *+5
 LDS STKTOP
 RTS
EVAL7 CMPB #3
 BNE EVAL7A
 LDAB DESCRC
 CMPB #4
 BGT EVAL2
 JSR CVHB
 BRA EVAL7B
EVAL7A CMPB #9
 BNE EVAL7F
 LDAB DESCRC
 CMPB #5
 BGT EVAL2
 JSR CVDB
EVAL7B STX TMPVAL
 JSR UPSCLR
*
* GENERATE CODE FOR CONSTANT
*
 LDAA TMPVAL
 LDAB TMPVAL+1
 LDX #CLN1+6
 JSR CVBTD
 LDX #CLN1
 JSR STR1
EVAL7D LDAA RUNCNT
 LDAB RUNCNT+1
 LDX #FCLN4+12
 JSR CVBTD
 LDX #FCLN4
 JSR OUTCMP
EVAL7E LDX RUNCNT
 STX NUMBER
 INX
 INX
 TST FLPFLG
 BEQ *+9
 INX
 INX
 INX
 INX
 INX
 INX
 INX
 STX RUNCNT
 LDAB RUNCNT+1
 CMPB #80
 BLE *+5
 JMP EXPERR
 JMP EVAL12
CLN1 FCC ' LDX #'
 RMB 5
 FCB $D
CLN2 FCC ' STX '
 RMB 5
 FCB $D
*
* HANDLE FLOATING CONSTANT
*
EVAL7F CMPB #$F
 BEQ *+5
 JMP EVAL2
 LDAA RUNCNT
 LDAB RUNCNT+1
 LDX #FCLN1+13
 JSR CVBTD
 LDX #FCLN1
 JSR STR1
 LDX #UNOPL2
 JSR STR1
 LDX #QL1
 JSR STR1
 LDAB #165
 JSR RTBL
 LDX #FCL2
 JSR STR1
 LDX #FTEMP
 BSR FCOUT
 LDX #FTEMP+2
 BSR FCOUT
 LDX #FTEMP+4
 BSR FCOUT
 LDX #FTEMP+6
 BSR FCOUT
 LDX #FTEMP+8
 BSR FCOUT
 JSR UPSCLR
 JMP EVAL7E
FCL2 FCC ' BRA *+12'
 FCB $D
FCL3 FCC ' FDB $'
 RMB 4
 FCB $D
FCOUT LDAA 0,X
 JSR OUTHL
 STAA FCL3+6
 LDAA 0,X
 JSR OUTHR
 STAA FCL3+7
 LDAA 1,X
 JSR OUTHL
 STAA FCL3+8
 LDAA 1,X
 JSR OUTHR
 STAA FCL3+9
 LDX #FCL3
 JMP STR1
EVAL8 JSR MNLKP
 TSTA
 BNE EVAL9
 CMPB #$F0
 BNE *+5
 JMP EVAL4
 LDX DESCRA
 LDAA 0,X
 CMPA #'.
 BNE EVAL9
 TST FLPFLG
 BNE EVAL8A
 BITB #$80
 BEQ *+5
 JMP MSMTCH
EOFPR CMPB #$39
 BNE *+5
 JMP EVAL9E
 CMPB #$36
 BNE EVAL8C
 STAB FLPFLG
 BRA EVAL8C
EVAL8A BITB #$80
 BEQ EVAL8B
 ANDB #$7F
 CMPB #$37
 BNE EVAL8C
 CLR FLPFLG
 BRA EVAL8C
EVAL8B BITB #$40
 BNE EVAL8C
 CMPB #$2C
 BEQ EVAL8C
 CMPB #$3A
 BEQ EVAL8C
 CMPB #$3B
 BEQ EVAL8C
 CMPB #$3D
 BEQ EVAL8C
 CMPB #$3E
 BEQ EVAL8C
 CMPB #$3F
 BEQ EVAL8C
 JMP MSMTCH
EVAL8C PSHB
 JMP EXPR1
EVAL9 JSR DEFS
 STX DMSAV
 STAB DMDATA
 BITB #$80
 BEQ *+5
 INC PARFLG
 BITB #3
 BNE *+5
 JMP EVAL9C
 ANDB #$40
 STAB DSTFLG
 LDAA DIMFLG
 LDAB STKCNT
 PSHA
 PSHB
 LDAA RUNCNT
 LDAB RUNCNT+1
 PSHA
 PSHB
 LDAA STPSTK
 LDAB STPSTK+1
 PSHA
 PSHB
 CLR STKCNT
 LDAB DMDATA
 TST FLPFLG
 BEQ EVAL9A
 BITB #8
 BNE *+5
 JMP MSMTCH
*
* GENERATE CODE FOR FLOATING ARRAY
*
 JSR FNDDIM
 LDX #STRP6
 JSR STR1
 LDX NUMBER
 STX XSAV
 LDX TMPVAL
 STX NUMBER
 JSR FUNOP2
 LDX #STRP7
 JSR STR1
 LDAB #165
 JSR RTBL
 PULB
 PULA
 STAA STPSTK
 STAB STPSTK+1
 PULB
 PULA
 STAA RUNCNT
 STAB RUNCNT+1
 PULB
 PULA
 STAA DIMFLG
 STAB STKCNT
 LDX XSAV
 STX NUMBER
 JSR UPSCLR
 JMP EVAL7E
EVAL9A BITB #8
 BEQ *+5
 JMP MSMTCH
 JSR FNDDIM
 LDX #DIML1
 JSR STR1
EVAL9B PULB
 PULA
 STAB STPSTK+1
 STAA STPSTK
 PULB
 PULA
 STAB RUNCNT+1
 STAA RUNCNT
 PULB
 PULA
 STAB STKCNT
 STAA DIMFLG
 JSR UPSCLR
 JMP EVAL7D
DIML1 FCC ' LDX 0,X'
 FCB $D
*
* GENERATE CODE FOR VARIABLE NAME
*
EVAL9C TST FLPFLG
 BNE EVAL9D
 BITB #8
 BEQ EVAL9E
 JMP MSMTCH
EVAL9D BITB #8
 BNE *+5
 JMP MSMTCH
 LDAA RUNCNT
 LDAB RUNCNT+1
 LDX #FCLN1+13
 JSR CVBTD
 LDX #FCLN1
 JSR STR1
 LDX #UNOPL2
 JSR STR1
 LDX #CLN1
 LDAA #5
 STAA CMPCNT
 JSR OUTCMP
 TST PARFLG
 BNE EVAL10
 LDAA #'#
 JSR WRTCHR
 LDAB #'#
 JSR TPCHAR
EVAL10 JSR OUTNAM
 JSR OUTCR
 LDAB #165
 JSR RTBL
 JSR UPSCLR
 JMP EVAL7E
EVAL9E LDX #CLN1
 LDAA #5
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTNAM
 JSR OUTCR
 TST PARFLG
 BEQ EVAL11
 LDX #DIML1
 JSR STR1
EVAL11 JSR UPSCLR
 JMP EVAL7D
EVAL12 TSX
 DEX
 CPX STPSTK
 BNE EVAL13
 LDX DESCRA
 LDAA 0,X
 CMPA #$D
 BEQ *+9
 CMPA #',
 BEQ *+5
 JMP EXPR2
 JMP EVAL4
EVAL13 PULA
 PSHA
 TST UNFLG
 BEQ *+5
 JMP EXPR2
 CMPA #'(
 BNE *+5
 JMP EXPR2
 PULA
 SUBA #$2A
 BGE *+5
 JMP EXPERR
 CMPA #29
 BGT *-5
 LDX #OPTBL
 TST FLPFLG
 BEQ *+5
 LDX #OPTBL2
 ASLA
 BEQ EVAL15
EVAL14 INX
 DECA
 BNE EVAL14
EVAL15 LDX 0,X
 JSR 0,X
 BRA EVAL12
*
* INTEGER FUNCTION TABLE
*
OPTBL FDB MULT
 FDB ADDZ
 FDB EXPR
 FDB SUBTR
 FDB MODPR
 FDB DIV
 FDB EXPERR
 FDB EXPERR
 FDB EXPERR
 FDB EXPERR
 FDB EXPERR
 FDB EXPERR
 FDB EXPERR
 FDB FLOTPR
 FDB PEEKPR
 FDB EOFPR
 FDB NOTPR
 FDB ABSPR
 FDB RANPR
 FDB SIGPR
 FDB ORPR
 FDB ANDPR
 FDB EXOPR
 FDB EQPR
 FDB GEPR
 FDB GTPR
 FDB LEPR
 FDB LTPR
 FDB NEPR
*
* FLOATING FUNCTION TABLE
*
OPTBL2 FDB FMUL
 FDB FADD
 FDB FEXP
 FDB FSUB
 FDB TENPR
 FDB FDIV
 FDB ACOSPR
 FDB ASINPR
 FDB ATANPR
 FDB COSPR
 FDB SINPR
 FDB TANPR
 FDB FIXPR
 FDB EXPERR
 FDB LOGPR
 FDB NATPR
 FDB NOTPR
 FDB FABS
 FDB XTOYPR
 FDB FSIGN
 FDB ORPR
 FDB ANDPR
 FDB EXOPR
 FDB EQPR
 FDB GEPR
 FDB GTPR
 FDB LEPR
 FDB LTPR
 FDB NEPR
 FDB FNEG
 RMB 100
EXSTK RMB 1
*
* DELAY OPERATION
*
DELAY CLR FLPFLG
 JSR EVALS
 LDAB #75
 JSR RTBL
 JMP MAIN1
* ASSEMBLER "EVALUATION ROUTINE
VALUE RMB 2
TMPVAL RMB 2
CLFLG RMB 1
CLASS RMB 1
OPERN RMB 1
NSEVL CLR VALUE
 CLR VALUE+1
 CLR CLFLG
 STAA CLASS
 CMPB #'*
 BEQ NSEVL3
 CMPB #'+
 BNE NSEVL2
NSEVL1 STAA CLFLG
 STAB OPERN
 BRA NSVLA
NSEVL2 CMPB #'-
 BEQ NSEVL1
 BRA NSVLC1
NSEVL3 LDX LC
 STX VALUE
 LDAA #2
 STAA CLFLG
 COM RELFLG
NSVLA LDX CUCHAR
 LDAA 0,X
 CMPA #$20
 BEQ NSVLB
 CMPA #$D
 BEQ NSVLB
 CMPA #',
 BNE NSVLC
NSVLB LDX VALUE
 STX ADR1
 CLRB
 RTS
NSVLC JSR NXTOK
 STAA CLASS
NSVLC1 CMPA CLFLG
 BNE NSVLF
NSVLD LDX #$0204
NSVLE CLRB
 COMB
 RTS
NSVLF CMPA #2
 BEQ NSVLH
 CMPA #1
 BEQ NSVLH
 CMPA #$24
 BNE NSVLD
NSVLG TST CLFLG
 BEQ NSVLD
 STAB OPERN
 STAA CLFLG
 BRA NSVLA
NSVLH CMPB #3
 BNE NSVLJ
 LDAB DESCRC
 CMPB #4
 BLE NSVLH1
 LDX #$0210
 BRA NSVLE
NSVLH1 JSR CVHB
 BRA NSVLM
NSVLJ CMPB #9
 BNE NSVLK
 LDAB DESCRC
 CMPB #5
 BLE NSVLJ1
 LDX #$0210
 BRA NSVLE
NSVLJ1 JSR CVDB
 BRA NSVLM
NSVLK CMPB #1
 BEQ NSVLL
 CMPA #1
 BNE NSVLD
NSVLL JSR LKPSYM
 BITB #$80
 BNE NSVLLA
 BITB #$40
 BEQ *+7
 COM RELFLG
 BRA NSVLM
 BITB #$10
 BEQ *+5
 COM CMNFLG
 BRA NSVLM
NSVLLA LDX #$0211
 BRA NSVLE
NSVLM STX TMPVAL
 TST CLFLG
 BNE NSVLP
 LDX TMPVAL
 STX VALUE
NSVLN LDAA CLASS
 STAA CLFLG
 JMP NSVLA
NSVLP LDAA OPERN
 CMPA #'+
 BNE NSVLP1
 LDX #VALUE
 JSR ADD16
 BRA NSVLN
NSVLP1 CMPA #'-
 BNE NSVLP2
 LDX #VALUE
 JSR SUB16
 BRA NSVLN
NSVLP2 CMPA #'*
 BNE NSVLP3
 LDAA VALUE
 LDAB VALUE+1
 LDX #TMPVAL
 JSR MPY16
 STAA VALUE
 STAB VALUE+1
 BRA NSVLN
NSVLP3 CMPA #'/
 BEQ NSVLP4
 JMP NSVLD
NSVLP4 LDAA VALUE
 LDAB VALUE+1
 LDX #TMPVAL
 JSR DIV16
 STAA VALUE
 STAB VALUE+1
 BRA NSVLN
*
* CONVERT HEX TO BINARY
*
HVAL RMB 2
CVHB LDX DESCRA
 CLR HVAL
 CLR HVAL+1
 LDAB DESCRC
 DEX
CVHB1 INX
 DECB
 BNE CVHB1
 LDAB DESCRC
 BSR CVHBS
 STAA HVAL+1
 DECB
 BEQ CVHBD
 DEX
 BSR CVHBS
 ASLA
 ASLA
 ASLA
 ASLA
 ORAA HVAL+1
 STAA HVAL+1
 DECB
 BEQ CVHBD
 DEX
 BSR CVHBS
 STAA HVAL
 DECB
 BEQ CVHBD
 DEX
 BSR CVHBS
 ASLA
 ASLA
 ASLA
 ASLA
 ORAA HVAL
 STAA HVAL
CVHBD LDX HVAL
 RTS
*
* CONVERT ASCII TO BINARY
*
CVHBS LDAA 0,X
 SUBA #$30
 CMPA #$9
 BLE *+4
 SUBA #7
 RTS
*
* CONVERT DECIMAL TO BINARY
*
DVAL RMB 2
DCOUNT RMB 1
TENVL RMB 2
DXSAV RMB 2
CVDB CLR DVAL
 CLR DVAL+1
 CLR TENVL
 CLR TENVL+1
 INC TENVL+1
 LDX DESCRA
 DEX
 LDAB DESCRC
 STAB DCOUNT
CVDB1 INX
 DECB
 BNE CVDB1
CVDB2 STX DXSAV
 LDAB 0,X
 ANDB #$F
 CLRA
 LDX #TENVL
 JSR MPY16
 ADDB DVAL+1
 ADCA DVAL
 BSR OVFLW
 STAA DVAL
 STAB DVAL+1
 DEC DCOUNT
 BEQ CVDB3
 CLRA
 LDAB #$A
 LDX #TENVL
 JSR MPY16
 STAA TENVL
 STAB TENVL+1
 LDX DXSAV
 DEX
 BRA CVDB2
CVDB3 LDX DVAL
 RTS
*
* 16 BIT MULTILPY
*
MPY16 PSHB
 PSHA
 LDAA 1,X
 PSHA
 LDAA 0,X
 PSHA
 LDAA #16
 PSHA
 TSX
 LDAA 3,X
MPY163 ASLB
 ROLA
 ASL 2,X
 ROL 1,X
 BCC MPY167
 ADDB 4,X
 ADCA 3,X
 BSR OVFLW
MPY167 DEC 0,X
 BNE MPY163
 INS
 INS
 INS
 INS
 INS
 RTS
OVFLW BVC OVFLW2
 TST OVFLG
 BNE OVFLW2
 STX XSAVR
 LDX #$0210
 JSR PRINTE
 LDX XSAVR
OVFLW2 RTS
XSAVR RMB 2
OVFLG RMB 1
*
* 16 BIT DIVIDE
*
DIV16 PSHB
 PSHA
 LDAA 0,X
 LDAB 1,X
 PSHB
 PSHA
 DES
 TSX
 LDAA #1
 TST 1,X
 BMI DIV153
DIV151 INCA
 ASL 2,X
 ROL 1,X
 BMI DIV153
 CMPA #17
 BNE DIV151
DIV153 STAA 0,X
 LDAA 3,X
 LDAB 4,X
 CLR 3,X
 CLR 4,X
DIV163 SUBB 2,X
 SBCA 1,X
 BCC DIV165
 ADDB 2,X
 ADCA 1,X
 CLC
 BRA DIV167
DIV165 SEC
DIV167 ROL 4,X
 ROL 3,X
 LSR 1,X
 ROR 2,X
 DEC 0,X
 BNE DIV163
 STAA 0,X
 STAB 1,X
 LDX 0,X
 INS
 INS
 INS
 PULA
 PULB
 RTS
*
* 16 BIT ADDITION
*
ADD16 PSHA
 PSHB
 LDAA 1,X
 LDAB 0,X
 ADDA 3,X
 ADCB 2,X
 BSR OVFLW
 STAA 1,X
 STAB 0,X
 PULB
 PULA
 RTS
*
* 16 BIT SUBTRACTION
*
SUB16 PSHA
 PSHB
  LDAA 1,X
 LDAB 0,X
 SUBA 3,X
 SBCB 2,X
 JSR OVFLW
 STAA 1,X
 STAB 0,X
 PULB
 PULA
 RTS
*
* PRINT A LINE ON THE TTY
*
PRINTL LDAA OPTNS
 BITA #$80
 BNE PLEND
 TST PASS
 BEQ PLEND
 TST MACFLG
 BEQ PRINT1
 BITA #$4
 BNE PLEND
PRINT1 BSR OUTL
PLEND RTS
SPACER LDAA OPTNS
 BITA #$80
 BNE *+7
 LDAA #$0C FORM-FEED
 JSR OUTCHR
 RTS
MCOUNT RMB 1
POP RMB 1
OPCD RMB 1
ADR1 RMB 1
ADR2 RMB 1
LINEN RMB 5
 FCB $2E
 FDB $2004
OUTL LDX #LINEN
 LDAA LNUM
 LDAB LNUM+1
 JSR CVBTD
 LDX #LINEN+1
 JSR PDATA1
 TST MACFLG
 BEQ *+7
 LDAA #'+
 JSR OUTCHR
 TST MCOUNT
 BNE OUTLA
 TST POP
 BNE OUTLA
 LDX #BLANK3
 JSR PDATA1
 BRA OUTL2
OUTLA LDX #LC
 JSR OUT4HS
 LDAB POP
 BEQ OUTL2
 CMPB #1
 BEQ OUTL1
 LDX #ADR1
 JSR OUT4HS
 LDX #BLANK5
 JSR PDATA1
 BRA OUTL6
OUTL1 LDX #ADR2
 JSR OUT2HS
 LDX #BLANK3
 JSR PDATA1
 BRA OUTL6
OUTL2 LDAB MCOUNT
 BNE OUTL3
 LDX #BLANK
 JSR PDATA1
 BRA OUTL6
OUTL3 LDX #OPCD
 JSR OUT2HS
 CMPB #1
 BNE OUTL4
 LDX #BLANK3
 JSR PDATA1
 BRA OUTL6
OUTL4 CMPB #2
 BNE OUTL5
 LDX #ADR2
 JSR OUT2HS
 LDX #BLANK6
 JSR PDATA1
 BRA OUTL6
OUTL5 LDX #ADR1
 JSR OUT4HS
OUTL6 TST CMNFLG
 BEQ *+6
 LDAA #'C
 BRA OUTL6B
 TST EXTFLG
 BEQ *+6
 LDAA #'X
 BRA OUTL6B
 TST ENTFLG
 BEQ *+6
 LDAA #'N
 BRA OUTL6B
 TST RELFLG
 BEQ *+6
 LDAA #'R
 BRA OUTL6B
 LDAA #$20
OUTL6B JSR OUTCHR
 JSR OUTS
 LDX CULINE
OUTL7 LDAA 0,X
 CMPA #$D
 BEQ OUTL8
 JSR OUTCHR
 INX
 BRA OUTL7
OUTL8 JSR CRLF
 CLR POP
 CLR MCOUNT
 CLR RELFLG
 RTS
BLANK FCB $20
 FCB $20
 FCB $20
BLANK3 FCB $20
 FCB $20
BLANK5 FCB $20
BLANK6 FCB $20
 FCB $20
 FCB $04
*
* CONVERT 16 BITS BINARY TO 5 DECIMAL CHARS
*
CVBTD STX SAVEX
 LDX #KIOK
CVDEC1 CLR SAVEA
CVDEC2 SUBB 1,X
 SBCA 0,X
 BCS CVDEC5
 INC SAVEA
 BRA CVDEC2
CVDEC5 ADDB 1,X
 ADCA 0,X
 PSHA
 STX SAVEX1
 LDX SAVEX
 LDAA SAVEA
 ADDA #$30
 STAA 0,X
 PULA
 INX
 STX SAVEX
 LDX SAVEX1
 INX
 INX
 CPX #KIOK+10
 BNE CVDEC1
 RTS
KIOK FDB 10000
 FDB 1000
 FDB 100
 FDB 10
 FDB 1
SAVEA RMB 1
SAVEX RMB 2
SAVEX1 RMB 2
*
* PRINT ERRORS
*
ERNUM RMB 2
ERMSA FDB $0D0A
 FCC '**** ERROR# '
ERMSB RMB 3
 FCB $20
ERMSC RMB 5
 FCB $20
 FCC ':'
 FCB 4
PRINTE PSHA
 PSHB
 STX ERNUM
 LDAA LPTSW
 BEQ *+5
 INC CONSW
 LDAA ERNUM
 ADDA #$30
 STAA ERMSB
 LDAA ERNUM+1
 JSR OUTHL
 STAA ERMSB+1
 LDAA ERNUM+1
 JSR OUTHR
 STAA ERMSB+2
 LDX #ERMSC
 LDAA LNUM
 LDAB LNUM+1
 JSR CVBTD
 LDX #ERMSA
 JSR PDATA1
 LDX CULINE
PE2 LDAA 0,X
 PSHA
 JSR OUTCHR
 PULA
 CMPA #$D
 BEQ PE3
 INX
 CPX CUCHAR
 BNE PE2
PE3 JSR CRLF
 PULB
 PULA
 LDX ECOUNT
 INX
 STX ECOUNT
 CLR CONSW
 LDX ERNUM
 RTS
*
* PROCESS DIGSET OPCODE
*
DIGSPR JSR LKPSYM
 CMPB #$FF
 BNE DGSPR2
 LDX LNUM
 STX LC
 JSR STOSYM
 LDX #COMPL3
 JSR STR1
 LDX #DIGL1
 JSR STR1
DGSPR2 CLR FLPFLG
 JSR EVALS
 LDX #DIGL2
 JSR STR1
 JMP MAIN1
DIGL1 FCC ' EXT DIGSET'
 FCB $D
DIGL2 FCC ' JSR DIGSET'
 FCB $D
* PROCESS DSECTION OPCODE
DSECPR LDX #LABL+6
 JSR STR1
 LDAA OPTNS
 STAA DSCTMP
 ORAA #$50
 STAA OPTNS
 JMP MAIN1
* PROCESS DEND OPCODE
DENDPR LDAA DSCTMP
 STAA OPTNS
 JMP MAIN1
DSCTMP RMB 1
* PROCESS CSECTION OPCODE
CSECPR INC COMFLG
 LDX #LABL+6
 JSR STR1
 JMP MAIN1
* PROCESS CEND OPCODE
CENDPR CLR COMFLG
 LDX #LABL+6
 JSR STR1
 JMP MAIN1
* PROCESS DECLAIRE-STRING OPCODE
DSTPR INC DSTFLG
 BRA DIMPR
DSTFLG RMB 1
* PROCESS INTEGER OPCODE
INTPR BRA DIMPR
DEFPR COM FLPFLG
DIMPR LDAA OPTNS
 STAA PFLAG
 TST COMFLG
 BNE DPR1
 LDX LBLCNT
 INX
 STX LBLCNT
 LDX #BLOKL2
 LDAA LBLCNT
 LDAB LBLCNT+1
 JSR CVBTD
 LDX #BLOKL+6
 JSR STR1
DPR1 JSR NXTOK
 CMPB #1
 BNE DPR2A
DPR2 JSR LKPSYM
 CMPB #$FF
 BEQ DPR3
 BITB #$80
 BEQ DPR2A
 LDAA OPTNS
 ORAA #$50
 STAA OPTNS
 BRA DPR3A
DPR2A JMP DPR4
DPR3 LDX LNUM
 STX LC
 JSR STOSYM
DPR3A TST FLPFLG
 BEQ DEFP1
 LDX SYMPTR
 LDAA 8,X
 ORAA #8
 STAA 8,X
DEFP1 TST COMFLG
 BEQ DEFP1A
 LDX #CMNL1
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTNAM
 LDAA #',
 JSR WRTCHR
 LDAB #',
 JSR TPCHAR
 BRA DEFP1B
CMNL1 FCC ' CMN'
DEFP1A JSR OUTNAM
 LDX #RMBZ
 LDAA #3
 STAA CMPCNT
 JSR OUTCMP
DEFP1B JSR NXTOK
 CMPB #'(
 BEQ DPR5
 CMPA #$D
 BEQ DEFP2
 CMPB #',
 BNE DPR4
DEFP2 LDX #OPTLN
 CLRA
 LDAB #2
 TST FLPFLG
 BEQ DEFP3
 LDAB #9
 BRA DEFP3
DPR4 LDX #$0303
 JSR PRINTE
 JMP MAIN1
DPR5 LDAA FLPFLG
 PSHA
 CLR FLPFLG
 JSR NXTOK
 PULA
 STAA FLPFLG
 CMPB #9
 BNE DPR4
 LDX SYMPTR
 LDAA 8,X
 ORAA #2
 STAA 8,X
 JSR CVDB
 TST DSTFLG
 BEQ *+3
 INX
 STX VALUE
 BMI DPR4
 JSR NXTOK
DPR6 LDX SYMPTR
 LDAA VALUE
 STAA 6,X
 LDAA VALUE+1
 STAA 7,X
 CMPB #')
 BEQ *+5
 JMP DPR9
 LDAA VALUE
 LDAB VALUE+1
DPR7 LDX #OPTLN
 TST DSTFLG
 BNE DEFP3
 TST FLPFLG
 BEQ DPR7A
 LDX #C9
 JSR MPY16
 LDX #OPTLN
 TSTA
 BMI DPR4
 BRA DEFP3
C9 FDB 9
DPR7A ASLB
 ROLA
 BMI DPR4
DEFP3 JSR CVBTD
 LDX #OPTLN
 LDAA #5
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTCR
 LDAA PFLAG
 STAA OPTNS
 TST DSTFLG
 BEQ DEFP3A
 LDX SYMPTR
 LDAA 8,X
 ORAA #$40
 STAA 8,X
DEFP3A LDX DESCRA
 LDAA 0,X
 CMPA #',
 BEQ DEFP4
 CMPA #$D
 BEQ DPR8
 JSR NXTOK
 CMPB #',
 BNE DPR8
DEFP4 JMP DPR1
DPR8 TST COMFLG
 BNE DPR8A
 LDX #LABL+1
 LDAA LBLCNT
 LDAB LBLCNT+1
 JSR CVBTD
 LDX #LABL
 JSR STR1
DPR8A JMP MAIN1
DPR9 LDAA FLPFLG
 PSHA
 CLR FLPFLG
 JSR NXTOK
 PULA
 STAA FLPFLG
 CMPB #9
 BNE DPR11
 JSR CVDB
 STX VALUE
 BMI DPR11
 JSR NXTOK
DPR10 LDX SYMPTR
 LDAA 8,X
 ORAA #1
 STAA 8,X
 LDAA 6,X
 LDAB 7,X
 LDX #VALUE
 JSR MPY16
 TSTA
 BPL *+5
DPR11 JMP DPR4
 JMP DPR7
*
* HANDLE PRINT OPCODE
*
PRNTPR CLRB
 STAB WRFLG
 STAB FIOFLG
 JMP WPR0
* HANDLE INPUT OPCODE
INPPR CLR FIOFLG
 LDAB #$FF
 STAB WRFLG
 JMP WPR0
* HANDLE OPEN OPCODE
OPENPR JSR IOCBPR
 JSR NXTOK
 CMPB #$27
 BNE OPE1
 LDX #STRCL1
 JSR STR1
 JSR QUOT2
 BRA OPE1A
OPE1 LDX DESCRA
 STX CUCHAR
 JSR GETADR
OPE1A LDAB #174
OPE2 JSR RTBL
 JMP MAIN1
* HANDLE CLOSE OPCODE
CLOSPR JSR IOCBPR
 LDAB #177
 BRA OPE2
* HANDLE REWIND OPCODE
REWPR JSR IOCBPR
 LDAB #180
 BRA OPE2
* PROCESS READ OPCODE
WRFLG RMB 1
FIOFLG RMB 1
READPR LDAB #$FF
 STAB WRFLG
 STAB FIOFLG
 JSR IOCBPR
 JMP WPR0
READ2 CMPB #1
 BEQ READ3
 LDX #$0310
 JSR PRINTE
 JMP WPR0
READ3 JSR LKPSYM
 CMPB #$FF
 BEQ READ4
 BITB #8
 BEQ READ3A
 STAB GAFLG
 STAB FLPFLG
 JSR EVADIM+3
 LDAB #90
 TST FIOFLG
 BEQ *+4
 LDAB #186
 JSR RTBL
 TST ERNUM
 BEQ *+5
 JMP MAIN1
 JMP WPR3B
READ3A TSTB
 BPL READ3B
 LDAB #45
 TST FIOFLG
 BEQ *+4
 LDAB #183
 JSR RTBL
 LDX #STRL1
 JSR STR1
 LDAA #$FF
 STAA GAFLG
 JSR EVADIM+3
 JSR STRD2
 JMP WPR3B
READ3B BITB #3
 BEQ READ4
 LDAB #45
 TST FIOFLG
 BEQ *+4
 LDAB #183
 JSR RTBL
 JSR STRDIM
 JMP WPR3B
READ4 LDAB #45
 TST FIOFLG
 BEQ *+4
 LDAB #183
 JSR RTBL
 LDX #STRP1
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTNAM
 JSR OUTCR
 JSR DEFS
 BRA WPR0
*
* PROCESS WRITE OPCODE
*
WRITPR CLR WRFLG
 LDAB #$FF
 STAB FIOFLG
 JSR IOCBPR
WPR0 JSR NXTOK
 CMPB #')
 BEQ WPR0
 CMPB #$27
 BNE WPR1
 JSR QUOTPR
 BRA WPR0
WPR1 CMPB #'/
 BNE WPR2
 LDAB #42
 TST FIOFLG
 BEQ *+4
 LDAB #207
 TST WRFLG
 BEQ *+11
 LDAB #42
 TST FIOFLG
 BEQ *+4
 LDAB #201
 JSR RTBL
 BRA WPR0
WPR2 CMPB #$D
 BNE *+5
 JMP MAIN1
 CMPB #'>
 BNE WPR3
 CLR FLPFLG
 JSR EVALS
 LDAB #57
 TST FIOFLG
 BEQ *+4
 LDAB #204
 JSR RTBL
 JMP WPR3B
WPR3 CMPB #',
 BEQ WPR0
 CMPB #'[
 BNE FMT2
 CLR FLPFLG
 JSR EVALS
 LDX #STRP1
 JSR STR1
 LDX DESCRA
 LDAA 0,X
 CMPA #',
 BEQ FMT1
 LDX #COMPL2
 JSR STR1
 BRA *+5
FMT1 JSR EVALS
 LDAB #210
 JSR RTBL
 LDX DESCRA
 LDAA 0,X
 CMPA #']
 BEQ WPR4
 BRA WPR3B
FMT2 CMPB #'%
 BNE WPR3A
* HANDLE STRING IO
 JSR GETADR
 BEQ *+5
 JMP MAIN1
 LDAB #243
 TST FIOFLG
 BEQ *+4
 LDAB #246
 TST WRFLG
 BEQ WPR30
 LDAB #54
 TST FIOFLG
 BEQ *+4
 LDAB #189
WPR30 JSR RTBL
 BRA WPR3B
WPR3A TST WRFLG
 BEQ *+5
 JMP READ2
 LDX DESCRA
 STX CUCHAR
 JSR PRESCN
 JSR EVALS
 TST ERNUM
 BEQ *+5
 JMP MAIN1
 LDAB #48
 TST FIOFLG
 BEQ *+4
 LDAB #192
 TST FLPFLG
 BNE WPR3C
 JSR RTBL
 BRA WPR3B
WPR3C LDAB #87
 TST FIOFLG
 BEQ *+4
 LDAB #195
 JSR FUNOP
WPR3B LDX CUCHAR
 DEX
 STX CUCHAR
WPR4 JMP WPR0
*
* HANDLE QUOTED MATERIAL IN IO STMTS
*
QL1 FCC ' LDX #*+9'
 FCB $D
QL3 FCC ' FCC '
QUOTE FCB $27
 FCB $D
PDOT FCC '.'
QL4 FCC ' FCB $04'
 FCB $D
QUOTPR LDX #QL1
 JSR STR1
 LDAB #51
 TST FIOFLG
 BEQ *+4
 LDAB #198
 JSR RTBL
QUOT2 LDAA #4
 STAA CMPCNT
 LDX #FCL2
 JSR OUTCMP
 LDX LBLCNT
 INX
 STX LBLCNT
 STX BLKBOT
 LDAA PDOT
 STAA OPTLN
 LDX #OPTLN+1
 LDAA BLKBOT
 LDAB BLKBOT+1
 JSR CVBTD
 BSR QPR1
 JSR OUTCR
 LDX #QL3
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 LDAA #$27
 JSR WRTCHR
 LDAB #$27
 JSR TPCHAR
 JSR FCCB
 LDX #QUOTE
 JSR STR1
 LDX #QL4
 JSR OUTCMP
 BSR QPR1
 LDX #LABL+7
 LDAA #5
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTCR
 LDX CUCHAR
 INX
 STX CUCHAR
 RTS
QPR1 LDX #OPTLN
 LDAA #6
 STAA CMPCNT
 JMP OUTCMP
IOCBPR JSR NXTOK
 CMPB #'(
 BNE IOCERR
 JSR GETADR
 BNE IOCERR
 LDAB #234
 JSR RTBL
 JSR NXTOK
 CMPB #')
 BEQ IOCB2
 LDX DESCRA
 STX CUCHAR
IOCB2 RTS
IOCERR LDX #$0334
 JSR PRINTE
 INS
 INS
 JMP MAIN1
*
* POKE OPCODE HANDLER
*
POKEPR CLR FLPFLG
 JSR EVALS
 TST ERNUM
 BNE POKES
 LDX #STRL1
 JSR STR1
 CLR FLPFLG
 JSR EVALS
 TST ERNUM
 BNE POKES
 LDAB #84
 JSR RTBL
POKES JMP MAIN1
* DEFINE STORAGE FOR VARIABLE
DEFS JSR LKPSYM
 CMPB #$FF
 BEQ DEFS2
 RTS
DEFS2 LDX LNUM
 STX LC
 JSR STOSYM
 LDX #DEFSL1
 JSR STR1
 LDX DESCRA
 LDAA DESCRC
 STAA CMPCNT
 JSR OUTCMP
 LDX #DEFSL2
 JSR STR1
 CLRB
 LDX #$0000
 RTS
DEFSL1 FCC ' BRA *+4'
 FCB $D
DEFSL2 FCC 'RMB 2'
 FCB $D
*
* ADDRESS TYPE 1
*
ADDR1 JSR ADRINT
 JSR NXTOK
 CMPB #$D
 BNE ADDR1B
ADDR1A LDX #$0204
 JSR PRINTE
 BRA ADDR1E
ADDR1B JSR ABRCK
 LDAB ABR
 BEQ ADDR1A
 JSR NXTOK
 CMPB #'#
 BNE ADDR1C
 COM IMMED
 JSR NXTOK
 CMPB #$27
 BNE ADDR1C
 LDX CUCHAR
 LDAA 0,X
 STAA ADR2
 BRA ADDR1K
ADDR1C JSR NSEVL
 JSR P2ERR
 LDAB IMMED
 BEQ ADDR1D
ADDR1K LDAB #$80
 STAB ORBYA
 LDAB #$C0
 STAB ORBYB
 BRA ADDR1H
ADDR1D JSR NXTOK
 JSR INXCK
 BNE ADDR1G
 TST CMNFLG
 BNE ADDR1L
 TST RELFLG
 BNE ADDR1L
 LDAB ADR1
 BEQ ADDR1F
ADDR1L LDAB #$B0
 STAB ORBYA
 LDAB #$F0
 STAB ORBYB
ADDR1E JSR LCNAB3
 BRA ADDR1J
ADDR1F LDAB #$90
 STAB ORBYA
 LDAB #$D0
 STAB ORBYB
 BRA ADDR1H
ADDR1G LDAB #$A0
 STAB ORBYA
 LDAB #$E0
 STAB ORBYB
ADDR1H JSR LCNAB2
ADDR1J JSR LCLCN
 JMP MAIN1
*
* ADDRESS TYPE 2
*
ADDR2 JSR ADRINT
 JSR NXTOK
 CMPB #$D
 BNE ADDR2B
ADDR2A LDX #$0204
 JSR PRINTE
 BRA ADDR2E
ADDR2B JSR ABRCK
 LDAB ABR
 BEQ ADDR2A
 JSR NXTOK
 JSR NSEVL
 JSR P2ERR
 JSR NXTOK
 JSR INXCK
 BNE ADDR2G
 TST CMNFLG
 BNE ADDR2K
 TST RELFLG
 BNE ADDR2K
 LDAB ADR1
 BEQ ADDR2F
ADDR2K LDAB #$B0
 STAB ORBYA
 LDAB #$F0
 STAB ORBYB
ADDR2E JSR LCNAB3
 BRA ADDR2J
ADDR2F LDAB #$90
 STAB ORBYA
 LDAB #$D0
 STAB ORBYB
 BRA ADDR2H
ADDR2G LDAB #$A0
 STAB ORBYA
 LDAB #$E0
 STAB ORBYB
ADDR2H JSR LCNAB2
ADDR2J JSR LCLCN
 JMP MAIN1
*
* ADDRESS TYPE 3
*
ADDR3 JSR ADRINT
 JSR NXTOK
 CMPB #$D
 BNE ADDR3B
 LDX #$0204
 JSR PRINTE
 BRA ADDR3D
ADDR3B JSR ABRCK
 TST ABR
 BEQ ADDR3C
 LDAB #$40
 STAB ORBYA
 LDAB #$50
 STAB ORBYB
 JSR LCNAB1
 BRA ADDR3F
ADDR3C JSR NSEVL
 JSR P2ERR
 JSR NXTOK
 JSR INXCK
 BNE ADDR3E
 LDAB #$70
 STAB ORBYA
ADDR3D JSR LCN3
 BRA ADDR3F
ADDR3E LDAB #$60
 STAB ORBYA
 JSR LCN2
ADDR3F JSR LCLCN
 JMP MAIN1
*
* ADDRESS TYPE 4
*
ADDR4 JSR ADRINT
 JSR NXTOK
 JSR ABRCK
 TST ABR
 BNE ADDR4A
 LDX #$0204
 JSR PRINTE
ADDR4A INC ORBYB
 JSR LCNAB1
 JSR LCLCN
 JMP MAIN1
*
* ADDRESS TYPE 5
*
ADDR5 JSR ADRINT
 JSR NXTOK
 CMPB #$D
 BNE ADDR5B
ADDR5A LDX #$0240
 JSR PRINTE
 BRA ADDR5E
ADDR5B CMPB #'#
 BNE ADDR5C
 COM IMMED
 JSR NXTOK
 CMPB #$27
 BNE ADDR5C
 LDX CUCHAR
 LDAA 0,X
 STAA ADR1
 LDAA 1,X
 STAA ADR2
 BRA ADDR5E
ADDR5C JSR NSEVL
 JSR P2ERR
 LDAB IMMED
 BNE ADDR5E
ADDR5D JSR NXTOK
 JSR INXCK
 BNE ADDR5G
 TST CMNFLG
 BNE ADDR5K
 TST RELFLG
 BNE ADDR5K
 LDAB ADR1
 BEQ ADDR5F
ADDR5K LDAB #$30
 STAB ORBYA
ADDR5E JSR LCN3
 BRA ADDR5J
ADDR5F LDAB #$10
 STAB ORBYA
 BRA ADDR5H
ADDR5G LDAB #$20
 STAB ORBYA
ADDR5H JSR LCN2
ADDR5J JSR LCLCN
 JMP MAIN1
*
* ADDRESS TYPE 6
*
ADDR6 JSR ADRINT
 JSR NXTOK
 CMPB #$D
 BNE ADDR5C
 BRA ADDR5A
*
* ADDRESS TYPE 7
*
ADDR7 JSR ADRINT
 JSR NXTOK
 CMPB #$D
 BNE ADDR7A
 LDX #$0204
 JSR PRINTE
 BRA ADDR7B
ADDR7A JSR NSEVL
 JSR P2ERR
 JSR NXTOK
 JSR INXCK
 BNE ADDR7C
ADDR7B LDAB #$10
 STAB ORBYA
 JSR LCN3
 BRA ADDR7D
ADDR7C JSR LCN2
ADDR7D JSR LCLCN
 JMP MAIN1
*
* ADDRESS TYPE 8
ADDR8 JSR ADRINT
 JSR NXTOK
 CMPB #$D
 BNE ADDR8A
 LDX #$0204
 JSR PRINTE
 BRA ADDR8D
ADDR8A TST PASS
 BEQ ADDR8D
 JSR NSEVL
 JSR P2ERR
 LDX LC
 INX
 INX
 STX LSAVE
 LDAA ADR2
 LDAB ADR1
 SUBA LSAVE+1
 SBCB LSAVE
 CMPB #$FF
 BNE ADDR8E
 TSTA
 BMI ADDR8C
ADDR8E CMPB #0
 BNE ADDR8F
 TSTA
 BPL ADDR8C
ADDR8F LDX #$0208
 JSR PRINTE
ADDR8C STAA ADR2
ADDR8D JSR LCN2
 JSR LCLCN
 JMP MAIN1
*
* ADDRESS TYPE 9
*
ADDR9 JSR ADRINT
 TST PASS
 BEQ ADDR9A
 JSR OUTBIN
ADDR9A INC MCOUNT
 INC LCN
 JSR PRINTL
 JSR LCLCN
 JMP MAIN1
ABR RMB 1
IMMED RMB 1
INDEX RMB 1
ORBYA RMB 1
ORBYB RMB 1
ADRINT CLR LCN
 CLR RELFLG
 CLR CMNFLG
 CLR EXTFLG
 CLR ENTFLG
 CLR POP
 STAB OPCD
 CLR MCOUNT
 CLR ABR
 CLR IMMED
 CLR INDEX
 CLR ADR1
 CLR ADR2
 CLR ORBYA
 CLR ORBYB
 RTS
ABRCK CMPB #'A
 BEQ ABRCKA
 CMPB #'B
 BEQ ABRCKA
 RTS
ABRCKA STAB ABR
 RTS
INXCK CMPB #',
 BNE INXCKR
 JSR NXTOK
 CMPB #'X
 BNE INXCKR
 COM INDEX
 RTS
INXCKR CLR INDEX
 RTS
P2ERR CMPB #$FF
 BNE P2ERRB
 TST PASS
 BEQ *+5
 JSR PRINTE
 CLR ADR1
 COM ADR1
P2ERRB RTS
LCNAB1 TST PASS
 BEQ LNAB1S
 LDAB OPCD
 LDAA ABR
 BEQ LNAB10
 CMPA #'B
 BEQ LNAB1B
 ORAB ORBYA
 BRA LNAB1C
LNAB1B ORAB ORBYB
LNAB1C STAB OPCD
LNAB10 JSR OUTBIN
 INC MCOUNT
 JSR PRINTL
LNAB1S INC LCN
 RTS
LCNAB2 TST PASS
 BEQ LCN2B
 LDAB OPCD
 LDAA ABR
 BEQ LCN2A
 CMPA #'B
 BEQ LNB2
 ORAB ORBYA
 BRA LNAB2S
LNB2 ORAB ORBYB
LNAB2S STAB OPCD
 BRA LCN2A
LCN2 TST PASS
 BEQ LCN2B
 CLR RELFLG
 LDAB OPCD
 ORAB ORBYA
 STAB OPCD
LCN2A JSR OUTBIN
 LDAB ADR2
 JSR OUTBIN
 INC MCOUNT
 INC MCOUNT
 JSR PRINTL
LCN2B INC LCN
 INC LCN
 RTS
LCNAB3 TST PASS
 BEQ LCN3B
 LDAB OPCD
 LDAA ABR
 BEQ LCN3A
 CMPA #'B
 BEQ LNB3
 ORAB ORBYA
 BRA LNAB3S
LNB3 ORAB ORBYB
LNAB3S STAB OPCD
 BRA LCN3A
LCN3 TST PASS
 BEQ LCN3B
 LDAB OPCD
 ORAB ORBYA
 STAB OPCD
LCN3A JSR OUTBIN
 LDAB ADR1
 JSR OUTBIN
 LDAB ADR2
 JSR OUTBIN
 TST CMNFLG
 BEQ *+6
 LDAB #'M
 BRA *+9
 TST RELFLG
 BEQ *+7
 LDAB #'R
 JSR OUTBNR
 INC MCOUNT
 INC MCOUNT
 INC MCOUNT
 JSR PRINTL
LCN3B INC LCN
 INC LCN
 INC LCN
 RTS
LCLCN LDAA LC+1
 LDAB LC
 ADDA LCN
 ADCB #0
 STAA LC+1
 STAB LC
 RTS
POCMN JSR ADRINT
 JSR LBLCK
 JSR NXTOK
 CMPB #1
 BEQ POCMN2
POCMN0 LDX #$0216
POCMN1 JSR PRINTE
 BRA POCMN4
POCMN2 TST PASS
 BNE POCMN3
 JSR STOSYM
 LDX SYMPTR
 STX CMNXS
 JSR NXTOK
 CMPB #',
 BNE POCMN0
 JSR NXTOK
 JSR NSEVL
 CMPB #$FF
 BEQ POCMN1
 LDX CMNXS
 LDAA #$BF
 ANDA 8,X
 ORAA #$10
 STAA 8,X
 LDAA CMNLC
 STAA 6,X
 LDAA CMNLC+1
 STAA 7,X
 LDAA ADR2
 LDAB ADR1
 ADDA CMNLC+1
 ADCB CMNLC
 STAA CMNLC+1
 STAB CMNLC
POCMN3 JSR LKPSYM
 LDX SYMPTR
 LDX 6,X
 STX ADR1
 COM POP
 COM CMNFLG
 INC MCOUNT
 INC MCOUNT
POCMN4 JSR PRINTL
 JMP MAIN1
CMNXS RMB 2
*
* PROCESS END OPCODE
*
POEND JSR ADRINT
 JSR LBLCK
POEND0 TST PASS
 BNE POEND1
 LDX LC
 STX TSTPH
 COM PASS
 JSR REWIND
 JMP PASS2
POEND1 TST CFLAG
 BEQ ENDP1
 LDX CULINE
 JSR STR1
 LDX LC
 STX TSTPH
POEND2 LDX BLKCNT
 CPX #BLKEND
 BGE ENDP1
 LDX #$0306
 JSR PRINTE
ENDP1 LDX TSTPH
 CPX LC
 BEQ ENDP2
 LDX #$0220
 JSR PRINTE
ENDP2 LDAA OPTNS
 BITA #$80
 BNE ENDP3
 TST CFLAG
 BNE *+5
 JSR PRINTL
 JSR SPACER
ENDP3 LDAA OPTNS
 BITA #$20
 BEQ SORT1
*
* LIST SYMBOL TABLE
*
 JMP ENDP6
SORT1  LDX #ZZZ
 STX CBLOCK
 CLR SORTF
 LDAA OPTNS
 ANDA #$7F
 STAA OPTNS
 LDX SYMTAB
 STX SYMPTR
 BRA SORT2A
SORT2 JSR SYMMOD
 CPX SYMTAB
 BNE SORT2A
 TST SORTF
 BNE SORT5
 JMP ENDP6
SORT2A LDAB 0,X
 CMPB #$20
 BEQ SORT2
 LDAB 8,X
 CMPB #$FF
 BEQ SORT2
 LDAA #$FF
 STAA SORTF
 STX CXS2
 STX PSTNG2
 LDX CBLOCK
 STX PSTNG1
 LDAB #6
 STAB PCOUNT
 LDX #PSTNG1
 JSR COMPAR
 BHI SORT4
 LDX CXS2
 BRA SORT2
SORT4 LDX CXS2
 STX CBLOCK
 BRA SORT2
SORT5 LDAB #6
 LDX CBLOCK
ENDP4 LDAA 0,X
 JSR OUTCHR
 INX
 DECB
 BNE ENDP4
 JSR OUTS
 STX XSAV
 LDAA 0,X
 LDAB 1,X
 LDX #LINEN
 JSR CVBTD
 LDX #LINEN
 JSR PDATA1
 LDX XSAV
 JSR OUT4HS
 STX ENDXS
 LDAB 0,X
 BITB #$80
 BEQ *+7
 LDAA #'P
 JSR OUTCHR
 BITB #$40
 BEQ *+14
 LDAA #'R
 TST CFLAG
 BEQ *+4
 LDAA #'S
 JSR OUTCHR
 BITB #$20
 BEQ *+7
 LDAA #'M
 JSR OUTCHR
 BITB #$10
 BEQ *+7
 LDAA #'C
 JSR OUTCHR
 BITB #8
 BEQ *+12
 TST CFLAG
 BNE *+7
 LDAA #'X
 JSR OUTCHR
 BITB #4
 BEQ *+7
 LDAA #'N
 JSR OUTCHR
 TST CFLAG
 BEQ ENDP4B
 BITB #3
 BEQ *+7
 LDAA #'D
 JSR OUTCHR
 BITB #8
 BEQ ENDP4B
 LDAA #'F
 JSR OUTCHR
ENDP4B LDAA 0,X
 BPL ENDP5
 TST CFLAG
 BNE ENDP5
 LDX #REDEF
 JSR PDATA1
ENDP5 LDX ENDXS
 LDAB #$FF
 STAB 0,X
 JSR CRLF
 JMP SORT1
ZZZ FCC '[[[[[['
 FDB 0000
 FCB 0
CBLOCK RMB 2
CXS2 RMB 2
SORTF RMB 1
ENDP6 LDX #ENDMB
 LDAA ECOUNT
 LDAB ECOUNT+1
 JSR CVBTD
 LDAA CMNLC
 LDAB CMNLC+1
 LDX #CMNSG
 JSR CVBTD
 JSR SPACER
 LDX #ENDMA
 JSR PDATA1
 JMP FLXCAL
REDEF FCC ' REDEFINED'
 FCB 4
ENDMA FDB $0D0A
 FDB $0D0A
 FCC 'THERE WERE: '
ENDMB RMB 5
 FCC ' ERRORS'
 FDB $0D0A
 FDB $0D0A
 FCC 'COMMON LENGTH= '
CMNSG RMB 5
 FCC '.'
 FDB $0D0A
 FCB 4
ENDXS RMB 2
*
* PROCESS ENTRY OPCODE
*
POENT JSR ADRINT
 JSR LBLCK
 JSR NXTOK
 CMPB #1
 BEQ POENT1
 LDX #$0216
 JSR PRINTE
 BRA POENT3
POENT1 TST PASS
 BEQ POENT4
 JSR LKPSYM
 CMPB #$FF
 BNE POENT2
 LDX #$0211
 JSR PRINTE
 BRA POENT3
POENT2 STX ADR1
 LDX SYMPTR
 LDAA 8,X
 ORAA #4
 STAA 8,X
 BSR PBLOCK
 LDAB ADR1
 JSR OUTBIN
 LDAB ADR2
 JSR OUTBIN
 LDAB #'R
 JSR OUTBNR
 LDAB #'N
 JSR OUTBNR
POENT3 COM POP
 COM ENTFLG
 INC MCOUNT
 INC MCOUNT
 JSR PRINTL
POENT4 JMP MAIN1
PBLOCK LDX SYMPTR
 LDAA #6
PBLK2 LDAB 0,X
 PSHA
 STX PBXS
 JSR OUTBIN
 PULA
 LDX PBXS
 INX
 DECA
 BNE PBLK2
 RTS
PBXS RMB 2
*
* PROCESS EQU OPCODE
*
POEQU JSR ADRINT
 LDX SYMPTR
 STX EQUXS
 TST LBFLG
  BEQ EQUE
EQUB  JSR NXTOK
 CMPB #$D
 BNE EQUC
 LDX #$0216
EQUA JSR PRINTE
 BRA EQUE
EQUC JSR NSEVL
 CMPB #$FF
 BEQ EQUA
 TST PASS
 BNE EQUD
 LDX EQUXS
 LDAA 8,X
 TST RELFLG
 BNE EQUF
 ANDA #$BF
 TST CMNFLG
 BEQ EQUF
 ORAA #$10
EQUF STAA 8,X
 LDAA ADR2
 STAA 7,X
 LDAA ADR1
 STAA 6,X
EQUD COM POP
 INC MCOUNT
 INC MCOUNT
EQUE JSR PRINTL
 JMP MAIN1
EQUXS RMB 2
*
* PROCESS EXTERNAL OPCODE
*
POEXT JSR ADRINT
 JSR LBLCK
 JSR NXTOK
 CMPB #1
 BEQ POEXT1
 LDX #$0216
 JSR PRINTE
 JSR PRINTL
 BRA POEXT4
POEXT1 INC LCN
 INC LCN
 INC LCN
 TST PASS
 BNE POEXT2
 JSR STOSYM
 LDX SYMPTR
 LDAA 8,X
 ORAA #8
 STAA 8,X
 BRA POEXT3
POEXT2 LDAB #$7E
 STAB OPCD
 JSR OUTBIN
 JSR LKPSYM
 JSR PBLOCK
 LDAB #'X
 JSR OUTBNR
 CLR ADR1
 CLR ADR2
 INC MCOUNT
 INC MCOUNT
 INC MCOUNT
 COM EXTFLG
 JSR PRINTL
POEXT3 JSR LCLCN
POEXT4 JMP MAIN1
*
* PROCESS FCB OPCODE
*
POFCB JSR ADRINT
 JSR NXTOK
 CMPB #$D
 BNE FCBB
FCBA LDX #$0216
 JSR PRINTE
 BRA FCBC
FCBB JSR NSEVL
 JSR P2ERR
 INC LCN
 TST PASS
 BEQ FCBD
 LDAB ADR2
 JSR OUTBIN
 INC MCOUNT
 INC POP
FCBC JSR PRINTL
FCBD JSR LCLCN
 JMP MAIN1
*
* PROCESS FCC OPCODE
*
POFCC JSR ADRINT
 JSR NXTOK
 CMPB #$27
 BEQ FCCB
FCCA LDX #$0204
 JSR PRINTE
 BRA FCCG
FCCB LDX CUCHAR
 LDAB 0,X
 CMPB #$D
 BEQ FCCA
 STAB ADR2
FCCC TST PASS
 BEQ FCCD
 TST CFLAG
  BEQ FCC1
 PSHB
 JSR TPCHAR
 PULA
 JSR WRTCHR
 BRA FCCD
FCC1 JSR OUTBIN
FCCD LDX CUCHAR
 INX
 STX CUCHAR
 INC LCN
 LDAB 0,X
 CMPB #$27
 BEQ FCCE
 CMPB #$D
 BNE FCCC
 BRA FCCF
FCCE LDAB 1,X
 CMPB #$27
 BNE FCCF
 TST CFLAG
 BEQ FCC2
 PSHB
 JSR TPCHAR
 PULA
 PSHA
 JSR WRTCHR
 PULB
FCC2 INX
 STX CUCHAR
 BRA FCCC
FCCF TST CFLAG
 BEQ *+3
 RTS
 INC POP
 INC MCOUNT
FCCG JSR PRINTL
 JSR LCLCN
 JMP MAIN1
*
* PROCESS FDB OPCODE
*
POFDB JSR ADRINT
 JSR NXTOK
 CMPB #$D
 BNE FDBB
FDBA LDX #$0216
 JSR PRINTE
 BRA FDBC
FDBB JSR NSEVL
 JSR P2ERR
 INC LCN
 INC LCN
 TST PASS
 BEQ FDBD
 LDAB ADR1
 JSR OUTBIN
 LDAB ADR2
 JSR OUTBIN
 TST RELFLG
 BEQ FDBF
 LDAB #'R
 BRA FDBG
FDBF TST CMNFLG
 BEQ FDBE
 LDAB #'M
FDBG JSR OUTBNR
FDBE INC MCOUNT
 INC MCOUNT
 COM POP
FDBC JSR PRINTL
FDBD JSR LCLCN
 JMP MAIN1
*
* PROCESS FFP OPCODE
*
POFFP JSR ADRINT
 INC FLPFLG
 JSR NXTOK
 CMPB #$F
 BNE FDBA
 LDAA #9
 STAA LCN
 TST PASS
 BEQ FDBD
 LDX FTEMP
 STX ADR1
 LDX #FTEMP
 JSR PBLK2
 BRA FDBE
*
* PROCES A FUNCTION IN STRUBAL
*
POFUNC JSR ADRINT
 CLR CMFLG
 CLR MACERR
 LDX #LABL+6
 JSR STR1
 JSR NXTOK
 CMPB #1
 BEQ POFNC3
POFNC2 LDX #$0340
 JSR PRINTE
 JMP MAIN1
POFNC3 JSR LKPSYM
 CMPB #$FF
 BNE POFNC2
 JSR STOSYM
 JSR XREF
 JMP POMAC1
POIFC JSR ADRINT
 JSR LBLCK
 JSR NXTOK
 CMPB #$D
 BNE POIFB
POIFA LDX #$0216
 JSR PRINTE
 BRA POIFE
POIFB JSR NSEVL
 CMPB #$FF
 BEQ POIFA
 JSR PSHIF
 TST CIFFLG
 BEQ POIFE
 LDX ADR1
 BNE POIFD
 CLR CIFFLG
 BRA POIFE
POIFD LDAA #$FF
 STAA CIFFLG
POIFE JSR PRINTL
 JMP MAIN1
CMFLG RMB 1
MACERR RMB 1
POMAC JSR ADRINT
 JSR PRINTL
 CLR CMFLG
 CLR MACERR
 TST PASS
 BNE POMAC2
 TST LBFLG
 BNE POMAC1
 COM MACERR
 LDX #$0226
 JSR PRINTE
 BRA POMAC2
POMAC1 LDX SYMPTR
 LDAA #$20
 STAA 8,X
 LDAA MACPTR
 STAA 6,X
 LDAA MACPTR+1
 STAA 7,X
POMAC3 JSR NXTOK
 CMPA #4
 BEQ POMAC3
 LDX DESCRA
 LDAA 0,X
 CMPA #'C
 BNE *+5
 COM CMFLG
POMAC2 JSR RDLINA
 LDX LNUM
 INX
 STX LNUM
 JSR PRINTL
 LDX CULINE
 LDAA 0,X
 CMPA #'*
 BNE POMAC5
 TST CMFLG
 BEQ POMAC2
 JSR MACMOV
 BRA POMAC2
POMAC5 CLR LBFLG
 LDX CULINE
 LDAA 0,X
 CMPA #$20
 BEQ POMAC6
 JSR NXTOK
 COM LBFLG
POMAC6 JSR NXTOK
 LDAA #4
 STAA PCOUNT
 LDX DESCRA
 STX PSTNG1
 LDX #MEND
 TST CFLAG
 BEQ *+5
 LDX #FEND
 STX PSTNG2
 LDX #PSTNG1
 JSR COMPAR
 BNE POMAC8
 TST LBFLG
 BEQ POMAC7
 LDX #$0227
 JSR PRINTE
 BRA POMAC7
POMAC8 JSR MACMOV
 JMP POMAC2
POMAC7 TST CFLAG
 BNE *+7
 TST PASS
 BNE POMACA
 LDAA #$17
 LDX MACPTR
 STAA 0,X
 INX
 STX MACPTR
POMACA JMP MAIN1
MACMOV TST CFLAG
 BNE *+7
 TST PASS
 BNE MACMVE
 TST MACERR
 BNE MACMVE
 LDX CULINE
 STX CUCHAR
MACLOP LDX CUCHAR
 LDAA 0,X
 INX
 STX CUCHAR
 LDX MACPTR
 CPX MACEND
 BNE MACMV1
 LDAA #$D
 STAA 0,X
 INX
 STX MACPTR
 LDX #$0228
 JSR PRINTE
 BRA MACMVE
MACMV1 STAA 0,X
 INX
 STX MACPTR
 CMPA #$D
 BNE MACLOP
MACMVE RTS
MEND FCC 'MEND'
FEND FCC 'FEND'
*
* PROCESS NAM OPCODE
*
PONAM JSR ADRINT
 JSR LBLCK
 JSR NXTOK
 CMPB #1
 BEQ PONAM1
 LDX #$0216
 JSR PRINTE
 JMP POENT3
PONAM1 TST PASS
 BNE PONAM2
 JSR STOSYM
 JMP POENT1
PONAM2 LDAB CMNLC
 JSR OUTBIN
 LDAB CMNLC+1
 JSR OUTBIN
 LDAB #'P
 JSR OUTBNR
 JMP POENT1
PONIF JSR ADRINT
 JSR LBLCK
 BSR PULIF
 JSR PRINTL
 JMP MAIN1
PSHIF TPA
 PSHA
 SEI
 STS STKSAV
 LDX @IFSTK
 CPX #IFSTK-8
 BEQ PSPLER
 LDS @IFSTK
 LDAA CIFFLG
 PSHA
 BRA PSPLCM
PULIF TPA
 PSHA
 SEI
 STS STKSAV
 LDX @IFSTK
 CPX #IFSTK
 BEQ PSPLER
 LDS @IFSTK
 PULA
 STAA CIFFLG
 BRA PSPLCM
PSPLER LDX #$0254
 JSR PRINTE
 BRA *+5
PSPLCM STS @IFSTK
 LDS STKSAV
 PULA
 TAP
 RTS
*
* PROCESS PAG OPCODE
*
POPAG JSR ADRINT
 JSR LBLCK
 TST PASS
 BEQ PAGEND
 LDAB LCOUNT
 BEQ PAGEND
 JSR SPACER
 CLR LCOUNT
PAGEND JMP MAIN1
*
* PROCESS RMB OPCODE
*
PORMB JSR ADRINT
 JSR NXTOK
 CMPB #$D
 BNE RMBB
 LDX #$0216
RMBA JSR PRINTE
 BRA RMBC
RMBB JSR NSEVL
 CMPB #$FF
 BEQ RMBA
 TST PASS
 BEQ RMBD
 JSR RMBOUT
 INC MCOUNT
 INC MCOUNT
 COM POP
RMBC JSR PRINTL
RMBD LDAA LC+1
 LDAB LC
 ADDA ADR2
 ADCB ADR1
 STAA LC+1
 STAB LC
 JMP MAIN1
RMBOUT CLRB
 LDX ADR1
 STX LSAVE
RMBOTA JSR OUTBIN
 LDX LSAVE
 DEX
 BEQ RMBOTB
 STX LSAVE
 CLRB
 BRA RMBOTA
RMBOTB RTS
*
* PROCESS SET OPCODE
*
SETXS RMB 2
POSET JSR ADRINT
 LDX CULINE
 STX CUCHAR
 LDAA 0,X
 CMPA #$20
 BNE SETC
SETA LDX #$0213
SETB JSR PRINTE
 JMP SETF
SETC JSR NXTOK
 JSR LKPSYM
 CMPB #$FF
 BNE SETD
 JSR STOSYM
SETD JSR XREF
 LDX SYMPTR
 STX SETXS
 JSR NXTOK
 JSR NXTOK
 JSR NSEVL
 CMPB #$FF
 BNE SETD1
 LDX #$0216
 BRA SETB
SETD1 LDX SETXS
 LDAA 8,X
 TST RELFLG
 BNE SETE
 ANDA #$BE
 TST CMNFLG
 BEQ SETE
 ORAA #$10
SETE STAA 8,X
 LDAA ADR1
 STAA 6,X
 LDAA ADR2
 STAA 7,X
 COM POP
 INC MCOUNT
 INC MCOUNT
SETF JSR PRINTL
 JMP MAIN1
*
* HANDLE COMPARISON OPERATIONS
*
EQPR LDX #EQLN
EVAL21 JSR CHKBIN
 STX COMPL+1
 BRA CMPR
EQLN FCC ' BEQ *+7'
 FCB $D
GEPR LDX #GELN
 BRA EVAL21
GELN FCC ' BGE *+7'
 FCB $D
GTPR LDX #GTLN
 BRA EVAL21
GTLN FCC ' BGT *+7'
 FCB $D
LEPR LDX #LELN
 BRA EVAL21
LELN FCC ' BLE *+7'
 FCB $D
LTPR LDX #LTLN
 BRA EVAL21
LTLN FCC ' BLT *+7'
 FCB $D
NEPR LDX #NELN
 BRA EVAL21
NELN FCC ' BNE *+7'
 FCB $D
CMPR TST FLPFLG
 BEQ CMPR1
 JSR FUNOP2
 JSR STAKDN
 LDAB #108
 JSR FUNOP
 BRA CMPR2
CMPR1 CLR COMPL
 COM COMPL
 LDAB #24
 STAB TMPVAL
 JSR BINOP2
CMPR2 LDX COMPL+1
 JSR STR1
 LDX #COMPL2
 JSR STR1
 LDX #COMPL3
 JSR STR1
 LDX #COMPL5
 JSR STR1
 JMP UNOP4
COMPL RMB 3
COMPL2 FCC ' LDX #0'
 FCB $D
COMPL3 FCC ' BRA *+5'
 FCB $D
COMPL4 FCC ' LDX #1'
 FCB $D
COMPL5 FCC ' LDX #$FFFF'
 FCB $D
*
* PROCESS RETURN OPCODE
*
RETPR LDX #ZRTS
 JSR STR1
 JMP MAIN1
ZRTS FCC ' RTS'
 FCB $D
*
* PROCESS STOP OPCODE
*
STOPPR LDAB #237
 JSR RTBL
 JMP MAIN1
*
* HANDLE IF THEN ELSE OPCODE
*
IFPR JSR PRESCN
 JSR EVALS
 TST ERNUM
 BNE IFPR4
IFPR0 JSR MNLKP
 TSTA
  BNE IFPR3
 CPX #IFPR2
 BEQ IFPR2
 JMP IFSTMT
IFPR2 JSR NXTOK
 CMPB #1
 BEQ IFPR2A
IFPR3 LDX #$0308
 JSR PRINTE
IFPR4 JMP MAIN1
IFPR2A LDX #IFL1
 JSR STR1
 LDX #JMPZ
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTNAM
 JSR OUTCR
 JSR XREF
 JSR NXTOK
 CMPB #$D
 BEQ IFPR4
 JSR MNLKP
 TSTA
 BNE IFPR3
 CPX #IFPR3
 BNE IFPR3
 JSR NXTOK
 CMPB #1
 BNE IFPR3
 LDX #JMPZ
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTNAM
 JSR OUTCR
 JSR XREF
 JMP MAIN1
IFL1 FCC ' BEQ *+5'
 FCB $D
IFSTMT COM IFFLG
 LDX LBLCNT
 INX
 STX LBLCNT
 STX IFLBL
 LDX #WHPRL2
 JSR STR1
 LDX #BLOKL2
 LDAA IFLBL
 LDAB IFLBL+1
 JSR CVBTD
 LDX #BLOKL+6
 JSR STR1
 LDAB #$20
 JSR TPCHAR
 LDAA #$20
 JSR WRTCHR
 JMP COMP2
IFL2 FCC ' BEQ .'
 RMB 5
 FCB $D
*
* HANDLE WHILE OPCODE
*
WHILPR LDX #LABL+6
 JSR STR1
 LDX LBLCNT
 INX
 STX LBLCNT
 LDAA LBLCNT
 LDAB LBLCNT+1
 LDX #LABL+1
 JSR CVBTD
 LDX #LABL
 JSR STR1
 LDX LBLCNT
 INX
 STX LBLCNT
 TPA
 PSHA
 SEI
 STS STKTOP
 LDS BLKCNT
 LDAA LBLCNT
 PSHA
 LDAA LBLCNT+1
 PSHA
 TSX
 DEX
 LDS STKTOP
 PULA
 TAP
 CPX #BLKSTR
 BNE WHPR2
 LDX #$0305
 JSR PRINTE
WHPR1 JMP MAIN1
WHPR2 STX BLKCNT
 JSR PRESCN
 JSR EVALS
 LDX #WHPRL2
 JSR STR1
 LDX #JMPZ
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 LDX #WHPRL+1
 LDAA LBLCNT
 LDAB LBLCNT+1
 JSR CVBTD
 LDX #WHPRL
 JSR STR1
 BRA WHPR1
WHPRL FCC '.'
 RMB 5
 FCC '+3'
 FCB $D
WHPRL2 FCC ' BNE *+5'
 FCB $D
*
* PRESCAN ROUTINE TO FIND EXPRESSION TYPE
*
PRESCN LDX CUCHAR
 STX AX
 LDAA #$FF
 STAA FLPFLG
PRES2 JSR NXTOK
 CMPB #$D
 BEQ PRERTN
 CMPB #1
 BNE PRES3
 JSR MNLKP
 TSTA
 BNE PRES2A
 LDX DESCRA
 LDAA 0,X
 CMPA #'.
 BNE PRERTN
 BITB #$80
 BNE PRERTN
 BITB #$40
 BNE PRES2
 CMPB #$2C
 BEQ PRES2
 CMPB #$3A
 BEQ PRES2
 CMPB #$3B
 BEQ PRES2
 CMPB #$3D
 BEQ PRES2
 CMPB #$3E
 BEQ PRES2
 CMPB #$3F
 BEQ PRES2
RTNINT CLR FLPFLG
PRERTN LDX AX
 STX CUCHAR
 RTS
PRES2A JSR LKPSYM
 CMPB #$FF
 BEQ RTNINT
 BITB #8
 BNE PRERTN
 BRA RTNINT
PRES3 CMPA #2
 BNE PRES4
 CMPB #3
 BEQ RTNINT
 TST DECFLG
 BNE PRERTN
 TST SIGDIG
 BEQ PRERTN
 JMP PRES2
PRES4 TSTB
 BEQ PRERTN
 JMP PRES2
*
* HANDLE BLOCK OPCODE
*
BLKSTR RMB 20
BLKEND EQU *-1
BLKCNT RMB 2
BLOKPR LDX #LABL+6
 JSR STR1
 TPA
 PSHA
 SEI
 STS STKTOP
 LDS BLKCNT
 PULA
 STAA TMPVAL+1
 PULA
 STAA TMPVAL
 TSX
 DEX
 LDS STKTOP
 PULA
 TAP
 CPX #BLKEND
 BGE BLKPR2
 LDX #$0311
 JSR PRINTE
BLKPR1 JMP MAIN1
BLKPR2 STX BLKCNT
 LDAA TMPVAL
 LDAB TMPVAL+1
 LDX #BLOKL+1
 JSR CVBTD
 LDX TMPVAL
 DEX
 STX TMPVAL
 LDAA TMPVAL
 LDAB TMPVAL+1
 LDX #BLOKL2
 JSR CVBTD
 LDX #BLOKL
 JSR STR1
 BRA BLKPR1
BLOKL FCC '.'
 RMB 5
 FCC ' JMP .'
BLOKL2 RMB 5
  FCB $D
*
* ON OPCODE PROCESSOR
*
ONL1 FCC ' LDX #.'
 RMB 5
 FCB $D
ONL2 FCC ' LDA A .ACCUM+1'
 FCB $D
ONL3 FCC ' DEC A'
 FCB $D
ONL4 FCC ' BGT *+4'
 FCB $D
ONL5 FCC ' JMP 0,X'
 FCB $D
ONL6 FCC ' INX'
 FCB $D
ONL7 FCC ' CPX #.'
 RMB 5
 FCC '-3'
 FCB $D
ONL8 FCC ' BEQ *-10'
 FCB $D
ONL9 FCC ' BRA *-15'
 FCB $D
ONPR CLR FLPFLG
 JSR EVALS
 CLR UBFLAG
 COM UBFLAG
 JSR UNOP2
 LDX LBLCNT
 INX
 STX BLKTOP
 INX
 STX BLKBOT
 STX LBLCNT
 LDAA BLKTOP
 LDAB BLKTOP+1
 LDX #ONL1+7
 JSR CVBTD
 LDAA BLKBOT
 LDAB BLKBOT+1
 LDX #ONL7+7
 JSR CVBTD
 LDX #ONL1
 JSR STR1
 LDX #ONL2
 JSR STR1
 LDX #ONL3
 JSR STR1
 LDX #ONL4
 JSR STR1
 LDX #ONL5
 JSR STR1
 LDX #ONL6
 JSR STR1
 LDX #ONL6
 JSR STR1
 LDX #ONL6
 JSR STR1
 LDX #ONL6
 JSR STR1
 LDX #ONL6
 JSR STR1
 LDX #ONL7
 JSR STR1
 LDX #ONL8
 JSR STR1
 LDX #ONL9
 JSR STR1
 JMP MAIN1
*
* PROCEDURE CALL OPCODE
*
CALLPR LDX #JSRZ
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 JSR NXTOK
 CMPB #1
 BNE CALL4
 LDX DESCRA
 STX BLKTOP
 LDAA DESCRC
 STAA BLKBOT
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTCR
 JSR NXTOK
 CMPB #$D
 BEQ CALL2
 CMPB #'(
 BNE CALL4
CALL2 LDAA #4
 STAA  CMPCNT
 LDX #FCL2
 JSR OUTCMP
 LDX LBLCNT
 INX
 STX LBLCNT
 LDAA PDOT
 STAA OPTLN
 LDX #OPTLN+1
 LDAA LBLCNT
 LDAB LBLCNT+1
 JSR CVBTD
 JSR QPR1
 JSR OUTCR
 LDX DESCRA
 LDAA 0,X
 CMPA #$D
 BEQ CALL5
CALL3 JSR NXTOK
CALL3A CMPB #1
 BEQ CALL4A
 CMPB #$2C
 BNE CALL4
 LDX #NULLP
 JSR STR1
 JSR NXTOK
 CMPB #$29
 BEQ CALL5
 BRA CALL3A
CALL4 JMP GTPR1
CALL4A LDAA #4
 STAA CMPCNT
 LDX #FCL3
 JSR OUTCMP
 JSR OUTNAM
 JSR OUTCR
 JSR XREF
 JSR NXTOK
 CMPB #',
 BEQ CALL3
 CMPB #')
 BNE CALL4
CALL5 LDX #MINUS1
 JSR STR1
 LDAA BLKBOT
 STAA DESCRC
 LDX BLKTOP
 STX DESCRA
 JSR LKPSYM
 CMPB #$FF
 BNE CALL6
 LDX LNUM
 STX LC
 JSR STOSYM
 LDAA #4
 STAA CMPCNT
 LDX #EXTZ
 JSR OUTCMP
 JSR OUTNAM
 JSR OUTCR
CALL6 LDX LBLCNT
 STX BLKBOT
 JMP GTPR4
EXTZ FCC ' EXT'
MINUS1 FCC ' FCB $FFFF'
 FCB $D
NULLP FCC ' FDB 0'
 FCB $D
PROCPR LDX #ENT
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 JSR NXTOK
 CMPB #1
 BEQ PROC2
PROCER  LDX #$0335
 JSR PRINTE
 JMP MAIN1
PROC2 JSR OUTNAM
 JSR OUTCR
 LDX LNUM
 STX LC
 JSR STOSYM
 JSR XREF
 JSR OUTNAM
 LDAB #240
 JSR RTBL
 LDAA #4
 STAA CMPCNT
 LDX #FCL2
 JSR OUTCMP
 LDX LBLCNT
 INX
 STX LBLCNT
 LDAA PDOT
 STAA OPTLN
 LDX #OPTLN+1
 LDAA LBLCNT
 LDAB LBLCNT+1
 JSR CVBTD
 JSR QPR1
 JSR OUTCR
 JSR NXTOK
 CMPB #$D
 BEQ PROC5
 CMPB #$28
 BNE PROCER
PROC3 JSR NXTOK
 CMPB #1
 BEQ PROC4
 CMPB #',
 BEQ PROC3
 CMPB #')
 BEQ PROC5
PROC3A BRA PROCER
PROC4 JSR LKPSYM
 CMPB #$FF
 BNE PROC3A
 JSR STOSYM
 JSR XREF
 LDX SYMPTR
 LDAA 8,X
 ORAA #$80
 STAA 8,X
 JSR OUTNAM
 LDX #DEFSL2
 JSR STR1
 BRA PROC3
PROC5 LDX #MINUS1
 JSR STR1
 JMP CALL6
ENT FCC ' ENT'
*
* PROCESS GOTO OPCODE
*
GOTOPR LDX #JMPZ
 STX OPPD
 BRA GTPR0
GOSBPR LDX #JSRZ
 STX OPPD
 BRA GTPR0
LABL FCC '.'
 RMB 5
 FCC ' EQU *'
 FCB $D
JMPZ FCC ' JMP'
JSRZ FCC ' JSR'
GFLAG RMB 1
BLKTOP RMB 2
BLKBOT RMB 2
OPPD RMB 2
GTPR0 JSR NXTOK
 CLR GFLAG
 CMPB #1
 BEQ GTPR3A
 CMPB #'(
 BEQ GTPR2
 LDX DESCRA
 LDAA 0,X
 CMPA #'@
 BNE GTPR1
 JSR EVALS
 LDX OPPD
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 LDX #ONL5+5
 JSR STR1
 JMP MAIN1
GTPR1 LDX #$0309
 JSR PRINTE
 JMP MAIN1
GTPR2 LDX  #LABL+7
 INC GFLAG
 LDAA #5
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTCR
 LDAA BLKTOP
 LDAB BLKTOP+1
 LDX #LABL+1
 JSR CVBTD
 LDAA #6
 STAA CMPCNT
 LDX #LABL
 JSR OUTCMP
GTPR3 JSR NXTOK
 CMPB #1
 BNE GTPR1
GTPR3A LDX OPPD
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTNAM
 JSR OUTCR
 JSR XREF
 TST GFLAG
 BEQ GTPR5
 JSR NXTOK
 CMPB #',
 BNE GTPR3B
 LDAA #4
 STAA CMPCNT
 LDX #ONL9
 JSR OUTCMP
 LDAA BLKBOT
 LDAB BLKBOT+1
 LDX #LABL+1
 JSR CVBTD
 LDX #LABL
 LDAA #6
 STAA CMPCNT
 JSR OUTCMP
 JSR OUTCR
 BRA GTPR3
GTPR3B CMPB #')
 BEQ GTPR4
 JMP GTPR1
GTPR4 LDAA BLKBOT
 LDAB BLKBOT+1
 LDX #LABL+1
 JSR CVBTD
 LDX #LABL
 JSR STR1
GTPR5 JMP MAIN1
* SUBROUTINE TO FIND VALUE OF ARRAY ELEMENT
FNDDIM CLR GAFLG
 LDX #CLN1
 LDAA #4
 STAA CMPCNT
 JSR OUTCMP
 TST PARFLG
 BNE FND1
 LDAA #'#
 JSR WRTCHR
 LDAB #'#
 JSR TPCHAR
FND1 JSR OUTNAM
 JSR OUTCR
 LDAA RUNCNT
 LDAB RUNCNT+1
 LDX #FCLN4+12
 JSR CVBTD
 LDX #FCLN4
 JSR STR1
 LDX RUNCNT
 STX TMPVAL
 INX
 INX
 STX RUNCNT
 JSR NXTOK
 CMPB #'(
 BEQ FND2
 TST GAFLG
 BEQ DIMERR
 RTS
DIMERR LDS STKTOP
 LDX #$0304
 TST GAFLG
 BEQ *+5
 LDX #$0313
 JMP PRINTE
FND2 LDAA TMPVAL
 LDAB TMPVAL+1
 PSHA
 PSHB
 LDAA DMSAV
 LDAB DMSAV+1
 PSHA
 PSHB
 LDAA DMDATA
 PSHA
 LDAA FLPFLG
 PSHA
 CLR FLPFLG
 TSX
 DEX
 DEX
 DEX
 STX STPSTK
 CLR DIMFLG
 INC DIMFLG
 JSR EXPR1
 PULA
 STAA FLPFLG
 PULA
 STAA DMDATA
 PULB
 PULA
 STAA DMSAV
 STAB DMSAV+1
 JSR STAKDN
 LDX DESCRA
 LDAA 0,X
 CMPA #',
 BEQ FND3
 CMPA #')
 BEQ FNDONE
 BRA DIMERR
FND3 LDAA DMDATA
 BITA #1
 BEQ DIMERR
 LDAA AX
 LDAB AX+1
 PSHA
 PSHB
 LDAA DMSAV
 LDAB DMSAV+1
 PSHA
 PSHB
 LDAB FLPFLG
 PSHB
 CLR FLPFLG
 TSX
 DEX
 DEX
 DEX
 STX STPSTK
 JSR EXPR1
 PULB
 STAB FLPFLG
 JSR STAKDN
 LDX #DIML2
 JSR STR1
 LDX #UNOPL2
 JSR STR1
 LDX #CLN1+6
 PULB
 PULA
 JSR CVBTD
 LDX #CLN1
 JSR STR1
 LDAB #18
 JSR RTBL
 LDX #UNOPL2
 JSR STR1
 PULB
 PULA
 LDX #FCLN3+12
 JSR CVBTD
 LDX #FCLN3
 JSR STR1
 LDAB #12
 JSR RTBL
FNDONE LDX #DIML2
 JSR STR1
 LDX #UNOPL2
 JSR STR1
 TST DSTFLG
 BNE FND4
 LDX #DIML3
 TST FLPFLG
 BEQ *+5
 LDX #DIML4
 JSR STR1
 LDAB #18
 JSR RTBL
 LDX #UNOPL2
 JSR STR1
FND4 PULB
 PULA
 STAA TMPVAL
 STAB TMPVAL+1
 LDX #FCLN3+12
 JSR CVBTD
 LDX #FCLN3
 JSR STR1
 LDAB #12
 JSR RTBL
 CLR DIMFLG
 RTS
DIML2 FCC ' DEX'
 FCB $D
DIML3 FCC ' LDX #2'
 FCB $D
DIML4 FCC ' LDX #9'
 FCB $D
EVADIM CLR GAFLG
 LDX #0
 STX RUNCNT
 CLR STKCNT
 CLR DIMFLG
 CLR NXTFLG
 STS STKTOP
 LDX DESCRA
 LDAA 0,X
 JSR GCHRTB
 BITA #$80
 BEQ EVAD1
 JSR MNLKP
 TSTA
 BNE EVAD2
EVAD1 LDX  #$0313
 JMP PRINTE
EVAD2 JSR DEFS
 STX DMSAV
 STAB DMDATA
 LDAA FLPFLG
 PSHA
 ANDB #8
 STAB FLPFLG
 LDAB DMDATA
 ANDB #$40
 STAB DSTFLG
 LDAB DMDATA
 ANDB #$80
 STAB PARFLG
 JSR FNDDIM+3
 PULA
 STAA FLPFLG
 RTS
* CHECK FOR ILLEGAL LABEL
LBLCK TST LBFLG
 BEQ LBLCK2
 TST PASS
 BNE LBLCK1
 JSR DELSYM
LBLCK1 LDX #$0223
 JSR PRINTE
LBLCK2 RTS
* SPECIAL OUTPUT ROUTINES
OUTBIN LDAA OPTNS
 BITA #$40
 BEQ *+3
 RTS
 TBA
 BSR OUTHL
 JSR OUTB
 TBA
 BSR OUTHR
 JMP OUTB
OUTBNR LDAA OPTNS
 BITA #$40
 BEQ *+3
 RTS
 TBA
 JMP OUTB
OUTHL LSRA
 LSRA
 LSRA
 LSRA
OUTHR ANDA #$F
 ADDA #$30
 CMPA #$39
 BLS *+4
 ADDA #7
RETCR RTS
*
* ASSORTED I/O ROUTINES
*
CRLF TST LPTSW
 BNE RETCR
 JMP FCRLF
PDATA2 BSR OUTCHR
 INX
PDATA1  LDAA 0,X
 CMPA #4
 BNE PDATA2
 BRA OUTCHR
OUT2H LDAA 0,X
OUT2HA BSR OUTHLL
 LDAA 0,X
 INX
 BRA OUTHRR
OUT4HS BSR OUT2H
OUT2HS BSR OUT2H
OUTS LDAA #$20
 BRA OUTCHR
OUTHLL BSR OUTHL
 BRA OUTCHR
OUTHRR BSR OUTHR
OUTCHR PSHA
 TST CONSW
 BEQ *+5
 JSR OUTEEE
 PULA
 PSHA
 TST LPTSW
 BNE *+5
 JSR OUTLPT
 PULA
OUTCHE RTS
*
* LINKAGES TO MASS-STORAGE
*
 EXT OPENI
 EXT OPENO
 EXT TABLES
 EXT CLOSI
 EXT CLOSO
 EXT GETB
 EXT OUTB
 EXT INITIO
 EXT REWIND
 ENT PDATA1
 ENT CRLF
 END
