Re: a tutorial on bootstrapping forth?



In article <aeadnW6COv4WRaTeRVn-iw@xxxxxxxxxxx>,
Dave Huseby <dave@xxxxxxxxxxxxxxxxxxx> wrote:
>For a while now I've been trying to find a good tutorial on implementing a
>forth system from scratch. I haven't found one yet so I decided to ask here
>and see if anybody knows of one.

Nobody starts a forth system from scratch. I'm supposedly the author
of a "new" forth system called ciforth, but I've started with figForth
(1978) and changed it, a dozen lines at a time.
If you look at the documentation of Marcel Hendrix iforth, you
will see a lot of phrase I added to tforth (transputer Forth)
in the early nineties. But tforth again was based on earlier
work of Marcel. Look at Bernd Paysan site, there is a paragraph
about the history of bigForth.

>>From my research I've learned about the inner/outer interpreters. I've even
>heard that some people have written extremely basic forth compilers in
>assembly that support only a handful of words (e.g. get/set a byte, colon,
>semicolon and a few others) and then they "cross-compile" forth code for
>the two interpreters into full featured Forth system.

It is true that you only really need write a couple of words in
assembler. But then you need an assembler to handle those. You must
decide whether you use an assembler only, an assembler embedded in
Forth, or an assembler embedded in C. This will greatly affect the
way you have to go about it.

>Does anybody know what the minimal set of words would be for the
>"cross-compile" bootstrapping method?

Don't ask! If you ask for a minimal set you get all those discussions
that you don't need addition, because you can use subtraction to
accomplish that, that you need only XOR as a logical operations, and
can build SWAP out of ROLL.
Ask for a practical minimal set instead.
This minimally contains the arithmetics and logical binary operators:
+ - * / AND XOR OR = < >
and unary operators:
0= NEGATE
Ignore any proposals where those are defined in terms of
each other.

Control operations ( IF THEN DO LOOP) are not basic.
In a threaded system they are mostly reduced to 2 operations:
JUMP_IF_ZERO and JUST_JUMP. (The ISO Forth standard defines
them in terms of a control stack. Postpone studying that
until later.)

The interesting part of a minimal set is what you need to
get started with the compiler/interpreter. That is much
more difficult. Don't expect clearcut answers.
It depends crucially on the decision to use assembler, Forth
plus assembler, or c plus assembler.

> Does anybody know of forth source for
>an inner and outer interpeter combo?

If you're educationally interested in the inner workings of a simple
Forth with a rather sharp distinction between inner and outer
interpreter, you could do worse than looking at ciforth (lina/wina),
see my site below. It comes with a single assembler source.
Use the regular ciforth documentation along the assembler source!

>
>Thanks,
>Dave

Groetjes Albert

--
--
Albert van der Horst,Oranjestr 8,3511 RA UTRECHT,THE NETHERLANDS
Economic growth -- like all pyramid schemes -- ultimately falters.
albert@xxxxxxxxxxxxxxxxxx http://home.hccnet.nl/a.w.m.van.der.horst
.