2 ; Ullrich von Bassewitz, 2004-04-04
4 ; CC65 runtime: Support for calling special irq routines declared as condes
7 ; There are two reasons, why this is a separate routine, and the generic
8 ; condes routine in condes.s is not used:
10 ; 1. Speed. Having several things hardcoded makes it faster. This is
11 ; important if it is called in each interrupt.
13 ; 2. Reentrancy. The condes routines must use self modyfiying code, which
14 ; means it is not reentrant. An IRQ using condes, that interrupts
15 ; another use of condes will cause unpredicatble behaviour. The current
16 ; code avoids this by using locking mechanisms, but it's complex and
17 ; has a size and performance penalty.
19 ; As the normal condes routine, this one has the limitation of 127 table
24 .export callirq_y ; Same but with Y preloaded
26 .import __INTERRUPTOR_TABLE__, __INTERRUPTOR_COUNT__
30 ; --------------------------------------------------------------------------
31 ; Call all IRQ routines. The function needs to use self modifying code and
32 ; is thereforce placed in the data segment.
33 ; NOTE: The routine must not be called if the table is empty!
38 ldy #.lobyte(__INTERRUPTOR_COUNT__*2)
41 lda __INTERRUPTOR_TABLE__,y
42 sta jmpvec+2 ; Modify code below
44 lda __INTERRUPTOR_TABLE__,y
45 sta jmpvec+1 ; Modify code below
46 sty index+1 ; Modify code below
47 jmpvec: jsr $FFFF ; Patched at runtime
48 index: ldy #$FF ; Patched at runtime