Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cc65:interrupt_handlers_in_c [2010-06-01 22:29]
uz
cc65:interrupt_handlers_in_c [2012-01-21 13:34] (current)
ol.sc [Interrupt handlers in C]
Line 6: Line 6:
 As any non trivial 6502 program, the code generated by cc65 makes use of the zero page. Zero page locations are also used for the argument stack, and as temporary storage for most of the runtime support functions. So when writing interrupt handlers in C, it is necessary to save the CPU registers plus these zero page locations. In addition to that, the functions that manipulate the stack pointer are not reentrant, so you have to setup a separate stack for the interrupt handler. As any non trivial 6502 program, the code generated by cc65 makes use of the zero page. Zero page locations are also used for the argument stack, and as temporary storage for most of the runtime support functions. So when writing interrupt handlers in C, it is necessary to save the CPU registers plus these zero page locations. In addition to that, the functions that manipulate the stack pointer are not reentrant, so you have to setup a separate stack for the interrupt handler.
  
-This means that interrupt handlers cannot be done without some assembler code. For many applications, the wrapper code written in assembler is more than what has to be done in the interrupt handler itself, so I do usually suggest to think about writing the interrupt handler completely in assembler (provided it is rather short). If you don't want to do this for some reason or another, you may want to have a look at the break handler functions in libsrc/dbg/dbgsupp.s. They do contain all code that would also be needed for an interrupt handler (saving registers and zero page locations, calling a C function)+This means that interrupt handlers cannot be done without some assembler code. For many applications, the wrapper code written in assembler is more than what has to be done in the interrupt handler itself, so I do usually suggest to think about writing the interrupt handler completely in assembler (provided it is rather short). If you don't want to do this for some reason or another, you may want to have a look at the function **set_irq**() declared in 6502.h.
cc65/interrupt_handlers_in_c.txt ยท Last modified: 2012-01-21 13:34 by ol.sc
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki