Optomize for size...

Go To Last Post
3 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are there any tips or tricks to optimize avr gcc code for size?

I've changed my project options to use the -Os option to optimize for size, and that lowered the size some, but are there any other tips or tricks to lower the size? (ex. do switch statements take up less program file space than if..else statements etc...)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Take a look at the application note
"AVR035: Efficient C Coding for AVR":
http://www.atmel.com/dyn/products/app_notes.asp?family_id=607

And at the article "Efficient C Code for Eight-Bit MCUs"
http://www.embedded.com/98/9811/9811fe3.htm

Regards
Sebastian

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Also take a look at the .LSS file that is generated when you build your avr-gcc project and look specifically for the "bloated" code and consider restructuring (often a cast is all that's needed)

Cliff