plasmo wrote:
What coding practice may I use to avoid dead cycle to I/O registers?
6502 "dead cycles" come in various flavors, most of them innocuous. For example, PLA, PLX, PLY etc have a dead cycle that reads from the next
available (ie, unused) stack location before reading the desired value. But this particular dead-cycle foible, like most, is unlikely to disturb I/O.
By far the #1 cause of trouble is the dead cycle that can occur during indexed addressing. If a page crossing occurs, a Partially Formed Address (PFA) can appear on the bus. It's partially formed in the sense that the low byte of the address is correct, but the high byte doesn't yet account for the carry that needs to occur. Thus, the dead cycle can spuriously read from an address that's $100 below the one that was intended... and, where certain I/O devices are concerned, reads can be destructive.
The solution is simple enough. Just avoid indexed addressing of an effective address that's $100 above your I/O. If you're afraid you might forget that rule, you can leave that space unused, or fill it with something that won't get indexed into.
The other foibles are arguably quirkier, but understanding them is arguably less important because they're far less likely to cause trouble. For example, a Read-Modify-Write instruction accesses the target address on three consecutive cycles, and you'd expect two reads followed by a write... but 6502 will do a read, then write the unmodified value back, then write the modified value. I don't think any 65xx-family I/O devices will be bothered by this, but as I recall someone here got bitten while using a non-65xx I/O device that wasn't okay with being written to on two consecutive cycles -- its specs called for some intervening recovery time. The remedial coding practice is, don't use R-M-W instructions on I/O devices.
Sorry I have not provided a comprehensive list, but I personally am comfortable with being on the lookout for this sort of thing. But if I'm wiring up an '816 and it's easy to make use of VDA (and often it is *VERY* easy) then I'll do so.
For more on the causes of dead cycles, see the document
here.
-- Jeff
_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html