View previous topic :: View next topic |
Author |
Message |
Guest
|
Compiler and functions.... |
Posted: Thu Oct 27, 2005 6:23 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
asmallri
Joined: 12 Aug 2004 Posts: 1634 Location: Perth, Australia
|
Re: Compiler and functions.... |
Posted: Thu Oct 27, 2005 7:33 am |
|
|
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!! |
|
![](templates/subSilver/images/spacer.gif) |
kypec
Joined: 20 Sep 2003 Posts: 54
|
|
Posted: Thu Oct 27, 2005 7:34 am |
|
|
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) {
...
} |
|
|
![](templates/subSilver/images/spacer.gif) |
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Thu Oct 27, 2005 7:46 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|