
 1000  *SAVE S.LABELLED GO'S
 1010  *--------------------------------
 1020  *      & GOTO <STR EXP>
 1030  *      & GOSUB<STR EXP>
 1040  *      REM "<LABEL>"
 1050  *
 1060  *      AS SUGGESTED BY TIM MOWCHANUK
 1070  *--------------------------------
 1080  AS.VALTYP  .EQ $11
 1090  AS.TEMPPT  .EQ $52,53
 1100  INDEX.REM  .EQ $5E
 1110  INDEX.GO   .EQ $5F
 1120  PRGBOT     .EQ $67,68
 1130  AS.CURLIN  .EQ $75,76
 1140  PNTR       .EQ $9B,9C
 1150  STRLEN     .EQ $9D
 1160  STRADR     .EQ $9E,9F
 1170  VPNT       .EQ $A0,A1
 1180  TXTPTR     .EQ $B8,B9
 1190  *--------------------------------
 1200  TKN.GOTO   .EQ $AB
 1210  TKN.GOSUB  .EQ $B0
 1220  TKN.REM    .EQ $B2
 1230  *--------------------------------
 1240  AMPERSAND.VECTOR .EQ $3F5 ... 3F7
 1250  *--------------------------------
 1260  AS.CHRGET  .EQ $00B1
 1270  AS.CHRGOT  .EQ $00B7
 1280  AS.MEMCHK  .EQ $D3D6
 1290  AS.NEWSTT  .EQ $D7D2
 1300  AS.GOTO1   .EQ $D941
 1310  AS.GOTO.3  .EQ $D95E
 1320  AS.UNDERR  .EQ $D97C
 1330  AS.FRMEVL  .EQ $DD7B
 1340  AS.SYNERR  .EQ $DEC9
 1350  AS.FRETMP  .EQ $E604
 1360  AS.GETADR  .EQ $E752
 1370  *--------------------------------
 1380         .OR $300
 1390         .TF B.LABELLED GO'S
 1400  *--------------------------------
 1410  SETUP  LDA #LABELLED.GOTO.AND.GOSUB
 1420         STA AMPERSAND.VECTOR+1
 1430         LDA /LABELLED.GOTO.AND.GOSUB
 1440         STA AMPERSAND.VECTOR+2
 1450         RTS
 1460  *--------------------------------
 1470  LABELLED.GOTO.AND.GOSUB
 1480         JSR AS.CHRGOT
 1490         CMP #TKN.GOTO
 1500         BEQ .3
 1510         CMP #TKN.GOSUB
 1520         BEQ .2       ...GOOD SYNTAX SO FAR
 1530  .1     JMP AS.SYNERR
 1540  *---SETUP GOSUB RETURN DATA------
 1550  .2     LDA #3
 1560         JSR AS.MEMCHK
 1570         LDA TXTPTR+1
 1580         PHA
 1590         LDA TXTPTR
 1600         PHA
 1610         LDA AS.CURLIN+1
 1620         PHA
 1630         LDA AS.CURLIN
 1640         PHA
 1650         LDA #TKN.GOSUB
 1660         PHA
 1670         BNE .4       ...ALWAYS
 1680  *---SETUP FOR GOTO---------------
 1690  .3     PLA          POP RETURN TO "NEWSTT"
 1700         PLA
 1710  *---FIND LABEL AFTER TOKEN-------
 1720  .4     JSR AS.CHRGET
 1730         BEQ .1
 1740         JSR AS.FRMEVL     EVALUATE EXPRESSION
 1750         BIT AS.VALTYP     $00 IF NUMERIC, $FF IF STRING
 1760         BMI .5            ...STRING
 1770  *---NUMERIC EXPRESSION-----------
 1780         JSR AS.GETADR     CONVERT TO INTEGER
 1790         JSR AS.GOTO1
 1800         JMP AS.NEWSTT
 1810  *---FREE ANY TEMP STRINGS--------
 1820  .45    LDA AS.TEMPPT+1
 1830         LDY #0
 1840         JSR AS.FRETMP
 1850  .5     LDA AS.TEMPPT
 1860         CMP #$56     EMPTY?
 1870         BCS .45      ...NO, FREE A STRING
 1880  *---COPY STRING LENGTH/ADDRESS---
 1890         LDY #2
 1900  .55    LDA (VPNT),Y
 1910         STA STRLEN,Y
 1920         DEY
 1930         BPL .55
 1940  *---SEARCH PROGRAM FOR LABEL-----
 1950         LDA PRGBOT+1      POINT TO BEGINNING
 1960         LDX PRGBOT           OF PROGRAM
 1970  *---LOOK AT NEXT LINE------------
 1980  .6     STA PNTR+1   UPDATE PNTR TO NEXT LINE
 1990         STX PNTR
 2000         LDY #1       HI-BYTE OF FWD PNTR
 2010         LDA (PNTR),Y
 2020         BEQ .11      ...END OF PROGRAM
 2030  *---CHECK FOR 'REM "'------------
 2040         LDY #4
 2050         LDA (PNTR),Y
 2060         CMP #TKN.REM
 2070         BNE .10      ...NOT REM STATEMENT
 2080  .7     INY          NEXT BYTE OF LINE
 2090         LDA (PNTR),Y
 2100         CMP #' '     IGNORE BLANKS BEFORE "
 2110         BEQ .7
 2120         CMP #'"'     " YET?
 2130         BNE .10      ...NO, NOT A LABEL
 2140  *---COMPARE LABEL----------------
 2150         STY INDEX.REM
 2160         LDA #-1
 2170         STA INDEX.GO
 2180  .8     INC INDEX.REM
 2190         LDY INDEX.REM
 2200         LDA (PNTR),Y
 2210         BEQ .1       ...EARLY END OF LABEL
 2220         INC INDEX.GO
 2230         LDY INDEX.GO
 2240         CMP #'"'     LEGAL END OF LABEL?
 2250         BEQ .9       ...YES
 2260         CMP (STRADR),Y
 2270         BEQ .8       ...KEEP MATCHING
 2280         BNE .10      ...DOESN'T MATCH
 2290  .9     CPY STRLEN   CORRECT LENGTH?
 2300         BNE .10      ...NO, KEEP SEARCHING
 2310  *---FOUND LABEL, SO GO TO IT-----
 2320         JSR AS.GOTO.3
 2330         JMP AS.NEWSTT
 2340  *---DOESN'T MATCH, TRY NEXT LINE-
 2350  .10    LDY #0       GET FORWARD POINTER
 2360         LDA (PNTR),Y      LO-BYTE
 2370         TAX
 2380         INY               HI-BYTE
 2390         LDA (PNTR),Y
 2400         BNE .6       ...NOT END OF PROGRAM YET
 2410  *---END OF PROGRAM, UNDEF LBL----
 2420  .11    JMP AS.UNDERR

