ASM question using rdlong/wrlong....
Chris_D
Posts: 305
Hi guys,
I am in a bit of a snag with my ASM learnings...
I have a number of variables in HUB memory that I need to access from with an ASM routine in a COG.· So far, I was able to get the pointer set up and passed through to the cog and I was able to write to it ...
······················· mov···· Hub_Index, par············· 'Makes a copy of the pointer which is passed as a parameter
······················ 'other lines of code......
······················· wrlong· A1P_AbsPos,Hub_Index··'copies A1P_AbsPos into the·hub variable pointed to by Hub_index
I remember seeing somewhere and can't find it again, some sort of trick that allowed easy access to other variables...
····· wrlong· A1P_AbsPos,Hub_Index··+ #4· 'Something like this I think?
I suspect it was easy and similar to shown above, but sure could use a bit of explanation and clarification.
Thanks!
Chris
·
I am in a bit of a snag with my ASM learnings...
I have a number of variables in HUB memory that I need to access from with an ASM routine in a COG.· So far, I was able to get the pointer set up and passed through to the cog and I was able to write to it ...
······················· mov···· Hub_Index, par············· 'Makes a copy of the pointer which is passed as a parameter
······················ 'other lines of code......
······················· wrlong· A1P_AbsPos,Hub_Index··'copies A1P_AbsPos into the·hub variable pointed to by Hub_index
I remember seeing somewhere and can't find it again, some sort of trick that allowed easy access to other variables...
····· wrlong· A1P_AbsPos,Hub_Index··+ #4· 'Something like this I think?
I suspect it was easy and similar to shown above, but sure could use a bit of explanation and clarification.
Thanks!
Chris
·
Comments
It works the same with wrlong
Now, at somepoint I need to reset the Hub_index back to the original setting.· Will the par retain its value?
If so, all I need to do then is simply repeat the mov·Hub_Index,par instruction to get back to my base pointer value.
Thank Mike!
Chris
When I declare these variables, I assume I have to make sure they are listed like this·?
· Long A1_Pos
· Long A2_Pos
····... and so on all the way through my list.
What I am trying to clarify is that the order in which I delcare them establishes their memory location relative to the first one.
Chris
·
As you can see, I'm saving the hub address of the led mode and the timing durations for each phase -- this lets me get to them later to check for changes. Here are the varaible declarations at the end of the ASM section:
I only need to read the green and red pin #s once so their address in the hub is not required.
That should do it, I on may way to dig meself into the next hole!
Chris