automated token numbers

This commit is contained in:
Michael Steil 2008-10-12 19:04:31 +00:00
parent c75db6a559
commit a40c027b70
13 changed files with 140 additions and 317 deletions

View File

@ -9,5 +9,6 @@ SEGMENTS {
VECTORS: load = BASROM, type = ro; VECTORS: load = BASROM, type = ro;
KEYWORDS: load = BASROM, type = ro; KEYWORDS: load = BASROM, type = ro;
CODE: load = BASROM, type = ro; CODE: load = BASROM, type = ro;
DUMMY: load = BASROM, type = zp; # don't include
} }

View File

@ -9,5 +9,6 @@ SEGMENTS {
VECTORS: load = BASROM, type = ro; VECTORS: load = BASROM, type = ro;
KEYWORDS: load = BASROM, type = ro; KEYWORDS: load = BASROM, type = ro;
CODE: load = BASROM, type = ro; CODE: load = BASROM, type = ro;
DUMMY: load = BASROM, type = zp; # don't include
} }

View File

@ -9,5 +9,6 @@ SEGMENTS {
VECTORS: load = BASROM, type = ro; VECTORS: load = BASROM, type = ro;
KEYWORDS: load = BASROM, type = ro; KEYWORDS: load = BASROM, type = ro;
CODE: load = BASROM, type = ro; CODE: load = BASROM, type = ro;
DUMMY: load = BASROM, type = zp; # don't include
} }

View File

@ -41,25 +41,6 @@ BYTES_FP := 5
MANTISSA_BYTES := BYTES_FP-1 MANTISSA_BYTES := BYTES_FP-1
MAX_EXPON = 10 MAX_EXPON = 10
TOKEN_GOTO := $88
TOKEN_GOSUB := $8C
TOKEN_REM := $8E
TOKEN_PRINT := $96
TOKEN_TAB := $9C
TOKEN_TO := $9D
TOKEN_FN := $9E
TOKEN_SPC := $9F
TOKEN_THEN := $A0
TOKEN_NOT := $A1
TOKEN_STEP := $A2
TOKEN_PLUS := $A3
TOKEN_MINUS := $A4
TOKEN_GREATER := $AA
TOKEN_EQUAL := $AB
TOKEN_SGN := $AD
TOKEN_LEFTSTR := $C1
RAMSTART3 := $2A00 RAMSTART3 := $2A00
RAMSTART2 := $2A00 RAMSTART2 := $2A00
LF689 := $F689 LF689 := $F689

View File

@ -85,25 +85,6 @@ MAX_EXPON = 10
RAMSTART2 := $0400 RAMSTART2 := $0400
RAMSTART3 := $0400 RAMSTART3 := $0400
TOKEN_GOTO := $89
TOKEN_GOSUB := $8D
TOKEN_REM := $8F
TOKEN_PRINT := $99
TOKEN_TAB := $A3
TOKEN_TO := $A4
TOKEN_FN := $A5
TOKEN_SPC := $A6
TOKEN_THEN := $A7
TOKEN_NOT := $A8
TOKEN_STEP := $A9
TOKEN_PLUS := $AA
TOKEN_MINUS := $AB
TOKEN_GREATER := $B1
TOKEN_EQUAL := $B2
TOKEN_SGN := $B4
TOKEN_LEFTSTR := $C8
OPEN := $FFC0 OPEN := $FFC0
CLOSE := $FFC3 CLOSE := $FFC3

View File

@ -24,66 +24,8 @@ SUBFLG := $000C;61
INPUTFLG := $000D;62 INPUTFLG := $000D;62
CPRMASK := $000E;63 CPRMASK := $000E;63
Z14 := $000F;64 ; Ctrl+O flag Z14 := $000F;64 ; Ctrl+O flag
;TEMPPT := $0015;65
;LASTPT := $0016;;66
;TEMPST := $0018;68
;INDEX := $0021;71
;DEST := $0023;73
;RESULT := $0025;75
;RESULT_LAST := $0028;78
;TXTTAB := $0029;79
;VARTAB := $002B;7B
;ARYTAB := $002D;7D
;STREND := $002F;7F
;FRETOP := $0031;81
;FRESPC := $0033;83
;MEMSIZ := $0035;;85
;CURLIN := $0037;87
;OLDLIN := $0039;89
;OLDTEXT := $003B;8B
;Z8C := $003D;8D
;DATPTR := $003F;8F
;INPTR := $0041;91
;VARNAM := $0043;93
;VARPNT := $0045;95
;FORPNT := $0047;97
;LASTOP := $0049;99
;CPRTYP := $004B;9B
;FNCNAM := $004C;9C
;TEMP3 := $004C;;9C ; same
;DSCPTR := $004E;9E
;DSCLEN := $0050;A0
JMPADRS := $0093;A1 JMPADRS := $0093;A1
;
LENGTH := $0094
;Z52 := $0052;
;TEMP1 := $0053;A3
;ARGEXTENSION := $0053;;A3 ; same!
;HIGHDS := $0054;A4
;HIGHTR := $0056;A6
;INDX := $0058;;A8
;TEMP2 := $0058;;A8 ; same!
;TMPEXP := $0058;;A8 ; same
;EXPON := $0059;A9
;LOWTR := $005A;AA ; $AB also EXPSGN?
LOWTRX := $0094;AA ; $AB also EXPSGN? LOWTRX := $0094;AA ; $AB also EXPSGN?
;EXPSGN := $005B;;AB
;FAC := $005C;AC
;FAC_LAST := $005F;;AF
;FACSIGN := $0060;B0
;SERLEN := $0061;B1
;SHIFTSIGNEXT := $0062;B2
;ARG := $0063;B3
;ARG_LAST := $0066;;B6
;ARGSIGN := $0067;B7
;STRNG1 := $0068;B8 ; TODO: also SGNCPR
;FACEXTENSION := $0069;;B9
;STRNG2 := $006A;BA
;CHRGET := $006C;BC
;CHRGOT := $0072;C2
;TXTPTR := $0073;C3
RNDSEED := $00D4 RNDSEED := $00D4
@ -112,24 +54,6 @@ MAX_EXPON = 10
RAMSTART3 := $0300 RAMSTART3 := $0300
CONST_MEMSIZ := $3FFF CONST_MEMSIZ := $3FFF
TOKEN_GOTO := $88
TOKEN_GOSUB := $8C
TOKEN_REM := $8E
TOKEN_PRINT := $97
TOKEN_TAB := $9D
TOKEN_TO := $9E
TOKEN_FN := $9F
TOKEN_SPC := $A0
TOKEN_THEN := $A1
TOKEN_NOT := $A2
TOKEN_STEP := $A3
TOKEN_PLUS := $A4
TOKEN_MINUS := $A5
TOKEN_GREATER := $AB
TOKEN_EQUAL := $AC
TOKEN_SGN := $AE
TOKEN_LEFTSTR := $C2
RAMSTART2 := $0300 RAMSTART2 := $0300
LC000 = $C000 LC000 = $C000

View File

@ -42,21 +42,3 @@ BYTES_FP := 5
MANTISSA_BYTES := BYTES_FP-1 MANTISSA_BYTES := BYTES_FP-1
MAX_EXPON = 10 MAX_EXPON = 10
TOKEN_GOTO := $88
TOKEN_GOSUB := $8C
TOKEN_REM := $8E
TOKEN_PRINT := $97
TOKEN_TAB := $9D
TOKEN_TO := $9E
TOKEN_FN := $9F
TOKEN_SPC := $A0
TOKEN_THEN := $A1
TOKEN_NOT := $A2
TOKEN_STEP := $A3
TOKEN_PLUS := $A4
TOKEN_MINUS := $A5
TOKEN_GREATER := $AB
TOKEN_EQUAL := $AC
TOKEN_SGN := $AE
TOKEN_LEFTSTR := $C2

View File

