avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] string initialization using "" and { }


From: Jan Waclawek
Subject: RE: [avr-gcc-list] string initialization using "" and { }
Date: Wed, 27 May 2009 18:24:00 +0200

> Since it understands the concept of a string as a constant,
> it stores the string constant in flash and then copies it into the stack
> frame (your first example).  

Unfortunately, much worse than that.

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...

JW







reply via email to

[Prev in Thread] Current Thread [Next in Thread]