Skip to main content
On the C64, it's kernal, not kernel
Source Link
Omar and Lorraine
  • 39.7k
  • 14
  • 138
  • 284

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 JMPs 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.

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 JMPs 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 kernel, 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.

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 JMPs 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 kernal, 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.

Updated to improve accuracy.
Source Link
Tommy
  • 38.2k
  • 3
  • 128
  • 176

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 interrupts were enabledthe triggering event was presumably an interrupt — it JMPs 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 kernel, 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.

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 interrupts were enabled — it JMPs 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 kernel, 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.

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 JMPs 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 kernel, 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.

Added exposition on chaining.
Source Link
Tommy
  • 38.2k
  • 3
  • 128
  • 176

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 interrupts were enabled — it JMPs 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 kernel, 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.

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 interrupts were enabled — it JMPs 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.

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 interrupts were enabled — it JMPs 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 kernel, 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.

Source Link
Tommy
  • 38.2k
  • 3
  • 128
  • 176
Loading