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

Count Instructions.

Hi,

I am using a C code in a 8051, I would like to know if there is any way of counting who match instructions I am using in these C code.In my case,it is important to know the "exact" number of µs that this code will need, because I am also using a timer, and these one has to be precise.

Many thanks

  • "is any way of counting who match instructions I am using in these C code"

    Look at the generated assembler.
    It's one of the Listing Options.

    "In my case,it is important to know the "exact" number of µs that this code will need"

    In that case, you must do it in assembler.

    'C' gives you absolutely no guarantee whatosever that any particualr 'C' source will generate any particular set of machine instructions.

  • And even if you count the instructions by hand (say in the .lst or .cod output) for one case, there is no guarantee that the C compiler and optimizer will always generate the same sequence of instructions for the same code.

    If you have to time based on instruction count, and you must be sure, use assembler.

  • "there is no guarantee that the C compiler and optimizer will always generate the same sequence of instructions for the same code."

    You should write this out 100 times, and pin it to your wall!