|
|
View previous topic :: View next topic |
Author |
Message |
DaCoTa Guest
|
Variable ordering optimization |
Posted: Wed Jan 15, 2003 9:15 am |
|
|
Is there a way to find the optimal ordering for variables? Sometimes, there are huge changes in code size when I add or remove a single variable or change the order of some variables. Is there a chance CCS will get some sort of allocation optimization built in sometime? I'm using 3.084 of PCM right now.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10718 |
|
|
Eric Minbiole Guest
|
Re: Variable ordering optimization |
Posted: Wed Jan 15, 2003 9:42 am |
|
|
:=Is there a way to find the optimal ordering for variables? Sometimes, there are huge changes in code size when I add or remove a single variable or change the order of some variables. Is there a chance CCS will get some sort of allocation optimization built in sometime? I'm using 3.084 of PCM right now.
I don't know of any automated way to do it. One thing I can think of is to try to keep variables that are used 'near' each other in the program close together in RAM. i.e., FuncA() uses a bunch of vars from bank 0, FuncB() uses vars from bank 1, etc. It is a bit tedious to do this, but it seems like it might minimize the amount of bank-switching code.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10720 |
|
|
regan Guest
|
Re: Variable ordering optimization |
Posted: Thu Jan 16, 2003 2:36 am |
|
|
:=Is there a way to find the optimal ordering for variables? Sometimes, there are huge changes in code size when I add or remove a single variable or change the order of some variables. Is there a chance CCS will get some sort of allocation optimization built in sometime? I'm using 3.084 of PCM right now.
Try putting all your most frequently used global variables in bank0. Put all your arrays in bank3 as they will usually be indirectly addressed. Locally declared variables are put at the end of RAM by default. You can get significant savings in code size if your declare some general purpose variables at the beginning of RAM and use them where ever local vars are required. I don't have PCW, but I think that it might offer a feature that allow you to put all the local variables in bank0. Perhaps someone else can answer that.
Regan.
___________________________
This message was ported from CCS's old forum
Original Post ID: 10736 |
|
|
mark r. hahn Guest
|
Re: Variable ordering optimization |
Posted: Sat Jan 18, 2003 10:04 am |
|
|
:=Is there a way to find the optimal ordering for variables? Sometimes, there are huge changes in code size when I add or remove a single variable or change the order of some variables. Is there a chance CCS will get some sort of allocation optimization built in sometime? I'm using 3.084 of PCM right now.
My experience is that CCS will try to stay in bank 0 when executing code. If it needs to reference a variable in a different bank, it will switch to that bank and then back to bank 0. This adds a bit of code everytime the compiler acesses a different bank. When optimizing it checks to see if switching back to 0 is useful (for example it may reference a var in bank 1 then reference another var also in bank 1). Another poster mentioned that local variables are allocated at the end of ram downward and global variables are allocated at the start of ram (bank 0).
If you are allocating a lot of global variables, you will quickly fill up bank 0, and hence any additional variables that you or the compiler create will be pushed into higher banks.
What I've had luck with is locating global variables that I don't reference that often in higher banks. See the #LOCATE directive for info on how to locate a variable at a specific address. By how often you reference a variable, I mean how many times does a reference appear in your code. It would be really nice if the CCS compiler had a cross reference utility that listed the number of times a reference was made to a variable.
Mark
___________________________
This message was ported from CCS's old forum
Original Post ID: 10780 |
|
|
|
|
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
|