Run-time support library functions
The TMS320C55x C compiler has many built-in C functions in its run-time support
library rts55.lib. Although these functions are helpful, most of them may run at a
slower speed due to the nested library function calls. We should try to avoid using them
in real-time applications if possible. For example, the MOD(%)operation we use to
simulate the circular addressing mode can be replaced by a simple AND(&)operation if
the size of the buffer is a base 2 number, such as 2, 4, 8, 16, and so on. The example given
in Table 6.5 shows the compiler will generate a more efficient assembly code (by
avoiding calling the library function I$$MOD) when using the logic operator AND
than the MOD operator, because the logic operation AND does not invoke any
function calls.
Loop counters
The for-loop is the most commonly used loop control operations in C programs for
DSP applications. The assembly code generated by the C55x C compiler varies depend-
ing on how the for-loop is written. Because the compiler must verify both the positive
and negative conditions of the integer loop counter against the loop limit, it creates
more lines of assembly code to check the entrance and termination of the loop. By using
an unsigned integer as a counter, the C compiler only needs to generate a code that
compares the positive loop condition. Another important loop-control method is to use
a down counter instead of an up counter if possible. This is because most of the built-in
conditional instructions act upon zero conditions. The example given in Table 6.6 shows
the assembly code improvement when it uses an unsigned integer as a down counter.
Local repeat loop
Using local repeat-loop is another way to improve the DSP run-time efficiency. The
local repeat-loop uses the C55x instruction-buffer-queue (see Figure 2.2) to store all the
Table 6.5 Example to avoid using library function when applying modulus operation
;Ns 2;
;Ns 2;
;k 2*Ns;
;k 2*NsÀ1;
;l (lNs)%k;
;l (lNs)&k;
MOV *SP(#04h),AR1
MOV T0,*SP(#07h)
MOV *SP(#0ah),T1
ADD *SP(#0bh),AR1
ADD *SP(#0bh),AR1,T0
AND *SP(#0ah),AR1
CALL I$$MOD
MOV AR1,*SP(#0bh)
MOV T0,*SP(#0bh)
SOFTWARE DEVELOPMENTS AND EXPERIMENTS USING THE TMS320C55X
293