@ -24,62 +24,6 @@ SUBFLG := $0061
INPUTFLG := $0062 INPUTFLG := $0062
CPRMASK := $0063 CPRMASK := $0063
Z14 := $0064 ; Ctrl+O flag Z14 := $0064 ; Ctrl+O flag
;TEMPPT := $0065
;LASTPT := $0066
;TEMPST := $68
;INDEX := $0071
;DEST := $0073
;RESULT := $0075
;RESULT_LAST := $0078
;TXTTAB := $0079
;VARTAB := $007B
;ARYTAB := $007D
;STREND := $007F
;FRETOP := $0081
;FRESPC := $0083
;MEMSIZ := $0085
;CURLIN := $0087
;OLDLIN := $0089
;OLDTEXT := $008B
;Z8C := $008D
;DATPTR := $008F
;INPTR := $0091
;VARNAM := $0093
;VARPNT := $0095
;FORPNT := $0097
;LASTOP := $0099
;CPRTYP := $009B
;FNCNAM := $009C
;TEMP3 := $009C ; same
;DSCPTR := $009E
;DSCLEN := $00A0
;JMPADRS := $00A1
;Z52 := $00A2
;TEMP1 := $00A3
;ARGEXTENSION := $00A3 ; same!
;HIGHDS := $00A4
;HIGHTR := $00A6
;INDX := $00A8
;TEMP2 := $00A8 ; same!
;TMPEXP := $00A8 ; same
;EXPON := $00A9
;LOWTR := $00AA ; $AB also EXPSGN?
;LOWTRX := $00AA ; $AB also EXPSGN?
;EXPSGN := $00AB
;FAC := $00AC
;FAC_LAST := $00AF
;FACSIGN := $00B0
;SERLEN := $00B1
;SHIFTSIGNEXT := $00B2
;ARG := $00B3
;ARG_LAST := $00B6
;ARGSIGN := $00B7
;STRNG1 := $00B8 ; TODO: also SGNCPR
;FACEXTENSION := $00B9
;STRNG2 := $00BA
;CHRGET := $00BC
;CHRGOT := $00C2
;TXTPTR := $00C3
RNDSEED := $00D4 RNDSEED := $00D4
@ -106,23 +50,4 @@ MANTISSA_BYTES := BYTES_FP-1
MAX_EXPON = 10 MAX_EXPON = 10
RAMSTART3 := $0300 RAMSTART3 := $0300
TOKEN_GOTO := $88
TOKEN_GOSUB := $8C
TOKEN_REM := $8E
TOKEN_PRINT := $97
TOKEN_TAB := $9C
TOKEN_TO := $9D
TOKEN_FN := $9E
TOKEN_SPC := $9F
TOKEN_THEN := $A0
TOKEN_NOT := $A1
TOKEN_STEP := $A2
TOKEN_PLUS := $A3
TOKEN_MINUS := $A4
TOKEN_GREATER := $AA
TOKEN_EQUAL := $AB
TOKEN_SGN := $AD
TOKEN_LEFTSTR := $C1
RAMSTART2 := $0300 RAMSTART2 := $0300

View File

@ -9,5 +9,6 @@ SEGMENTS {
VECTORS: load = BASROM, type = ro; VECTORS: load = BASROM, type = ro;
KEYWORDS: load = BASROM, type = ro; KEYWORDS: load = BASROM, type = ro;
CODE: load = BASROM, type = ro; CODE: load = BASROM, type = ro;
DUMMY: load = BASROM, type = zp; # don't include
} }

View File

@ -9,5 +9,6 @@ SEGMENTS {
VECTORS: load = BASROM, type = ro; VECTORS: load = BASROM, type = ro;
KEYWORDS: load = BASROM, type = ro; KEYWORDS: load = BASROM, type = ro;
CODE: load = BASROM, type = ro; CODE: load = BASROM, type = ro;
DUMMY: load = BASROM, type = zp; # don't include
} }

View File

@ -8,3 +8,43 @@
.endrep .endrep
.byte .strat(str,.strlen(str)-1) | $80 .byte .strat(str,.strlen(str)-1) | $80
.endmacro .endmacro
.macro keyword_addr key, vec, token
.segment "VECTORS"
.addr vec
.segment "KEYWORDS"
htasc key
define_token token
.endmacro
.macro define_token token
.segment "DUMMY"
.ifnblank token
token := <(*-DUMMY_START)+$80
.endif
.res 1
.endmacro
.macro keyword_rts key, vec, token
.segment "VECTORS"
.word vec-1
.segment "KEYWORDS"
htasc key
define_token token
.endmacro
.macro keyword key, token
.segment "KEYWORDS"
htasc key
define_token token
.endmacro
;.macro define_token name
; .segment "VECTORS"
; name := <(*-TOKEN_ADDRESS_TABLE)/2+$80
;.endmacro
.macro define_token_init
.segment "DUMMY"
DUMMY_START:
.endmacro

204
msbasic.s
View File

@ -169,9 +169,6 @@ DSCLEN:
JMPADRS: JMPADRS:
.endif .endif
.res 1 .res 1
.ifndef CONFIG_SMALL
LENGTH:
.endif
Z52: Z52:
.res 1 .res 1
ARGEXTENSION: ARGEXTENSION:
@ -256,165 +253,152 @@ STACK := $0100
.byte $00,$13,$56 .byte $00,$13,$56
.endif .endif
define_token_init
.segment "VECTORS" .segment "VECTORS"
TOKEN_ADDRESS_TABLE: TOKEN_ADDRESS_TABLE:
.segment "KEYWORDS" .segment "KEYWORDS"
TOKEN_NAME_TABLE: TOKEN_NAME_TABLE:
.macro keyvec key, vec keyword_rts "END", END
;.local label keyword_rts "FOR", FOR
.segment "VECTORS" keyword_rts "NEXT", NEXT
;label: keyword_rts "DATA", DATA
;.out label
.addr vec
.segment "KEYWORDS"
htasc key
.endmacro
.macro keyrts key, vec
.segment "VECTORS"
.word vec-1
.segment "KEYWORDS"
htasc key
.endmacro
keyrts "END", END
keyrts "FOR", FOR
keyrts "NEXT", NEXT
keyrts "DATA", DATA
.ifdef CONFIG_CBM_ALL .ifdef CONFIG_CBM_ALL
keyrts "INPUT#", INPUTH keyword_rts "INPUT#", INPUTH
.endif .endif
keyrts "INPUT", INPUT keyword_rts "INPUT", INPUT
keyrts "DIM", DIM keyword_rts "DIM", DIM
keyrts "READ", READ keyword_rts "READ", READ
.ifdef APPLE .ifdef APPLE
keyrts "PLT", PLT keyword_rts "PLT", PLT
.else .else
keyrts "LET", LET keyword_rts "LET", LET
.endif .endif
keyrts "GOTO", GOTO keyword_rts "GOTO", GOTO, TOKEN_GOTO
keyrts "RUN", RUN keyword_rts "RUN", RUN
keyrts "IF", IF keyword_rts "IF", IF
keyrts "RESTORE", RESTORE keyword_rts "RESTORE", RESTORE
keyrts "GOSUB", GOSUB keyword_rts "GOSUB", GOSUB, TOKEN_GOSUB
keyrts "RETURN", POP keyword_rts "RETURN", POP
.ifdef APPLE .ifdef APPLE
keyrts "TEX", TEX keyword_rts "TEX", TEX, TOKEN_REM
.else .else
keyrts "REM", REM keyword_rts "REM", REM, TOKEN_REM
.endif .endif
keyrts "STOP", STOP keyword_rts "STOP", STOP
keyrts "ON", ON keyword_rts "ON", ON
.ifdef CONFIG_NULL .ifdef CONFIG_NULL
keyrts "NULL", NULL keyword_rts "NULL", NULL
.endif .endif
.ifdef KBD .ifdef KBD
keyrts "PLOD", PLOD keyword_rts "PLOD", PLOD
keyrts "PSAV", PSAV keyword_rts "PSAV", PSAV
keyrts "VLOD", VLOD keyword_rts "VLOD", VLOD
keyrts "VSAV", VSAV keyword_rts "VSAV", VSAV
.else .else
keyrts "WAIT", WAIT keyword_rts "WAIT", WAIT
keyrts "LOAD", LOAD keyword_rts "LOAD", LOAD
keyrts "SAVE", SAVE keyword_rts "SAVE", SAVE
.endif .endif
.ifdef CONFIG_CBM_ALL .ifdef CONFIG_CBM_ALL
keyrts "VERIFY", VERIFY keyword_rts "VERIFY", VERIFY
.endif .endif
keyrts "DEF", DEF keyword_rts "DEF", DEF
.ifdef KBD .ifdef KBD
keyrts "SLOD", SLOD keyword_rts "SLOD", SLOD
.else .else
keyrts "POKE", POKE keyword_rts "POKE", POKE
.endif .endif
.ifdef CONFIG_CBM_ALL .ifdef CONFIG_CBM_ALL
keyrts "PRINT#", PRINTH keyword_rts "PRINT#", PRINTH
.endif .endif
keyrts "PRINT", PRINT keyword_rts "PRINT", PRINT, TOKEN_PRINT
keyrts "CONT", CONT keyword_rts "CONT", CONT
keyrts "LIST", LIST keyword_rts "LIST", LIST
.ifdef CONFIG_CBM_ALL .ifdef CONFIG_CBM_ALL
keyrts "CLR", CLEAR keyword_rts "CLR", CLEAR
.else .else
keyrts "CLEAR", CLEAR keyword_rts "CLEAR", CLEAR
.endif .endif
.ifdef CONFIG_CBM_ALL .ifdef CONFIG_CBM_ALL
keyrts "CMD", CMD keyword_rts "CMD", CMD
keyrts "SYS", SYS keyword_rts "SYS", SYS
keyrts "OPEN", OPEN keyword_rts "OPEN", OPEN
keyrts "CLOSE", CLOSE keyword_rts "CLOSE", CLOSE
.endif .endif
.ifndef CONFIG_SMALL .ifndef CONFIG_SMALL
keyrts "GET", GET keyword_rts "GET", GET
.endif .endif
.ifdef KBD .ifdef KBD
keyrts "PRT", PRT keyword_rts "PRT", PRT
.endif .endif
keyrts "NEW", NEW keyword_rts "NEW", NEW
.segment "KEYWORDS" .segment "KEYWORDS"
htasc "TAB(" keyword "TAB(", TOKEN_TAB
htasc "TO" keyword "TO", TOKEN_TO
htasc "FN" keyword "FN", TOKEN_FN
htasc "SPC(" keyword "SPC(", TOKEN_SPC
htasc "THEN" keyword "THEN", TOKEN_THEN
htasc "NOT" keyword "NOT", TOKEN_NOT
htasc "STEP" keyword "STEP", TOKEN_STEP
htasc "+" keyword "+", TOKEN_PLUS
htasc "-" keyword "-", TOKEN_MINUS
htasc "*" keyword "*"
htasc "/" keyword "/"
.ifdef KBD .ifdef KBD
htasc "#" keyword "#"
.else .else
htasc "^" keyword "^"
.endif .endif
htasc "AND" keyword "AND"
htasc "OR" keyword "OR"
htasc ">" keyword ">", TOKEN_GREATER
htasc "=" keyword "=", TOKEN_EQUAL
htasc "<" keyword "<"
.segment "VECTORS" .segment "VECTORS"
UNFNC: UNFNC:
keyvec "SGN", SGN keyword_addr "SGN", SGN, TOKEN_SGN
keyvec "INT", INT keyword_addr "INT", INT
keyvec "ABS", ABS keyword_addr "ABS", ABS
.ifdef KBD .ifdef KBD
keyvec "VER", VER keyword_addr "VER", VER
.else .else
.ifdef KIM .ifdef KIM
keyvec "USR", IQERR keyword_addr "USR", IQERR
.else .else
keyvec "USR", USR keyword_addr "USR", USR
.endif .endif
.endif .endif
keyvec "FRE", FRE keyword_addr "FRE", FRE
keyvec "POS", POS keyword_addr "POS", POS
keyvec "SQR", SQR keyword_addr "SQR", SQR
keyvec "RND", RND keyword_addr "RND", RND
keyvec "LOG", LOG keyword_addr "LOG", LOG
keyvec "EXP", EXP keyword_addr "EXP", EXP
keyvec "COS", COS keyword_addr "COS", COS
keyvec "SIN", SIN keyword_addr "SIN", SIN
keyvec "TAN", TAN keyword_addr "TAN", TAN
keyvec "ATN", ATN keyword_addr "ATN", ATN
.ifdef KBD .ifdef KBD
keyvec "GETC", GETC keyword_addr "GETC", GETC
.else .else
keyvec "PEEK", PEEK keyword_addr "PEEK", PEEK
.endif .endif
keyvec "LEN", LEN keyword_addr "LEN", LEN
keyvec "STR$", STR keyword_addr "STR$", STR
keyvec "VAL", VAL keyword_addr "VAL", VAL
keyvec "ASC", ASC keyword_addr "ASC", ASC
keyvec "CHR$", CHRSTR keyword_addr "CHR$", CHRSTR
keyvec "LEFT$", LEFTSTR keyword_addr "LEFT$", LEFTSTR, TOKEN_LEFTSTR
keyvec "RIGHT$", RIGHTSTR keyword_addr "RIGHT$", RIGHTSTR
keyvec "MID$", MIDSTR keyword_addr "MID$", MIDSTR
.ifdef CBM2_KBD .ifdef CBM2_KBD
htasc "GO" keyword "GO"
.endif .endif
.byte 0 .segment "KEYWORDS"
.byte 0
.segment "VECTORS" .segment "VECTORS"
MATHTBL: MATHTBL:

View File

@ -9,5 +9,6 @@ SEGMENTS {
VECTORS: load = BASROM, type = ro; VECTORS: load = BASROM, type = ro;
KEYWORDS: load = BASROM, type = ro; KEYWORDS: load = BASROM, type = ro;
CODE: load = BASROM, type = ro; CODE: load = BASROM, type = ro;
DUMMY: load = BASROM, type = zp; # don't include
} }