Hi all,
i need to synchronize my arduino with another IC modem and i need to know how many time is needed for execute "each C instruction".
Looking the ATMEGA328 Datasheet I've seen that each "low level" instruction take 1/16000 more or less 62.5 nano second ...
i need to know how many time is needed for execute "each C instruction".
The Arduino doesn't execute C instructions. The compiler converts the C instructions of machine instructions, and then optimizes them. The linker links them all together to form an executable. You will have a very difficult time determining how long "a C instruction" takes to execute, since many turn into more than one machine instruction.
i = 0;
is going to take a different amount of time than
i++;
will take, and
Serial.print(i);
will take a different amount to time depending on whether there is room in the outgoing buffer, or not.
you need to look at the compiled code assembly. C/C++ code has little relationship to actual code size.
For example, in your example, int i will most probably evaporate into a single load instruction.
You can search your IDE installation for 'avr-objdump.exe', it will have a help screen you can view.
This is how I do it in windows and the 1.5.2 IDE ( using a bat file in shell:SendTo ):
D:\arduino-1.5.2\hardware\tools\avr\bin\avr-objdump.exe -S %1 > %1%.txt