Rptb instruction – Texas Instruments TMS320C3x User Manual

Page 188

Advertising
background image

Repeat Modes

7-4

Example 7–1. Repeat-Mode Control Algorithm

if RM == 1

; If in repeat mode (RPTB or RPTS)

if S == 1

; If RPTS

if first time through

; If this is the first fetch

fetch instruction from memory

; Fetch instruction from memory

else

; If not the first fetch

fetch instruction from IR

; Fetch instruction from IR

RC – 1

RC

; Decrement RC

if RC < 0

; If RC is negative
; Repeat single mode completed

0

ST(RM)

; Turn off repeat-mode bit

0

S

; Clear S

PC + 1

PC

; Increment PC

else if S == 0

; If RPTB

fetch instruction from memory

; Fetch instruction from memory

if PC == RE

; If this is the end of the block

RC – 1

RC

; Decrement RC

if RC

0

; If RC is not negative

RS

PC

; Set PC to start of block

else if RC < 0

; If RC is negative

0

ST(RM)

; Turn off repeat mode bits

0

S

; Clear S

PC + 1

PC

; Increment PC

7.1.3

RPTB Instruction

The RPTB instruction repeats a block of code a specified number of times.

The number of times to repeat the block is the RC (repeat

count) register value

plus 1. Because the execution of RPTB does not load the RC, you must load this
register yourself. The RC register must be loaded before the RPTB instruction is
executed. A typical setup of the block repeat operation is shown in Example 7–2.

Example 7–2. RPTB Operation

LDI 15,RC

; Load repeat counter with 15

RPTB

ENDLOOP

; Execute the block of code

STLOOP

; from STLOOP to ENDLOOP 16
; times

.
.
.

ENDLOOP

Advertising