No description or website provided.
Haskell Forth C
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


hthforth is a Forth-2012 written in Haskell and Forth. The idea is to
keep pace with the development of the proposed Forth 200x standard
(currently called Forth-2012).
Visit for more information.

The main idea with this Forth is to implement a cross compiler
for embedded systems development.

Forth works differently from many other languages in that it lacks syntax
and is not suitable to parse using normal parsing techniques.
Instead, one has to build a Forth system from another Forth system which
acts as a bootstrapper, a technique that is called meta compiling in
the Forth world.
This Forth is meant to be such meta compiler, or more correctly, a cross
compiler, as the intended target will be different.

Haskell is the implementation language used here. The cross compiler
can be built using Haskell cabal.

Current status is that all core words are in place for the hosted Forth.
The cross compiler is able to compile a subset of the language
and produce sketchy assembler output for Cortex-M.

To build hthforth, you will need to have Haskell installed. The
current version of GHC used is 7.8.3, but 7.6.3 should also work well.
(GHC 7.10 has not yet been tried).

With a suitable GHC, do the following in the top level directory:
% cabal configure
% cabal build

To run hthforth:
% dist/build/hthforth/hthforth

When started, there is a very small subset of core words available. To
bring more words in:
LOAD-SOURCE src/lib/core.fs

After loading the core words, you can enable the cross compiler:

At this point a small amount of words and library code are availalbe.
You can load more words and even try something on your own:
LOAD-SOURCE src/lib/target-core.fs

At any point, you can generate assembler output to a desired target
using a suitable DUMP- word:
DUMP-MSP430 430.s

This gives a source file 'arm.s' using Cortex-M assembler. The MSP430 output
(which is even more stetchy at this point) will be written to '430.s'.

At the moment, the output is not accepted by the GNU assembler due to too
advanced expressions (I am quite certain that it is too picky).
Later on this need to be worked around, or try another assembler that
actually can handle it.

If you want to GNU assembler, install GNU binutils and build a cross assembler.

For MSP430, use:
./configure --target=msp430-elf

For Cortex-M use:
./configure --target=arm-elf

To exit hthforth, type BYE or press Ctrl-C.

Haskeline is used, so you have full command line history and editing

October 2015, Håkan Thörngren,

There is also a Trello board for this project available at which is currently
not kept so well updated. Most project planning and ideas
take place in the (which is not always up to date in
the repository), a file to be opened with Emacs org mode.