Variable organization in Main RAM
Vega256
Posts: 197
Hey guys,
Lets suppose that I have code in a similar format as this,
where I have two var sections. Is the Prop going to set up these variables sequentially although they are in two separate var sections?
Lets suppose that I have code in a similar format as this,
var var0 var1 var3 var var4 var5
where I have two var sections. Is the Prop going to set up these variables sequentially although they are in two separate var sections?
Comments
So if your variables are of the same type they will appear in that order.
In DAT blocks they will remain in the order you declared them.
BUT beware that gaps between byte and words and between words and longs may be introduced as the compiler puts words on even addresses and longs on addresses divisible by 4.
For example if you have
and then you change it to
Is there now a wasted 'gap' in cog ram where variables 3/4/5 were at?
Also, is there a more dynamic way to assign cog ram long location/numbering, then the way I am doing it?
'dynamic way' ... what do you mean? What are you trying to do? Is there some reason why you're labelling every line? Are you trying to use an array / table?
If it's just a table, why not do
So becomes
This is not dynamic in the sense that you can change things at run-time, but it's set up so you can recompile and everything adjusts.
Ok, and do you still have to assign numeric non zero values to variable1-variable7 (underneath of base), or can you just set them to
variable1 long 0
variable2 long 0
etc, and use the myCode section with that?
The 'myCode' stuff was just an example of how you'd reference the variables.
This way if I decide to add (insert) or remove a variable name, I wouldn't have to renumber them like I would if I decided to add/remove in the bottom code block example?
I'm looking for a more efficient way to do the bottom block, which stores hub ram addresses in cog ram so that I can read from or write to them. So yes, something that allows me to do the pointer array more efficiently. If I find that I have to add something in, I have to shift the numerical value by 4n (n being the number of cog ram variable pointers I am inserting in the 'middle') by hand, and then update all of the numeric values under the instantiation portion of my PASM code.
There may not be a more efficient way, but my gut tells me there is. The way I am doing it is setting the byte shift by hand and by a static value (4, 8, 12, 16 etc) and it would be nice if I didn't have to hard code that static value, but I could instead put something dynamic, so that if I did have to insert something any other place but at the end of the list, I did not have to then compensate and hand reenter in the newly shifted values by 4 x the number of newly inserted longs.
I've known how to count to 10 or 20 in German since I was a kid, just never how to spell the words.
Suppose I have this variable section in which data types are intermingled.
After compilation, will the variables be sorted out by type and order such that they are arranged like this?
Or does it just organize with respect to type without regard of order?