view src/vars.s @ 80:bb50ac9fdf37

Checkpoint with very basic integer and floating point arithmetic, untested This commit has implementations for floating point add, subtract, multiply, and divide, along with 32 bit signed integer equivalents. These can probably be optimized and they are untested.
author William Astle <lost@l-w.ca>
date Sat, 07 Oct 2023 02:56:59 -0600
parents 2d52cd154ed1
children 663d8e77b579
line wrap: on
line source

                *pragmapush list
                *pragma list
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Start of memory which has the direct page and other data.
                org 0
dpstart         equ *                           ; start of direct page
zero            rmb 2                           ; constant zero word used for faster zeroing of 16 bit registers
binval          rmb 2                           ; arbitary binary value, usually a line number or integer
memtop          rmb 2                           ; absolute top of memory in 64K memory map
memsize         rmb 2                           ; top of memory not reserved
freetop         rmb 2                           ; top of free memory (bottom of string space)
stringtab       rmb 2                           ; bottom of used string space
stackptr        rmb 2                           ; bottom of the "stack frame" stack (the actual stack is below here)
progtext        rmb 2                           ; pointer to start of program text
vartab          rmb 2                           ; pointer to start of integer scalars
objecttab       rmb 2                           ; pointer to start of arrays and other variable sized objects
freestart       rmb 2                           ; pointer to start of unallocated memory
readlinenoecho  rmb 1                           ; if nonzero, the readline routine won't echo its input
console_curptr  rmb 2                           ; current cursor pointer for console driver
console_blnkdel rmb 1                           ; cursor blink delay
console_truelc  rmb 1                           ; set to nonzero if the console supports true lower case (gfx, etc.)
filenum         rmb 1                           ; current input/output channel
fileeof         rmb 1                           ; flag for whether last read detected EOF
keyb_flags      rmb 1                           ; shift flags for the keyboard
keyb_joystate   rmb 1                           ; joystick button state
keyb_repdel     rmb 1                           ; repeat delay
keyb_curscan    rmb 1                           ; current repeating scan code
keyb_buffw      rmb 2                           ; keyboard ring buffer write pointer
keyb_buffr      rmb 2                           ; keyboard ring buffer read pointer
curline         rmb 2                           ; pointer to current line
contline        rmb 2                           ; pointer to line for CONT
contstmt        rmb 2                           ; interpretation pointer for CONT
curstmt         rmb 2                           ; start of statement currently being interpreted
endflag         rmb 1                           ; 00 = END, FF = STOP
stringstackptr  rmb 2                           ; anonymous string descriptor stack pointer
tok_skipkw      rmb 1                           ; flag for when skipping an unrecognized keyword
tok_skipdt      rmb 1                           ; flag for when processing DATA
tok_kwtype      rmb 1                           ; primary/secondary type flag for tokens
tok_kwnum       rmb 1                           ; the actual token number
tok_kwmatchl    rmb 1                           ; the length of the best match during lookup
tok_kwmatch     rmb 2                           ; the current best matched token number
; General value accumulators used during expression evaluation
val0            rmb val.size                    ; value accumulator 0 - current expression value
val1            rmb val.size                    ; value accumulator 1 - usually left operand of binary operator
; The fpa0 and fpa1 areas are used for scratch work during floating point operations. They are only used
; by floating point operations. This saves a fair fiew clock cycles over simply working off the index register
; pointers passed into the routines and it also allows for being able to leave the input operands for the
; routines unmodified, or to overlap the input and output operands. These floating point accumulators can hold
; the maximum precision floating point values used by the system.
fpa0            rmb fpa.size                    ; floating point accumulator 1
fpa1            rmb fpa.size                    ; floating point accumulator 1
fpa0extra       rmb 1                           ; "extra" bytes for calculations
fpa0extra1      rmb 1
fpa0extra2      rmb 1
fpa0extra3      rmb 1
fpa0extra4      rmb 1
fpa0extra5      rmb 1
fpa0extra6      rmb 1
fpa0extra7      rmb 1
fpa0extra8      rmb 1
fpa0extra9      rmb 1
fpa0extra10     rmb 1
fpa0extra11     rmb 1
fpa0extra12     rmb 1
                rmb 0x71-*                      ; align RSTFLG/RSTVEC for stock ROM compatibility
RSTFLG          rmb 1                           ; 0x55 if RSTVEC is valid
RSTVEC          rmb 2                           ; points to warm start routine (must start with NOP)
inputptr        rmb 2                           ; pointer to current program execution location
                rmb 0x100-*                     ; make sure the stuff that isn't direct page is outside of it
SW3VEC          rmb 3                           ; SWI3 vector (for compatibility)
SW2VEC          rmb 3                           ; SWI2 vector (for compatibility)
SWIVEC          rmb 3                           ; SWI vector (for compatibility)
NMIVEC          rmb 3                           ; NMI vector (for compatibility)
IRQVEC          rmb 3                           ; IRQ vector (for compatibility)
FRQVEC          rmb 3                           ; FIRQ vector (for compatibility)
keyb_state      rmb 8                           ; rollover table state
keyb_buff       rmb keyb_bufflen                ; the keyboard ring buffer
linebuff        rmb linebuffsize                ; the line input buffer
tokebuff        rmb linebuffsize+50             ; make it as long as line buffer plus a margin
stringstack     rmb 5*stringstacknum            ; reserve space for the anonymous string descriptor stack           
stringstackend  equ *                           ; end of string stack buffer
                ifne *&0x1ff
                rmb 0x200-(*&0x1ff)
                endc
textscreen      rmb 0x200                       ; the actual text screen (must be on 512 byte alignment)
heapstart       equ *                           ; start of dynamically allocated stuff
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; The heap has the following items in order:
;
; Program text: preceded by a NUL and pointed to by progtext
; Variable table: pointed to by vartab; contains records for all scalar and array variables
; Free space: unused memory between the object table and the stack; pointed to by freestart
; The stack: grows downward from the bottom of string space, pointed to by the stack pointer, obviously
; String space: garbage collected non-constant string data pointed to by freetop
; Reserved memory: immediately above string space; pointed to by memsize
; Actual top of RAM: top of reserved memory; pointed to by memtop
;
; The variable table consists of several symbol tables defined as follows:
;
; Pointer       Size of entry   Variable types
; vartabint     4               Integer scalars
; vartablong    6               Long integer scalars
; vartabfloat   7               Floating point scalars
; vartabstring  6               String scalars
;
; Each entry starts with 2 bytes for the variable name followed by the data payload.
                *pragmapop list