nested reps
ke4pjw
Posts: 1,274
I am guessing that nested reps are a no-no?
{Spin2_v52}
CON ' Constants
_CLKFREQ = 160_000_000
PUB start() | i, c
org
rep @.outerloop, #10
rep @.innerloop, #10
add c, #1
.innerloop
add i, #1
.outerloop
end
debug(udec(c))
debug(udec(i))


Comments
I got something similar
Easy to fix, though
No, you can't nest reps. Ada tells us all about it here
That doc also says: "The last instruction in the REP loop should not be a relative-addressed jump or call, since the PC will already have looped back to the top by the time the target address is computed."
A relative-addressed jump or call can definitely be the last instruction as long as the number of REP instructions is added to the branch address, e.g.
tjz x,#branch_address+4if four repeated instructions. (Just tested this successfully in cog exec.)Of course you can do it if you correct for the looping, but the point is that it doesn't work normally.