amforth is a compact forth interpreter and compiler for the atmel avr atmega micro controller family. It is implemented in assembly language and forth itself. It is an interactive system runnung completly on the controller. It does not need additional hardware beyond a power supply. A (serial) terminal is a nice to have ;=)
amforth is published under the GNU Public License v2 (GPL).
amforth implements an ANS94 indirect threading 16bit Forth with very few missing CORE words, some words from the extension word sets and a few own words.
amforth can be downloaded from the project page.
Karl Lunt has written an excellent User guide on how to use and work with amforth. Thank you Karl! A more technical description is the Documentation (PDF, 6.5.2008). which is slowly growing.
m* was in fact um*.
code and end-code. code starts a new dictionary header
with the XT set to the data field. The 2nd one appends the jmp NEXT call into the dictionary.
case / endcase words. Added them as forth
library.-jtag (turns off JTAG at runtime) and -wdt (turns off
watch dog timer at runtime. They need to be implemented as primitives due to timing requirements.quit: Keep base when handling an exception.
hex 8000 . froze the controller. Now it prints -8000.
Thanks to Lubos for the hint.base from quit to cold. turnkey be
used to change it permanently. Thanks to Lubos for the hint.\ demo file #include ans94/marker.frt marker empty
tx0) made more robust.
dict_compiler.inc. Without these words the forth system is (more or less) a
pure interactive system without extensibility.[char], fill./int to -int and int to +int, it's more fortish ;=)
spaces and place.i!.do/loop and co.find and icompare for better readability.cold to application specific turn key action. Added
error checking in receive module.
leave and ?do.
# to ansi (from single cell value to double cell). Double cell values do not work (yet).deferred words instead of tick-variables. Works for EEPROM based vectors (turnkey),
RAM based (PAUSE) and User based (EMIT etc) vectors.wdr (Watchdog reset), d> and d< (double cell compare).amforth uses the serial line uart0 (hard coded) as the terminal. Serial line settings are 9600 8N1, no flow control.
Development hardware is a evaluation board running varios atmega at 8 MHz or 16MHz with a few led's and pushbuttons. Targets for the final version are robots (asuro and ct-bot) and model railroad systems using atmega32 and atmega8. Some special notes for the Atmel Butterfly.
The source is developed with avra (linux) and sometimes debugged in the simulator from the AVR Studio 4.13 (Windows).
These are known effects that one may call bugs for the lastest development revision (trunk). They may or may not get fixed for the next release(s).
The following code does not work: : x0 ." " ; (compiling a string with len 0 (zero)).
This is due to the fact that ." uses word internally which skips the
leading characters used as delimiters. Thanks to Michael Kalus for this analysis.
s>d and d>s for conversion.
The return stack has an off-by-one effect when using it's addresses:
> : rstest 1234 >r rp@ @ . r@ . r> ; ok > rstest 3405 1234 ok > : rstest2 1234 >r rp@ 1+ @ . r@ . r> ; ok > rstest2 1234 1234 ok >
# has double cell stack effects but does not work with values beyond single cell.
amforth has the following known differences to ans94. This list is not complete and the entries here are not considered bugs.
+loop and loop assume signed values for both
loop counter and loop limit.