Assuming you're not actually going to chain the existing interrupt handler to your own, I think you should end with rti
and more besides.
A disassembly of the C64 firmware shows that IRQs jump to FF48
, which pushes A, X and Y to the stack in that order, loads the value that was at the top of the stack and if it does not have $10
set — i.e. if the triggering event was presumably an interrupt — it JMP
s to your (0314)
.
So at the end of your routine you should pull Y, X and A from the stack, then perform an rti
to pull the status register and the old program counter.
Or just jump to EA81
, where the normal IRQ routine that started at EA31
does that.
Addendum: the safest way, assuming you're not trying to usurp the kernelkernal, would be just to keep hold of whatever was in (0314)
before you installed yourself, and jump to that. Dynamically writing it into your own code is a decent way of doing that without worrying about storage — end with a dummy JMP $0000
and then copy whatever is currently in 0314
to the argument of that instruction before writing in your own code's address.