Sample Pp C Program - Texas Instruments TMS320C80 User Manual

1995 digital signal processing products
Table of Contents

Advertisement

Prototyping Code Using Linker Command Files
Example 3–1.Sample PP C Program
/********************************************************
* example.c
*
********************************************************/
#include <mvp.h>
#pragma DATA_SECTION(A,".a_sect")
#pragma DATA_SECTION(B,".b_sect")
#define BUF_SIZE 1536
short A[BUF_SIZE];
short B[BUF_SIZE];
main()
{
}
long dot_product(short *A, short *B, int vect_size)
{
}
3.4.3.1 Allocating Memory In Sections
In the code, the vectors are allocated by using the #pragma direc-
tive. This directive allocates space in the sections that are de-
fined in the linker command file. A sample #pragma directive is
as follows:
#pragma DATA_SECTION(A,".a_sect")
This sample line allocates space for A in a section named
.a_sect; the memory block used for .a_sect is defined in the linker
command file.
In assembly language, #pragma is equivalent to the .sect and
.usect assembler directives. To allocate the vector A in assembly
language, the proper directive would be as follows:
A
In this way, you can use the linker to specify where to place vari-
ables in memory.
3-8
TMS320C80 to TMS320C82 Software Compatibility User's Guide
This example C code calculates the dot
product of vectors A and B.
/* allocate space for A in a named section .a_sect */
/* allocate space for B in a named section .b_sect */
/* define the buffer size for A and B */
long dot_prod;
dot_prod = dot_product(A,B,BUF_SIZE);
int i;
long dot_prod;
dot_prod = 0;
for (i=0; i<vect_size; i++)
{
dot_prod = dot_prod + A[i] * B[i]; /* calculate the
}
return(dot_prod);
.usect ".a_sect",1536
/* set initial value of the
accumulator to zero
dot product */
*/

Advertisement

Table of Contents
loading

This manual is also suitable for:

Tms320c82

Table of Contents