SRAM space pointers

A project log for blinkyBasic

BASIC interpreter for the Arduino. Inspired by the Woz's Integer BASIC.

Bob BurnsBob Burns 10/17/2015 at 22:450 Comments

One of the challenges of writing a BASIC for the Arduino is the amount of available SRAM space. The Atmega328p has only 0x8FF bytes which include the stack and the internal i/o registers. So what I did was use a 32K eeprom chip and locally store a table of pointers. So my SRAM space looks like this:

0x0000 - 0x00FF register

0x0100 - 0x0569 program pointer memory. 6 bytes per pointer: first 2 bytes are line number, 2nd 2 bytes are a pointer to the next line, and 3rd 2 bytes are a pointer to the EEPROM address. (0A 00 06 01 00 00 is line 10). I also wrote a neat algorithm so you can insert line numbers by pointing to the end of the ppm space. Equals 188 lines max.

0x0570 - 0x062A int pointers. 4 bytes per poiner. first 2 bytes = 2 char name, 2nd 2 bytes = 16bit value. LSB first. 46 possible vars. But with the dim function I'm hoping to be able to use arrays.

0x062B - 0x0655 string pointers. 4 bytes per pointer. like ints. maximum chars in eprom are 128 chars.

0x0656 - 0x75F internal variables and pointers (265 bytes)

0x0760 - 0x080C input buffer. for getline and other buffering

0x080D - 0x0881 output buffer

0x0882 - 0x08FF stack. 125 bytes of stack. tight squeeze.