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

Compiler and functions....

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








Compiler and functions....
PostPosted: Thu Oct 27, 2005 6:23 am     Reply with quote

Hi all,
I'm using a PIC16F877A and I have a question that maybe is a silly question, but that can clarify some doubts I have...

I wrote a function and then I call it during the program.
I try to optimize this function and I hope that the compiler loads it only once in the program memory and jump to the function address every time I call during the execution of my code...
But when I look into the .tre file I find this function many and many times, what does it mean?

Thanks in advantage, Andrea
asmallri



Joined: 12 Aug 2004
Posts: 1635
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: Compiler and functions....
PostPosted: Thu Oct 27, 2005 7:33 am     Reply with quote

Anonymous wrote:
Hi all,
I'm using a PIC16F877A and I have a question that maybe is a silly question, but that can clarify some doubts I have...

I wrote a function and then I call it during the program.
I try to optimize this function and I hope that the compiler loads it only once in the program memory and jump to the function address every time I call during the execution of my code...
But when I look into the .tre file I find this function many and many times, what does it mean?

Thanks in advantage, Andrea


Take out your optimization and look at the file again
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
kypec



Joined: 20 Sep 2003
Posts: 54

View user's profile Send private message

PostPosted: Thu Oct 27, 2005 7:34 am     Reply with quote

If you want the compiler to include the body of your function
only once in the program memory then use #separate directive
just before the function definition.
Code:
#separate
int8 my_func(int1 arg1,int8 arg8) {
   ...
}
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Thu Oct 27, 2005 7:46 am     Reply with quote

Quote:
But when I look into the .tre file I find this function many and many times, what does it mean?
Calling a function has overhead, for short functions the compiler might decide it's better to handle them as #inline. The compiler decisions are based on the optimizer settings, optimizing for speed or program size.
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