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: Yann Ramin
Subject: Re: [avr-gcc-list] refactoring to reduce code size
Date: 28 Jan 2003 22:00:38 -0800

Some simple things to check for:

I assume you're using -Os?
Use char for most number types, int and especially long is expensive ram
and codewise. 
Are you using any libraries? 
Are you using #defines which calculate stuff? Try pre-calculating any
variables (i.e., don't calculate values for the baud rate register, even
in a #define, since it will turn into code. Use constants).
Try to not use functions like printf() and derivatives. itoa and ltoa is
useful for printing numbers, and are pretty small.
Avoid dealing with floating point numbers.


On Tue, 2003-01-28 at 20:34, Alex Shepherd wrote:
> Hi Guys,
> 
> I am in the process of writing some code to run in a Mega8, however I will
> probably run out of FLASH before I fit in all the features I would like.
> 
> In an effort to try and find the biggest functions, I have tried looking at
> the list files that the compiler produces but alas I find them a bit hard to
> follow and after the optimiser has rearranged things I find it hard to
> recognise which does what and wonder if there are any other tools that I can
> use to more easily determine the sizes of functions etc to maybe highlight
> where I should look first. Hopefully I can find some obvious things to free
> up space.
> 
> 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.
> 
> Cheers
> 
> Alex Shepherd
> 
> avr-gcc-list at http://avr1.org

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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