As a rule, vintage 6502 computers don't map their I/O devices into zero page. It's almost a tradition that the decode hardware will put I/O at some higher address instead.
I have edited this post in light of subsequent discussions. Here are the main points to consider:
- benefits of I/O in z-pg: speed
- benefits of I/O in z-pg: smaller code size
- possible impediment: users' unfamiliarity with the idea
- possible impediment: consumption of zero-page addresses (balanced against fast I/O as a priority)
- possible impediment: decode hardware has less freedom to ignore address lines -- you need full decoding (or close to it).
Code Size and Speed
The chart below shows various instructions commonly used for I/O, listing the size and speed. In the cases (shown in color) where a given mode or instruction is not available, a roughly-equivalent "next best" code sequence is evaluated. For BBS/BBR and their equivalents, the usual optional extra cycles apply (for branch-taken and branch-taken with a page crossing). The 33% speedup for byte-oriented I/O (eg LDA STA) is noteworthy. Even greater are the gains for BBS/BBR (about 55%) and SMB/RMB (100%
IMO, these gains could in some cases make or break the viability of a heavily I/O bound application. Example: SPI or a software UART.
If I were being more rigorous, the equivalent routines should begin with PHA and end with PLA. But that'll often be unnecessary, as Garth mentions below.
On the '816, "Zero Page" is known as Direct Page, and is relocatable via the Direct Page register. It's worth remembering that, during I/O, this register must be set to zero (or whatever page is decoded for I/O). This is usually a non-issue but may be a nuisance if you're using D's esoteric capabilities elsewhere in your code.
Possible Impediments
In the thread that leads up to this one, Garth remarked that I/O mapped in Zero-pg is not normal for our applications. Certainly I/O in Zero-pg is uncommon -- and the pros & cons are worth reviewing! The rarity of I/O in Z-pg is partly explained by the high premium placed on Zero-page itself:
- with I/O in Z-pg, it's more important to fully decode the I/O address since it's undesirable to have many images of each device.
- in vintage microcomputers, free addresses in Z-pg are unobtainium. That's a regrettable reality.
- Unfortunately, yesterday's reality engenders a mindset that some modern-day builders seem to accept without question -- namely, that nothing merits the sacrifice of Z-pg. But in the context of a new design, the tradeoff might be attractive -- or even compelling.
Finally, I think I/O in Z-pg is rare simply because it's not talked about enough. IOW, its potential gets overlooked -- and that's a shame. But it wouldn't happen if we examine the matter on a case-by-case basis. My own experience has been 100% positive, and even WDC maps the I/O of its W65C134S into Zero-page. As I say, this approach needs to be mentioned more often.
-- Jeff
An incidental point (also from the other thread):