RPT #8bit/loc16
6-312
RPT #8bit/loc16 Repeat Next Instruction
SYNTAX OPTIONS OPCODE OBJMODE RPT CYC
RPT #8bit 1111 0110 CCCC CCCC X − 1
RPT loc16 1111 0111 LLLL LLLL X − 4
Operands #8bit
8-bit constant immediate value (0 to 255 range)
loc16
Addressing mode (see Chapter 5)
Description
Repeat the next instruction. An internal repeat counter (RPTC) is loaded with a value
N that is either the specified #8bit constant value or the content of the location pointed
to by the “loc16” addressing mode. After the instruction that follows the RPT is exe-
cuted once, it is repeated N times; that is, the instruction following the RPT executes
N + 1 times. Because the RPTC cannot be saved during a context switch, repeat loops
are regarded as multicycle instructions and are not interruptible.
Note on syntax:
Parallel bars (||) before the repeated instruction are used as a reminder that
the instruction is repeated and is not interruptable.
When writing inline assembly, use the syntax
asm(|| RPT #8bt/ loc16 || instruction”);
Not all instructions are repeatable. If an instruction that is not repeatable follows the
RPT instruction, the RPTC counter is reset to 0 and the instruction only executes
once. The 28x Assembly Language tools check for this condition and issue warnings.
Flags and
Modes
None
Repeat
This instruction is not repeatable. If this instruction follows the RPT instruction, it re-
sets the repeat counter (RPTC) and executes only once.
Example
; Copy the number of elements specified in VarA from Array1
; to Array2:
; int16 Array1[N]; // Located in high 64K of program space
; int16 Array2[N]; // Located in data space
; for(i=0; i < VarA; i++)
; Array2[i] = Array1[i];
MOVL XAR2,#Array2 ; XAR2 = pointer to Array2
RPT @VarA ; Repeat next instruction
; [VarA] + 1 times
|| XPREAD *XAR2++,*(Array1) ; Array2[i] = Array1[i],
; i++