Analog Devices ee-32 Application Notes

Engineer To Engineer Note EE-32
Notes on using Analog Devices’ DSP, audio, & video components from the Computer Products Division
Phone: (800) ANALOG-D or (781) 461-3881, FAX: (781) 461-3010, EMAIL: dsp.support@analog.com
Language Extensions: Memory Storage Types, ASM & Inline Constructs
Last Modified: 05/11/96
Language extensions
The G21 C compiler supports a set of extensions to the ANSI standard for the C programming language. These extensions are specific to the ADSP processors and comprise:
Support for separate program and data memory
(keywords pm, dm)
Support for inline functions
Support for asm() inlining of assembly language
The following demo code will help illustrate the use of these extensions and provide further information on them.
LANG_EXT.C
/* lang_ext.c */ /* program demonstrating the use of the G21 extensions */ /* to the C language */
1 #include "pointdef.h" /* contains predefined pointers */
int aux;
static int dm x ; /* placing variables in specific */ static int dm y ; /* memory spaces */
5 static int pm z ;
static int dm i[3]={10,20,30};
DINT pointer; /* DINT is defined in pointdef.h */
/* for a pointer to a dm integer */
static inline int add(void) /* define add() as inline */
a
{
10 z=x+y;
return z; }
static inline void Set_Fl(short flag) /* define Set_Fl() as inline */
/* this function just sets */ /* Flag 0, 1 or 2 */
{
15 switch (flag)
{ case 0: asm volatile("set fl0;");
break;
case 1: asm volatile("set fl1;");
20 break;
case 2: asm volatile("set fl2;");
break;
}
}
25 static inline void reset_fl1(void) /* to reset Flag 1 and count */
/* the amount of resets */ { static int pm rst_fl1_count; rst_fl1_count++; asm volatile("reset fl1;");
30 }
void main (void) { /* several pointer operations */
/* based on the use of the keywords */ /* pm/dm and the file pointdef.h */
pointer=i; /* pointer points to i[0]=10 */ x = *pointer++; /* x=10 ; pointer points to i[1]=20 */
35 aux=(*pointer)++; /* aux=20; i[1]=21; */
y=i[1]; /* y=21 */ add();
Set_Fl(0); /* calling the inline functions */ asm volatile("reset fl0;");
40 Set_Fl(1);
reset_fl1();
asm volatile("toggle fl1;"); reset_fl1(); }
EE-32 Page 2
Notes on using Analog Devices’ DSP, audio, & video components from the Computer Products Division
Phone: (800) ANALOG-D or (781) 461-3881, FAX: (781) 461-3010, EMAIL: dsp.support@analog.com
Loading...
+ 3 hidden pages