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

Measure internal cycles needed for an operation

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







Measure internal cycles needed for an operation
PostPosted: Sun Jun 15, 2003 3:11 am     Reply with quote

Hello !

I have to measure the No. of cycles needed for loop like:


movlw 0x20,N
DELAY: decfsz 0x20
goto DELAY

( or more complicated loops )
is it equals to: 1+(N-1)+2 + (N-1) ?
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515251
R.J.Hamlett
Guest







Re: Measure internal cycles needed for an operation
PostPosted: Sun Jun 15, 2003 4:45 am     Reply with quote

:=Hello !
:=
:=I have to measure the No. of cycles needed for loop like:
:=
:=
:= movlw 0x20,N
:=DELAY: decfsz 0x20
:= goto DELAY
:=
:=( or more complicated loops )
:=is it equals to: 1+(N-1)+2 + (N-1) ?
Simplest way. Load the hex file into the MPLAB simulator, add a breakpoint in front of the code, and immediately after the code, open the stopwatch window, and run it.
You can do it 'by hand', by using the chips data sheet, by looking at the cycles needed for each operation. In the case given:
movlw 0x20,N
//One cycle - four clocks
DELAY: decfsz 0x20
//One cycle, when no skip. Three cycles for the 'skip', when
//the next instruction is a two cycle instruction (GOTO).
goto DELAY
//Two cycles.
Starting with twenty, the test will be '19' on the first pass,
and will execute 19 times as a loop, and then once as the skip past. So the code will take:
1+((1+2)*19)+3 cycles = 61 cycles

Best Wishes
___________________________
This message was ported from CCS's old forum
Original Post ID: 144515254
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