Commit Graph

8 Commits

Author SHA1 Message Date
Virgil Dupras
80ab395823 forth: Simplify execution model
Change the mainloop so that words are executed immediately after they're read.
This greatly simplifies execution model and allow the "DEFINE" word to become
an IMMEDIATE and stop its "copy from compiled words" scheme.

The downside to this is that flow control words no longer work when being used
directly in the input buffer. They only work as part of a definition.

It also broke "RECURSE", but I've replaced it with "BEGIN" and "AGAIN".

Another effect of this change is that definitions can now span multiple lines.

All in all, it feels good to get rid of that COMPBUF...
2020-03-15 22:46:17 -04:00
Virgil Dupras
7befe56597 forth: improve input flow
Readline, instead of being triggered by the end of execution of the last
compiled line is now triggered "just in time", by "WORD".

This allows IMMEDIATE words reading input buffer to span multiple lines
( comments for example, but colon definitions will soon follow ).
2020-03-14 19:10:39 -04:00
Virgil Dupras
764b2222c7 forth: replace (fbr?) by SKIP?
This will allow us to support backward branching with just one new (bbr) word.
Also, this allow us to have "(" word sooned in core.fth and thus allow for
earlier commenting.
2020-03-14 09:23:58 -04:00
Virgil Dupras
5b1ca474d4 forth: Add word "("
Also, fix "RECURSE" in IMMEDIATE contexts.
2020-03-13 19:33:16 -04:00
Virgil Dupras
d60ea4cb30 forth: Forth-ify RECURSE
This comes with RS-modifying words. Also, this commit separates ";" from "EXIT",
allowing EXIT to be used in definitions (was needed for RECURSE).
2020-03-13 16:40:55 -04:00
Virgil Dupras
d0d92a4559 forth: Forth-ify IF and ELSE
Now, I really need comments...
2020-03-12 21:49:10 -04:00
Virgil Dupras
fb54fd51af forth: implement THEN in Forth
Also, add "," and "C,"
2020-03-12 13:52:27 -04:00
Virgil Dupras
a8e573c84a forth: add bin dict compilation stage!
Big one.

This allows us to write higher order words directly in Forth, which is much
more convenient than writing post-immediate (see "NOT" structure in diff if
you want to see what I mean) structures in ASM.

These structures can then be written to ROM (rather than loaded in RAM for
definitions loaded at run-time).

That's quite a bit of tooling that was added, 2 compilations stages, but I
think it's well worth it.
2020-03-12 00:14:44 -04:00