
Repeat Mode
7-3
Program Flow Control
7.1.1
Control Bits
Two bits are important to the operation of RPTB, RPTBD and RPTS:
The
RM
(repeat-mode flag) bit in the status register specifies whether or
not the processor fetches instructions during the repeat mode.
If RM = 0, fetches are not made in repeat mode.
If RM = 1, fetches are made in repeat mode.
The
S bit
is internal to the processor and cannot be programmed, but this
bit is necessary to fully describe the operation of RPTB, RPTBD, and
RPTS.
If RM = 1 and S = 0, RPTB or RPTBD is executing. Program fetches
occur from memory.
If RM = 1 and S = 1, RPTS is executing. After the first fetch (from
memory), program fetches occur from the instruction register (IR).
7.1.2
Repeat-Mode Operation
Information in the repeat-mode registers and associated control bits is used
to control the modification of the PC when instruction fetches are being made
in repeat mode. The repeat modes compare the contents of the RE register
(repeat end address register) with the program counter (PC) after the execu-
tion of each instruction. If they match and the repeat counter is nonnegative,
the repeat counter is decremented, the PC is loaded with the repeat start ad-
dress, and processing continues. The fetches and appropriate status bits are
modified as necessary. Note that the repeat counter (RC) is never modified
when the repeat-mode flag (RM) is 0.
The repeat counter should be loaded with a value one less than the number
of times to execute the block; for example, an RC value of 4 would execute the
block five times. The detailed algorithm for the update of the PC is shown in
Example 7–1.
Notes:
1)
The maximum number of repeats occurs when RC = 8000 0000h. This
results in 8000 0001h repetitions. The minimum number of repeats oc-
curs when RC = 0. This results in one repetition.
2)
RE should be greater than or equal to RS (RE
≥
RS). Otherwise, the code
will not repeat even though the RM bit remains set to 1.
3)
By writing a 0 into the repeat counter or writing 0 into the RM bit of the
status register, you can stop the the loop before it completes.