Loop Trip Count Using Bdec - Texas Instruments TMS320C6000 Programmer's Manual

Hide thumbs Also See for TMS320C6000:
Table of Contents

Advertisement

Example 8–20. Loop Trip Count Using BDEC
.global _count_loop_iterations
_count_loop_iterations .cproc count
.reg
ZERO
SUB
BDEC
does_not_iterate:
.return iters
loop:
.trip
ADD
BDEC
.return iters
.endproc
Example 8–21. Loop Tip Count Using BDEC With Extra Loop Iterations
.global _count_loop_iterations
_count_loop_iterations .cproc count
.reg
MVK
SUB
loop:
.trip
ADD
BDEC
.return iters
.endproc
i, iters
iters
count,
1,
i
loop,
i
1
iters,
1,
iters
loop,
i
Another approach to using BDEC is to allow the loop to execute extra itera-
tions, and then compensate for these iterations after the loop. This is particu-
larly effective in cases where the cost of the conditional flow before the loop
is greater than the cost of executing the body of the loop, as in the example
above. Example 8–21 shows one way to apply this modification.
i, iters
–1,
iters
count,
1,
i
1
iters,
1,
iters
loop,
i
; Initialize our return value to 0.
; i = count – 1;
; Do not iterate if count < 1.
; Loop does not iterate, just return 0.
; This loop is guaranteed to iterate at
; least once.
; iters++
; while (i–– >= 0);
; Return our number of iterations.
; Loop executes exactly 1 extra iteration,
; so start with the iteration count == –1.
; Force "count==0" to iterate exactly once.
; This loop is guaranteed to iterate at
; least once.
; iters++
; while (i–– >= 0);
; Return our number of iterations.
'C64x Programming Considerations
Linear Assembly Considerations
8-47

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the TMS320C6000 and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents