Re:Project-Nested: An NES Emulator Running on the SNES
by a1369209993 on Sunday July 11, 2021 @06:34PM
(#27805008)
> there's no special benefit you get from having code in the zero page anyways afaik.
You save one cycle off each instruction that modifies another instruction, which can important for inner loops. See eg http://www.linusakesson.net/programming/gcr-decoding/index.p..., although that's a disk-induced realtime requirement, rather than hblank/beam-induced.
Re:Project-Nested: An NES Emulator Running on the SNES
by stormbrew on Monday July 12, 2021 @12:02AM
(#27806917)
ah ok yeah that makes sense. If you're directly modifying the instructions then yeah there's a big benefit to the zero page. I think I misread the GP post and missed the self-modifying context somehow.
Thanks for clarifying :)
Re:Project-Nested: An NES Emulator Running on the SNES
by bonzini on Monday July 12, 2021 @02:55AM
(#27807798)
For an example, search for 0073 or CHRGET at https://www.pagetable.com/c64ref/c64disasm/
That said, the stack was used as a fast indirect jump address location pretty frequently, as described here, essentially abusing the fact that PHS and RTS are 1 byte instructions: http://www.6502.org/tutorials/6502opcodes.html#RTS
And really since basically all PC-modifying instructions operate on either relative (b*), absolute-indirect (jmp), absolute (jmp, jsr), or stack-indirect (rts, rti) there's no special benefit you get from having code in the zero page anyways afaik.