|
|
View previous topic :: View next topic |
Author |
Message |
Bilal
Joined: 24 Apr 2010 Posts: 75 Location: Islamabad
|
machine cycles |
Posted: Sun Oct 31, 2010 7:36 am |
|
|
hi.. i want to know how can i calculate proper time of execution of instructions in ccs c.. as we can do in assembly language (with machine cycles)
thanks _________________ ... |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9255 Location: Greensville,Ontario
|
|
Posted: Sun Oct 31, 2010 7:42 am |
|
|
Once you've compiled a working program, printout the listing (filename.lst).
draw a couple of vertical lines down the right side
in this new 'column', write the machine cycles for that line, usually 1, 2 if a compare-branch instruction. Details are in the 'instruction set' info.
add the column up and you have the total machine cycles.
time to execute this code depends upon processor,crystal used, any PLL info, etc.
hth
jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19568
|
|
Posted: Sun Oct 31, 2010 9:27 am |
|
|
Or just put the code into a simulator like MPLAB, add a couple of markers, and let the stopwatch do the work for you.
This has been answered before, and a search here should find more detailed replies, but the big problem is that quite simple single instructions, can have dozens of different timings, dependent of 'circumstances'. Where values have to be retrieved from, the types of the values involved, whether the same numbers are used 'nearby', so can be retrieved from temporary storage, or need to have their locations 'calculated' first, etc. etc.. You will probably find that the total time for a simple addition, could vary from just a couple of machine cycles, to perhaps 600 machine cycles (floats retrieved from an array).....
Best Wishes |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|