▲ | addaon 2 days ago | |
> how does a Forth interpreter work in a Harvard architecture microprocessor You compile to "direct threaded code" in data memory; direct threaded code represents a sequence of calls as a sequence of addresses to call. So while "normal" threaded code (what Wikipedia calls "subroutine threading") would just have
And then executing that means jumping to the first instruction, direct threaded code would have
And then there's a suuuuper tiny runtime (like four of five instructions, literally) that has a "runtime instruction pointer" or whatever you want to call it, and just increments that and does an indirect call through to the next word whenever it's returned to. |