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 support@ccsinfo.com

Counting number of instructions in CCS C

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



Joined: 13 Jan 2007
Posts: 91

View user's profile Send private message Visit poster's website

Counting number of instructions in CCS C
PostPosted: Sat Jul 10, 2010 11:25 am     Reply with quote

I would like to find out, *without* opening the assembly listing, the number of instructions for a line ( or a number of lines ) in CCS C.

Is this possible ( even in conjuction with tools like MPLAB using the plugin )?

For example,

1. I want to find out how many instructions

Code:
delay_us(200);


generates

2. I want to find out how many instructions

Code:
set_timer1(0);
delay_us(200);


generates

3. Then, I would like to count the number of clock cycles it took to execute each function, *without* opening the assembly listing
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Jul 10, 2010 11:55 am     Reply with quote

MPLAB Stopwatch can count instruction cycles.
http://www.ccsinfo.com/forum/viewtopic.php?t=38351
vsmguy



Joined: 13 Jan 2007
Posts: 91

View user's profile Send private message Visit poster's website

PostPosted: Sat Jul 10, 2010 6:41 pm     Reply with quote

PCM programmer wrote:
MPLAB Stopwatch can count instruction cycles.
http://www.ccsinfo.com/forum/viewtopic.php?t=38351


YES!

I remember doing this a long time ago - and it required a little bit of fiddling around - can't seem to find those instructions.

Now, thanks to you - oh great Midrange PIC Programmer, I found them once again :-D
vsmguy



Joined: 13 Jan 2007
Posts: 91

View user's profile Send private message Visit poster's website

PostPosted: Mon Jul 12, 2010 7:29 pm     Reply with quote

PCM programmer wrote:
MPLAB Stopwatch can count instruction cycles.
http://www.ccsinfo.com/forum/viewtopic.php?t=38351


One more question - how do I do the same *but* between two lines in assembly generated by CCS?

For example, say I have written a function called func() that generates the following assembly:

0011: MOVLW 26
0012: MOVWF 04
0013: BCF 03.7
0014: MOVF 00,W

I want to find out how many cycles it takes between lines 11 and 13 - how do I do that?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 12, 2010 8:29 pm     Reply with quote

Look it up in the PIC data sheet. For example, for the 18F452, look in
this section:
Quote:

TABLE 20-2: PIC18FXXX INSTRUCTION SET

It lists the number of cycles used by each type of instruction.
Just count them off in the .LST file.
vsmguy



Joined: 13 Jan 2007
Posts: 91

View user's profile Send private message Visit poster's website

PostPosted: Mon Jul 12, 2010 9:56 pm     Reply with quote

PCM programmer wrote:
Look it up in the PIC data sheet. For example, for the 18F452, look in
this section:
Quote:

TABLE 20-2: PIC18FXXX INSTRUCTION SET

It lists the number of cycles used by each type of instruction.
Just count them off in the .LST file.


That's what I am doing manually now and it's kinda time consuming for longwinded and involved code ( look at my latest post on delay_us inaccuracy ).

The MPLAB Stopwatch seems to be language independent and and counts the number of ticks.

I was asking if there is anyway I could get it to count ticks by setting breakpoints in the assembly code generated by CCS?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Jul 12, 2010 10:16 pm     Reply with quote

Start exploring MPLAB. Go to the View menu. Bring up the Disassembly
Listing window. Put your breakpoints in there. Explore the program.
Read the Help file.
vsmguy



Joined: 13 Jan 2007
Posts: 91

View user's profile Send private message Visit poster's website

PostPosted: Mon Jul 12, 2010 10:39 pm     Reply with quote

PCM programmer wrote:
Start exploring MPLAB. Go to the View menu. Bring up the Disassembly
Listing window. Put your breakpoints in there. Explore the program.


That's it. Thanks again.

PCM programmer wrote:
Read the Help file.


I should :'(
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