Commit Graph

31 Commits

Author SHA1 Message Date
Virgil Dupras
b72901175e forth: Word-ify "[']" and "'" 2020-03-17 16:17:51 -04:00
Virgil Dupras
d91af99fde forth: make "'" push 0 when not finding a word 2020-03-17 15:54:17 -04:00
Virgil Dupras
3a70dff53d forth: add word 'ABORT"' 2020-03-17 15:31:15 -04:00
Virgil Dupras
25b6e75cf7 forth: add words "."" and "(print)" 2020-03-17 15:22:13 -04:00
Virgil Dupras
6314c60ede forth: add word ".X" 2020-03-17 14:05:53 -04:00
Virgil Dupras
839d7097e7 forth: add words "MOD" and "/MOD" 2020-03-16 22:36:29 -04:00
Virgil Dupras
aec98a7a3a forth: separate COMPILE and [COMPILE] 2020-03-16 21:31:43 -04:00
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
e1f815baeb forth: Forth-ify main loop a bit
Add words "COMPILE" and "DROP". The goal is to soon make "DEFINE" immediate
and have it compile from input directly. This whole "main loop compiles
everything and DEFINE picks up compiled atoms" is a bit messy.
2020-03-14 17:48:24 -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
d5a7d5faf8 forth: add words "(fbr)", "(fbr?)", "'", "[']" 2020-03-12 21:16:20 -04:00
Virgil Dupras
fb54fd51af forth: implement THEN in Forth
Also, add "," and "C,"
2020-03-12 13:52:27 -04:00
Virgil Dupras
f89e7bd503 forth: add words "C@" and "C!" 2020-03-11 22:11:54 -04:00
Virgil Dupras
80f63cd185 forth: add words "2DUP", "2SWAP", "2OVER" 2020-03-11 21:58:16 -04:00
Virgil Dupras
2ddca57f3f forth: add string and logic routines, as well as "RECURSE"
The goal was to be able to implement "(" in forth, but I realised that my
INTERPRET approach was wrong. Compiling the line beforehand is, after all,
not good. I'll have to change it again.
2020-03-10 16:02:40 -04:00
Virgil Dupras
aac0a57a68 forth: add words "PC!" and "PC@" 2020-03-10 13:00:57 -04:00
Virgil Dupras
0b3f6253e4 forth: add support for IMMEDIATE words 2020-03-09 22:13:11 -04:00
Virgil Dupras
0e8af3cea4 forth: clarify the meaning of "wordref"
Also, make entry labels in dict.asm be wordref instead of entry ref.
2020-03-09 15:12:44 -04:00
Virgil Dupras
e8a4768304 forth: add words "IF", "ELSE", "THEN" 2020-03-09 14:19:51 -04:00
Virgil Dupras
03e529b762 forth: simplify execution model and handle literals better
This scheme of "when we handle line-by-line, compile one word at a time then
execute" so that we could allow words like "CREATE" to call "readword" before
continuing was a bad scheme. It made things like branching outside of a colon
definition impossible.

This commit implement a new "litWord". When an undefined word is encountered at
compile time, it is included as-is in a string literal word. It is at run time
that we decide what to do with it.
2020-03-09 14:14:26 -04:00
Virgil Dupras
5cadde557c forth: add "VARIABLE" 2020-03-07 22:23:08 -05:00
Virgil Dupras
989d8bbabf forth: add "DOES>" and "CONSTANT" 2020-03-07 22:18:14 -05:00
Virgil Dupras
53024d88f5 forth: add "DUP", "OVER", "SWAP", "?", "+!", "ALLOT" 2020-03-07 21:12:30 -05:00
Virgil Dupras
580214426a forth: add +-*/ 2020-03-07 19:42:07 -05:00
Virgil Dupras
30f188b984 forth: add word ":" 2020-03-07 18:54:16 -05:00
Virgil Dupras
e7cd3182d0 forth: add words "CREATE", "@", "!", "HERE", "QUIT" 2020-03-07 17:09:45 -05:00
Virgil Dupras
49228e418c apps/forth: new (WIP) application 2020-03-07 12:13:15 -05:00