Hi!
I need a way to go back to eg. line 10 of the main program before the main loop starts (an alternative may be to restart the main program entirely). This also needs to work from any called subprograms.
MAIN PROGRAM
INSTRUCTION1
INSTRUCTION2
; Place to restart from
ONI resetSignal CALL InterruptProgram
INSTRUCTION3
CYCLE:
; Main-loop
CALL SubProgram ()
GOTO CYCLE
Display More
I have thought about the following solutions and wonder what you may consider the most proper way of doing it or if you have any input:
One solution may be to monitor the signal in a PC program, eg.
PC PROGRAM
; Alternative 1
IF SIG (resetSignal) THEN
BRAKE
HOLD
KILL
PRIME Main, -1
CONTINUE
END
; Alternative 2
IF SIG (resetSignal) THEN
BRAKE
JUMP MainProgram
END
Display More
I feel the first alternative is kind of a hack as it resets the execution stack which I feel is unnecessary? Alternative 2 feels more proper in a way? Another solution may be to use an ONI instruction and replicate the same ONI instruction in every subprogram called from the main program.
MAINPROGRAM
------------
ONI resetSignal CALL InterruptProgram
...
SUBPROGRAM
----------
ONI resetSignal CALL InterruptProgram
...
INTERRUPTPROGRAM
----------------
BRAKE
JUMP MainProgram
Display More
The problem now is that I have to remember to put ONI instructions in every subprogram. The JUMP instruction also mentions that it may not jump to the source program, but I guess by calling it from within the InterruptProgram it might work as the MainProgram is then no longer the source program.
I am not able to test this right now so I am just asking to verify if I am on the right track or if I should do something different that is more "proper".
Thank you very much and sorry for the long post!