![Texas Instruments TMS320C80 Скачать руководство пользователя страница 48](http://html.mh-extra.com/html/texas-instruments/tms320c80/tms320c80_user-manual_1094755048.webp)
Prototyping Code Using Linker Command Files
3-8
TMS320C80 to TMS320C82 Software Compatibility User’s Guide
Example 3–1.Sample PP C Program
/********************************************************
* example.c This example C code calculates the dot
* product of vectors A and B.
********************************************************/
#include <mvp.h>
/* allocate space for A in a named section .a_sect */
#pragma DATA_SECTION(A,”.a_sect”)
/* allocate space for B in a named section .b_sect */
#pragma DATA_SECTION(B,”.b_sect”)
/* define the buffer size for A and B */
#define BUF_SIZE 1536
short A[BUF_SIZE];
short B[BUF_SIZE];
main()
{
long dot_prod;
dot_prod = dot_product(A,B,BUF_SIZE);
}
long dot_product(short *A, short *B, int vect_size)
{
int i;
long dot_prod;
dot_prod = 0; /* set initial value of the
accumulator to zero */
for (i=0; i<vect_size; i++)
{
dot_prod = do A[i] * B[i]; /* calculate the
dot product */
}
return(dot_prod);
}
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 .usect ”.a_sect”,1536
In this way, you can use the linker to specify where to place vari-
ables in memory.
Содержание TMS320C80
Страница 1: ...TMS320C80 to TMS320C82 Software Compatibility User s Guide 1995 Digital Signal Processing Products ...
Страница 2: ...SPRU154 Printed in U S A November 1995 M418017 9741 revision ...
Страница 8: ...vi TMS320C80 to TMS320C82 Software Compatibility User s Guide ...
Страница 16: ...xiv TMS320C80 to TMS320C82 Software Compatibility User s Guide ...
Страница 30: ...1 14 TMS320C80 to TMS320C82 Software Compatibility User s Guide ...
Страница 40: ...2 10 TMS320C80 to TMS320C82 Software Compatibility User s Guide ...
Страница 64: ...A 6 TMS320C80 to TMS320C82 Software Compatibility User s Guide ...