4 ms·
Thank you, I didn't know about the jsr instruction. I always imagined forth does this somehow with jmps. Another main difference from true compiled code is tha
by terminalcommand 4y ago
Thank you, I didn't know about the jsr instruction. I always imagined forth does this somehow with jmps.
Another main difference from true compiled code is that your entire program consists of subroutine calls. There are no inline instructions and a main function.
I've got a lot of reading to do on this. "Indirect jsr", I'll experiment with this.
Okay I'm convinced, forth is not interpreted when it's compiled to threaded code :). There is no main loop that reads instructions and dispatches them dynamically, the program flow is linear with subroutine calls stacked under each other.
- dreamcompiler 4y agoExactly. And there are many other inline instructions (e.g. for doing arithmetic etc) but I didn't show them here. Any instruction the CPU supports can be present in a Forth program. In a compiled Forth, words can be specified as a list of calls to other Forth words or as raw assembly instructions, or both.
- terminalcommand 4y agoThank you for the explanation. Wow, these were questions stuck in my mind for a long time. Things make sense now.