DerTrueForce wrote:
Here's a bit of a PSA(At least, I like to think so).
WDCs 65c02 has WAI and STP instructions, acccording to its datasheet. The programming manual says that the 'c02 does not have them.
Maybe some errata on the programming manual is in order?
The manual is generally correct, as it was intended to cover the 6502 family, not specific iterations. These instructions are unique to WDC versions.
WDC added
STP and
WAI to the 65C02, 65C802 and 65C816 when they were converted to a static core design long ago (I don't recall the exact year anymore). The intent of these instructions is to accommodate applications in which the MPU may have nothing to do for a long period of time and it is desired to reduce power consumption to the absolutely lowest possible level. When
STP or
WAI is executed the internal clock is stopped in the high state, causing current consumption to fall into the micro-ampere range. As the 'C02 and '816 are fully static, the registers will retain their contents as long as the device remains powered. If the 'C02 or '816 is combined with low power static RAM that goes catatonic when not selected (which many such devices do), a small battery can sustain such a system for long periods of time. This is the basis for operating implanted medical devices, such as automatic defibrillators.
In normal programming, one would not use either of these instructions, as they cause a total cessation of activity until a hardware interrupt (in the case of
WAI) or reset occurs.
WAI preceded by
SEI would be most useful to the hobbyist in a real-time data acquisition device, as interrupt latency is reduced to one clock period or less.