how to calculate clock cycle of an instruction

i have written a simple program to test how i can build a timer using loops accurately.
void setup()
long a=0;
void loop()

I have created the elf file and thereby txt file. but i don’t know how to read it.
in this program i want to create a 1 sec delay accurately for my another project.
can anyone tell me in this program what should be the corresponding value(in 100,9108), values that is shown here are just the predictable values.
how many instruction cycle be executed per loop, per instruction, how i should calculate the values correspondingly?

disasm.txt (21.6 KB)

Instruction lengths are listed in the "Instruction set" section of appropriate AVR datasheet for the processor.
When calculating, remember that conditional branch instructions have different cycle counts, depending on whether or not the condition was fulfilled.

The Lost Art of Cycle Counting

How accurately do you need your timing to be? +/- how many millisecs?


in this program i want to create a 1 sec delay accurately for my another project.

That is not a good way to create an accurate 1 second delay. You should use the Arduino clock to control the timing, not try to guess how long your code takes and then pad it out.

I often wonder why the Blink without Delay Sketch isn't the Standard Arduino "Hello World" example?... Might serve well, properly commented and perhaps a slight thoughtful error deliberately introduced and alluded to in the sketch documentation... so that it might produce a more interesting effect when 'corrected' and perhaps to encourage the new user to read the sketch first... IMO many of the users don't often even really try to suss out why the basic one works as it does... my point is that it teaches methods that are more likely to "Shoot the User in the Foot" than it does to teach the new user to "think" before before writing anything really useful... in particular there are two simple practices that I have always found to produce a sketch that is planned and thus has a slight chance of producing a better working first attempt.
This in particular from both the engineering aspect and the language issues that confront the new user...
In particular to answer the question that this new user is really asking.


Remember that counting clock cycles is only appropriate for assembly language (or machine code). C/C++ code varies on how it is transformed into machine code, depending upon which compiler, compiler options and version of the compiler are used.

Try this - think you will find it keeps pretty accurate time - within 4-8 uS
(hopefully no compile bugs, can't try it here)

unsigned long oneHundredth = 10000UL; // 10,000uS = 0.01S
byte  hundredths; // use to count to 50, 50/100ths = 0.5S
byte ledPin = 13; // = PORTB, bit 5

unsigned long currentMicros;
unsigned long previousMicros;
unsigned long elapsedMicros;

void setup(){
pinMode (ledPin, OUTPUT);
void loop(){
currentMicros = micros(); // capture current time
elapsedMicros = currentMicros - previousMicros; // see how much time has passed
  if (elapsedMicros >= oneHundredth){ // 0.01S passed, so:
  previousMicros = previousMicros + oneHundredth; // set up for next time interval
  hundredths = hundredths +1; // increment the 0.01S counter
    if (hundredths == 50){ // 0.5S passed?
    hundredths = 0; // reset the counter
    PIND = PIND | 0b00100000; // toggle LED pin by writing 1 to Input register
    } // 0.5S check
  } // 0.01S check
} // end loop