I have some 6502 machine-language routines that I'd like to be as portable as possible across all, or as many as possible, Commodore 8-bit machines, including the PET (BASIC 1.0, 2.0, 4.0), VIC-20 and C64 (BASIC 2.0), C16, C116 and Plus/4 TED machines (BASIC 3.5) and the C128 (BASIC 7.0).
I sometimes require temporary zero-page storage just for the duration of my routine. (Indirect addressing modes on the 6502 are available only through zero-page locations, so storage elsewhere is not an option for those.) The criteria for an ideal temporary location are as below, roughly in order of importance.
It's probable that there are few or even no locations for which all all criteria can be satisfied for all machines; don't let that stop you from proposing locations that satisfy as many of them as you can manage. Answers should discuss any limitations of proposed memory locations, including what machines they won't work on, which of the criteria below are not being met, under what circumstances the routines using those locations would be unsafe to call, and anything else that might be relevant to making an engineering decision about using those locations in the a particular application. To be clear, I am not seeking perfection here, and answers and comments saying "this can't be done perfectly" are unhelpful.
The locations are not used by anything run during interrupt service, so they will not be changed under me as my routine runs.
Changing the locations will not break the KERNAL, including not interfering with ongoing I/O that might be in progress by my callers.
If my routine is being called from a running BASIC program, changing the locations will not interfere with the running program. If it's being called from the machine-language monitor (for those models that have it), changing the locations will not interfere with the monitor.
If the locations are used in interactive mode between program runs (i.e. at the BASIC prompt), BASIC re-initialises them when it needs those locations so that I can safely leave my trash in them after my routine exits.
The locations are not obvious "popular" locations (such as $FB-$FE on the C64) that other routines I didn't write are likely to want to use for long-term storage.
Ideal locations would be ones that are used by ROM routines strictly for very short-term storage (i.e., only while the routine is running) and not used by any code that could be called from interrupts. (The known use by ROM routines would ensure that user-written machine-language routines will not be using those locations for long-term storage.)
These sorts of locations seem to be fairly easy to find for individual systems (e.g., $03-$06 "storage for RENUMBER," according to the Plus/4 PRG), but looking through various individual memory maps for the PET, C64 and Plus/4 there seem to be a lot of differences, enough that it's hard to find locations satisfying the criteria above.
I'd also be interested in any references to zero-page memory maps that cover multiple systems, rather than just particular computers (e.g. C64) or particular families (e.g., TED series).