Bug with PE6 and simulating both Tasks and Interrupts

#1
Hi there!

I just started tinkering with my first Picaxe project, employing both interrupts and tasks. When using the simulator to run my program, it looks like the instruction pointer for the program isn't properly captured when the interrupt is fired, resulting in the program resuming at the wrong location.

The following program demonstrates the issue, using the 6.0.9.3 PE6 editor to simulate a 14M2 chip. I have not yet determined if this is also affecting compiled on-chip programs.

Code:
SUSPEND 1                  ' disable task 1; not needed for bug repro
SETINT %00000001,%00000001 ' C.0

main:

    LET b0 = 100
    b0 = b0 + 23

    PAUSE 5000             ' trigger interrupt while paused (toggle C.0)
    GOTO main

interrupt:

    PAUSE 50
    SETINT %00000001,%00000001

    RETURN

start1:

    LET b1 = 200
    b1 = b1 + 46

    PAUSE 7000
    GOTO start1
Simulate and step through the PAUSE statement in main(), triggering the interrupt after the PAUSE statement executes (make sure to set the input to low once the interrupt is handled). When the interrupt returns, execution should resume on the GOTO main statement. Instead it resumes on the interrupt label, effectively corrupting the stack.

If you add a statement in main() between the PAUSE and GOTO statement and repeat the simulation, execution resumes on the GOTO statement instead. This isn't a reliable workaround though as triggering the interrupt on the GOTO statement yields the same issue. Finally, disabling the task by renaming the start1 label shows that the instruction pointer is tracked properly and the interrupt resumes at the proper location.

I've noticed other forum posts regarding open issues with interrupts and tasks; perhaps this can help track them down.
 
#2
I have not yet determined if this is also affecting compiled on-chip programs.
This issue doesn't appear to affect on-chip programs. I just put together a simple circuit that flashes LEDs at different frequencies per task, and the return from the interrupt isn't corrupting the stack as in the simulator.
 
Top