3.3.15.1.1 REPEAT Operation

The loop count for REPEAT operations is held in the 32-bit Repeat Loop Counter register (RCOUNT), which is memory-mapped. RCOUNT is initialized by the REPEAT instruction. The REPEAT instruction sets the REPEAT Loop Active (RA) Status bit (SR[4]) to ‘1’ if the RCOUNT is a non-zero value.

RA is a read-only bit and cannot be modified through software. For REPEAT loop count values greater than ‘0’, the Program Counter is not incremented. Furthermore, Program Counter increments are inhibited until RCOUNT = 0.

For a loop count value equal to ‘0’, REPEAT has the effect of a NOP and the RA (SR[4]) bit is not set. The REPEAT loop is essentially disabled before it begins, allowing the target instruction to execute only once while prefetching the subsequent instruction (i.e., normal execution flow).

Note: The instruction immediately following the REPEAT instruction (i.e., the target instruction) is always executed at least one time, and it is always executed one time more than the value specified in the 20-bit literal or the W register operand.