1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-10 15:58:05 +11:00
Commit Graph

27 Commits

Author SHA1 Message Date
Virgil Dupras
9451c599e0 forth: Make (parse) indirect and Forth-ify (parsec) 2020-03-17 21:19:56 -04:00
Virgil Dupras
4212d5161f forth: Word-ify number parsing 2020-03-17 17:46:58 -04:00
Virgil Dupras
707f1dbae1 forth: Word-ify "[COMPILE]" 2020-03-17 17:29:03 -04:00
Virgil Dupras
549cf74e9d forth: inline code from "apps/lib"
Forth-ification of Collapse OS goes forward. What will happen is that assembly
code in apps/ will become Forth code. The concept of an assembler code library
will become obsolete.

However, Forth's core use some of that code. To facilitate the transition, I'm
inlining that code directly in Forth's code.
2020-03-17 12:49:06 -04:00
Virgil Dupras
017a469d9c forth: Forth-ify "." 2020-03-17 12:26:28 -04:00
Virgil Dupras
5d5517ac44 forth: allow DEFINE's ";" to be at the start of a newline
Previous to this commit, DEFINE's algo would miss a ";" right after a newline.

This allows for a much nicer formatting+comment of core.fs.
2020-03-16 22:09:23 -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
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
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
c3838714d5 forth: improve execution model
My approach with RS was slightly wrong: RS' TOP was always containing current
IP. It worked, but it was problematic when came the time to introduce
RS-modifying words: it's impossible to modify RS in a word without immediately
messing your flow.

Therefore, what used to be RS' TOS has to be a variable that isn't changed
midway by RS-modifying words. I guess that's why RS is called *return* stack...
2020-03-13 16:01:09 -04:00
Virgil Dupras
d5a7d5faf8 forth: add words "(fbr)", "(fbr?)", "'", "[']" 2020-03-12 21:16:20 -04:00
Virgil Dupras
ff281f69a8 forth: add "UNWORD" flag
Also, reorder word fields so that the flag field is more easily accessible.
2020-03-12 11:39:27 -04:00
Virgil Dupras
ea5f33558a forth: make branching offsets 1 byte
Those bytes, those precious bytes!
2020-03-11 19:52:49 -04:00
Virgil Dupras
3996f0c825 forth: fix IF/THEN/ELSE in colon defs 2020-03-11 17:53:27 -04:00
Virgil Dupras
6757c097ea forth: change the whole execution model again
Things are better now, but immediates inside colons are broken. However,
IF/THEN/ELSE are now immediates and it's much cleaner this way. Still, this
commit has too much stuff in it, I need to commit, I don't want to lose this
step.
2020-03-10 21:37:06 -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
0b3f6253e4 forth: add support for IMMEDIATE words 2020-03-09 22:13:11 -04:00
Virgil Dupras
03bd9ee39b forth: make readCompWord read from RS' BOS instead of TOS
Previous approach was broken with regards to defined word using CREATE.

Also, reduce name length by one to make space for a new flags field for
"immediate" (which isn't used yet).
2020-03-09 19:50:51 -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
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
f0cf10ab7c forth: Check for PS underflow 2020-03-07 20:20:11 -05:00
Virgil Dupras
ad2aca4620 forth: add number literals support 2020-03-07 19:25:55 -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
391ddb9984 forth: add word "." 2020-03-07 12:50:54 -05:00
Virgil Dupras
49228e418c apps/forth: new (WIP) application 2020-03-07 12:13:15 -05:00