Welcome to the Open Source home of

A lesser Forth


About

F– (pronounced "F minus") is an implementation of ANS Forth that uses a VM generator running on an ANS Forth to compile Forth into source code suitable for plugging into a C-based microcontroller project. F– can easily invoke C functions, or include chunks of C code, since C is its "assembly language". C projects can execute F– functions by invoking the VM. F– allows arbitrary backends to be plugged in so it can be used to express the VM in languages other than C such as assembly, Ada, Verilog, Forth, etc. Forth Inc. offers a concise description of Forth:

Forth is a computer programming language originally designed for embedded and real-time applications. It's a high-level language characterized by an interactive programming style, which dramatically shortens development times, and by extremely small target program size.

The purpose of F– is to provide a portable yet efficient computing platform for embedded applications. It uses a thin client debugger in conjunction with a host PC to provide an interactive Forth console. The target CPU fits a 32-bit VM, math and I/O libraries, multitasker and debugger into a ROM footprint between 4KB and 8KB depending on target language and size/speed tradeoffs. ANS Forth may be used as the target language, enabling you to build a simulator that runs on your PC to model peripherals and missing hardware while executing the same binary that will run on your MCU. This allows a significant amount of development before hardware is available.

The VM uses a fast interpreter to execute bytecode fetched from application memory. Bytecode applications are far more compact than equivalent compiled C applications, allowing more features to be squeezed into a given microcontroller. The experience of the major Forth companies who have C and Forth versions of the same application is that the Forth version generally compiles to half the size of the C version. Since the token threading used by F– is even more compact than this, you can expect to see a 3:1 size advantage (compared to C) when compiling applications for F–. Even so, you can run really large applications without much on-chip ROM (maybe your C libraries used it all up) since the cost of going off-chip to a serial SPI flash is small when time-critical code is on-chip.

F–'s compiler creates a VM as single file of source code containing the ROM image of your Forth application and the VM that executes it. The C version, for example, produces vm.c and vm.h. F– provides a processor-independent platform for running compact applications, leveraging the productivity and compactness of Forth against advances in mainstream tools.


Host Forths

F– loads on top of a 32-bit ANS Forth. If you are using Windows, you will need one of the following:

If you are using Linux, you can use gForth. At this point, the debugger serial port hasn't been ported to gForth/Linux but hopefully someone will do this.


Downloads

See the download section of the project page.


Contributing

See Making contributions to Fminus. If you would rather not hassle with SourceForge's CVS, you can use the discussion group to point out bugs and opportunities for improvement.

There are plenty of things to do:



Need help learning Forth?

Here are some free online resources:

Forth Inc. sells a good textbook:


Licenses

This Open Source project is hosted on Source Forge.

Different parts of F– have different licenses:



Acknowledgments

Lots of thanks to those who have helped make F– possible, among which are: