CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

machine cycles

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Bilal



Joined: 24 Apr 2010
Posts: 75
Location: Islamabad

View user's profile Send private message Send e-mail

machine cycles
PostPosted: Sun Oct 31, 2010 7:36 am     Reply with quote

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: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sun Oct 31, 2010 7:42 am     Reply with quote

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: 19551

View user's profile Send private message

PostPosted: Sun Oct 31, 2010 9:27 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Oct 31, 2010 2:59 pm     Reply with quote

Here is the post that Ttlemah referred to, which explains how to use the
stopwatch feature in MPLAB:
http://www.ccsinfo.com/forum/viewtopic.php?t=38351
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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