Does anyone know why a blank Arduino Sketch Uses 450 Bytes of Program Storage Space and has 9 Bytes of Global Variable? Why?
How does this compare with other AVR compilers?
Does anyone know why a blank Arduino Sketch Uses 450 Bytes of Program Storage Space and has 9 Bytes of Global Variable? Why?
How does this compare with other AVR compilers?
thanks for the link. do you know if using other AVR compilers will use the about the same amount of space?
They do vary, but something in the order of 400-500 bytes would be expected. If the AVR has more interfaces/pins, this would have more initialization code to setup. Even X86 has code on the boot drive to find what to load or put a message saying boot sector missing!
Clem
The concept - valid on any other kind of environment too - is that the system when creates a blank stuff as in your case, it is NOT creating nothing, it is creating ONE THING: the blank stuff. So first of all you should see this apparently strange behaviour in the right perspective: the concept of "no program" should be represented just as any other program, and it occupy a space in the environment. Obviously minimal but it needs.
The other aspect that is involved to this other "strange" behaviour, is related to the hardware and how the system represent data and bytes, instruction and so on. Bytes data architecture should follow internal hardware architecture so there is a standard bytes alignment, a minimal number of words occupied and so on. Then as your program grows a bit, if the aligned memory storage is sufficient it does not increase in size. This phenomenon is more explicitly visible as much you go near the machine language, as it occur in the case of microcontrollers programming.
Compilers are smarter than us. If you allocate memory with no value, it is set aside and that is all. When you set a value, then a value is et in global to remember ot. No surprise to me, but I work with these for over 40 years. The loop may be optimized out of existence. I have seen this too. The behaviour is predictable IF you know how they generate code.
thank you Clem, but thiss brings me back to pondering why a blank Arduino sketch would have the 9 bytes global variables when we have not used any yet.
what are those 9 bytes for variables for?
i wish we can compare it with other compilers or AVR IDE.
i believe in other AVR IDEs it goes something like this
int main(){
/*main is like the setup section of arduino*/
/**this is the loop section**/
while(1)
{
//codes for the loop section here
}
/**end of loop section**/
}
if we compile this will we get similar byte usage with the Arduino.
I am trying to understand one of the pros and cons of a given IDE.