2 ms·
What do you think about using 6C, indirect jump? Instead of a little thunk, some 16 bits of data can be set aside in a fixed location. We mutate only the low or
by kazinator 8y ago
What do you think about using 6C, indirect jump? Instead of a little thunk, some 16 bits of data can be set aside in a fixed location. We mutate only the low order address and then do an indirect jump through it.
LDA OPTBL-2,Y
STA OPADDR
JMP (OPADDR)
The contents of OPADDR+1 is initialized once on entry into the interpreter. Or perhaps statically.
Another thing would be self-modifying code (if we can forgo ROM-ming this, which Woz couldn't): the interpreter mutates the operand of an immediate JMP instruction to set up the address. That instruction then simply follows; there is no need to branch to it. Same as your thunk, but placed inline.
Ah, the first machine language program I wrote was on the 6502 and used self-modifying code to march through the graphics buffer. Indexed addressing modes were the next chapter in the Rodney Zaks book.
- tom_ 8y agoYes, 5 cycles, good point... that's much better. My excuse for not thinking of this very obvious improvement is that I never wrote any speed-sensitive ROM code ;) I doubt I ever used JMP indirect. For this sort of thing running from RAM, I'd typically use self-modifying code and a JMP absolute, which is where the idea of having a little thunk came from.
- sehugg 8y agoThis is what the PLASMA VM does (https://github.com/dschmenk/PLASMA https://github.com/dschmenk/PLASMA). All opcodes are even numbers so that the dispatch addresses can be stored as two-byte addresses.