Miscellaneous #12
The Apple II Firmware WAIT Routine

Revised by Matt Deatherage (November 1988)
Written by Matt Deatherage (May 1988)

This Technical Note expands on the already documented descriptions of the Apple II firmware WAIT routine, which guaranteed a minimum, not an exact, specified delay.


As described in the Apple IIe Technical Reference Manual and the Apple IIc Technical Reference Manual, Second Edition, the WAIT routine located in ROM at $FCA8 waits for a certain amount of time before returning to the calling program. The delay is listed in the IIe manual as being 1/2(26+27A+5A^2), where A is the value in the accumulator when WAIT is called. The value returned by this expression is the number of clock cycles taken by the routine, not the amount of time that passes while it waits. To obtain the elapsed time in microseconds, you must multiply the result by the scaling factor 14 / 14.318181.

Different formulas have appeared in different firmware listings published by Apple in the past, but the above formula is in all current publications, and has been verified as correct by Developer Technical Support. If there were nothing in the system except a 65C02 (or 65816) microprocessor, this formula would be completely accurate. However, this is not the case in an Apple II, as there are interrupts, changing system speeds, fast and slow RAM, and numerous other additions to the system that can cause extra overhead when a routine is executed.

For these reasons, the WAIT routine should be used only as a minimum delay. It should not be expected to wait for exactly the time specified by the WAIT formula.

The Apple IIGS Firmware Reference correctly notes this fact, as well as including the scaling factor (14 / 14.318181) to return the minimum delay in microseconds without further calculation.

Further Reference


This and all of the other Apple II Technical Notes have been converted to HTML by Aaron Heiss as a public service to the Apple II community, with permission by Apple Computer, Inc. Any and all trademarks, registered and otherwise, are properties of their owners.