News for hackers. Stuff that matters.
Re:Project-Nested: An NES Emulator Running on the SNES by bonzini on Sunday July 11, 2021 @03:11PM (#27803766)
I expect that some games would put subroutines once in the zero page and then self-modify addresses in there.

Instructions are only written once but could potentially be written by any store with zero page indirect[1] or indexed addressing.

[1] that is ($AA,X) or ($AA),Y

Re:Project-Nested: An NES Emulator Running on the SNES by stormbrew on Sunday July 11, 2021 @05:17PM (#27804583)
The zero page is very small, I don't think this was done that much. You'd constantly be writing large gobs of stuff into it and that'd be very slow.

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.

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/