Came across this interesting idea while trying to improve a 16bit ring buffer implementation. I've not seen it before.
(Interesting in this case as I have to do compares on the buffer, and of course that means I won't access the low byte at all for most words)
"..a trick for making Forth hella-fast on the 65c02. You want to use a
split parameter stack. Most people who implement Forth will have a
single stack of 16-bit numbers. This is grossly inefficient because
every push or pop involves two decrement or increments of the X
register. The trick is to implement your parameter stack as two 8-bit
stacks, one for the high bytes and one for the low bytes. You still
effectively get a 16-bit stack, but your high and low bytes aren't
adjacent anymore. The advantage is that now you only need to do one
decrement or increment of the X register for each push or pop. Having
the high and low bytes adjacent doesn't do you any good, because there
is no addressing mode that allows you to work with them as a 16-bit
value. You might as well have them in separate 8-bit stacks."
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Came across this interesting idea while trying to improve a 16bit ring buffer implementation. I've not seen it before.
(Interesting in this case as I have to do compares on the buffer, and of course that means I won't access the low byte at all for most words)