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

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

Re: [avr-gcc-list] refactoring to reduce code size


From: E. Weddington
Subject: Re: [avr-gcc-list] refactoring to reduce code size
Date: Wed, 29 Jan 2003 09:23:03 -0700

On 29 Jan 2003 at 17:34, Alex Shepherd wrote:

> I would also appreciate any other suggestions about the sorts of
> things to do or avoid doing to generally reduce code size or how
> others go about analysing code on embedded systems to reduce code
> space.
> 
> Having come from coding on bigger machines (PCs) I may well be doing
> some expensive (code size wise) things that I need to change.
> 

Along with the other suggestions posted, I would also suggest you 
take a hard look at any switch statements and the assembly it 
produces. AFAIU, it depends on how many cases you have in the swtich 
how GCC will implement it. Sometimes it may be optimal, other times 
not.

If the cases are sequential values, it *might* be more prudent to 
implement it as a table. Other times, if there are not many cases, a 
simple if-elseif structure will be more efficient on space. You'll 
probably have to experiment with the C code and see what assembly it 
produces.

HTH,
Eric
avr-gcc-list at http://avr1.org



reply via email to

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