M.Earnshaw
11-06-2010, 05:41 PM
Hi all,
I was just wondering if its possible to write a dedicated object in spin/asm, store it in eeprom, and load it in and initialise a cog with it on demand, with access to the variables already in hub?
If all the individual cog 'images' have identical opening sections (Con, Obj, Var), with the variables layed out identically, would this allow it?
In theory, the way I see it, as long as the hub variables are placed in the same place then a cog image would just write to the variable.
E.g.
Each cog image has the same opening section: (Semi-Pseudo code)
Con
(Some constants)
Obj
Object 1
Object 2
Var
Long a, b, c
Word d, e, f
Byte g, h, i
Object A is then created using the above header, that reads from a, adds 10, and writes it to b.
This is run on Cog 0.
Object B is created, using the same header, but this time reads from b, subtracts 10, and then writes to a. This object is stored in eeprom.
The Hub ram is then blanked after the variables onwards.
If Cog 1 is then loaded with Object B from eeprom, will the 2 cogs be able to communicate even though they are 2 seperate objects?
I think thats the best way I can explain it, its been driving me mad for the past day trying to figure out if its possible. The theory sounds fine to me in principle, but I might be missing something.
I was just wondering if its possible to write a dedicated object in spin/asm, store it in eeprom, and load it in and initialise a cog with it on demand, with access to the variables already in hub?
If all the individual cog 'images' have identical opening sections (Con, Obj, Var), with the variables layed out identically, would this allow it?
In theory, the way I see it, as long as the hub variables are placed in the same place then a cog image would just write to the variable.
E.g.
Each cog image has the same opening section: (Semi-Pseudo code)
Con
(Some constants)
Obj
Object 1
Object 2
Var
Long a, b, c
Word d, e, f
Byte g, h, i
Object A is then created using the above header, that reads from a, adds 10, and writes it to b.
This is run on Cog 0.
Object B is created, using the same header, but this time reads from b, subtracts 10, and then writes to a. This object is stored in eeprom.
The Hub ram is then blanked after the variables onwards.
If Cog 1 is then loaded with Object B from eeprom, will the 2 cogs be able to communicate even though they are 2 seperate objects?
I think thats the best way I can explain it, its been driving me mad for the past day trying to figure out if its possible. The theory sounds fine to me in principle, but I might be missing something.