interrupt usage

MearCat

Member
Within the interrupt subprocedure at the end of a BASIC program, is ok for me to put a goto before the return, or will this cause
problems/crash the program? Does it HAVE to return from the interrupt subprocedure or can I put a goto before the return as per this code...

eg.

Start:
:
setint %00000001, %00000001
:
goto Start

Interrupt:
:
:
goto Start
return
 

BeanieBots

Moderator
The interrupt routine is a subprocedure.
As with any other subprocedure, you MUST return eventually. It is OK to have goto's within the procedure but if you do not RETURN, then the place where the PICAXE stores where to return to, will not hold valid data. The next interrupt will return to the wrong place, other gosubs will be directed the wrong line of code and eventually the PICAXE will crash.
 
Hi MearCat,
dont forget that in the actual code you also have to re-activate the setint command before you return from the interrupt sub procedure.
 

hippy

Ex-Staff (retired)
Try it and see :)

When the interrupt routine is entered, further interrupts are disable until another SETINT is issued and the RETURN is executed. Whether interrupts are locked out until any RETURN is next executed or whether it has to be the RETURN which belongs to the Interrupt routine itself I don't know - There are a number of ways this could have been implemeted in the Firmware. It's been one of those things I've been intending to investigate but haven't got round to.

If you are set up for interrupt handling, it would be worthwhile doing some experiments yourself, and I and others I am sure would be grateful to know what the answer is.
 
Top