1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-09 01:48:05 +11:00
Commit Graph

18 Commits

Author SHA1 Message Date
Virgil Dupras
fb54fd51af forth: implement THEN in Forth
Also, add "," and "C,"
2020-03-12 13:52:27 -04:00
Virgil Dupras
3819dbc083 forth: remove CMPDST
We now always do ","-style writes in (HERE), even in IMMEDIATE mode. Simplifies
things and paves the way for compiling words in Forth.
2020-03-12 13:08:11 -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
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
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
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
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
f0cf10ab7c forth: Check for PS underflow 2020-03-07 20:20:11 -05:00
Virgil Dupras
580214426a forth: add +-*/ 2020-03-07 19:42:07 -05:00
Virgil Dupras
e7cd3182d0 forth: add words "CREATE", "@", "!", "HERE", "QUIT" 2020-03-07 17:09:45 -05:00
Virgil Dupras
6f9d28b325 forth: add word "bye"
And make interpret action looping until BYE.
2020-03-07 13:15:19 -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