First page Back Continue Last page Overview Graphics

Delay Loop


The LDX cycle instruction requires two bus cycles, the DEX one cycle. The BNE takes three cycles when branching but only one cycle when not branching. The total execution time required can be calculated using the following equation. The numbers in parenthesis represent cycle times.
LDX Loop w/branch back Loop w/no branch back
1 * (2) + 13 * (1 + 3) + 1 * (1 + 1) = # Bus Cycles

The number of bus cycles can be multiplied by the time for each bus cycle to get the total execution time.

In the above calculation it is assumed that the processor is making 16-bit memory accesses and that byte alignment is not a problem. This is the case when accessing internal memory. Using external memory configured for 8-bit accesses would extend the execution time.

Delay loops can be used for short delays, but would not be used for long delays since the processor is tied up during the delay and cannot be used for other tasks.