Overhauled Gforth package

David Kuehling dvdkhlng at gmx.de
Mon Sep 20 05:37:37 EDT 2010


>>>>> "Emeka" == Emeka  <emekamicro at gmail.com> writes:

> David, Sorry that I am asking this silly question. I have learned
> FORTH in the past for fun, however it was shallow and I didn't even
> play with the Interpreter.   But I am still at lost why FORTH is used
> behind the scene in most OS. Could you explain this to me? If ti
> because of the foot print? Or What?

Well, it is _not_ used behind the scenes in /most/ OS :)

However, it is used in some embedded systems.  Also some boot-loaders
are based on Forth (open-firmware).  

The nice thing about Forth is something I'd call cross-layer-design for
its components.  With a little creative integration it manages to fit
compiler/interpreter/interactive terminal into one very small program.
Something like 8k for an interactive, fully usuable Forth
interpreter/compiler is easily possible.

So if you load such a Forth into your hardware, you have something like
a mini-OS, that you can use as a debug console.  So it makes sense to
use it as a boot loader.  In case something is wrong, and the main OS
cannot boot, I still have a Forth prompt where I can diagnose the
problem.  And on a Forth prompt I can do almost _everything_, like raw
read/write of system memory.  To me it sometimes feels like a
replacement for JTAG debugging equipment.

Look at the open-hardware Wiki-Reader [1].  It has Forth embedded into
its firmware [2], for testing and debugging the hardware.

Note that Gforth though is a much more advanced Forth system, with more
functionality, than these tiny embedded Forths.  Heck it even comes with
a (largely undocumented :( regexp parser that compiles regexps to VM
code.  Also it includes a parser generator, that generates VM code
(something like yacc), see [3].

cheers,

David

[1] http://thewikireader.com/
[2] http://github.com/wikireader/wikireader/tree/master/samo-lib/forth/
[3] http://www.complang.tuwien.ac.at/forth/gray.zip
-- 
GnuPG public key: http://user.cs.tu-berlin.de/~dvdkhlng/dk.gpg
Fingerprint: B17A DC95 D293 657B 4205  D016 7DEF 5323 C174 7D40
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
URL: <http://lists.en.qi-hardware.com/pipermail/discussion/attachments/20100920/aa3b3508/attachment.pgp>


More information about the discussion mailing list


interactive