You can poll the RCON register and see if it gives you a hint of what caused the reset. The most likely cause however is that you end up at a RETURN without a prior GOSUB.

/Henrik.