compiler Efficiency

I'm totally new to the Arduino- just got the first led blink program working.

I'm a bit surprised that the led blink program which comes with the IDE already takes up over 1K of program space.
Considering the arduino only has 14k of program space total, that doesn't leave a whole lot of room left for a real program.

Most of that 1K is the library code necessary to support a basic sketch. Doubling the amount of code will only add about 50 bytes. Actual code sizes are hard to predict because different functions can result in more library code being linked in but you may be pleasantly surprised in how much code can fit in 14k

Most of that 1K is the library code necessary to support a basic sketch. Doubling the amount of code will only add about 50 bytes. Actual code sizes are hard to predict because different functions can result in more library code being linked in but you may be pleasantly surprised in how much code can fit in 14k

That's a relief to know.

Thanks

How efficient is the compiler with standard functions like reading, writing, servos etc, concerning both program size and speed.

Are they still ok to use or very large and complex programs, or is it butter then to read and write registers manually?

How efficient is the compiler with standard functions like reading, writing, servos etc, concerning both program size and speed.

The compiler is essentially gcc, targeted toward avr.

Since most linux distros (and probably *nix distros in general) use gcc for -everything-, what does that tell you?

I'd say it is an OK compiler, off hand...

:stuck_out_tongue:

One thing, what is the optimization flag that the arduino ide uses in the gcc call?

what is the optimization flag that the arduino ide uses in the gcc call?

Arduino uses "-Os"; the compiler is pretty good; I look at the code it produces on a pretty regular basis, and I'm generally happy. It has the usual limitations of a high-level language in terms of not supporting things like mixed-sized math or direct use of processor flags, and it's pretty easy to accidentally do things that make your code slower than it ought to be (typically: using integer sizes bigger than necessary. The 32bit math produced for longs may be about as good as possible for 32bit math on an 8-bit CPU, but it is an 8-bit CPU and the amount of code needed to do 32bit math is ... depressing.)

the amount of code needed to do 32bit math is ... depressing

A 24bit datatype would have been nice. ::slight_smile: