mov AC0, *AR3
; Save result in AC0
mov AC1, *AR4
; Save result in AC1
outloop
; End of outer loop
The above example uses two repeat instructions to control a nested repetitive oper-
ation. The block-repeat structure
rptb label_name-1
(more instructions . . . )
label_name
executes a block of instructions between the rptb instruction and the end label
label_name. The maximum number of instructions that can be used inside a block-
repeat loop is limited to 64 Kbytes of code. Because of the pipeline scheme, the minimum
cycles within a block-repeat loop are two. The maximum number of times that a loop can
be repeated is limited to 65 536 ( 2
16
) because of the 16-bit block-repeat counters.
2.7 Mixed C and Assembly Language Programming
As discussed in Chapter 1, the mixing of C and assembly programs are used for many
DSP applications. C code provides the ease of maintenance and portability, while
assembly code has the advantages of run-time efficiency and code density. We can
develop C functions and assembly routines, and use them together. In this section, we
will introduce how to interface C with assembly programs and review the guidelines of
the C function calling conventions for the TMS320C55x.
The assembly routines called by a C function can have arguments and return values
just like C functions. The following guidelines are used for writing the C55x assembly
code that is callable by C functions.
Naming convention: Use the underscore `_' as a prefix for all variables and routine
names that will be accessed by C functions. For example, use _my_asm_func as the name
of an assembly routine called by a C function. If a variable is defined in an assembly
routine, it must use the underscore prefix for C function to access it, such as _my_var. The
prefix `_' is used by the C compiler only. When we access assembly routines or variables in
C, we don't need to use the underscore as a prefix. For example, the following C program
calls the assembly routine using the name my_asm_func without the underscore:
extern int my_asm_func /* Reference an assembly function */
void main( )
{
int c;
/* Define local variable
*/
c my_asm_func( ); /* Call the assembly function
*/
}
This C program calls the following assembly routine:
.global _my_asm_func ; Define the assembly function
_my_asm_func
; Name of assembly routine
mov #0x1234, T0
ret
; Return to the call function
68
INTRODUCTION TO TMS320C55X DIGITAL SIGNAL PROCESSOR