]> git.sur5r.net Git - cc65/commitdiff
Save/restore jmpvec as it is used by generated code - see g_callind().
authorOliver Schmidt <ol.sc@web.de>
Mon, 23 Oct 2017 16:57:28 +0000 (18:57 +0200)
committerOliver Schmidt <ol.sc@web.de>
Mon, 23 Oct 2017 16:57:28 +0000 (18:57 +0200)
libsrc/common/interrupt.s

index 950d3d78745f6fcc9bfae9ea929196ac097e3f88..6bdbb5fe4d2d41dc0cd3e6cb47090a24343a0bf0 100644 (file)
@@ -8,7 +8,7 @@
 
         .export         _set_irq, _reset_irq
         .interruptor    clevel_irq, 1           ; Export as low priority IRQ handler
-        .import         popax, __ZP_START__
+        .import         popax, __ZP_START__, jmpvec
 
         .include        "zeropage.inc"
 
@@ -84,6 +84,12 @@ zpsave: .res    zpsavespace
         dex
         bpl     @L2
 
+        ; Save jmpvec
+        lda     jmpvec+1
+        pha
+        lda     jmpvec+2
+        pha
+
         ; Set C level interrupt stack
         lda     irqsp
         ldx     irqsp+1
@@ -93,15 +99,21 @@ zpsave: .res    zpsavespace
         ; Call C level interrupt request handler
         jsr     irqvec
 
-        ; Copy back our zero page content
+        ; Mark interrupt handled / not handled
+        lsr
+
+        ; Restore our zero page content
         ldx     #.sizeof(::zpsave)-1
-@L3:    ldy     zpsave,x
-        sty     <__ZP_START__,x
+@L3:    lda     zpsave,x
+        sta     <__ZP_START__,x
         dex
         bpl     @L3
 
-        ; Mark interrupt handled / not handled and return
-        lsr
+        ; Restore jmpvec and return
+        pla
+        sta     jmpvec+2
+        pla
+        sta     jmpvec+1
         rts
 
 .endproc