annotate src/vars.s @ 132:917b4893bb3d

Checkpoint before redoing a bunch of code for clarity
author William Astle <lost@l-w.ca>
date Mon, 24 Jun 2024 23:44:39 -0600
parents 9f23ddc5165f
children e49bd0493baf
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)
132
917b4893bb3d Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents: 130
diff changeset
14 prog_linetab rmb 2 ; pointer to start of the program line table
917b4893bb3d Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents: 130
diff changeset
15 prog_linetabp rmb 2 ; pointer to the first free program line table entry
917b4893bb3d Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents: 130
diff changeset
16 prog_text rmb 2 ; start of the program text data (immediately after the line table)
917b4893bb3d Checkpoint before redoing a bunch of code for clarity
William Astle <lost@l-w.ca>
parents: 130
diff changeset
17 vartab rmb 2 ; pointer to start of integer scalars (the runtime heap)
73
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
18 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
19 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
20 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
21 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
22 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
23 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
24 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
25 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
26 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
27 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
28 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
29 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
30 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
31 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
32 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
33 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
34 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
35 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
36 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
37 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
38 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
39 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
40 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
41 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
42 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
43 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
44 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
45 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
46 parse_curtok rmb 1 ; current token type code
130
9f23ddc5165f Various updates to parsing scheme to handle errors and make it build
William Astle <lost@l-w.ca>
parents: 121
diff changeset
47 parse_stackptr rmb 2 ; saved stack pointer for bailing out from random parse points
100
6db72a92ff7a Make value accumulator descriptions consistent and make usage consistent
William Astle <lost@l-w.ca>
parents: 85
diff changeset
48 ; 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
49 ; 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
50 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
51 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
52 ; 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
53 ; 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
54 ; 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
55 ; 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
56 ; 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
57 ; system.
80
bb50ac9fdf37 Checkpoint with very basic integer and floating point arithmetic, untested
William Astle <lost@l-w.ca>
parents: 73
diff changeset
58 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
59 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
60 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
61 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
62 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
63 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
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71 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
72 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
73 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
74 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
75 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
76 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
77 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
78 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
79 ifne *&0x1ff
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
80 rmb 0x200-(*&0x1ff)
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
81 endc
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
82 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
83 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
84 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
85 ; 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
86 ;
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
87 ; 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
88 ; 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
89 ; 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
90 ; 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
91 ; 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
92 ; 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
93 ; 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
94 ;
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
95 ; 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
96 ;
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
97 ; 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
98 ; vartabint 4 Integer scalars
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
99 ; vartablong 6 Long integer scalars
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
100 ; vartabfloat 7 Floating point scalars
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
101 ; vartabstring 6 String scalars
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
102 ;
2d52cd154ed1 Split some code into separate files for easier management
William Astle <lost@l-w.ca>
parents:
diff changeset
103 ; 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
104 *pragmapop list