annotate src/vars.s @ 125:0607e4e20702

Correct offset error for keyword table lookup
author William Astle <lost@l-w.ca>
date Sun, 07 Jan 2024 20:35:51 -0700
parents 5d5472b11ccd
children 9f23ddc5165f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
73
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
1 *pragmapush list
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
2 *pragma list
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
3 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
4 ; Start of memory which has the direct page and other data.
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
5 org 0
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
6 dpstart equ * ; start of direct page
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
7 zero rmb 2 ; constant zero word used for faster zeroing of 16 bit registers
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
8 binval rmb 2 ; arbitary binary value, usually a line number or integer
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
9 memtop rmb 2 ; absolute top of memory in 64K memory map
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
10 memsize rmb 2 ; top of memory not reserved
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
11 freetop rmb 2 ; top of free memory (bottom of string space)
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
12 stringtab rmb 2 ; bottom of used string space
119
a6a53e5c04bd Make a call stack implementation that is more complete and maybe cleaner.
William Astle <lost@l-w.ca>
parents: 100
diff changeset
13 cstackptr rmb 2 ; bottom of the "stack frame" stack (the actual stack is below here)
73
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
14 progtext rmb 2 ; pointer to start of program text
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
15 vartab rmb 2 ; pointer to start of integer scalars
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
16 objecttab rmb 2 ; pointer to start of arrays and other variable sized objects
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
17 freestart rmb 2 ; pointer to start of unallocated memory
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
18 readlinenoecho rmb 1 ; if nonzero, the readline routine won't echo its input
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
19 console_curptr rmb 2 ; current cursor pointer for console driver
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
20 console_blnkdel rmb 1 ; cursor blink delay
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
21 console_truelc rmb 1 ; set to nonzero if the console supports true lower case (gfx, etc.)
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
22 filenum rmb 1 ; current input/output channel
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
23 fileeof rmb 1 ; flag for whether last read detected EOF
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
24 keyb_flags rmb 1 ; shift flags for the keyboard
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
25 keyb_joystate rmb 1 ; joystick button state
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
26 keyb_repdel rmb 1 ; repeat delay
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
27 keyb_curscan rmb 1 ; current repeating scan code
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
28 keyb_buffw rmb 2 ; keyboard ring buffer write pointer
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
29 keyb_buffr rmb 2 ; keyboard ring buffer read pointer
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
30 curline rmb 2 ; pointer to current line
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
31 contline rmb 2 ; pointer to line for CONT
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
32 contstmt rmb 2 ; interpretation pointer for CONT
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
33 curstmt rmb 2 ; start of statement currently being interpreted
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
34 endflag rmb 1 ; 00 = END, FF = STOP
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
35 stringstackptr rmb 2 ; anonymous string descriptor stack pointer
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
36 tok_skipkw rmb 1 ; flag for when skipping an unrecognized keyword
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
37 tok_skipdt rmb 1 ; flag for when processing DATA
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
38 tok_kwtype rmb 1 ; primary/secondary type flag for tokens
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
39 tok_kwnum rmb 1 ; the actual token number
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
40 tok_kwmatchl rmb 1 ; the length of the best match during lookup
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
41 tok_kwmatch rmb 2 ; the current best matched token number
121
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents: 119
diff changeset
42 parse_noout rmb 1 ; flag for whether we're outputting encoded lines when parsing
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents: 119
diff changeset
43 parse_tokenst rmb 2 ; pointer into input buffer of start of currently parsed token
5d5472b11ccd Initital skeleton of separation of separate parsing scheme
William Astle <lost@l-w.ca>
parents: 119
diff changeset
44 parse_curtok rmb 1 ; current token type code
100
6db72a92ff7a Make value accumulator descriptions consistent and make usage consistent
William Astle <lost@l-w.ca>
parents: 85
diff changeset
45 ; General value accumulators used during expression evaluation. These are in the same format used for storing
6db72a92ff7a Make value accumulator descriptions consistent and make usage consistent
William Astle <lost@l-w.ca>
parents: 85
diff changeset
46 ; values in variables with the exception of having a type flag.
80
bb50ac9fdf37 Checkpoint with very basic integer and floating point arithmetic, untested
William Astle <lost@l-w.ca>
parents: 73
diff changeset
47 val0 rmb val.size ; value accumulator 0 - current expression value
bb50ac9fdf37 Checkpoint with very basic integer and floating point arithmetic, untested
William Astle <lost@l-w.ca>
parents: 73
diff changeset
48 val1 rmb val.size ; value accumulator 1 - usually left operand of binary operator
100
6db72a92ff7a Make value accumulator descriptions consistent and make usage consistent
William Astle <lost@l-w.ca>
parents: 85
diff changeset
49 ; The fpa0 and fpa1 areas are used for scratch work during floating point operations. They are only used by
6db72a92ff7a Make value accumulator descriptions consistent and make usage consistent
William Astle <lost@l-w.ca>
parents: 85
diff changeset
50 ; floating point operations and operations related to floating point such as number conversion. This saves a fair
6db72a92ff7a Make value accumulator descriptions consistent and make usage consistent
William Astle <lost@l-w.ca>
parents: 85
diff changeset
51 ; few clock cycles over simply working off the index register pointers passed into the routines and it also allows
6db72a92ff7a Make value accumulator descriptions consistent and make usage consistent
William Astle <lost@l-w.ca>
parents: 85
diff changeset
52 ; for being able to leave the input operands for the routines unmodified, or to overlap the input and output
6db72a92ff7a Make value accumulator descriptions consistent and make usage consistent
William Astle <lost@l-w.ca>
parents: 85
diff changeset
53 ; operands. These floating point accumulators can hold the maximum precision floating point values used by the
6db72a92ff7a Make value accumulator descriptions consistent and make usage consistent
William Astle <lost@l-w.ca>
parents: 85
diff changeset
54 ; system.
80
bb50ac9fdf37 Checkpoint with very basic integer and floating point arithmetic, untested
William Astle <lost@l-w.ca>
parents: 73
diff changeset
55 fpa0 rmb fpa.size ; floating point accumulator 1
bb50ac9fdf37 Checkpoint with very basic integer and floating point arithmetic, untested
William Astle <lost@l-w.ca>
parents: 73
diff changeset
56 fpa1 rmb fpa.size ; floating point accumulator 1
85
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 80
diff changeset
57 fpaextra rmb 12 ; "extra" bytes for calculations
73
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
58 rmb 0x71-* ; align RSTFLG/RSTVEC for stock ROM compatibility
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
59 RSTFLG rmb 1 ; 0x55 if RSTVEC is valid
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
60 RSTVEC rmb 2 ; points to warm start routine (must start with NOP)
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
61 inputptr rmb 2 ; pointer to current program execution location
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
62 rmb 0x100-* ; make sure the stuff that isn't direct page is outside of it
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
63 SW3VEC rmb 3 ; SWI3 vector (for compatibility)
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
64 SW2VEC rmb 3 ; SWI2 vector (for compatibility)
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
65 SWIVEC rmb 3 ; SWI vector (for compatibility)
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
66 NMIVEC rmb 3 ; NMI vector (for compatibility)
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
67 IRQVEC rmb 3 ; IRQ vector (for compatibility)
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
68 FRQVEC rmb 3 ; FIRQ vector (for compatibility)
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
69 keyb_state rmb 8 ; rollover table state
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
70 keyb_buff rmb keyb_bufflen ; the keyboard ring buffer
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
71 linebuff rmb linebuffsize ; the line input buffer
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
72 tokebuff rmb linebuffsize+50 ; make it as long as line buffer plus a margin
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
73 stringstack rmb 5*stringstacknum ; reserve space for the anonymous string descriptor stack
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
74 stringstackend equ * ; end of string stack buffer
85
663d8e77b579 Implmement BCD floating point and update number parsing and printing
William Astle <lost@l-w.ca>
parents: 80
diff changeset
75 strbuff rmb 20 ; temporary string buffer for converting numbers and other things
73
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
76 ifne *&0x1ff
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
77 rmb 0x200-(*&0x1ff)
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
78 endc
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
79 textscreen rmb 0x200 ; the actual text screen (must be on 512 byte alignment)
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
80 heapstart equ * ; start of dynamically allocated stuff
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
81 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
82 ; The heap has the following items in order:
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
83 ;
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
84 ; Program text: preceded by a NUL and pointed to by progtext
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
85 ; Variable table: pointed to by vartab; contains records for all scalar and array variables
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
86 ; Free space: unused memory between the object table and the stack; pointed to by freestart
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
87 ; The stack: grows downward from the bottom of string space, pointed to by the stack pointer, obviously
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
88 ; String space: garbage collected non-constant string data pointed to by freetop
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
89 ; Reserved memory: immediately above string space; pointed to by memsize
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
90 ; Actual top of RAM: top of reserved memory; pointed to by memtop
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
91 ;
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
92 ; The variable table consists of several symbol tables defined as follows:
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
93 ;
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
94 ; Pointer Size of entry Variable types
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
95 ; vartabint 4 Integer scalars
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
96 ; vartablong 6 Long integer scalars
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
97 ; vartabfloat 7 Floating point scalars
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
98 ; vartabstring 6 String scalars
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
99 ;
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
100 ; Each entry starts with 2 bytes for the variable name followed by the data payload.
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
101 *pragmapop list