TForth
I once discovered this abandoned DOS Forth on my own home page, and noticed
that it (after a few bug fixes) wasn't all that bad. It's a direct
threaded Forth, with its kernel of less than 4kB (or with everything
compiled, about 9kB), it's a pretty small and non-bloated system.
I got a lot of inspiration from
isForth, but TForth is smaller
and is NOT compatible with any other Forth (which, by the way, is a proud
tradition within the Forth community).
Now I have added support for hashed dictionaries (which makes it quite a lot
faster, about 30%), and converted to FASM (which is about 3 times faster than
NASM). Together these changes reduce the build time from about 45 to 15 seconds
on my 386. TForth is now also tested in my 286 laptop, and it runs fine!
Unfortunately FASM requires a 386, so it can't be completely built from
scratch on a 286.
Features
- Small size, between 4kB and 10kB depending on what you compile
- Comes with several example programs, such as a Langton's Ant
implementation, a prime number calculator (which uses the most interesting way
of calculating ln(x) ever implemented in Forth, I think) and a BrainFuck
compiler which allows you to inline BrainFuck code in your TForth programs
- Has documentation
- Features hash tables for dictionaries (this makes it about 30% faster on
my 386, and the mere fat that I list this in the feature list ought to tell
you something about the Forth community)
- Exception handling
To do
- Add internal file buffering (could probably improve the compilation time
significantly)
- Separate code and data (could create a large speedup on modern chips, and
also allow slightly larger programs without things getting too inconvenient
- Add a better line editor
Getting started
First of all, read the documentation. But if you just want to give it a try,
here is how you run the demos (prime.f, ant.f):
- Start tf.com (if you don't have this file, run build.bat to build it)
- Type:
fload demo\ant.f
- Type:
use ant
- Now the words in ant (or prime, if that's what you loaded) are ready for
use. Just type the name of the word you want to use and press enter.
The ant.f program uses "run" to start the demonstration.
Downloads
Home |About me |Chinese |Research |Software |Electronics |Radio