Fast way of checking block for non-zero in SPIN
MacTuxLin
Posts: 821
Kinda having a brain-freeze now. Is there a way to && %111...111 (long) and left shift to see if a long contains a bit in SPIN? Needed to quickly check a block of 3,074 longs for any bit set.
Thanks
Thanks
Comments
If you have a spare cog, you could use a short assembly routine that is running all the time, waiting for its shared memory long to get cleared to zero, then it scans the block and sets the shared long to the address of the first non-zero long found (and even the first bit number in the high order word of the long), then goes back to wait for the shared long to be cleared.
Thanks Jon. Cool, I'll give this a shot & if it is still not fast enough, I'll change my code to make way for a spare cog for PASM.
Thanks