Overview

This is a simulation of a Forth-based graphing calculator running on a 6507 microprocessor, which is a derivative of the 6502. The calculator has an 8 level stack. Unlike most Forths, stack items can be one of four types: 64-bit decimal floating point, 16-bit hexadecimal number, 16-bit garbage collected pointer, and strings up to 8 characters in length. The floating point numbers use decimal arithmetic and have 12 digits of precision with an exponent range of ±999.

See System information above to pause the simulation and step through the program.

GitHub: 6507 Graphing Calculator


Input
Numbers, operations, and words (in Forth, “words” are equivalent to functions or subroutines) can be entered on the input line. Multiple items can be entered on the same line.

Before
After

The exponent symbol is lowercase e which is accessed with shift+e. Uppercase E will not work!

Shift+e for exponent symbol
Uppercase E will not work!

Input has the following limitations:


Data Types
There are four data types. Check the Word List to see which data types each word accepts.

float

decimal floating point number with 12 decimal digits of precision and ±999 exponent range. Press shift+e for exponent symbol.
Minimum value: 1e-999

Maximum value: 9.99999999999e999
Examples: 5, 3.14159, 123e20

raw hex

16-bit hexadecimal number. Prefixed with $.
Examples: $7, $1AF9

smart hex

16-bit garbage collected pointer. Prefixed with $. The pointer is automatically updated during garbage collection. Produced by the word ' and cannot be entered manually by the user.

string

string of up to 8 characters.
Example: "HELLO!"


Variables
Variables can be created with the word VAR and stored to with the word STO. If a variable does not exist, STO will create it. To recall the value stored in a variable, use the variable's name. Pressing Shift+S produces the symbol 🡪 which is a shortcut for STO.

Storing 5 in X
Fetching the value of X


Value of X
Shift+S for 🡪 is also STO

Important: Do NOT use ! or C! to store data in a variable! These words are for low-level system access only.


Words
See the Word List for a description of each word the calculator supports. Below is a list of all words organized by category:

Stack - Words for manipulating the stack
CLEAR DROP DUP OVER ROT -ROT SWAP

Math - Words for mathematical calculations
+ - * / ABS MAX MIN COS SIN TAN DEG PI

Logic - Words for bitwise logic operations
AND NOT OR XOR LS RS

Variables - Words for managing variables
VAR STO

Programming - Words for defining and controling programs
: ; EXIT HALT QUIT

Conditionals - Words for conditional program structures
= <> > < IF ELSE THEN

Loops - Words for loop structures
DO LOOP LEAVE I J K BEGIN AGAIN UNTIL

System - Words for low-level system access
! @ C! C@ ' EXEC FREE

Important: Do NOT use ! or C! to store data in a variable! These words are for low-level system access only.


Programming
The programming model is very similar to other Forths. New words are defined with the : word and end with ; (in Forth, “words” are equivalent to functions or subroutines). The following example defines a word FOO that pushes 5 to the stack:
: FOO 5 ;

The calculator has 2 KB of RAM with about 1.6 KB free for programs and variables.

See the Words section above for all supported words.


Hardware
Processor: MOS 6507


RAM: 2 KB
ROM: 8 KB

Current prototype: