Memory Usage in Propellor
StephenMoore
Posts: 188
Back to the beginners circle...
Does the DAT variable section of a Spin program load main Prop RAM or Cog RAM?
Are DAT variables equally accessible by Spin routines and Assembly programs during run-time?
Does the DAT variable section of a Spin program load main Prop RAM or Cog RAM?
Are DAT variables equally accessible by Spin routines and Assembly programs during run-time?
Comments
variables in the VAR-section are "local" within the *.SPIN-file they are defined in.
DAT-variables are GLOBAL to all *.SPIN-files but can be accessed only over a pointer
You can pass this pointers to assembly-code.
If a cog runs assembly-code all PASM-commands effect only COG-RAM except the RDLONG/WRLONG-commands that read write to HUB-RAM
keep the questions coming
best regards
Stefan
Nothing gets loaded to COGs RAM unless your program does it with cognew/coginit. Except of course COG 0 is loaded with the Spin interpreter at start up which then runs you top level object.
A COG that you start with Spin can access the vars and dat in it's object. Be aware that all instances of the same object share the dat section but get their own var section.
A cog that you start with PASM can also access vars and dat with wrlong, rdlong etc. But then you have to arange for the PASM to get the addresses of the things you want to access.
Any Spin or PASM can actually access any locatin in HUB if it knows what address to use.
Apparently the Spin program rights to the DAT variuables and the PASM program is able to access them as well.
Can anyone shed some light on this?
After starting the COG there is no link! This means that any change in these variables won't affect the PASM code.
SPIN always works in HUB-RAM and PASM always works in COG-RAM (except when using wr/rd... instructions)
Of course you could now set different values and start a different COG. After loading the HUB-RAM into the COG-RAM there is also no link. And of course there is also no link between the first and the second COG started with this program.
This is some kind of an injection of parameters into the memory that's loaded into the COG. It's usefull if you have parameters that only have to be set once. This way you don't need to waste COG-RAM for code that fetches these values from somewhere.