Hi Michael,
Refer TMS320C55x DSP Programmer's Guide (spru376.pdf) for different
optimization tips.
The below explanation is from spru376.pdf
Local vs Global Symbol Declarations
Locally declared symbols (symbols declared within a C function), are
allocated
space by the compiler on the software stack. Globally declared symbols
(symbols
declared at file level) are allocated space in the compiler generated .bss
section by default. The C operating environment created by the C boot
routine,
_c_int00, places the C55x DSP in CPL mode. CPL mode enables stack based
offset addressing and disables DP offset addressing. The compile accesses
Global objects via absolute addressing modes. Because the full address of
the global object is encoded as part of the instruction in absolute
addressing
modes, this can lead to larger code size and potentially slower code. CPL
mode favors the use of locally declared objects, since it takes advantage of
stack offset addressing. Therefore, if at all possible, it is better to declare
and
manipulate local objects rather than global objects. When function code
requires
multiple use of a non-volatile global object, it is better to declare a local
object and assign it the appropriate value:
extern int Xflag;
int function(void)
{
int lflag = Xflag;
.
x = lflag ? lfag & 0xfffe : lfag;
.
.
return x;
}
Hope this clarifies your doubt.
Regards,
Namana
Michael Schuster <schuster@schu...> wrote: Hi,
of course. Compiled with -O3. Changing volatile doesn't make a difference
at
all with this prog (no diff with global or local vars) . My solution now is
to write a function with local vars and then inline the whole function.
Nevertheless, I want to understand the compiler, as we have to achieve
maximum of performance (no dsp bios or such things).
Thanks for your comments.
Michael
Am Dienstag, 13. Dezember 2005 14:39 schrieben Sie: > hi,
>
> have you declared the local variable also with the
> keyword 'volatile'?
>
> regards,
> Dileepan.
>
> --- Michael Schuster <schuster@schu...> wrote:
> > Hi,
> > I'm working on a very small piece of code on my
> > c5503 system.
> >
> > I have global Variables:
> >
> > volatile int* adc_1_ptr;
> > int* adc_data;
> > adc_1_ptr = (volatile int*) 0x0ffffe; // extern
> > ADC on Async-EMIF
> > adc_data = (int*) 0xffC1; //
> > internal memory
> >
> > and the instructions
> > *adc_data++ = *adc_1_ptr;
> > *adc_data++ = *adc_1_ptr;
> > *adc_data++ = *adc_1_ptr;
> >
> > This code is translated to asm :
> > MOV dbl(*(#_adc_1_ptr)), XAR2
> > AMOV #65473, XAR3 ; |39|
> > MOV *AR2, *AR3+ ; |40|
> > MOV dbl(*(#_adc_1_ptr)), XAR2
> > MOV *AR2, *AR3+ ; |41|
> > MOV dbl(*(#_adc_1_ptr)), XAR2
> > MOV *AR2, *AR3 ; |42|
> >
> >
> > If I declare the vars adc_1_ptr and
> > adc_data as local vars, the compiler does generate
> > the asm-structure
> >
> > MOV dbl(*(#_adc_1_ptr)), XAR2
> > AMOV #65473, XAR3 ; |39|
> > MOV *AR2, *AR3+ ; |40|
> > MOV *AR2, *AR3+ ; |41|
> > MOV *AR2, *AR3 ; |42|
> >
> > which is faster. How comes?
> >
> >
> > Thanks in advance
> > M. Schuster
> >
> > --
> > ____________________________________________________
> > Dr.-Ing. Michael Schuster
> > Geschtsfrer
> >
> > Enertex Bayern GmbH
> > Innovative Systemlungen der Energie- und
> > Elektrotechnik
> > www.enertex.de
> >
> > Erlachstra 13 91301 Forchheim
> > Tel: ++49-9191-974 637 Fax: ++49-9191-974 687
> > Mob:0175 5151913
Reply by mayu 33691●December 13, 20052005-12-13
The last one is faster.
During the operation the contents in AR2 do not change so the last two
instrations
mov dbl(*(#_adc_1_ptr)), XAR2
are redundancy.
> Hi,
> I'm working on a very small piece of code on my c5503 system.
>
> I have global Variables:
>
> volatile int* adc_1_ptr;
> int* adc_data;
> adc_1_ptr = (volatile int*) 0x0ffffe; // extern ADC on Async-EMIF
> adc_data = (int*) 0xffC1; // internal memory
>
> and the instructions
> *adc_data++ = *adc_1_ptr;
> *adc_data++ = *adc_1_ptr;
> *adc_data++ = *adc_1_ptr;
>
> This code is translated to asm :
> MOV dbl(*(#_adc_1_ptr)), XAR2
> AMOV #65473, XAR3 ; |39|
> MOV *AR2, *AR3+ ; |40|
> MOV dbl(*(#_adc_1_ptr)), XAR2
> MOV *AR2, *AR3+ ; |41|
> MOV dbl(*(#_adc_1_ptr)), XAR2
> MOV *AR2, *AR3 ; |42|
> If I declare the vars adc_1_ptr and
> adc_data as local vars, the compiler does generate the asm-structure
>
> MOV dbl(*(#_adc_1_ptr)), XAR2
> AMOV #65473, XAR3 ; |39|
> MOV *AR2, *AR3+ ; |40|
> MOV *AR2, *AR3+ ; |41|
> MOV *AR2, *AR3 ; |42|
>
> which is faster. How comes?
> Thanks in advance
> M. Schuster
>
> --
> ____________________________________________________
> Dr.-Ing. Michael Schuster
> Gesch?ftsfhrer
>
> Enertex Bayern GmbH
> Innovative Systeml?sungen der Energie- und Elektrotechnik
> www.enertex.de
>
> Erlachstra?e 13 91301 Forchheim
> Tel: ++49-9191-974 637 Fax: ++49-9191-974 687 Mob:0175 5151913
>
Reply by Michael Schuster●December 13, 20052005-12-13
Hi,
of course. Compiled with -O3. Changing volatile doesn't make a difference
at
all with this prog (no diff with global or local vars) . My solution now is
to write a function with local vars and then inline the whole function.
Nevertheless, I want to understand the compiler, as we have to achieve
maximum of performance (no dsp bios or such things).
Thanks for your comments.
Michael
Am Dienstag, 13. Dezember 2005 14:39 schrieben Sie: > hi,
>
> have you declared the local variable also with the
> keyword 'volatile'?
>
> regards,
> Dileepan.
>
> --- Michael Schuster <schuster@schu...> wrote:
> > Hi,
> > I'm working on a very small piece of code on my
> > c5503 system.
> >
> > I have global Variables:
> >
> > volatile int* adc_1_ptr;
> > int* adc_data;
> > adc_1_ptr = (volatile int*) 0x0ffffe; // extern
> > ADC on Async-EMIF
> > adc_data = (int*) 0xffC1; //
> > internal memory
> >
> > and the instructions
> > *adc_data++ = *adc_1_ptr;
> > *adc_data++ = *adc_1_ptr;
> > *adc_data++ = *adc_1_ptr;
> >
> > This code is translated to asm :
> > MOV dbl(*(#_adc_1_ptr)), XAR2
> > AMOV #65473, XAR3 ; |39|
> > MOV *AR2, *AR3+ ; |40|
> > MOV dbl(*(#_adc_1_ptr)), XAR2
> > MOV *AR2, *AR3+ ; |41|
> > MOV dbl(*(#_adc_1_ptr)), XAR2
> > MOV *AR2, *AR3 ; |42|
> >
> >
> > If I declare the vars adc_1_ptr and
> > adc_data as local vars, the compiler does generate
> > the asm-structure
> >
> > MOV dbl(*(#_adc_1_ptr)), XAR2
> > AMOV #65473, XAR3 ; |39|
> > MOV *AR2, *AR3+ ; |40|
> > MOV *AR2, *AR3+ ; |41|
> > MOV *AR2, *AR3 ; |42|
> >
> > which is faster. How comes?
> >
> >
> > Thanks in advance
> > M. Schuster
> >
> > --
> > ____________________________________________________
> > Dr.-Ing. Michael Schuster
> > Geschtsfrer
> >
> > Enertex Bayern GmbH
> > Innovative Systemlungen der Energie- und
> > Elektrotechnik
> > www.enertex.de
> >
> > Erlachstra 13 91301 Forchheim
> > Tel: ++49-9191-974 637 Fax: ++49-9191-974 687
> > Mob:0175 5151913
>
> __________________________________________________
>
--
____________________________________________________
Dr.-Ing. Michael Schuster
Geschtsfrer
Enertex Bayern GmbH
Innovative Systemlungen der Energie- und Elektrotechnik
www.enertex.de
and the instructions
*adc_data++ = *adc_1_ptr;
*adc_data++ = *adc_1_ptr;
*adc_data++ = *adc_1_ptr;
This code is translated to asm :
MOV dbl(*(#_adc_1_ptr)), XAR2
AMOV #65473, XAR3 ; |39|
MOV *AR2, *AR3+ ; |40|
MOV dbl(*(#_adc_1_ptr)), XAR2
MOV *AR2, *AR3+ ; |41|
MOV dbl(*(#_adc_1_ptr)), XAR2
MOV *AR2, *AR3 ; |42|
If I declare the vars adc_1_ptr and
adc_data as local vars, the compiler does generate the asm-structure