This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to know No. of cycles used by a C statement?

Hellow all,

In the uVision 2.0 for 8051, how to determine the exact No. of cycles taken to execute a C Language statement? Given that performane analyzer works only on complete functions, not on a single line basis.

e.g.
Temp = P2; // Takes (??) cycles
Array[Counter] = Temp; // Takes (??) cycles

If(SignBit == 1) // Takes (??) cycles
Temp = 0xF0; // Takes (??) cycles
else
Temp = 0x0; // Takes (??) cycles


Thanks in advance for your time.

Parents
  • Look at the assembler listing, and the data sheet for your particular processor.

    The assembler listing will tell you precisely what instructions the compiler has used to implement your 'C' source line, and the data sheet will tell you how many clock cycles each of those instructions takes.

    This will, of course, be affected by the optimiser setting - and the optimiser may "blur" the distinction between specific 'C' source lines.

    At http://www.8052.com/users/awneil/8051_INSTRUCTION_SET.XLS I have posted the data for a Triscend E5 - which I believe is the same as the Dallas "accelerated" 8051 parts.

Reply
  • Look at the assembler listing, and the data sheet for your particular processor.

    The assembler listing will tell you precisely what instructions the compiler has used to implement your 'C' source line, and the data sheet will tell you how many clock cycles each of those instructions takes.

    This will, of course, be affected by the optimiser setting - and the optimiser may "blur" the distinction between specific 'C' source lines.

    At http://www.8052.com/users/awneil/8051_INSTRUCTION_SET.XLS I have posted the data for a Triscend E5 - which I believe is the same as the Dallas "accelerated" 8051 parts.

Children