PASM question about declaring variables...
Chris_D
Posts: 305
Hi guys,
I am still working on my first PASM program and am doing pretty good (had it actually working but needs much improvement).· The one thing that is causing me confusion (as I copied the method from examples) is how variables are declared within a PASM program.· THere are two ways it is done...
Variable_1····· LONG··· Preset value
or
Variable_2···· RES····· 1
I can see that the first method allows me to preset the value and method two does not.· However, I also seem to recall that there is something more "complex" going on which dictates when to use which method.· Can someone clarify this for me?
Thanks
Chris
·
I am still working on my first PASM program and am doing pretty good (had it actually working but needs much improvement).· The one thing that is causing me confusion (as I copied the method from examples) is how variables are declared within a PASM program.· THere are two ways it is done...
Variable_1····· LONG··· Preset value
or
Variable_2···· RES····· 1
I can see that the first method allows me to preset the value and method two does not.· However, I also seem to recall that there is something more "complex" going on which dictates when to use which method.· Can someone clarify this for me?
Thanks
Chris
·
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lt's not particularly silly, is it?
Being that the first method consumes a variable of HUB memory, does that mean that HUB memory is accessed everytime that variable is accessed?· If so, that would me the time to access it would be much longer than an undefined variable.
Chris
No. When you load the cog the contents are copied from HUB ram to the COG directly. From then on, every access to that variable from inside the cog is local, just the same as the RES variables.
That is unless you manually access the HUB ram incarnation of it using rdlong/wrlong.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
lt's not particularly silly, is it?
Chris