Tuesday, December 2, 2014

Understanding 6502 assembly on the Commodore 64 - (20) May I Interrupt?

     In the last few chapters we've had to get through a lot of dry, but necessary stuff.  I figured since this is chapter 20, well do something fun.  Just about every 60th of a second, everything we do it put on hold for the computer to run its own housekeeping chores.  Cursor blink, keyboard input check, screen refresh, that sort of stuff.  To the user it is transparent, as if the 6502 is multitasking and running code in the background.  Arguably it is, but it isn't.  But it is the stuff of genius how this is accomplished.


Click here for Chapter 20






2 comments:

  1. Actually $0314/$0315 is only half the story. The actual hardware IRQ vector is at $fffe/$ffff, which contains $ff48 when you have the kernel switched in.

    The routine @ $ff48 basically checks the source of the IRQ (whether hardware IRQ or a BRK command) and then indirectly JMPs to the soft vectors ($0314/$0315 for IRQ and $0316/$0317 for BRK.

    Check it - http://unusedino.de/ec64/technical/aay/c64/romff48.htm

    It is definitely better to switch out the kernel and run your IRQ (or NMI) using the hardware vectors, unless you really need the kernel etc, which in the world of demo writing it exactly never :)

    ReplyDelete
  2. Correct, in this example though were just hanging off the existing IRQ, were not generating one. Latching on to the IRQ as shown is one of the Basic tasks one would find in the demonstration of IRQ's for beginners. No Demo code here today.

    ReplyDelete