view TL1/TL1.txt @ 178:4d83154d2a78

add - {} some builtin in TL/1
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 15 Apr 2019 09:43:28 +0900
parents 694412798333
children
line wrap: on
line source

1000 *******TL/1*************
1010 GAME EQU $B503
1020 TXTTOP EQU $FB7E
1030 BASE EQU $FB
1040 DPAGE EQU BASE*$100
1050  SETDP BASE
1060 MSTACK EQU $FE52-$100
1070 INEEE EQU $B003
1080 OUTEEE EQU $B006
1090 ** DPAGE DEFINE
1100  ORG DPAGE+$10
1110 INDN RMB 1
1120 OUTDN RMB 1
1130 LB RMB 2
1140 GB RMB 2
1150 MHIGH RMB 1
1160 MOD RMB 1
1170 WT1 RMB 1
1180 WT2 RMB 1
1190 RNDH RMB 1
1200 RNDL RMB 1
1210 DREG RMB 1 
1220 DBUF RMB 3
1230 XR RMB 2
1240 YR RMB 2
1250 ZR RMB 2
1260 PFTBEG RMB 2
1270 PC RMB 2
1280 SREG RMB 2
1290 SP RMB 2
1300 PFMAX RMB 2 
1310 LSW RMB 1 
1320 SY RMB 1
1330 CH RMB 1 
1340 VAL RMB 1 
1350 GL RMB 1 
1360 OPER RMB 1 
1370 GLL RMB 1 
1380 INDEX RMB  1
1390 RMCODE RMB 1
1400 ACC RMB 1
1410 LSIZE RMB 1
1420 TCOUNT RMB 1 
1430 TEND RMB 2 
1440 WEND RMB 2
1450 AMODE RMB 1
1460 RSW RMB 1
1470 GEND RMB 2
1480 SSW RMB  1
1490
1500  ORG $5000
1510 **
1520 COMP LDA #BASE
1530  TFR A,DP
1540  CLRA
1550  STA OUTDN
1560  STA LSW
1570  STA INDEX
1580  STA AMODE
1590  STA LSIZE
1600  STA RSW
1610  STA PFMAX
1620  LDX #MSTACK
1630  STX SP
1640  LEAX 2,x
1650  STX PFTBEG
1660  CLRB
1670 C1 STA ,X+
1680  DECB
1690  BNE C1
1700  INCA
1710  STA TCOUNT
1720  LDA #' '
1730  STA CH
1740  LDX TXTTOP 
1750  LEAX 2,X 
1760  STX SREG
1770  LEAX WTBLE,PCR
1780  STX TEND
1790  LEAX OBJECT,PCR
1800  STX PC
1810  STX OBJMP+1,PCR
1820 ** 
1830  LBSR CRLF
1840  BSR REG0
1850  LBSR WORD
1860  CMPA #$30 PROC?
1870  BNE  *+4
1880  BSR REGNAM  
1890  BSR REG0
1900  CMPA #$31 FUNC?
1910  BNE  *+4
1920  BSR REGNAM
1930  CLR LSIZE
1940  BSR REG0
1950  LBSR PROG 
1960  LBSR STPOUT
1970  LDX TEND
1980  STX GEND
1990 PLOOP LDA  SY
2000  CMPA #$8F /END CODE
2010  LBEQ ENDL
2020  CMPA #$4
2030  BCC ERR4
2040  DECA
2050  STA  AMODE
2060  LDA VAL
2070  LBSR DEFPF
2080  LBSR PUTHS
2090  FDB $03BD
2100  FDB PSHLB
2110  BSR REG0
2120  CLR LSIZE
2130  LBSR WORD
2140  CMPA #$37 
2150  BNE PL1
2160  BSR REGNAM
2170  LDA #$38 )
2180  LBSR CHECK
2190 PL1 BSR PROG
2200  LDB AMODE
2210  CMPB #1
2220  BNE *+5
2230  LBSR RETP
2240  LDX GEND 
2250  STX TEND
2260  LDB #5
2270  STB TCOUNT
2280  BRA PLOOP
2290 **
2300 * REGIST ZERO
2310 **
2320 REG0 LDX TEND
2330  CLR ,X+
2340  STX TEND
2350  INC TCOUNT
2360  RTS
2370 **
2380 *  REGIST NAME
2390 **
2400 REGNAM COM RSW
2410  LBSR WORD
2420  LDB RSW
2430  BEQ *+5
2440 ERR4 LBRA ERROR
2450  LDX TEND
2460  LDA LSIZE
2470  STA ,X
2480  INC LSIZE
2490  LDX WEND
2500  STX TEND
2510  BSR WORD1
2520  CMPA #$36 
2530  BNE REG2
2540  BSR WORD1
2550  BNE ERR4
2560  LDA VAL
2570  ADDA LSIZE
2580  BSR WORD1 
2590  LDA  #$3A
2600  LBSR CHECK
2610 REG2 CMPA #$3C
2620  BEQ REGNAM
2630  RTS
2640 **
2650 * PROGRAM
2660 **
2670 PROG CMPA #$32 VAR?
2680  BNE *+4
2690  BSR REGNAM
2700  BSR REG0
2710  CMPA #$33 ARRAY?
2720  BNE *+4
2730  BSR REGNAM
2740  LDB #-1 
2750  STB INDEX
2760 **
2770 *  STATEMENT 
2780 **
2790 STAT BSR SSTAT
2800  LDB SSW
2810  BEQ RTS1
2820  LBRA ERROR 
2830 **
2840 * STATEMENTS LIST
2850 **
2860 STLIST BSR SSTAT 
2870  LDB SSW
2880  BEQ STLIST
2890 RTS1 RTS
2900 **
2910 * SINGLE STATEMENT
2920 **
2930 SSTAT CLRA
2940  STA ACC 
2950  STA SSW 
2960  LDA SY
2970 **
2980 *  MULTIPLE STATEMENTS
2990 **
3000 SS1 CMPA #$34
3010  BCS SS2
3020  CMPA #$38
3030  BCC SS2
3040  ADDA #4
3050  PSHS A
3060  BSR WORD1
3070  BSR STLIST
3080  PULS A
3090  CLR SSW
3100  LBRA CHECK
3110 **
3120 * STOP
3130 **
3140 SS2 CMPA #$50
3150  BNE SS3
3160  BSR STPOUT
3170 WORD1 LBRA WORD
3180 **
3190 STPOUT LBSR PUTHS
3200  FCB 3,$7E
3210  FDB MONIT
3220  RTS
3230 **
3240 * RETURN
3250 **
3260 SS3 CMPA #$51
3270  BNE SS4
3280  LDB AMODE
3290  LBEQ ERR4
3300  PSHS B
3310  BSR WORD1
3320  PULS B
3330  DECB 
3340  BEQ RETP
3350  LBSR EXPR
3360 RETP LBSR PUTHS
3370  FDB $037E
3380  FDB PULLB
3390  RTS
3400 **
3410 * PROC CALL
3420 **
3430 SS4 CMPA #2
3440  LBEQ PFCALL
3450  CMPA #$E0
3460  BCS SS5
3470  LBRA PFCALL
3480 **
3490 * ASSIGNMENT STATEMENT 
3500 **
3510 SS5 CMPA #7
3520  BCS ASSIGN
3530  LBRA SS6
3540 ASSIGN LDB GL 
3550  PSHS B
3560  LDB VAL
3570  PSHS B
3580  CMPA #5
3590  BNE ASS1
3600  LBSR SUBSC1
3610  LDB ,S
3620  LDA LSW 
3630  BNE AS0
3640  LDA #$8B 
3650  LBSR PUTAB
3660  LDA  #1
3670  BRA   AS2
3680 AS0 ADDB OPER 
3690  STB ,S
3700  CLR LSW
3710  BRA   AS1
3720 ASS1 CMPA #6
3730  BNE ASS2 
3740  LBSR DSUBSC 
3750  LDA #2
3760  BRA AS2 
3770 ASS2  CMPA #4
3780  BEQ *+5 
3790  LBRA ERROR 
3800  LBSR WORD 
3810 AS1 CLRA 
3820 AS2 PSHS  A 
3830  LDA SY
3840  CMPA #$3C
3850  BNE  *+9
3860  LBSR  WORD 
3870  BSR   ASSIGN
3880  BRA   AS3
3890  LDA   #$3D 
3900  LBSR  CHECK
3910  LDA   #$27 
3920  LBSR  CHECK
3930  LBSR  EXPR
3940 AS3 PULS D
3950  STB   OPER     4--
3960  PULS B
3970  STB  GLL
3980  TSTA 
3990  BNE   AS4
4000  LBSR  PUTX 
4010  LDA   #$A7 
4020  LDB   OPER 
4030  LBRA  PUTAB
4040 AS4   DECA 
4050  BNE   AS5
4060  LBSR  PUTX 
4070  LDA   #$33 
4080  LBSR  PUTA 
4090  LBRA  STABX 
4100 AS5 LBSR  PUTHS
4110  FCB  10
4120  FDB   $33D7          PULB; STB WT2
4130  FCB   WT2
4140  FDB   $33D7          PULB; STB WT
4150  FCB   WT1 $DE,WT2    LDX WT2
4160  FDB   $A700          STA X
4170  CLR   INDEX
4180  RTS
4190 **
4200 ** NON-STATEMENT
4210 **
4220 SSEND COM SSW
4230  RTS
4240 **
4250 SS6 CMPA #$58 
4260  BCC SSEND 
4270  CMPA #$52
4280  BCS SSEND
4290  SUBA #$51
4300  PSHS A
4310  LBSR WORD
4320  PULS B
4330 **
4340 *  REPEAT UNTIL 
4350 **
4360  DECB
4370  BNE SS7
4380  STB INDEX
4390  BSR ASTOUT
4400  LBSR STLIST
4410  LDA #$60
4420  LBSR CHECK
4430  LBSR EXPR
4440  LBSR PUTHS
4450  FCB 2
4460  FDB $2603
4470  CLR SSW
4480  BRA   MINOUT 
4490 **
4500 * FOR-TO
4510 **
4520 SS7 DECB
4530  BNE SS8
4540  CMPA #4
4550  BEQ *+5
4560  LBRA ERROR
4570  LDB VAL
4580  PSHS B
4590  LDB GL
4600  PSHS B
4610  LBSR ASSIGN
4620  LDA #$61
4630  LBSR CHECK
4640  CLR ACC
4650  LBSR EXPR
4660  LDA #$64
4670  LBSR CHECK
4680  BSR ASTOUT
4690  LDA   #$36
4700  LBSR PUTA
4710  CLR   INDEX
4720  LBSR STAT
4730  LDA  #$32
4740  LBSR PUTA
4750  PULS D
4760  STA GLL
4770  STB OPER
4780  LDA #$A1
4790  LBSR PUTABX
4800  LBSR PUTHS
4810  FCB 2
4820  FDB $2305
4830  LDA #$6C
4840  LDB OPER
4850  LBSR PUTAB
4860 MINOUT LBRA PULJMP
4870 ASTOUT LBRA PSHDEF 
4880 **
4890 * WHILE-DO
4900 **
4910 SS8 DECB
4920  BNE SS9
4930  STB INDEX
4940  BSR ASTOUT
4950  LBSR EXPR
4960  LDA #$64
4970  LBSR CHECK
4980  LBSR PUTHS
4990  FCB 2
5000  FDB $2603
5010  BSR SLAOUT 
5020  LDB INDEX 
5030  PSHS B
5040  LBSR STAT
5050  PULS B
5060  STB INDEX
5070  BSR PEROUT 
5080  BSR MINOUT
5090 PLUOUT LBRA PULDEF
5100 **
5110 ** IF—THEN
5120 **
5130 SS9 DECB
5140  BNE SS10
5150  LBSR EXPR
5160  LDA #$65 
5170  LBSR CHECK
5180  LBSR PUTHS
5190  FCB 2
5200  FDB $2603
5210  BSR SLAOUT 
5220  LDB INDEX
5230  PSHS B
5240  LBSR STAT
5250  PULS B
5260  CMPB INDEX 
5270  BEQ *+4
5280  CLR INDEX 
5290  BRA PLUOUT 
5300 SLAOUT LBRA PSHJMP
5310 PEROUT LBRA STCHG
5320 ***
5330 * CASE—OF
5340 SS10 DECB
5350  BNE SS11
5360  LBSR EXPR
5370  LDA #$66
5380  LBSR CHECK
5390  CLRB
5400 S10A INCB
5410  PSHS B
5420  STB ACC 
5430  LBSR LEXPR 
5440  LDA #$81 
5450  LBSR AOPER
5460  LBSR PUTHS
5470  FCB 2
5480  FDB $2703
5490  BSR SLAOUT
5500  LDB INDEX
5510  PSHS B
5520  LBSR STAT
5530  BSR SLAOUT
5540  BSR PEROUT
5550  BSR PLUOUT
5560  PULS B
5570  STB INDEX 
5580  PULS B
5590  LDA SY
5600  CMPA #$67
5610  BNE S10A
5620  PSHS B 
5630  LBSR WORD
5640  LBSR STAT
5650  CLR INDEX
5660  PULS A
5670  LBRA PLDFN 
5680 **
5690 * WRITE STATEMENT
5700 **
5710 SS11 LDA #$37
5720  LBSR CHECK
5730  LBSR EXPR
5740  LBSR PUTHS
5750  FDB $0297
5760  FCB OUTDN
5770  LDA #$3D
5780  LBSR CHECK
5790 WTLP CLR ACC
5800  BSR WTERM
5810  LDA SY
5820  CMPA #$3C
5830  BNE WTEN
5840  LBSR WORD
5850  BRA WTLP
5860 WTEN LDA #$36
5870  LBRA CHECK
5880 **
5890 WTERM CMPA #$6C
5900  BNE WR1
5910  LBSR PUTHS
5920  FDB $03BD
5930  FDB PUTSTR
5940  LDA CH
5950 WR01 CMPA #'"'
5960  BEQ WR02
5970  LBSR PUTA
5980  LBSR GETCH
5990  BRA WR01
6000 WR02 CLRA
6010  STA INDEX
6020  LBSR PUTA
6030  LBSR GETCH
6040  LBRA WORD
6050 **
6060 WR1 CMPA #$6B
6070  BNE WR3
6080  LBSR WORD
6090  CMPA #$37
6100  BEQ WR2
6110  LBSR PUTHS
6120  FDB $03BD
6130  FDB CRLFA
6140  RTS
6150 **
6160 WR2 LBSR WEXPR
6170  BSR WTEN
6180  LBSR PUTHS
6190  FDB $03BD
6200  FDB CRLFA
6210  RTS
6220 **
6230 WR3 CMPA #$6A
6240  BNE WR4
6250  LBSR SUBSC
6260  LBSR PUTHS
6270  FDB $03BD
6280  FDB SPACEA
6290  RTS
6300 **
6310 WR4 CMPA #$A9
6320  BNE WR5
6330  LBSR SUBSC
6340  LBSR PUTHS
6350  FDB $03BD
6360  FDB PUTCA
6370  RTS
6380 **
6390 WR5 CMPA #$26
6400  BNE WR6
6410  LBSR DSUBSC
6420  LBSR PUTPLB
6430  LBSR PUTHS
6440  FDB $03BD
6450  FDB PUTDA+1
6460  BRA WR66
6470 **
6480 WR6 LBSR EXPR
6490  LBSR PUTHS
6500  FDB $03BD
6510  FDB PUTDA
6520 WR66 CLR INDEX
6530 RTS11 RTS
6540 **
6550 * PUTX & PUTB
6560 **
6570 PUTABX PSHS D
6580  BSR PUTX
6590  PULS D 
6600  BRA PUTAB
6610 **
6620 * PUT LP, OR GB BY INDEX
6630 **
6640 PUTX LDB GLL 
6650  CMPB INDEX 
6660  BEQ RTS11 
6670  STB INDEX 
6680  ADDB #LB+1
6690  LDA #$DE 
6700 ***
6710 * PUT ACC A&B
6720 **
6730 PUTAB   BSR PUTA
6740  TFR B,A
6750 **
6760 * PUT ACCA RS AN OBJECT
6770 **
6780 PUTA STX RNDH
6790  LBSR AOUT
6800  LDX RNDH
6810  RTS
6820 **
6830 * PUTHS STRING
6840 **
6850 PUTHS LDX ,S++
6860  LDB ,X+
6870 PS1 LDA ,X+
6880  BSR PUTA
6890  DECB
6900  BNE PS1
6910  JMP ,X
6920 **
6930 ** CHECK ACC
6940 **
6950 CHECK CMPA SY
6960  BEQ WORD
6970 **
6980 * ERROR
6990 **
7000 ERROR LBSR PUTSTR
7010  FDB $0D0A
7020  FCC "ERROR ",0
7030  LDX TEND
7040  LEAX 1,X
7050  NEG ,X
7060 ER0 LDA ,X+
7070  LBSR PUTCA
7080  CMPX WEND
7090  BNE ER0
7100  JMP GAME
7110 **
7120 * WORD DECORDER
7130 **
7140 WORD BSR WORDS
7150  LDA SY
7160  RTS
7170 WORDS CLRB
7180  STB SY
7190  STB VAL
7200  LDA CH
7210 ** SKIP CONT  ,SPACE.;
7220 WD1 CMPA #$21
7230  BCS SKIP
7240  CMPA #'.'
7250  BEQ SKIP
7260  CMPA #';'
7270  BNE WD2
7280 SKIP BSR GETCH
7290  BRA WD1
7300 **
7310 *  COMMENT
7320 **
7330 WD2 CMPA #'%'
7340  BNE WD3
7350  BSR GETCH
7360  CMPA #$20
7370  BCC *--4
7380  BRA WD1
7390 **
7400 * ASCC CONST
7410 **
7420 WD3 CMPA #'\''
7430  BNE WD4
7440  BSR GETCH
7450  STA VAL
7460  BSR GETCH
7470 GETCH PSHS X
7480  LBSR MEMIN
7490  STA CH
7500  PULS X,PC
7510 * HEX CONSTANT
7520 WD4 CMPA #'$'
7530  BNE WD5
7540 WD40 BSR GETCH
7550  BSR TSTNA
7560  BEQ WD41
7570  BCC RTS2
7580  CMPA #'F'+1
7590  BCC RTS2
7600  SUBA #7
7610 WD41 SUBA #'0'
7620  LDB VAL
7630  ASLB
7640  ASLB
7650  ASLB
7660  ASLB
7670  PSHS B
7680  ADDA ,S+
7690  STA VAL
7700  BRA WD40
7710 **
7720 * TEST ALPHA NUMERIC
7730 TSTNA CMPA #'0'
7740  BCS NAF
7750  CMPA #'9'+1
7760  BCS NT
7770  CMPA #'A'
7780  BCS NAF
7790  CMPA #'Z'+1
7800  BCS AT
7810 NAF CLRB CLEAR C
7820 AT LDB #-1
7830 RTS2 RTS
7840 NT CLRB
7850  RTS
7860 ** DECIMAL CONSTANT
7870 WD5 BSR TSTNA
7880  BNE WD6
7890 WD50 SUBA #'0'
7900  PSHS A
7910  LDA VAL
7920  LDB #10
7930  MUL
7940  ADDA ,S+
7950  STA VAL
7960  BSR GETCH
7970  BSR TSTNA
7980  BEQ WD50
7990  RTS
8000 * THE OTHER WORDS
8010 WD6 LDX TEND
8020  PSHS A
8030  NEGA
8040  LEAX 1,X
8050  BSR STAONE
8060  PULS A
8070  BSR TSTNA
8080  BCC TLOOK1
8090 WD61 LDA CH
8100  BSR TSTNA
8110  BCS *+4
8120  BNE TLOOK1
8130  BSR STAONE
8140  BRA  WD61
8150 STAONE STA ,X+
8160  STX WEND
8170  BRA GETCH 
8180 TLOOK1 LDA RSW
8190  BEQ TLOOK
8200  COM RSW
8210  RTS
8220 **
8230 * WORD TABLE SEARCH
8240 **
8250 TLOOK LDA TCOUNT 
8260  STA SY
8270  LDX TEND 
8280 S01 LDU WEND 
8290 S02 LDA ,-U
8300  CMPA ,-X 
8310  BEQ S06
8320 S03 TST ,X
8330  BEQ S05 
8340  BMI S04 
8350  LEAX -1,X
8360  BRA  S03 
8370 S04 LEAX -1,X 
8380  BRA S01 
8390 S05 DEC SY
8400  BNE S01
8410  LBRA ERROR
8420 S06 TSTA 
8430  BPL S02
8440  LDB ,-X
8450  STB VAL
8460  LDA SY
8470  CMPA #1
8480  BNE *+6
8490  TFR B,A 
8500  BRA S07 
8510  CMPA #4 
8520  BCS  RTSS
8530  LDB  #1
8540  TST AMODE
8550  BEQ *+6
8560  CMPA #6
8570  BCS *+3 
8580  NEGB 
8590  STB GL
8600  ANDA #$FD
8610 S07 STA SY
8620 RTSS RTS
8630 **
8640 * ARITHMATIC EXPRESSION
8650 **
8660 WEXPR LBSR WORD
8670 EXPR BSR LEXPR
8680  BSR OLOAD 
8690 RTE RTS
8700 ** WORD * LEXPR
8710 WLEXPR LBSR WORD
8720 **
8730 * LOGICAL EXPRESSION
8740 **
8750 LEXPR BSR REXPR
8760 LE1 LDY SY
8770  CMPA #$82
8780  BCS RTE
8790  CMPA #$8A+1
8800  BCC RTE
8810  PSHS A
8820  LBSR WORD
8830  BSR REXPR
8840  LDB LSW
8850  BNE LE2
8860  LBSR PUTHS
8870  FDB $0397 
8880  FCB WT1
8890  FCB $32
8900  PULS A
8910  ADDA #$10
8920  LDB #WT1
8930  LBSR PUTAB 
8940  BRA LE1
8950 LE2 PULS A
8960  BSR OCORD 
8970  BRA LE1
8980 **
8990 * RELATIONAL EXPRESS 
9000 **
9010 REXPR BSR AEXPR
9020 RE1 LDA SY
9030  CMPA #$21 
9040  BCS      RTE 
9050  CMPA #$30 
9060  BCC RTE
9070  PSHS A
9080  LBSR WORD 
9090  ASR AEXPR 
9100  LDA #$80 
9110  BSR AOPER 
9120  PULS A
9130  LBSR PUTHS
9140  FCB 6
9150  FCB $3,$4F,$20,$02,$86,$FF
9160  BRA RE1
9170 ** ADDING OPERATFR
9180 AOPER LDB LSW
9190  BNE OCORD 
9200  PSHS A
9210  CMPA #$80 
9220  BEQ  *+5 
9230  BSR PUTPUL
9240  FCB $8C 
9250  BSR PUTPLB
9260  PULS A
9270  SUBA #$70
9280 PUTA1 LBRA PUTA
9290 ** OUTPUT SAVED L-CC 
9300 OLOAD LDA LSW 
9310  BEQ RTE 
9320  LDA ACC
9330  BEQ *+6 
9340  LDA #$36
9350  BSR PUTA1 
9360  LDA #$86
9370 OCORD PSHS A
9380  CLRA
9390  STA LSW
9400  COMA
9410  STA ACC
9420  LDA AMODE
9430  CMPA #$20
9440  BNE *+5
9450  LBSR PUTX
9460  CLR LSW
9470  PULS A
9480  ADDA AMODE
9490  LDB OPER
9500  LBRA PUTAB
9510 * PUT 'TAB:PULS A'
9520 PUTPUL LBSR PUTHS
9530  FCB 2
9540  FDB $1632
9550 RTE1 RTS 
9560 * PUT 'PULS B'
9570 PUTPLB LDA #$33
9580  BRA PUTA1
9590 **
9600 *  ADDING EXPRESSION
9610 **
9620 AEXPR BSR MEXPR
9630 AE1 LDA SY
9640  CMPA #$80
9650  BEQ  AE2
9660  CMPA #$8B 
9670  BNE RTE1
9680 AE2 PSHS A
9690  LBSR WORD
9700  BSR MEXPR
9710  PULS A
9720  BSR AOPER
9730  BRA AE1
9740 **
9750 *  MUTIPLYING EXPRESSION
9760 **
9770 MEXPR BSR TERM 
9780 ME1 LDA SY
9790  CMPA #$8E
9800  BEQ ME2
9810  CMPA #$8F
9820  BNE RTE1
9830 ME2 PSHS A
9840  LBSR WORD
9850  BSR TERM
9860  LDB LSW 
9870  BEQ ME3
9880  LDA #$C6
9890  BSR OCORD
9900  FCB $8C
9910 ME3 BSR PUTPUL 
9920  PULS A
9930  CMPA #$8E 
9940  BHS ME4
9950  LBSR PUTHS
9960  FCB 3
9970  FCB $BD
9980  FDB MULT
9990  BRA ME1
10000 ME4 LBSR PUTHS
10010  FCB 3
10020  FCB $BD
10030  FDB DIV
10040  BRA ME1
10050 **
10060 * TERM
10070 **
10080 TERM LDA SY
10090  BNE TM1
10100 * SAVE L-COMMAND 
10110 SLOAD PSHS A
10120  LBSR OLOAD
10130  LDA VAL 
10140  STA OPER 
10150  LDA GL
10160  STA GLL
10170  PULS A
10180  STA AMODE 
10190  COM LSW 
10200  LBRA WORD 
10210 * CONST TRUE & FALSE
10220 TM1 CMPA #$A0
10230   BEQ TM01
10240   CMPA #$A1
10250   BNE TM2
10260 TM01  SUBA #$A1
10270   STA VAL
10280   CLRA
10290   BRA SLOAD
10300 * SYSTEM VAR MHIGH & MOD
10310 TM2    CMPA #$16
10320   BRA *+6
10330   CMPA #$17
10340   BNE TM3
10350   STA VAL
10360   LDA #$10
10370   BRA SLOAD
10380 * SIMPLE VARIABLE 
10390 TM3    CMPA #4
10400   BNE TM4
10410   LDA #$20
10420   BRA SLOAD
10430 * ( EXPTRSSION ) 
10440 TM4    CMPA #$35
10450   BCS TM5
10460   CMPA #$38
10470   BCC TM5
10480   PSHS A
10490   LBSR WLEXPR
10500   PULS A
10510   ADDA #4
10520   LBRA CHECK
10530 ** FUNCTION CALL
10540 TM5    CMPA #3
10550   BMI *+6
10560   CMPA #$E0
10570   BCS TM6
10580   BSR OLP 
10590 PFCALL LDA VAL
10600   PSHS A 
10610   LBSR WORD
10620   CMPA #$37 
10630   BNE PFC1 
10640   LDA LSIZE
10650   PSHS A 
10660   INC LSIZE 
10670 PFC2     INC LSIZE 
10680   LBSR WEXPR
10690   CLRB
10700   STB ACC 
10710   DECB
10720   STB    GLL
10730   LDA #$A7 
10740   LDB LSIZE 
10750   LBSR PUTABX 
10760   LDA SY 
10770   CMPA #$3C 
10780   BEQ PFC2 
10790   PULS A
10800   STA LSIZE 
10810   LDA #$3B 
10820   LBSR CHECK 
10830 PFC1 LDB #-1 
10840   STB ACC 
10850   STB INDEX 
10860   LDA #$86 
10870   LDB LSIZE
10880  LBSR PUTAB
10890  PULS A
10900  CMPA #$C0
10910  BCC *+5
10920  LBRA CALPF
10930  LDX #LIBR
10940  SUBA #$C0
10950 PFC3 BEQ PFC4
10960  LEAX 2,X
10970  DECA
10980  BRA PFC3
10990 PFC4 LDA #$BD
11000  LBSR PUTA
11010  LDD ,X
11020  LBRA PUTAB
11030 **
11040 OLP LBSR OLOAD
11050  LDB ACC 
11060  BEQ RTS4
11070  LDA #$36 
11080  LBSR PUTA
11090  CLR ACC 
11100 RTS4 RTS
11110 ** FUNCTION RND
11120 TM6 CMPA #$70 
11130  BNE TM61 
11140  BSR SUBSC
11150  LBSR PUTHS
11160  FCB $03BD
11170  FDB RND
11180  RTS
11190 * FUNTION GET
11200 TM61 CMPA #$71
11210  BNE TM62 
11220  BSR SUBSC
11230  LBSR PUTHS
11240  FDB $0597
11250  FCB INDN,$BD
11260  FDB GETCH
11270  RTS
11280 * FUNCTION READ 
11290 TM62 CMPA #$72 
11300  BNE TM7
11310  BSR SUBSC
11320  LBSR PUTHS
11330  FDB $0597
11340  FDB INDN
11350  FCB $8D
11360  FDB GETDA
11370  RTS
11380 * FUNCTION NOTASL ET AL
11390 TM7 CMPA #$40
11400  BCS TM8
11410  CMPA #$49+1
11420  BCC TM8
11430  PSHS A
11440  BSR SUBSC
11450  PULS A
11460  LBRA PUTA
11470 * ARRAY
11480 TM8 CMPA #$5
11490  BNE TM9
11500  LDB VAL
11510  PSHS B
11520  LDB GL
11530  PSHS B
11540  BSR SUBSC1
11550  PULS B
11560  STB GLL
11570  PULS B
11580  LDA LSW
11590  BEQ ARY1
11600  ADDB OPER 
11610  STB OPER
11620  LDA #$20 
11630  STA AMODE
11640  RTS 
11650 ARY1 LDA #$8B
11660  LBSR PUTABX
11670  LBRA LDAAX
11680 **
11690 DSUBSC LDA #$3C
11700  BSR SUBS1
11710  LDA #$3B
11720  PSHS A
11730  BRA SUBS2
11740 SUBSC LDA #$3E
11750 SUBS1 PSHS A
11760  LBSR WORD
11770  LDA #$37
11780  LBSR CHECK
11790 SUBS2 LBSR EXPR
11800  PULS A 
11810  LBRA CHECK
11820 SUBSC1 LBSR WORD
11830  LDA #$36
11840  LBSR CHECK
11850  LBSR LEXPR
11860  LDB LSW
11870  BEQ SBS5
11880  LDB AMODE
11890  BEQ SBS5
11900  LBSR OLOAD
11910 SBS5 LDA #$3A
11920  LBRA CHECK
11930 * MEM FUNCTION
11940 TM9 CMPA #6
11950  BNE TM10
11960  BSR DSUBSC
11970  LBSR PUTHS
11980  FDB $0997
11990  FCB WT2
12000  FDB $3297
12010  FCB WT1,$DE,WT1
12020  FDB $A600
12030  CLR INDEX 
12040  RTS
12050 ** FOR EXPANTION
12060 TM10 LBRA ERROR
12070 **
12080 * LIBRARY ADDRESSS TABLE
12090 **
12100 LIBR RMB 80
12110 **
12120 * ADDRESS DEPENDENT CODE
12130 * GENARATION
12140 **
12150 * SET PRC—FUNC TABLE
12160 **
12170 SETPFT PSHS A 
12180  LDB #3
12190  MUL
12200  ADDD PFTBEG
12210  STD XR 
12220  PULS A,PC
12230 **
12240 TWICE LBSR PUTSTR
12250  FCB $0D,$0A
12260  FCC "TWICE!",0
12270  JMP GAME
12280 **
12290 * DEF PROC-FUNC
12300 **
12310 DEFPF BSR SETPFT
12320  LDX XR
12330  TST ,X
12340  BNE TWICE
12350  COM ,X
12360  LDX 1,X
12370  STX YR 
12380  LDX XR 
12390  LEAX 1,X
12400  BSR PCST 
12410  LDX YR
12420 DP1 BEQ RT10
12430  LDX ,X
12440  STX ZR
12450  LDX YR
12460  BSR PCST 
12470  LDX ZR
12480  STX YR
12490  BRA DP1
12500 **
12510 * CALL PORC-FUNC
12520 **
12530 CALPF BSR SETPFT
12540  INCA
12550  CMPA PFMAX
12560  BCS *+4
12570  STA PFMAX
12580  LDA #$BD
12590  BSR AOUT
12600  LDX XR
12610  LDD 1,X
12620  LDX PC
12630  BSR STAABX 
12640  LDX XR
12650  TST ,X
12660  BNE PC2ADD
12670  LEAX 1,X
12680  BSR PCST
12690  BRA PC2ADD
12700 **
12710 * PUL-DEF N TIMES
12720 **
12730 PLDFN PSHS A
12740  BSR PULDEF
12750  DEC ,S
12760  BNE *-4
12770  PULS A,PC
12780 **
12790 * PULL AND DEFINE
12800 **
12810 PULDEF BSR PULSTK
12820 PCST LDD PC
12830 STAABX STD ,X
12840 RT10 RTS
12850 **
12860 JMPOUT LDA #$7E
12870 AOUT LDX PC
12880  STA ,X
12890  BRA INCPC1
12900 **
12910 PULSTK LDX SP
12920  LEAX 2,x
12930  STX SP
12940  LDD ,X
12950  LDX ,X
12960  RTS
12970 **
12980 *  PUL STACK & Jump
12990 **
13000 PULJMP BSR JMPOUT
13010  BSR PULSTK
13020 PCST2 LDX PC
13030  BSR STAABX
13040 INCPC LEAX 1,X
13050 INCPC1 LEAX 1,X
13060 SETPC STX PC
13070  RTS
13080 **
13090 * PUSH STACK & JUMP
13100 **
13110 PSHJMP BSR JMPOUT
13120  BSR PSHDEF
13130 PC2ADD LDX PC
13140  BRA INCPC
13150 **
13160 * PUSH STRCK & DEFINE
13170 **
13180 PSHDEF LDX SP
13190  BSR PCST
13200  LEAX -2,X
13210  STX SP
13220  RTS
13230 **
13240 OUTPC3 BSR AOUT 
13250  LDD PC
13260  ADDD #3
13270  BRA PCST2
13280 **
13290 * LDA R,X
13300 LDAAX LDA #$B7
13310  BSR OUTPC3
13320  LDA #$A6
13330 LA1 BSR AOUT 
13340  BRA INCPC1
13350 **
13360 * STA B,X
13370 STABX LDA #$F7
13380  BSR OUTPC3
13390  LDA #$A7
13400  BRA LA1
13410 **
13420 * STACK TOP CHANGE
13430 **
13440 STCHG LDU SP
13450  LEAU 2,U
13460  PULU D,X
13470  EXG D,X
13480  PSHU D,X
13490  RTS
135n0 **
13510 * END OF LOAD
13520 **
13530 ENDL LDX PFTBEG
13540  LDA PFMAX
13550 EL1 BEQ EL
13560  TST ,X
13570  BEQ UDERR
13580 EL2 LEAX 3,X
13590   DECA
13600  BRA EL1
13610 UDERR PSHS A
13620  STA ZR
13630  SUBA PFMAX
13640  NEGA
13650  PSHS A
13660  LBSR PUTSTR
13670  FDB $0D0A
13680  FCC "UNDEF",0
13690  PULS A
13700  LBSR PUTCA
13710  PULS A
13720  LDX ZR
13730  BRA EL2
13740 EL LDX PC
13750  STX VARPTR+1,PCR
13760  JMP GAME
13770 **
13780 * INPUT ROUTINE
13790 * GET ONE CHR FORM MEMORY
13800 **
13810 MEMIN LDX SREG
13820  LDA ,X+
13830  BEQ LEND
13840 MEM1 STX SREG
13850 MEM2 LBRA PUTCA
13860 LEND LDA #$D 
13870  BSR MEM2
13880  LDA #$A
13890  TST ,X++
13900  BPL MEM1 
13910  LDA #'/'
13920  RTS
13930 **********************
13940 * ADVANCE WORD
13950 **
13960 WTABLE FCB 0 END MARK 
13970  FCB $30,-'P'
13980  FCC "ROC" 
13990  FCB $31,-'F'
14000  FCC "UNC" 
14010  FCB $32,'V'
14020  FCC "AR"
14030  FCB $33,-'A'
14040  FCC "RRAY"
14050  FCB $34,-'B'
14060  FCC "EGIN"
14070  FCB $35,';'
14080  FCB $36,-'['
14090  FCB $37,-'('
14100  FCB $38,-'E'
14110  FCC "ND"
14120  FCB $39,-'=' 
14130  FCB $3A,-']'
14140  FCB $3B,-')'
14150  FCB $3C,-','
14160  FCB $3D,-':'
14170  FCB $50,-'S'
14180  FCC "TOP"  
14190  FCB $51,-'R'
14200  FCC "ETURN"
14210  FCB $55,-'I'
14220  FCC "F"
14230  FCB $65,-'T'  
14240  FCC "HEN"
14250  FCB $53,-'F'  
14260  FCC "OR"  
14270  FCB $61,-'T'  
14280  FCC "O"
14290  FCB $52,-'R'
14300  FCC "EPEAT"
14310  FCB $60,-'U'
14320  FCC "NTIL"
14330  FCB $54,-'W'  
14340  FCC "HILE"
14350  FCB $64,-'D'  
14360  FCC "O"
14370  FCB $56,-'C'  
14380  FCC "ASE"
14390  FCB $66,-'O'  
14400  FCC "F"  
14410  FCB $67,-'E'  
14420  FCC "LSE"
14430  FCB $57,-'W'
14440  FCC "RITE"
14450  FCB $69,-'A'
14460  FCC "SCII"  
14470  FCB $6A,-'S'
14480  FCC "PACE"
14490  FCB $68,-'C'  
14500  FCC "RLF"  
14510  FCB $6C,-'"'
14520  FCB $8B,-'+'
14530  FCB $80,-'-'
14540  FCB $8E,-'*'  
14550  FCB $8F,-'/'
14560  FCB $82,-'S'
14570  FCC "BC"
14580  FCB $84,-'A'
14590  FCC "ND"
14600  FCB $88,-'E'
14610  FCC "OR"
14620  FCB $89,-'A'  
14630  FCC "DC"
14640  FCB $8A,-'O'  
14650  FCC "R"
14660  FCB $22,-'>'  
14670  FCB $25,-'<'
14680  FCB $26,-'#'
14690  FCB $27,-'=' 
14700  FCB $2D,-'L','T'
14710  FCB $2E,-'G','T'
14720  FCB $40,-'N','E','G'
14730  FCB $43,-'N','O','T'
14740  FCB,$43,-'C','O','M'
14750  FCB $44,-'L','S','R'
14760  FCB $46,-'R','O','R'
14770  FCB $47,-'A','S','R'
14780  FCB $48,-'A','S','L'
14790  FCB $49,-'R','O','L'
14800  FCB $06,-'M','E','M'
14810  FCB $A0,-'T'
14820  FCC "RUE"
14830  FCB $A1,-'F'
14840  FCC "ALSE"
14850  FCB $16,-'M'
14860  FCC "HIGH"
14870  FCB $17,-'M'
14880  FCC "OD"
14890  FCB $70,-'R','N','D'
14900  FCB $71,-'G','E','T'
14910  FCB $72,-'R'
14920  FCC "EAD"
14930 ******
14940 WTBLE RMB $500
14950 ******
14960 * SUPORTING ROUTINES
14970 * & I/0 CONTROL
14980 **
14990 SYSTEM EQU $8837
15000 RUB EQU $8
15010 STACK EQU $FE00
15020 ** OBJECT START
15030 C LDS #STACK
15040 VARPTR LDX #0
15050  STX GB
15060  STX LB
15070 OBJMP JMP >0
15080 **
15090 * PUSH LB & SET NEW LP
15100 **
15110 PSHLB CLRB
15120  ADDD LB
15130  STD WT1
15140  LDX WT1
15150  LDD LB
15160  STD ,X++
15170  STX LB
15180  RTS
15190 **
15200 * PULL LB
15210 **
15220 PULLB LDX LB
15230  LDX ,--X
15240  STX LB
15250  TSTA
15260  RTS
15270 **
15280 * RND FUNCTION
15290 **
15300 RND PSHS A
15310  LDA RNDL
15320  LDB #125
15330  MUL
15340  ADDD #1
15350  STA RNDL
15360  PSHS A
15370  LDA RNDH
15380  LDB #125
15390  MUL
15400  ADDA ,S+
15410  STA RNDH
15420  PULS B
15430  MUL
15440  INCA
15450  RTS
15460 **
15470 * DVISITION SET MOD 
15480 **
15490 DIV STB WT1
15500  BEQ ERDIV 
15510  TFR A,B
15520  CLRA
15530  STA WT2
15540 DV0 INC WT2
15550  ASL WT1
15560  BCC DV0
15570 DV1 ROR WT1
15580  CMPB WT1
15590  BCS DV2
15600  SUBB WT1
15610  ORCC #1
15620  BRA *+4
15630 DV2 ANDCC #$FE CLR C
15640  ROLA
15650  DEC WT2
15660  BNE DV1
15670  STB MOD
15680  TSTA
15690  RTS
15700 **
15710 ERDIV STB OUTDN
15720  LBSR CRLF
15730  LBSR PUTSTR
15740  FCC "ERR DIV 0",0
15750 MONIT JMP SYSTEM
15760 **
15770 MULT MUL
15780  STA MHIGH
15790  TFR B,A
15800  RTS
15810 **
15820 * PUT A IN DECIMAL
15830 **
15840 PUTDA CLRB
15850 PUTDR STB DREG
15860  LEAX ,S
15870  LEAS -4,S
15880  CLR 1,X
15890  LDB #3
15900 P0 PSHS B
15910  LDB #10
15920  BSR DIV
15930  ADDB #$30
15940  STB ,X
15950  LEAX -1,X
15960  PULS B
15970  DECB
15980  BNE P0
15990  COM 3,X
16000  LDA #'0'
16010  LDB #4
16020 P1 LEAX 1,X
16030  DECB
16040  CMPA ,X
16050  BEQ P1
16060  COM 4,S
16070  LDA DREG
16080  PSHS B
16090  SUBA ,S+
16100  BCS PRX
16110  BSR SPACEA
16120 PRX LDB ,X
16130  BEQ P4
16140  BSR PUTCA 
16150  LEAX 1,X 
16160  BRA PRX 
16170 P4 LEAS 4,S
16180 CL1 RTS
16190 ** 
16200 * GET IN A DECIMAL
16210 ** 
16220 GETDA CLRA
16230  PSHS A
16240  BSR GETCA 
16250  CMPA #RUB 
16260  BNE GD1 
16270  PULS A
16280  LDB #10 
16290  LBSR DIV
16300  BRA GETDA+1 
16310 GD1 SUBA #'0'
16320  BCS GD2
16330  CMPA #10
16340  BCC GD2 
16350  STA DBUF 
16360  PULS A
16370  LDB #10 
16380  MUL
16390  ADDB DBUF 
16400  TFR B,A
16410  BRA GETDA+1 
16420 GD2 PULS A,PC
16430 **
16440 * SPACE A TIMES 
16450 **
16460 SPACEA BEQ CL1
16470  PSHS A
16480  LDA #' '
16490  BSR PUTCA
16500  PULS A
16510  DECA
16520  BRA SPACEA
16530 **
16540 * STR OUT
16550 **
16560 PUTSTR PSHS X
16570  LDX 2,S
16580 STR1 LDA ,X+
16590  BEQ STR2
16600  LBSR PUTCA
16610  BRA STR1
16620 STR2 STX 2,S
16630  PULS X,PC
16640 **
16650 * CRLF
16660 **
16670 CRLF LDA #$0D
16680  BSR PUTCA 
16690  LDA #$0A
16700  BRA PUTCA
16710 **
16720 * CRLF A TIMES
16730 **
16740 CRLFA BEQ CL1
16750  PSHS A
16760  BSR CRLF 
16770  PULS A
16780  DECA
16790  BRA CRLFA
16800 **
16810 * PUTCHR A
16820 **
16830 PUTCA PSHS X 
16840  LDB OUTDN
16850  LEAX OUTAT,PC
16860  ASLB 
16870  JSR [B,X]
16880  PULS X,PC
16890 **
16900 * GET ACCA ONE CHR
16910 **
16920 GETCA PSHS X
16930  LDB INDN
16940  LEAX INAT,PC
16950  ASLB
16960  JSR [B,X] 
16970  PULS X,PC
16980 **
16990 * INPUT ROUTINE ADDRESS
17000 **
17010 INAT FDB INEEE 
17020  RMB 4
17030  RMB 14
17040 **
17050 * OUTPUT AOUTINE ADDRESS
17060 **
17070 OUTAT FDB OUTEEE
17080  RMB 6
17090  RMB 12
17100 
17110 * OBJECT PG AREA
17120 
17130 OBJECT NOP
17140  END