Overview
amforth is a compact forth interpreter and compiler for the atmel avr atmega microcontroller family which is implemented in assembly language and amforth itself. It is an interactive system running completly on the controller. It does not need additional hardware beyond a power supply. It places no restrictions for hardware extensions that can be connected with the controller, e.g. external RAM.
amforth is published under the GNU Public License v2 (GPL).
amforth implements an almost compatible ANS94 indirect threading 16bit Forth with very few missing CORE words, some words from the extension word sets (including some words from the Forth200x) and a few of its own words.
amforth needs ca 8KB Flash memory, ca 30 bytes EEPROM and ca 150 bytes RAM for the core system (including the compiler 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. For those who want to take a deeper look into the system is the Technical Documentation (PDF, 10.3.2009). which is slowly growing.
News
- 11.4.2009: release 3.4
- core: renamed the words for the serial terminal to be more generic since they can deal with any serial port, not only the first one.
- lib: dropped
forgetsince it cannot work with multiple wordlists, fixedmarker. - core: changed again
digit?stack effect (and fixed a little bug). - core:
numberhonors a leading &, $ or % sign to temporarily switch to DECIMAL, HEX or BIN base resp. Thanks to Michael Kalus for factoring the code.
- 22.2.2009: release 3.3
- core: faster
noop. - added ANS94 search order wordlist.
- core:
withinhad problems with signed boundaries, literal numbers are processed faster (again). - core: improved
digit?andnumber. They now report errors on invalid characters at the wrong position. The following strings are no longer valid numbers: --1 or 0@ (in base hex). - core:
-1 spacesnow prints nothing, Fix from Lothar Schmidt. - core:
(loop)(runtime of loop) now checks for equality only, as specified in ANS94.
- core: faster
- 10.1.2009: release 3.2
- core: bugfix for trailling 0x00 byte during
itype. - core: enable use of other usart port than 0.
- pc-host: Ken Staton wrote a nice pc based terminal with upload functionality.
- core: New controllers: ATmega328P and ATmega640.
- core: changed
digittodigit?found in many other forth's. - core: new word
within. - core: split application dictionary definition into 2 parts, one for the lower flash, one for the upper (NRWW) flash. Both can be empty, but need to exists.
- core: changed some names for internal constants (baudrate -> BAUD) and registers (EEPE vs EEWE).
- core: new directory
driversfor low level driver functions. Currently only the generic ISR and the USART0 interrupt handler.
- core: bugfix for trailling 0x00 byte during
- 10.11.2008: release 3.1
- core:
icomparenow has a similiar stack effect ascompare. - core: new word:
environment?. Supports/holdquery. - core: Strings in flash (incl. names in the dictionary) contain now 16bit length information, previously only 8 bit.
- core:
- 17.10.2008: release 3.0
- core:
s"new with interpreter semantics.s" hello world" typeworks at the command prompt. The compiled version is: hw s" hello world" itype ;. - core: Placement of Stacks is now an application setting. See example apps.
- core: added VM register A and B. See http://www.complang.tuwien.ac.at/anton/euroforth/ef08/papers/pelc.pdf for details. Uses Atmega Register R6:R7, R8:R9 resp.
- core: added
cmoveas a primitve. - core:
f_cpuused the old (pre-2.7) stack order for double cell values. - lib: moved some definitions to more appropriate files.
- core:
- 1.8.2008: release 2.9
- core:
heap,hereandedpare now VALUEs.dpis gone (usehere) - lib: more VT100 sequences.
- core: The TIB location and size are accessible with the VALUEs
TIBandTIBSIZE. - core: fixed TIBSIZE default configuration.
- lib: created math.frt, contains among others the standard words
sm/rem,fm/mod. - Alexander Guy fixed a bug in
u*/mod. - Bernard Mentink adapted Julian Noble's Finite State Machine code.
- applications: Lubos Pekny designed a smart computer with a 4line character LCD and a PS/2 keyboard. Details are in the Application Repository, a video is here.
- core:
Notes
amforth uses the serial line uart0 (can be changed at compile time) as the terminal. Serial line settings are 9600 8N1, no flow control.
Development hardware is a evaluation board running varios atmega's at 8 MHz or 16MHz with a few led's and pushbuttons. Targets for the final version are robots and model railroad systems using atmega32 and atmega168. 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).
Known Bugs
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."useswordinternally which skips the leading characters used as delimiters. Thanks to Michael Kalus for this analysis. - up to and including core version 2.6 double cell values have the order: TOS low part, NOS high part. Since 2.7 this is
the other way around. You should always use
s>dandd>sfor 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 >
Differences to ANS94
amforth has the following known differences to ans94. This list is not complete and the entries here are not considered bugs.
+loopassumes signed values for both loop counter and loop limit.