Pnut arrays?
kbash
Posts: 117
in Propeller 2
I'm trying to re-write a program to take advantage of the P2 block moves instead of just moving individual values into and out of Hub ram.
However... I can't figure out how to manipulate values indexed from a start location with Pnut.
I can reserve blocks of cog memory with RES for instance:
VALSX res 8 ( which I THINK reserves 8 longs in memory)
but I've tried various combinations of VALSX[1], VALSX+1, @VALS etc and haven't managed to make it work. Is there an example of how to access a value indexed from a starting cog memory location?
Comments
you have code in a cog needing indexed access into a HUB array or indexed access into a COGram array or indexed access into the LUTram
because all work different
more input,
Mike
I need to move data in blocks, first from Hub memory to CogA's ram memory ( blocks of about 25 variables. Let's say they are going from hub ram locations 5000 - 5024 to CogA ram locations 475-499 )
I'm currently doing this with individual RDLONG instructions into individual variables but I know I'm wasting a lot of program space.
I do calculations on that data then move the "Answers" into 20 variables in the shared LUT and set a LUT "flag" that triggers CogB into action.
CogB loads those 20 variables from the shared LUT into it's RAM using individual RDLUT instructions then uses those variables to do its operation. When done, CogB puts the resulting data back into another location in the LUT which CogA uses for feedback on it's next setup for CogB.
This is what I'm doing now: setting up pointers, moving the data individually, then using those values in my control routine. What I'd LIKE to do is have my variables moved into memory in a block, then only change a base pointer to the data for the next operation. This would let me "Hot Swap" data eliminating the several microsecond delays I have now from one operation to the next.
Doing this same thing in a block move should save time and memory
To USE that data, In spin, it would just be something like:
I'm not sure how to index from the start of the block (VALS[0] +1, +5, etc. ) in P2 assembly to use the values in the other variables.
I just saw your info Electrodude, I'll see if I can decipher how to use it to do what I need. Thanks!
( but if you know of any sample code that does some of the things I mentioned, I'd love to see some working examples)
KenB
there is also another way I havn't tested yet, but it is from @Cluso99 so it will probably work
It looks like you are wasting a lot of code space...
Enjoy!
Mike
MOV PTRA,##$3010 (missing $)
use
LOC PTRA,#$3010
as it saves an instruction, and that's what LOC is for.
thanks,
Mike
I managed to get a program indexing to data in an array using the alts instruction. I thought I was good to go when I tried to comment out some unused code at the end of the program. When I did this, the program stopped working correctly. ( unusual delays got added to the operation ) Also, if I comment out the unused MOV loopcnt, #0 in line 76, the operation changes also.
I have tried this same program compiled with Pnut AND the spin2 compiler. I have tried it running in cog 0 and
( as here ) running it from an initializing cog. All work the same. I suspect the problem is my understanding of the ALTS instruction, but for the life of me, I don't understand why commenting out unused code would change the functionality of the "Running" code. Can anyone spot what I'm missing? I'd like to post (correctly working ) code as an example of how to use ALTS Base + index but it's obvious I'm missing something. Any clues what?
( the program blinks LEDs on the P2-EV board according to a group of variables with the LED port addresses in them )
It's been years (decades) since I've done pointers in Assembly. I'm trying to get the hang of the P2's instruction set before I start working with the P2 in Spin or C++.
With minimal documentation ( that I know is being diligently worked on ) and new tools, some of this doesn't click the first time through my brain.