Is it possible/practical to run sections of a single DAT section in separate cogs?
Octahedron
Posts: 18
What I am trying to do is to pass a memory location of common HUB memory pool to two separate cogs and simply make sure it is an even number and past the value to the very next long and see if it works. If I use separate objects and call each object and it loads the PASM into each cog it works. If I try to put them together and point further down in the DAT section and start from there it doesnt work. Am I trying to do something that is not possible?
Thanks for your time.
Thanks for your time.
PUB Start(MemoryPointer) cognew(@entry, MemoryPointer) cognew(@even, MemoryPointer) DAT '* Assembly language memory writing * 'KISS - read it, write it, correct odd numbers. '@entry all the PASM is loaded but zero loop never runs '@even the entry loop should not be loaded into the second cog 'but seem to be anyway so it is broken! org 0 entry mov t1,par 'get starting address of the memory pool rdlong t2,t1 'get the first value add t1,#4 'skip to the next long 4 bytes away wrlong t2,t1 'write the the value from the first memory location to the second jmp entry 'Well that was so much fun lets do it again! 'The other part I wish to run to make the first number only even and runs in its own cog! even mov t1,par 'get starting address of the memory pool rdlong t2,t1 'get the first value test t2, #1 wz 'Is it even? if_nz add t2,#1 'If it is odd add one to it if_nz wrlong t2,t1 'Correct the odd number jmp even 'Lots of fun, lets do it again! ' Uninitialized data ' t1 res 1 t2 res 1 fit 496
Comments
hough in your 'even' routine you are only reading and writing the first value in the pool, is this intentional?
Thinking probably not, remember that each cog gets a separate copy of the variables that get loaded into COG mem.
Here is the modification, I would also duplicate the cog variables if I were you.
As for my intentions with this code, yes the simple functions are intentional. One cog to is only used to move the number from the first to the second and the other ensures that the number in the first memory location is even. I was trying to understand the problem so I kept it as simple as possible.
Thanks for your time and help!
The cognew(@even,MemoryPointer) loads the code starting at the address of even into the cog beginning at address 0, though with out the second ORG 0 your assembly is compiled as if it starts at a higher address so when your loop happens it is jumping to an address past the end of the code (because the label offset was calculated for a different base address than is being used).
Thank you, I feel bad that I did not notice that, I hope you got in in time to prevent him making a habit of that.