Yet Another Forth For Arduino

Hi All,

I just posted my Forth environment for the Arduino. It is based on the ANSI Forth draft standard DPANS94, and I've implemented all but one of the core words, plus some others for manipulating the I/O. I would appreciate some feed back from people who are familiar with Forth. It can be found here GitHub - sdwood68/YAFFA: YAFFA - Yet Another Forth For Arduino

Can you explain some of the details that are typically relevant in a Forth implementation:

  1. is this a full interactive Forth, or some sort of cross compiler?
  2. Implementing Forth in a HLL like C++ seems counter-intuitive. How's performance, and what other tradeoffs and benefits are there (I see a bunch of "throw()" calls. Does that mean it has real error-trapping capabilities?)
  3. Does it have non-volatile storage of any kind for new words? Support for some sort of filesystem? If new words are stored in RAM, how much space is available?
  4. What's the one (core standard) word you didn't implement?
  5. What arduino-specific words have been implemented?
  6. Are you going to write any documentation (covering the previous questions)?

westfw:
Can you explain some of the details that are typically relevant in a Forth implementation:

  1. is this a full interactive Forth, or some sort of cross compiler?
  2. Implementing Forth in a HLL like C++ seems counter-intuitive. How's performance, and what other tradeoffs and benefits are there (I see a bunch of "throw()" calls. Does that mean it has real error-trapping capabilities?)
  3. Does it have non-volatile storage of any kind for new words? Support for some sort of filesystem? If new words are stored in RAM, how much space is available?
  4. What's the one (core standard) word you didn't implement?
  5. What arduino-specific words have been implemented?
  6. Are you going to write any documentation (covering the previous questions)?
  1. This is an interactive Forth.
  2. Implementing Forth in a HLL is slower than assembly, but it greatly improves portability, and I wanted something the was native to the Arduino IDE. As I learn more about the how Forth is suppose to work, I intend to try and improve performance were ever I can. There is limited error trapping. As I learn more, I will improve it. Detected errors cause an end to execution, compilation, or interpretation and the stacks are purged.
  3. Currently there is no non-volatile storage. I want to add the ability to store words into the EEPROM and to retrieve them.
  4. The last word I have not figured out is ">NUMBER". I can't find any good examples of its use.
  5. I've implemented wrappers for pinRead, pinWrite, pinMode, eeRead, eeWrite, analogRead, ananlogWrite.
  6. Eventually I will write documentation covering the above and the implementation choices I've made.

I'm welcome to anyone who may want to help. Right know I'm looking into unifying the "Forth Space" in RAM, write now there are seperate memory locations for Name, Code, and Data space. which breaks up the storage of an new word into the multiple areas. The intent is to unify the three areas and make each new word definition occupy a single continuous block of memory.

I've updated the code on github. I consolidated the separate memory regions for name, code and data space, into a unified area. I also did some more testing of DO, LOOP, +LOOP, CREATE, DOES>, and RECURSE.

Great idea. Congrats. HLL FORTH is fine, you can get the speed you need one way or the other (write in C / asm and wrap it in a word). I am going to give it a try.

Hello!
How can I use YAFFA.
Describe for the beginner.

Stuart,

Nice job on YAFFA.

I downloaded it to run on NodeMCU kit with ESP8266. I tried to turn the onboard LED on and off, and found that the order of parameters are reversed. The digital pin is Pin2. Commands to run it must be:
1 2 pinMode
0 2 pinWrite
1 2 pinWrite

According to glossary.txt, if I type:
2 1 pinMode

YAFFA locks up.

Regards,

Chen-Hanson Ting.

Here is a wild attempt of writing a Forth Virtual Machine for the Arduino.

120 primitives/instructions in the Virtual Machine. 3.5 Kbyte without the kernel dictionary strings (pure vm). Byte token thread with a built-in instruction level trace (optional). Multi-tasking with context switch back to the Arduino sketch on forth level yield, delay and halt.

Cheers!

The latest development of the Arduino Forth Virtual Machine (Arduino-FVM) includes a Token Compiler and a traditional Forth outer interpreter that allows definitions in data and program memory.

Token Compiler, Arduino-FVM/Compiler.ino at master · mikaelpatel/Arduino-FVM · GitHub
Forth Interpreter, Arduino-FVM/Forth.ino at master · mikaelpatel/Arduino-FVM · GitHub

The byte token threaded inner interpreter introduces tail call optimization.

Cheers!