Compiling Assembly Script in External EEPROM to Arduino Code

I'm working on a simple game console, and I'm planning to use a cartridge system using an EEPROM. I know that you can read and write data from an EEPROM, but can you compile the data into executable Arduino code, and vice versa? I've heard you could use Forth, a language for the Arduino. The only problem here is that I'm using a library made by Adafruit to control the LCD screen the console is running on, and I doubt Forth can convert that. So yeah. That's my dilemma.

Thanks in advance!

You can make FORTH use the library, but then you have to implement the library interface and usage in FORTH. It’s easier to do it all in FORTH. It’s fun to learn to control the hardware in FORTH instead of assembler. And writing an assembler in FORTH is common practice, I’ve written such assemblers for a couple of 8 bit controllers in the 80s.

Question is whether you want to spend some time learning FORTH or you want a faster solution.

Two ideas come to mind.

The first one is complex, but, I think, possible. Given what you have said so far, I suspect you don’t have much experience, so it will be well beyond your capabilities at this time, and probably my own also. Two Arduinos (maybe two atmega/attiny chips): one to run the game; the second to read the eeprom and upload the compiled code (Hex file) for a selected game to the first Arduino, using either serial or ISP method. I know that Crossroads (a forum member) has done something similar and built a device which can read a hex file from an sd card and upload that to an Arduino, and this is basically the same idea.

The second idea is far simpler. The cartridge contains, instead of an eeprom, the “arduino” (or an atmega chip) programmed with a game. The rest of the console system (display, buttons etc) is “dumb”, having no processor of its own, until the cartridge is inserted. To keep the number of pins in the cartridge connector down, all the components in the console need to communicate over a bus, like i2c or SPI.

Great idea, an exchangeable controller in a docking station :slight_smile:
Eventually the docking station contains another Arduino that connects the bus to the sensors and actuators. The display most probably uses an bus already.

This may be a complete red herring, but:

There was a thread on the forums recently that centred around a plug in RAM expansion module for an Arduino Mega board.

Now, if that RAM was actually EEPROM (no reason why not) then you would have a plug in "cartridge".

The one thing I'm not sure about is if that memory can be mapped into the address space so code can be run from it directly.

FORTH can do whatever you want, but it is not efficient on an Arduino which is the wrong Architecture.

Apart from a processor what was deliberately built solely to execute FORTH, the 6809 was the microprocessor most directly suited to FORTH.

markd833:
The one thing I’m not sure about is if that memory can be mapped into the address space so code can be run from it directly.

Not on an ATmega, which is why the EEPROM “cartridge” concept fails with or without FORTH. :astonished:

FORTH code can reside everywhere because it is not normally executable machine code. Primitives in machine code can reside in the controller, including the firmware for all peripherals.

Ok, I think I might have an idea. What if the EEPROM was stored with pure ASCII text? I doubt this will work, but perhaps the Arduino could decode it, and then somehow execute it?

Or, the ASCII text could contain my own simple language, containing all of the things you need to control the screen, where the Arduino can Lex and Parse it?

I seem to remember that somebody wrote a boot loader that can read code from eeprom instead of Serial.

Maybe a solution; you will have to research it yourself.

Is the code on the cartridge written and/or compiled for the arduino, or are you using cartridges originally made for another processor, such as a commercial game system?

david_2018:
Is the code on the cartridge written and/or compiled for the arduino, or are you using cartridges originally made for another processor, such as a commercial game system?

I'm planning to simply use an external EEPROM that you put into the hardware. I could also find a way to connect the Arduino to an external EEPROM, where you can then interchange it with others.

FORTH includes its own parser and compiler for ASCII source code.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.