![]() |
![]() |
Sega Megadrive Assembly Programming BasicsCopyright, Lewis Bassett, December 2005
Section 2 - The Interrupt Routines In the last section we made a ROM header, which we'll insert into every Megadrive program we write. In the next few sections, I'll show you how to write a complete template file, which after being assembled, will run successfully on a Megadrive. After this, we can begin to actually start programming graphics and stuff. Our interrupt vector, which we defined in the header file, contains references to the following code labels: Interrupt HBL VBLWe need to write subroutines for each of those. Later on, as we progress, I'll explain what each of these interrupts are used for. For the time being however, we'll just write blank subroutines that will pass control back to processor. Here's a blank routine for all the slots which refer to 'Interrupt': Interrupt: rte;Notice that the subroutie ends with 'rte' instead of 'rts'. RTE (ReTurn from Exception) is used to pass control back to the processor from an interrupt exception. The RTS instruction will not work for these. The 'HBL' and 'VBL' routines are also defined in exactly the same way: HBL: rte;
VBL: rte;These routines can be inserted anywhere after the header, although most programmers like to insert them after all their main program code. In the next two sections, I'll explain about the TMSS security code, and how to pad the final ROM to a vallid size. After this, I'll bring all of this together and show you how to write a template for a working Megadrive program. |