Record Address, sharing variables
T Chap
Posts: 4,223
Hey guys, a few years ago I was working on some stepper code where a new cog was apparently accessing a variable outside itself.
Below is a snippet.
I cannot remember what the + 4 meant. Obviously the Long at radr X cannot never be larger than the same value X added to 4 , but I cannot recall what this was doing.
Can someone remind me of what this trick might be doing? My only guess is that it is comparing a long @X with some variable 4 places down in memory.
Below is a snippet.
If LONG[noparse][[/noparse]radr] >LONG[noparse][[/noparse]radr + 4]
I cannot remember what the + 4 meant. Obviously the Long at radr X cannot never be larger than the same value X added to 4 , but I cannot recall what this was doing.
Can someone remind me of what this trick might be doing? My only guess is that it is comparing a long @X with some variable 4 places down in memory.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I am 1011, so be surprised!
Advertisement sponsored by dfletch:
Come and join us on the Propeller IRC channel for fast and easy help!
Channel: #propeller
Server: irc.freenode.net or freenode.net
If you don't want to bother installing an IRC client, use Mibbit. www.mibbit.com
Long X, Xcurrent
So it was comparing X against the current position. I am not sure why it wouldn't be written If LONG[noparse][[/noparse]radr1] >LONG[noparse][[/noparse]radr2], since it is getting radr a a parameter passed from the call, could just easily pass both var's. I suppose this was just less wordy method, I am sure I borrowed this, or maybe Mike even wrote this as an example for me some time back.
It does appear that this was a method to have a parameter in one cog getting accessed by a new cog, so the LONG[noparse][[/noparse]radr]. Although I could have sworn that I just read that variables were not accessible outside an object. In this case, a method starts a new cog MoveX, which relies on the variable X and Xcurrent (Xcurrent written as radr + 4) to know where the stepper is.
Thanks for the info guys.