> The "constant initialiser" is stored in initialised .data. 
> I.e. it eats FLASH (as the .data initialiser), precious .data 
> RAM, and of coursre the RAM in stack when actually used.
> 
> I was playing with initialised local arrays a few days ago 
> and found out, that avr-gcc performs this same pessimisation 
> for any initialised local array, whose initialiser is other 
> than 1, 2 or 4 bytes long. 
> 
> Got the pattern?
> 
> It's much better if such array is initialised 
> element-by-element: the ldi/st pattern wastes FLASH rather than RAM.
> 
> I would submit a request for enhancement, but was recently 
> pointed out by the seasoned avr-gcc developers, that there's 
> no reason in submitting RFEs without simultaneously providing 
> a patch...

I suppose the proper question here is "what are you using the array
for?"  If you are using it for parsing strings (comparing to a constant
string, which is what Zoran appears to be doing), you could use the
PROGMEM attribute (or PSTR) for the constant string and the strncmp_P()
function to call the constant string straight out of flash:

    char foo[128];
    . . .
    if ( strncmp_P( foo, PSTR( "abd" ), 3 ) == 0 )
    {. . .

I would need to look at the implementation of strncmp_P to decide if
this is as efficient as Jan would like.

Best regards, 

Stu Bell 
DataPlay (DPHI, Inc.) 



_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to