Repeating negative numbers.
Quick Question: How many times does this repeat?
repeat -1
' statements
repeat -1
' statements
Comments
A long time ago I tried repeat... step -1 and got completely unexpected behavior....
In any event, I suspect the short answer is, "One more time than repeat -2."
-Phil
As far as I know this is a feature that is unique to Spin:-)
@heater - your joking right?
Might be:)
* An empty repeat loop takes about 224 clocks per pass
* So, at 80MHz, the counter variable would be changing at a rate of ~357000 per second
* Monitoring Hub RAM for values that changed at that rate found the counter
* watching the counter showed that it starts at whatever value you specify, so
* starting at -1 will keep going negative at that specified rate, terminating one the counter reaches 0
* at 80MHz, it will take about 3.34 hours to complete an empty "repeat (-1)"
Jonathan
(Why doesn't parallax document this...)
-Phil
So far I know the repeat occurs more than 100,000,000 times (I left a program runing while reading the forums). I think lonesocks answer is better.
Dave
Cog 0: 002c 00000000 - 0018 34 ldlim1 Cog 0: 0030 ffffffff - 0019 08 02 tjz 2 Cog 0: 0030 ffffffff - 001b 09 7e djnz -2 Cog 0: 0030 fffffffe - 001b 09 7e djnz -2 Cog 0: 0030 fffffffd - 001b 09 7e djnz -2 Cog 0: 0030 fffffffc - 001b 09 7e djnz -2 Cog 0: 0030 fffffffb - 001b 09 7e djnz -2 Cog 0: 0030 fffffffa - 001b 09 7e djnz -2 Cog 0: 0030 fffffff9 - 001b 09 7e djnz -2 Cog 0: 0030 fffffff8 - 001b 09 7e djnz -2 Cog 0: 0030 fffffff7 - 001b 09 7e djnz -2 Cog 0: 0030 fffffff6 - 001b 09 7e djnz -2 Cog 0: 0030 fffffff5 - 001b 09 7e djnz -2 Cog 0: 0030 fffffff4 - 001b 09 7e djnz -2 Cog 0: 0030 fffffff3 - 001b 09 7e djnz -2 Cog 0: 0030 fffffff2 - 001b 09 7e djnz -2