Question: PASM, COG, and Static methods
Mike G
Posts: 2,702
I have PASM running in a COG. I'd like to share the COG process across multiple objects, like a static method. I'd have to carve out HUB memory so the other methods could access the PASM process through interface pointers. That would create dependencies between objects at run time.
I'm thinking that I'll have to have as many instances of the PASM processes (COGs) as I have PASM consumer objects. Is that correct?
I'm thinking that I'll have to have as many instances of the PASM processes (COGs) as I have PASM consumer objects. Is that correct?
Comments
You have one piece of PASM-code. This uses some HUB RAM to check what it should do - let's call that the PASM interface RAM. And now you want this to be used by several objects.
Well ... it's not necessary to have n PASM COGs for n "users".
1. For example you could use locks to synchronize the access to the PASM interface RAM.
2. Or you could have n "PASM interface RAM" sections. The PASM simply checks these one after another. Each object only works with it's own interface.
I was struggling with how to implement the interface to a single COG. localroger, that makes sense, I just need to create some test code to solidify my understanding.
MagIO2, yeah I'll have to lock memory.
Help, I'm horribly lost. What does it mean to create an object with a PASM image? Does that mean the object consists of nothing but a DAT block?
And what is the address of a PASM image? The PASM image is in cog RAM, and that's not accessible by SPIN code. Do you mean proving the address of the first symbol (or entry point) in the DAT block in hub RAM? How would one use that for this purpose?
For each object you need at least one PUB. In this case it would be a getPASMAdr function which then returns the address of the PASM-code.
All the programs which use this object can then call getPASMAdr and do a COGNEW on their own.
But as told above, this requires one COG to run the PASM code per "user".