Repeat Modes
7-2
7.1
Repeat Modes
The repeat modes of the ’C3x can implement zero-overhead looping. For many
algorithms, most execution time is spent in an inner kernel of code. Using the
repeat modes allows these time-critical sections of code to be executed in the
shortest possible time.
The ’C3x provides two instructions to support zero-overhead looping:
-
RPTB (repeat a block of code). RPTB repeats execution of a block of code
a specified number of times.
-
RPTS (repeat a single instruction). RPTS fetches a single instruction once
and then repeats its execution a number of times. Since the instruction is
fetched only once, bus traffic is minimized.
RPTB and RPTS are 4-cycle instructions. These four cycles of overhead occur
during the initial execution of the loop. All subsequent executions of the loop
have no overhead (0 cycle).
Three registers (RS, RE, and RC) control the updating of the program-counter
(PC) when it is modified in a repeat mode. Table 7–1 describes these registers.
Table 7–1. Repeat-Mode Registers
Register
Function
RS
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
ÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁÁ
Repeat start-address register. Holds the address of the first instruction
of the block of code to be repeated.
RE
Repeat end-address register. Holds the address of the last instruction
of the block of code to be repeated. RE
w
RS (see subsection 7.1.2).
RC
Repeat-counter register. Contains 1 less than the number of times
the block remains to be repeated. For example, to execute a block
n times, load n – 1 into RC.
Correct operation of the repeat modes requires that all of the above registers
must be initialized correctly. RPTB and RPTS perform this initialization in
slightly different ways.