|
|
|
|
|
by Gordonjcp
1309 days ago
|
|
> But what made it so popular for the early boot process, and where else was it used? Probably simplicity. You can get a very basic Forth system going in a few dozen assembly instructions. Then, you write some Forth "primitives", words written in assembly, to do things like basic arithmetic, branching, stack manipulation, and memory manipulation. There are endless debates about how many primitives you really need, but in general a couple of dozen primitives ought to get you started. Then the rest of Forth is just written in Forth! You might not really have recognisable Forth source at this stage but more complex words can be written out as lists of the addresses of primitives. Think of it as like rolling your own macro assembler. The "inner interpreter" reads these lists of addresses and either jumps directly to the machine code in a primitive, or into a command that starts the inner interpreter chewing on a new word, pushing the one you've just come from onto the return stack. It seems really really complex until at some point as you stare at it, it'll just snap into focus and you see it's actually a very simple thing that does a very clever trick. |
|
> if you have an interactive terminal, a dictionary, and the colon compiler, can you really build everything else based on just eight primitives?
> Turns out the answer is yes
The eight primitives come from an old usenet thread: https://groups.google.com/g/comp.lang.forth/c/NS2icrCj1jQ