easy way to tell PASM-code HUB-RAM-variables adresses

I played around a little bit with the capswitch-code (capacitive proximity sensor).
Code is attached.
When I analysed the code first I wondered where the heck gets this variable "reslt" updated??
Then I discovered in the PASM-DAT-section of the code a "PASM"-variable "reslt_ptr" is defined.
First thing that is done in the SPIN-code is assigning
reslt_ptr := @reslt
After this assigning the PASM-code can use this "PASM"-variable "reslt_ptr" to do HUB-RAM-writes to the SPIN-variable "reslt"
Wow cool so this is a second way how to tell PASM-code HUB-RAM-adresses. First way is the second parameter of cognew which starts PASM-code
Do I understand right that the assigning has to be done before starting the PASM-cog? The cognew(@PASM-entry..) copies the DAT-section to the cog-RAM
and this means all initialisation
Code is attached.
When I analysed the code first I wondered where the heck gets this variable "reslt" updated??
Then I discovered in the PASM-DAT-section of the code a "PASM"-variable "reslt_ptr" is defined.
First thing that is done in the SPIN-code is assigning
reslt_ptr := @reslt
After this assigning the PASM-code can use this "PASM"-variable "reslt_ptr" to do HUB-RAM-writes to the SPIN-variable "reslt"
Wow cool so this is a second way how to tell PASM-code HUB-RAM-adresses. First way is the second parameter of cognew which starts PASM-code
Do I understand right that the assigning has to be done before starting the PASM-cog? The cognew(@PASM-entry..) copies the DAT-section to the cog-RAM
and this means all initialisation
Comments
The perferred method of passing location is to use the address passed to par and use that address as the starting point and add 4 to get the next long location in hub (only pass long locations with par).
Poking the values in with Spin prior to lanching the code is easier though (which is why I usually do it that way).
If you want your code to be C friendly, you shouldn't go poking around in Spin.
Yes, because the code resides in the hub at that point and your Spin code can get to it; once it's in the cog it's beyond reach.
An argument has been made -- and I have come to agree -- that the interface code should not modify the assembly code. While this is possible in Spin, it limits that object and the assembly code used in it to Spin projects. With PropGCC coming this is considered bad form (my opinion), and I just chastised myself in print no less (May Nuts & Volts column) for doing this in past projects.
I'm not a big C programmer but I do write objects that many find useful. My goal, then, is to have any PASM code I write be useful in my Spin projects, as well as be compatible with PropGCC (and other languages that support launching PASM code into its own cog). I realize that this can create some small redundancies, but it's worth it.
For example, in an AC phase dimmer I'm working on now, here is the interface and the associated PASM. Note that variables in the object are modified and then the first in the group is passed via the PAR register to the PASM code that knows how deal with things from there.
And to be honest that's what you should be allowed to do with most of the objects! Say you instanciate 3 full duplex serial interfaces. You'd have to wait until the first one is loaded into the COG before you can start the next one. Using PAR you can fire all three up in parallel which means call the start methods directly one after the other. (COGNEW does not wait for the COG to be loaded completely, it immediately returns and you can continue)