5 ms·
I think you can speed up the 6502 version by moving it into the zero page and not using indexed mode. Of course, zero page memory is even more restricted than t
by Someone 6y ago
I think you can speed up the 6502 version by moving it into the zero page and not using indexed mode. Of course, zero page memory is even more restricted than the 64kB you have in total, but that might be worth it in some cases.
Even if this isn’t in the zero page, it surprises me that those expensive x indirect loads and stores are cheaper than worth having to increase the source and destination addresses often, but that probably is because my 6502 is very rusty.
Also: I stared at that code for a while, but couldn’t figure out why that jmp immer is there. If you move the 3 instructions starting at lastpage to the end, it can be removed, can’t it? (I didn’t check, but there may be further code shuffles that do not decrease the number of instructions, but do decrease the number of branches and with it, the number of cycles spent)
- jhallenworld 6y agoI knew 6502 people would improve it :-) >moving it into the zero page and not using indexed mode I'm not sure I follow.. you mean restrict the memcpy to only within the zero-page? >jmp inner.. Yeah, it doesn't matter to much, not in the inner loop. You could move the start of the code to right after the rts also..
- Someone 6y agoNo, moving the code into the zero page. See https://retrocomputing.stackexchange.com/a/92 https://retrocomputing.stackexchange.com/a/92 for what the Basic in the Commodore 64 does. Increasing an address is faster in the zero page, and self-modifying code is faster. That combines the two.
- jhallenworld 6y agoOh I see: inc $c9 5 cycles 00c8: lda $xxxx 4 cycles vs. lda $xxxx,x 4 inx 2 Mine is still faster...
- Someone 6y agoLuckily, I said my 6502 is rusty :-). You can win a cycle increasing the high byte of pointers, but that probably isn’t worth the zero page memory in most cases.
- jacquesm 6y agoThe 6809 could move its zero page around!
- Flow 6y agoAnd stack too IIRC.
- jacquesm 6y agoThat's correct. The reason for this is that they foresaw using the CPU for multi-tasking with each application using it's own code, data, stack and zero page (scratch) data. That's also why it has relocatable code. A small multi-tasking OS called OS-9 was written and released for it: https://en.wikipedia.org/wiki/OS-9 https://en.wikipedia.org/wiki/OS-9