REP seems to not allow debug to operate as an instruction
Bob Drury
Posts: 236
in Propeller 2
It seems that debug is ignored if used in REP instruction. See attached code. I wonder why?
Regards
Bob (WRD)
Comments
I didn't look at the code, but debug is an interrupt and interrupts will be ignored during REP looping. You can read this in the google document https://docs.google.com/document/d/1gn6oaT5Ib7CytvlZHacmrSbVBJsD9t_-kmvjd7nUR6o in chapter 'INSTRUCTION REPEATING'.
Is this debug an interrupt? I think it might be a jump to subroutine somewhere and then a jump back...
Either way, it won't work with REP...
The actual behavior does not appear documented anywhere, but it was discussed in this forum somewhere a while ago...
The REP construct is very sensitive to loop disturbances. For example, you can't use CALL or any kind of JMP in a REP loop which is likely what's happening with DEBUG.
Reminder: You can drop PASM2 code into a Spin2 method which means you don't have to launch an extra cog. I find this incredibly valuable for learning. For example:
This code gives the same result as my CRC8 method shared in another thread -- it just takes more cycles for the same packet.
Dnalor is correct for Pnut/PropTool. REP puts a hold on interrupts, and debug is highest level IRQ in the prop2 under Pnut solution. So debug won't respond until the REP is completed. The REP instruction is built this way to prevent unexpected branching.
Rayman is correct for FlexSpin/C/Basic. There, debug will possibly create a bug because a branch instruction cancels the REP for good. Branching out of a REP is legal, but you need to account for it terminating the REP.