AnsweredAssumed Answered

tricky assembler optimization

Question asked by pfeifferc on May 16, 2011
Latest reply on Jun 22, 2011 by gyi

Hi !

 

my system is able to receive 2byte/3byte and 4byte packet audio data from the network

copy this to internal DAC conform data is optimized for 32bit data format -> copy from src to dest with no extra processing

 

but: copy from 3byte packet =24bit signed audio format to 4byte(32bit) format need some extra shift etc. instructions

 

so if optimized my c-code and look into the generated code and now the code-snippet need 7cycles to process one sample.

the corresponding 32bit format code need 2cycles. (16bit format need 5cycles)

 

so my question is now, how could this code optimized

regards chris

 

- code is given by

 

for(i=0; i<copyLen; i++)    //13.4.11 = 547cycl.

    {  /* 7cycles - optimized */
              sample  = (*pEtherBytes++);
          sample |= (*pEtherBytes++)<<8;
          sample |= (char)((*pEtherBytes++))<<16;
          *pRcvdPtr++=sample;          
         
    }

 

gen asm-code is

 

.P105L216:
//-------------------------------------------------------------------
//   Loop at ".\src\ADI_ETHER_BF537.c" line 3091 col 8 inlined at ".\src\ADI_ETHER_BF537.c" line 2578 col 30
//-------------------------------------------------------------------
//   This loop executes 1 iteration of the original loop in estimated 7 cycles.
//-------------------------------------------------------------------
//   This loop's resource usage is:
//     Group 1             used   5 out of    7 ( 71.4%)
//     16-bit Instruction  used   8 out of   14 ( 57.1%)
//     32-bit Instruction  used   4 out of    7 ( 57.1%)
//     Store               used   1 out of    7 ( 14.3%)
//-------------------------------------------------------------------
LOOP_BEGIN .P105L216L;
R2 = B[P1++] (Z);
R0 = B[P1++] (Z);
R0 = R0 << 8 || R3 = B[P1++] (X);
R0 = R2 | R0;
R2 = R3 << 16;
R0 = R0 | R2;
[I0++] = R0;
LOOP_END .P105L216L;

IDE also shows that after Hardware loop Begin there is a NOP inserted - dont understand why

Outcomes