]> git.sur5r.net Git - cc65/commitdiff
Moved IRQ hooking / unhooking from startup code to constructor / destructor to avoid...
authorol.sc <ol.sc@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 12 Feb 2013 22:39:38 +0000 (22:39 +0000)
committerol.sc <ol.sc@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Tue, 12 Feb 2013 22:39:38 +0000 (22:39 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@5985 b7a2c559-68d2-44c3-8de9-860c34a00d81

36 files changed:
libsrc/apple2/Makefile
libsrc/apple2/crt0.s
libsrc/apple2/irq.s [new file with mode: 0644]
libsrc/apple2/reboot.s
libsrc/apple2enh/Makefile
libsrc/atari/Makefile
libsrc/atari/crt0.s
libsrc/atari/irq.s [new file with mode: 0644]
libsrc/atmos/Makefile
libsrc/atmos/crt0.s
libsrc/atmos/irq.s [new file with mode: 0644]
libsrc/c128/Makefile
libsrc/c128/crt0.s
libsrc/c128/irq.s [new file with mode: 0644]
libsrc/c16/Makefile
libsrc/c16/crt0.s
libsrc/c16/irq.s [new file with mode: 0644]
libsrc/c64/Makefile
libsrc/c64/crt0.s
libsrc/c64/irq.s [new file with mode: 0644]
libsrc/cbm510/Makefile
libsrc/cbm510/irq.s [new file with mode: 0644]
libsrc/cbm610/Makefile
libsrc/cbm610/irq.s [new file with mode: 0644]
libsrc/lynx/Makefile
libsrc/lynx/crt0.s
libsrc/lynx/irq.s [new file with mode: 0644]
libsrc/pet/Makefile
libsrc/pet/crt0.s
libsrc/pet/irq.s [new file with mode: 0644]
libsrc/plus4/Makefile
libsrc/plus4/irq.s [new file with mode: 0644]
libsrc/runtime/callirq.s
libsrc/vic20/Makefile
libsrc/vic20/crt0.s
libsrc/vic20/irq.s [new file with mode: 0644]

index ab6e5c6585ba16fbff15d113d976e2c60245b6ec..791aa6dc4bf02c108b5d1f651a28cefc45e1c9b4 100644 (file)
@@ -104,6 +104,7 @@ S_OBJS=     _scrsize.o              \
        home.o                  \
        initcwd.o               \
        iobuf.o                 \
+       irq.o                   \
        isdevice.o              \
        joy_stat_stddrv.o       \
        joy_stddrv.o            \
index ba4e0dcf14a04c1c7aa81422c131a2079c1b7d75..27c44f016dced102309cbe7af2b79a41dfa3a7e5 100644 (file)
@@ -5,75 +5,72 @@
 ;
 
         .export         _exit, done, return
-        .export         __STARTUP__ : absolute = 1     ; Mark as startup
+        .export         __STARTUP__ : absolute = 1      ; Mark as startup
         .import         zerobss
-        .import        initlib, donelib
-        .import        callmain, callirq
-        .import         __LC_START__, __LC_LAST__      ; Linker generated
-        .import                __INIT_RUN__, __INIT_SIZE__     ; Linker generated
-        .import                __ZPSAVE_RUN__                  ; Linker generated
-        .import                __INTERRUPTOR_COUNT__           ; Linker generated
+        .import         initlib, donelib
+        .import         callmain
+        .import         __LC_START__, __LC_LAST__       ; Linker generated
+        .import         __INIT_RUN__, __INIT_SIZE__     ; Linker generated
+        .import         __ZPSAVE_RUN__                  ; Linker generated
 
         .include        "zeropage.inc"
         .include        "apple2.inc"
 
-; ------------------------------------------------------------------------
-
         .segment        "STARTUP"
 
         ; ProDOS TechRefMan, chapter 5.2.1:
         ; "For maximum interrupt efficiency, a system program should not
         ;  use more than the upper 3/4 of the stack."
         ldx     #$FF
-        txs                            ; Init stack pointer
-
-       ; Switch in LC bank 2 for W/O
-       bit     $C081
-       bit     $C081
-
-       ; Set source start address
-       lda     #<(__ZPSAVE_RUN__ + __INIT_SIZE__)
-       ldy     #>(__ZPSAVE_RUN__ + __INIT_SIZE__)
-       sta     $9B
-       sty     $9C
-
-       ; Set source last address
-       lda     #<(__ZPSAVE_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
-       ldy     #>(__ZPSAVE_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
-       sta     $96
-       sty     $97
-
-       ; Set destination last address
-       lda     #<__LC_LAST__
-       ldy     #>__LC_LAST__
-       sta     $94
-       sty     $95
-
-       ; Call into Applesoft Block Transfer Utility - which handles zero
-       ; sized blocks well - to move content of the LC memory area
-       jsr     $D396           ; BLTU + 3
-
-       ; Set source start address
-       lda     #<__ZPSAVE_RUN__
-       ldy     #>__ZPSAVE_RUN__
-       sta     $9B
-       sty     $9C
-
-       ; Set source last address
-       lda     #<(__ZPSAVE_RUN__ + __INIT_SIZE__)
-       ldy     #>(__ZPSAVE_RUN__ + __INIT_SIZE__)
-       sta     $96
-       sty     $97
-
-       ; Set destination last address
-       lda     #<(__INIT_RUN__ + __INIT_SIZE__)
-       ldy     #>(__INIT_RUN__ + __INIT_SIZE__)
-       sta     $94
-       sty     $95
-
-       ; Call into Applesoft Block Transfer Utility - which handles moving
-       ; overlapping blocks upwards well - to move the INIT segment
-       jsr     $D396           ; BLTU + 3
+        txs                     ; Init stack pointer
+
+        ; Switch in LC bank 2 for W/O
+        bit     $C081
+        bit     $C081
+
+        ; Set source start address
+        lda     #<(__ZPSAVE_RUN__ + __INIT_SIZE__)
+        ldy     #>(__ZPSAVE_RUN__ + __INIT_SIZE__)
+        sta     $9B
+        sty     $9C
+
+        ; Set source last address
+        lda     #<(__ZPSAVE_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
+        ldy     #>(__ZPSAVE_RUN__ + __INIT_SIZE__ + __LC_LAST__ - __LC_START__)
+        sta     $96
+        sty     $97
+
+        ; Set destination last address
+        lda     #<__LC_LAST__
+        ldy     #>__LC_LAST__
+        sta     $94
+        sty     $95
+
+        ; Call into Applesoft Block Transfer Utility - which handles zero
+        ; sized blocks well - to move content of the LC memory area
+        jsr     $D396           ; BLTU + 3
+
+        ; Set source start address
+        lda     #<__ZPSAVE_RUN__
+        ldy     #>__ZPSAVE_RUN__
+        sta     $9B
+        sty     $9C
+
+        ; Set source last address
+        lda     #<(__ZPSAVE_RUN__ + __INIT_SIZE__)
+        ldy     #>(__ZPSAVE_RUN__ + __INIT_SIZE__)
+        sta     $96
+        sty     $97
+
+        ; Set destination last address
+        lda     #<(__INIT_RUN__ + __INIT_SIZE__)
+        ldy     #>(__INIT_RUN__ + __INIT_SIZE__)
+        sta     $94
+        sty     $95
+
+        ; Call into Applesoft Block Transfer Utility - which handles moving
+        ; overlapping blocks upwards well - to move the INIT segment
+        jsr     $D396           ; BLTU + 3
 
         ; Delegate all further processing to keep the STARTUP segment small
         jsr     init
         ; Avoid re-entrance of donelib. This is also the _exit entry
 _exit:  ldx     #<exit
         lda     #>exit
-        jsr     reset          ; Setup RESET vector
+        jsr     reset           ; Setup RESET vector
 
         ; Switch in ROM in case it wasn't already switched in by a RESET
-       bit     $C082
+        bit     $C082
 
         ; Call module destructors
         jsr     donelib
 
-        ; Check for valid interrupt vector table entry number
-        lda     int_num
-        beq     exit
-
-        ; Deallocate interrupt vector table entry
-        dec     i_param                ; Adjust parameter count
-        jsr     $BF00          ; MLI call entry point
-        .byte   $41            ; Dealloc interrupt
-        .addr   i_param
-
         ; Restore the original RESET vector
 exit:   ldx     #$02
 :       lda     rvsave,x
@@ -122,8 +109,6 @@ exit:   ldx     #$02
         ; We're done
         jmp     (done)
 
-; ------------------------------------------------------------------------
-
         .segment        "INIT"
 
         ; Save the zero page locations we need
@@ -148,11 +133,11 @@ init:   ldx     #zpspace-1
         ;  address of a routine that ... closes the files."
         ldx     #<_exit
         lda     #>_exit
-        jsr     reset          ; Setup RESET vector
+        jsr     reset           ; Setup RESET vector
 
         ; Check for ProDOS
-        ldy     $BF00          ; MLI call entry point
-        cpy     #$4C           ; Is MLI present? (JMP opcode)
+        ldy     $BF00           ; MLI call entry point
+        cpy     #$4C            ; Is MLI present? (JMP opcode)
         bne     basic
         
         ; Check ProDOS system bit map
@@ -179,80 +164,20 @@ basic:  lda     HIMEM
 :       sta     sp
         stx     sp+1
 
-        ; Check for interruptors
-        lda     #<__INTERRUPTOR_COUNT__
-        beq     :+
-
-        ; Check for ProDOS
-        cpy     #$4C           ; Is MLI present? (JMP opcode)
-        bne     prterr
-
-        ; Allocate interrupt vector table entry
-        jsr     $BF00          ; MLI call entry point
-        .byte   $40            ; Alloc interrupt
-        .addr   i_param
-        bcs     prterr
-
-       ; Enable interrupts as old ProDOS versions (i.e. 1.1.1)
-       ; jump to SYS and BIN programs with interrupts disabled
-       cli
+        ; Enable interrupts as old ProDOS versions (i.e. 1.1.1)
+        ; jump to SYS and BIN programs with interrupts disabled
+        cli
 
         ; Call module constructors
-:       jsr     initlib
+        jsr     initlib
 
-       ; Switch in LC bank 2 for R/O
-       bit     $C080
+        ; Switch in LC bank 2 for R/O
+        bit     $C080
 
         ; Push arguments and call main()
         jmp     callmain
 
-        ; Print error message and return
-prterr: ldx     #msglen-1
-:       lda     errmsg,x
-        jsr     $FDED          ; COUT
-        dex
-        bpl     :-
-        rts
-
-errmsg: .ifdef  __APPLE2ENH__
-        .byte   $8D,     't'|$80, 'p'|$80, 'u'|$80, 'r'|$80, 'r'|$80
-        .byte   'e'|$80, 't'|$80, 'n'|$80, 'i'|$80, ' '|$80, 'c'|$80
-        .byte   'o'|$80, 'l'|$80, 'l'|$80, 'a'|$80, ' '|$80, 'o'|$80
-        .byte   't'|$80, ' '|$80, 'd'|$80, 'e'|$80, 'l'|$80, 'i'|$80
-        .byte   'a'|$80, 'F'|$80, $8D
-        .else
-        .byte   $8D,     'T'|$80, 'P'|$80, 'U'|$80, 'R'|$80, 'R'|$80
-        .byte   'E'|$80, 'T'|$80, 'N'|$80, 'I'|$80, ' '|$80, 'C'|$80
-        .byte   'O'|$80, 'L'|$80, 'L'|$80, 'A'|$80, ' '|$80, 'O'|$80
-        .byte   'T'|$80, ' '|$80, 'D'|$80, 'E'|$80, 'L'|$80, 'I'|$80
-        .byte   'A'|$80, 'F'|$80, $8D
-        .endif
-
-msglen = * - errmsg
-
-; ------------------------------------------------------------------------
-
-        .segment        "LOWCODE"
-
-        ; ProDOS TechRefMan, chapter 6.2:
-        ; "Each installed routine must begin with a CLD instruction."
-intptr: cld
-
-        ; Call interruptors and check for success
-        jsr     callirq
-        bcc    :+
-
-        ; ProDOS TechRefMan, chapter 6.2:
-        ; "When the routine that can process the interrupt is called, it
-        ;  should ... return (via an RTS) with the carry flag clear."
-        clc
-        rts
-
-        ; ProDOS TechRefMan, chapter 6.2:
-        ; "When a routine that cannot process the interrupt is called,
-        ;  it should return (via an RTS) with the cary flag set ..."
-:       sec
-        rts
+        .code
 
         ; Setup RESET vector
 reset:  stx     SOFTEV
@@ -266,37 +191,24 @@ quit:   jsr     $BF00           ; MLI call entry point
         .byte   $65             ; Quit
         .word   q_param
 
-; ------------------------------------------------------------------------
-
         .rodata
 
-        ; MLI parameter list for quit        
-q_param:.byte   $04            ; param_count
-        .byte   $00            ; quit_type
-        .word   $0000          ; reserved
-        .byte   $00            ; reserved
-        .word   $0000          ; reserved
-       
-; ------------------------------------------------------------------------
+        ; MLI parameter list for quit
+q_param:.byte   $04             ; param_count
+        .byte   $00             ; quit_type
+        .word   $0000           ; reserved
+        .byte   $00             ; reserved
+        .word   $0000           ; reserved
 
         .data
 
-        ; MLI parameter list for (de)alloc interrupt
-i_param:.byte   $02            ; param_count
-int_num:.byte   $00            ; int_num
-        .addr   intptr         ; int_code
-
         ; Location to jump to when we're done
 done:   .addr   DOSWARM
 
-; ------------------------------------------------------------------------
-
         .segment        "ZPSAVE"
 
 zpsave: .res    zpspace
 
-; ------------------------------------------------------------------------
-
         .bss
 
 rvsave: .res    3
diff --git a/libsrc/apple2/irq.s b/libsrc/apple2/irq.s
new file mode 100644 (file)
index 0000000..67bcbf2
--- /dev/null
@@ -0,0 +1,94 @@
+;
+; Oliver Schmidt, 2012-11-17
+;
+; IRQ handling (Apple2 version)
+;
+
+        .export         initirq, doneirq
+        .import         callirq, __dos_type, _exit
+
+        .include        "zeropage.inc"
+        .include        "apple2.inc"
+
+        .segment        "INIT"
+
+initirq:
+        ; Check for ProDOS
+        lda     __dos_type
+        beq     prterr
+
+        ; Allocate interrupt vector table entry
+        jsr     $BF00           ; MLI call entry point
+        .byte   $40             ; Alloc interrupt
+        .addr   i_param
+        bcs     prterr
+        rts
+
+        ; Print error message and exit
+prterr: ldx     #msglen-1
+:       lda     errmsg,x
+        jsr     $FDED           ; COUT
+        dex
+        bpl     :-
+        jmp     _exit
+
+errmsg: .ifdef  __APPLE2ENH__
+        .byte   $8D,     't'|$80, 'p'|$80, 'u'|$80, 'r'|$80, 'r'|$80
+        .byte   'e'|$80, 't'|$80, 'n'|$80, 'i'|$80, ' '|$80, 'c'|$80
+        .byte   'o'|$80, 'l'|$80, 'l'|$80, 'a'|$80, ' '|$80, 'o'|$80
+        .byte   't'|$80, ' '|$80, 'd'|$80, 'e'|$80, 'l'|$80, 'i'|$80
+        .byte   'a'|$80, 'F'|$80, $8D
+        .else
+        .byte   $8D,     'T'|$80, 'P'|$80, 'U'|$80, 'R'|$80, 'R'|$80
+        .byte   'E'|$80, 'T'|$80, 'N'|$80, 'I'|$80, ' '|$80, 'C'|$80
+        .byte   'O'|$80, 'L'|$80, 'L'|$80, 'A'|$80, ' '|$80, 'O'|$80
+        .byte   'T'|$80, ' '|$80, 'D'|$80, 'E'|$80, 'L'|$80, 'I'|$80
+        .byte   'A'|$80, 'F'|$80, $8D
+        .endif
+
+msglen = * - errmsg
+
+        .code
+
+doneirq:
+        ; Check for valid interrupt vector table entry number which
+        ; IS necessary as this gets called even if initirq failed.
+        lda     int_num
+        beq     :+
+
+        ; Deallocate interrupt vector table entry
+        dec     i_param         ; Adjust parameter count
+        jsr     $BF00           ; MLI call entry point
+        .byte   $41             ; Dealloc interrupt
+        .addr   i_param
+:       rts
+
+        .segment        "LOWCODE"
+
+intptr:
+        ; ProDOS TechRefMan, chapter 6.2:
+        ; "Each installed routine must begin with a CLD instruction."
+        cld
+
+        ; Call interruptors and check for success
+        jsr     callirq
+        bcc     :+
+
+        ; ProDOS TechRefMan, chapter 6.2:
+        ; "When the routine that can process the interrupt is called, it
+        ;  should ... return (via an RTS) with the carry flag clear."
+        clc
+        rts
+
+        ; ProDOS TechRefMan, chapter 6.2:
+        ; "When a routine that cannot process the interrupt is called,
+        ;  it should return (via an RTS) with the cary flag set ..."
+:       sec
+        rts
+
+        .data
+
+        ; MLI parameter list for (de)alloc interrupt
+i_param:.byte   $02             ; param_count
+int_num:.byte   $00             ; int_num
+        .addr   intptr          ; int_code
index 9986371cfa5f35c1e60e2e36bf451964a624edd0..89c34bdf0f43b1fc1ffbc8e50f8a0a5ea9eb3399 100644 (file)
@@ -4,8 +4,8 @@
 ; void rebootafterexit (void);
 ;
 
-        .constructor   initreboot
-        .export                _rebootafterexit
+        .constructor    initreboot, 11
+        .export         _rebootafterexit
         .import         done, return
 
 _rebootafterexit := return
index 4b1d8814dfb77ffd14f4f20ffdffe28171aaafe1..f27d2fdcdff5fe59a4060e89aeef5a60e85dd294 100644 (file)
@@ -107,6 +107,7 @@ S_OBJS=     _scrsize.o              \
        home.o                  \
        initcwd.o               \
        iobuf.o                 \
+       irq.o                   \
        isdevice.o              \
        joy_stat_stddrv.o       \
        joy_stddrv.o            \
index 514e0df844d707b36754c9b186b6cd1320a2fa7e..8c861928340a6fbec029aeee863333c832bbd0b7 100644 (file)
@@ -103,6 +103,7 @@ OBJS =      _scrsize.o              \
        graphics.o              \
        initcwd.o               \
        inviocb.o               \
+       irq.o                   \
        joy_stat_stddrv.o       \
        joy_stddrv.o            \
        kbhit.o                 \
index 4542d8945ecd89d891711a64fb225628fd2c7b45..1a404f0214acbb1ceab95a3ce859535402fa2f35 100644 (file)
@@ -12,8 +12,7 @@
        .export         __STARTUP__ : absolute = 1      ; Mark as startup
 
        .import         initlib, donelib
-       .import         callmain, zerobss, callirq
-       .import         __INTERRUPTOR_COUNT__
+       .import         callmain, zerobss
        .import         __STARTUP_LOAD__, __ZPSAVE_LOAD__
        .import         __RESERVED_MEMORY__
 
@@ -23,7 +22,8 @@
 ; ------------------------------------------------------------------------
 ; EXE header
 
-       .segment "EXEHDR"
+.segment       "EXEHDR"
+
        .word   $FFFF
        .word   __STARTUP_LOAD__
        .word   __ZPSAVE_LOAD__ - 1
@@ -31,7 +31,7 @@
 ; ------------------------------------------------------------------------
 ; Actual code
 
-       .segment        "STARTUP"
+.segment       "STARTUP"
 
        rts     ; fix for SpartaDOS / OS/A+
                ; they first call the entry point from AUTOSTRT and
@@ -74,22 +74,9 @@ L1:  lda     sp,x
        sta     APPMHI+1
        sta     sp+1                    ; setup runtime stack part 2
 
-; If we have IRQ functions, chain our stub into the IRQ vector
-
-       lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ1
-       lda     VVBLKI
-       ldx     VVBLKI+1
-       sta     IRQInd+1
-       stx     IRQInd+2
-       lda     #6
-       ldy     #<IRQStub
-       ldx     #>IRQStub
-       jsr     SETVBV
-
 ; Call module constructors
 
-NoIRQ1:        jsr     initlib
+       jsr     initlib
 
 ; Set left margin to 0
 
@@ -117,19 +104,9 @@ NoIRQ1:    jsr     initlib
 
 _exit: jsr     donelib         ; Run module destructors
 
-; Reset the IRQ vector if we chained it.
-
-       pha                     ; Save the return code on stack
-       lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ2
-       lda     #6
-       ldy     IRQInd+1
-       ldx     IRQInd+2
-       jsr     SETVBV
-
 ; Restore system stuff
 
-NoIRQ2:        ldx     spsave
+       ldx     spsave
        txs                     ; Restore stack pointer
 
 ; Restore left margin
@@ -166,28 +143,17 @@ L2:       lda     zpsave,x
 
        rts
 
-; ------------------------------------------------------------------------
-; The IRQ vector jumps here, if condes routines are defined with type 2.
-
-IRQStub:
-       cld                             ; Just to be sure
-       jsr     callirq                 ; Call the functions
-       jmp     IRQInd                  ; Jump to the saved IRQ vector
+; *** end of main startup code
 
 ; ------------------------------------------------------------------------
-; Data
-
-.data
-
-IRQInd: jmp    $0000
-
-; *** end of main startup code
 
 .segment       "ZPSAVE"
 
 zpsave: .res   zpspace
 
-       .bss
+; ------------------------------------------------------------------------
+
+.bss
 
 spsave:                .res    1
 appmsav:       .res    1
diff --git a/libsrc/atari/irq.s b/libsrc/atari/irq.s
new file mode 100644 (file)
index 0000000..543e9c0
--- /dev/null
@@ -0,0 +1,49 @@
+;
+; IRQ handling (ATARI version)
+;
+
+       .export         initirq, doneirq
+       .import         callirq
+
+       .include        "atari.inc"
+
+; ------------------------------------------------------------------------
+
+.segment       "INIT"
+
+initirq:
+       lda     VVBLKI
+       ldx     VVBLKI+1
+       sta     IRQInd+1
+       stx     IRQInd+2
+       lda     #6
+       ldy     #<IRQStub
+       ldx     #>IRQStub
+       jsr     SETVBV
+       rts
+
+; ------------------------------------------------------------------------
+
+.code
+
+doneirq:
+       lda     #6
+       ldy     IRQInd+1
+       ldx     IRQInd+2
+       jsr     SETVBV
+       rts
+
+; ------------------------------------------------------------------------
+
+.segment       "LOWCODE"
+
+IRQStub:
+       cld                             ; Just to be sure
+       jsr     callirq                 ; Call the functions
+       jmp     IRQInd                  ; Jump to the saved IRQ vector
+
+; ------------------------------------------------------------------------
+
+.data
+
+IRQInd: jmp    $0000
index 532a8786664e0bfdb3898696f74b61b5efdd4b87..6aa68c1c351d2c815b607e3383e53aece0944b8c 100644 (file)
@@ -81,6 +81,7 @@ OBJS  =       _scrsize.o              \
         gotox.o                 \
         gotoxy.o                \
         gotoy.o                 \
+        irq.o                   \
         joy_stat_stddrv.o       \
         joy_stddrv.o            \
         kbhit.o                 \
index bc11ce5d9283ccd906b0af4e718792284d61dc0e..d88e4c3ff58e34f90b3a965852ce3a2f1801ee54 100644 (file)
@@ -7,15 +7,13 @@
        .export         _exit
        .export         __STARTUP__ : absolute = 1      ; Mark as startup
        .import         initlib, donelib
-       .import         callmain, zerobss, callirq
-       .import         __INTERRUPTOR_COUNT__
+       .import         callmain, zerobss
        .import         __RAM_START__, __RAM_SIZE__
        .import         __ZPSAVE_LOAD__, __STACKSIZE__
 
        .include        "zeropage.inc"
        .include        "atmos.inc"
 
-
 ; ------------------------------------------------------------------------
 ; Oric tape header
 
@@ -70,24 +68,9 @@ L1:  lda     sp,x
        lda     #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
        sta     sp+1            ; Set argument stack ptr
 
-; If we have IRQ functions, chain our stub into the IRQ vector
-
-       lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ1
-       lda     IRQVec
-       ldx     IRQVec+1
-       sta     IRQInd+1
-       stx     IRQInd+2
-       lda     #<IRQStub
-       ldx     #>IRQStub
-       sei
-       sta     IRQVec
-       stx     IRQVec+1
-       cli
-
 ; Call module constructors
 
-NoIRQ1: jsr    initlib
+       jsr     initlib
 
 ; Push arguments and call main()
 
@@ -97,21 +80,9 @@ NoIRQ1: jsr  initlib
 
 _exit: jsr     donelib         ; Run module destructors
 
-; Reset the IRQ vector if we chained it.
-
-       pha                     ; Save the return code on stack
-       lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ2
-       lda     IRQInd+1
-       ldx     IRQInd+2
-       sei
-       sta     IRQVec
-       stx     IRQVec+1
-       cli
-
 ; Restore system stuff
 
-NoIRQ2: ldx    spsave
+       ldx     spsave
        txs
        lda     stsave
        sta     STATUS
@@ -129,34 +100,13 @@ L2:       lda     zpsave,x
        rts
 
 ; ------------------------------------------------------------------------
-; The IRQ vector jumps here, if condes routines are defined with type 2.
-
-IRQStub:
-       cld                             ; Just to be sure
-       pha
-       txa
-       pha
-       tya
-       pha
-       jsr     callirq                 ; Call the functions
-       pla
-       tay
-       pla
-       tax
-       pla
-       jmp     IRQInd                  ; Jump to the saved IRQ vector
-
-; ------------------------------------------------------------------------
-; Data
-
-.data
-
-IRQInd: jmp    $0000
 
 .segment       "ZPSAVE"
 
 zpsave: .res   zpspace
 
+; ------------------------------------------------------------------------
+
 .bss
 
 spsave: .res   1
diff --git a/libsrc/atmos/irq.s b/libsrc/atmos/irq.s
new file mode 100644 (file)
index 0000000..19b1e83
--- /dev/null
@@ -0,0 +1,64 @@
+;
+; IRQ handling (Oric version)
+;
+
+       .export         initirq, doneirq
+       .import         callirq
+
+       .include        "atmos.inc"
+
+; ------------------------------------------------------------------------
+
+.segment       "INIT"
+
+initirq:
+       lda     IRQVec
+       ldx     IRQVec+1
+       sta     IRQInd+1
+       stx     IRQInd+2
+       lda     #<IRQStub
+       ldx     #>IRQStub
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+       rts
+
+; ------------------------------------------------------------------------
+
+.code
+
+doneirq:
+       beq     NoIRQ2
+       lda     IRQInd+1
+       ldx     IRQInd+2
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+       rts
+
+; ------------------------------------------------------------------------
+
+.segment       "LOWCODE"
+
+IRQStub:
+       cld                             ; Just to be sure
+       pha
+       txa
+       pha
+       tya
+       pha
+       jsr     callirq                 ; Call the functions
+       pla
+       tay
+       pla
+       tax
+       pla
+       jmp     IRQInd                  ; Jump to the saved IRQ vector
+
+; ------------------------------------------------------------------------
+
+.data
+
+IRQInd:        jmp     $0000
index 3d698de78e3ac13703cbe2077ec312ec19ea4cb1..90153a57e573f77fbe62c74e5512aa932e580174 100644 (file)
@@ -77,6 +77,7 @@ OBJS =        _scrsize.o              \
         devnum.o                \
         fast.o                  \
         get_tv.o                \
+        irq.o                   \
         joy_stat_stddrv.o       \
         joy_stddrv.o            \
         kbhit.o                 \
index 64fec19a00a0124556aa7d15d2e9940fa334d4a1..4315947e1a8c37d9ae98e2045c08f8c3a62edf9e 100644 (file)
 ; Startup code for cc65 (C128 version)
 ;
 
-       .export         _exit
-        .export         __STARTUP__ : absolute = 1      ; Mark as startup
-       .import         callirq, initlib, donelib
-       .import         zerobss
-       .import         push0, callmain
-        .import         RESTOR, BSOUT, CLRCH
-       .import         __INTERRUPTOR_COUNT__
-       .import         __RAM_START__, __RAM_SIZE__, __STACKSIZE__
-       .importzp       ST
+       .export         _exit
+       .export         __STARTUP__ : absolute = 1      ; Mark as startup
+       .import         initlib, donelib
+       .import         zerobss
+       .import         push0, callmain
+       .import         RESTOR, BSOUT, CLRCH
+       .import         __RAM_START__, __RAM_SIZE__, __STACKSIZE__
+       .importzp       ST
 
-        .include        "zeropage.inc"
-       .include        "c128.inc"
+       .include        "zeropage.inc"
+       .include        "c128.inc"
 
 
-; ------------------------------------------------------------------------
-; Constants
-
-IRQInd         = $2FD  ; JMP $0000 - used as indirect IRQ vector
-
 ; ------------------------------------------------------------------------
 ; Startup code
 
-.segment               "STARTUP"
+.segment       "STARTUP"
 
 Start:
 
 ; Switch to the second charset
 
-       lda     #14
-       jsr     BSOUT
+       lda     #14
+       jsr     BSOUT
 
 ; Before doing anything else, we have to setup our banking configuration.
 ; Otherwise just the lowest 16K are actually RAM. Writing through the ROM
 ; to the underlying RAM works, but it is bad style.
 
-       lda     MMU_CR          ; Get current memory configuration...
-               pha                     ; ...and save it for later
-               lda     #MMU_CFG_CC65   ; Bank0 with kernal ROM
-       sta     MMU_CR
+       lda     MMU_CR          ; Get current memory configuration...
+       pha                     ; ...and save it for later
+       lda     #MMU_CFG_CC65   ; Bank0 with kernal ROM
+       sta     MMU_CR
 
 ; Save the zero page locations we need
 
-               ldx     #zpspace-1
-L1:    lda     sp,x
-       sta     zpsave,x
-       dex
-               bpl     L1
+       ldx     #zpspace-1
+L1:    lda     sp,x
+       sta     zpsave,x
+       dex
+       bpl     L1
 
 ; Clear the BSS data
 
-       jsr     zerobss
+       jsr     zerobss
 
 ; Save system stuff and setup the stack
 
-       pla                     ; Get MMU setting
-       sta     mmusave
+       pla                     ; Get MMU setting
+       sta     mmusave
 
-               tsx
-               stx     spsave          ; Save the system stack pointer
+       tsx
+       stx     spsave          ; Save the system stack pointer
 
-       lda     #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
+       lda     #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
        sta     sp
        lda     #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
-               sta     sp+1            ; Set argument stack ptr
-
-; If we have IRQ functions, chain our stub into the IRQ vector
-
-        lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ1
-       lda     IRQVec
-               ldx     IRQVec+1
-       sta     IRQInd+1
-       stx     IRQInd+2
-       lda     #<IRQStub
-       ldx     #>IRQStub
-       sei
-       sta     IRQVec
-       stx     IRQVec+1
-       cli
+       sta     sp+1            ; Set argument stack ptr
 
 ; Call module constructors
 
-NoIRQ1: jsr     initlib
+       jsr     initlib
 
 ; Set the bank for the file name to our execution bank. We must do this,
 ; *after* calling constructors, because some of them may depend on the
 ; original value of this register.
 
-        lda     #0
-        sta     FNAM_BANK
+       lda     #0
+       sta     FNAM_BANK
 
 ; Push arguments and call main()
 
-        jsr     callmain
+       jsr     callmain
 
 ; Back from main (this is also the _exit entry). Run module destructors
 
-_exit:  jsr     donelib
-
-; Reset the IRQ vector if we chained it.
-
-        pha                            ; Save the return code on stack
-       lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ2
-       lda     IRQInd+1
-       ldx     IRQInd+2
-       sei
-       sta     IRQVec
-       stx     IRQVec+1
-       cli
+_exit:  pha                    ; Save the return code on stack
+       jsr     donelib
 
 ; Copy back the zero page stuff
 
-NoIRQ2: ldx     #zpspace-1
+       ldx     #zpspace-1
 L2:    lda     zpsave,x
-       sta     sp,x
-       dex
-       bpl     L2
+       sta     sp,x
+       dex
+       bpl     L2
 
 ; Place the program return code into ST
 
@@ -128,49 +96,25 @@ L2:        lda     zpsave,x
 
 ; Reset the stack and the memory configuration
 
-       ldx     spsave
-       txs
-               ldx     mmusave
+       ldx     spsave
+       txs
+       ldx     mmusave
        stx     MMU_CR
 
 ; Done, return to BASIC
 
-       rts
-
-; ------------------------------------------------------------------------
-; The C128 has ROM parallel to the RAM starting from $4000. The startup code
-; above will change this setting so that we have RAM from $0000-$BFFF. This
-; works quite well with the exception of interrupts: The interrupt handler
-; is in ROM, and the ROM switches back to the ROM configuration, which means
-; that parts of our program may not be accessible. To solve this, we place
-; the following code into a special segment called "LOWCODE" which will be
-; placed just above the startup code, so it goes into a RAM area that is
-; not banked.
-
-.segment        "LOWCODE"
-
-IRQStub:
-       cld                             ; Just to be sure
-       lda     MMU_CR                  ; Get old register value
-       pha                             ; And save on stack
-       lda     #MMU_CFG_CC65           ; Bank 0 with kernal ROM
-       sta     MMU_CR
-               jsr     callirq                 ; Call the functions
-       pla                             ; Get old register value
-       sta     MMU_CR
-               jmp     IRQInd                  ; Jump to the saved IRQ vector
-
+       rts
 
 ; ------------------------------------------------------------------------
 ; Data
 
-.segment        "ZPSAVE"
+.segment       "ZPSAVE"
 
 zpsave:        .res    zpspace
 
+; ------------------------------------------------------------------------
+
 .bss
+
 spsave:        .res    1
 mmusave:.res   1
-
-
-
diff --git a/libsrc/c128/irq.s b/libsrc/c128/irq.s
new file mode 100644 (file)
index 0000000..aad4679
--- /dev/null
@@ -0,0 +1,63 @@
+;
+; IRQ handling (C128 version)
+;
+
+       .export         initirq, doneirq
+       .import         callirq
+
+       .include        "c128.inc"
+
+IRQInd = $2FD          ; JMP $0000 - used as indirect IRQ vector
+
+; ------------------------------------------------------------------------
+
+.segment       "INIT"
+
+initirq:
+       lda     IRQVec
+       ldx     IRQVec+1
+       sta     IRQInd+1
+       stx     IRQInd+2
+       lda     #<IRQStub
+       ldx     #>IRQStub
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+       rts
+
+; ------------------------------------------------------------------------
+
+.code
+
+doneirq:
+       lda     IRQInd+1
+       ldx     IRQInd+2
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+       rts
+
+; ------------------------------------------------------------------------
+; The C128 has ROM parallel to the RAM starting from $4000. The startup code
+; above will change this setting so that we have RAM from $0000-$BFFF. This
+; works quite well with the exception of interrupts: The interrupt handler
+; is in ROM, and the ROM switches back to the ROM configuration, which means
+; that parts of our program may not be accessible. To solve this, we place
+; the following code into a special segment called "LOWCODE" which will be
+; placed just above the startup code, so it goes into a RAM area that is
+; not banked.
+
+.segment       "LOWCODE"
+
+IRQStub:
+       cld                             ; Just to be sure
+       lda     MMU_CR                  ; Get old register value
+       pha                             ; And save on stack
+       lda     #MMU_CFG_CC65           ; Bank 0 with kernal ROM
+       sta     MMU_CR
+       jsr     callirq                 ; Call the functions
+       pla                             ; Get old register value
+       sta     MMU_CR
+       jmp     IRQInd                  ; Jump to the saved IRQ vector
index 24f8acb44b3bcf30da7ceb658cb4d33d46777e2b..7eb6ba75660aa261759e5ccbc44dd6dd9d701793 100644 (file)
@@ -68,6 +68,7 @@ OBJS =        _scrsize.o              \
         crt0.o                  \
         devnum.o                \
         get_tv.o                \
+        irq.o                   \
         joy_stat_stddrv.o       \
         joy_stddrv.o            \
         kbhit.o                 \
index 88b328afd0d2703c4c0b1a91ce286e32990e8bc1..4df348f6eb2d23e210e0a10708c1893fe44fe1a4 100644 (file)
@@ -6,31 +6,29 @@
 ;
 
        .export         _exit
-        .export         __STARTUP__ : absolute = 1      ; Mark as startup
-       .import         initlib, donelib, callirq
-       .import         callmain, zerobss
-        .import         MEMTOP, RESTOR, BSOUT, CLRCH
-       .import         __INTERRUPTOR_COUNT__
-       .importzp       ST
-
-        .include        "zeropage.inc"
-       .include        "plus4.inc"
+       .export         __STARTUP__ : absolute = 1      ; Mark as startup
+       .import         initlib, donelib
+       .import         callmain, zerobss
+       .import         MEMTOP, RESTOR, BSOUT, CLRCH
+       .importzp       ST
 
+       .include        "zeropage.inc"
+       .include        "plus4.inc"
 
 ; ------------------------------------------------------------------------
 ; Startup code
 
-.segment               "STARTUP"
+.segment       "STARTUP"
 
 Start:
 
 ; Save the zero page locations we need
 
-        ldx    #zpspace-1
+       ldx     #zpspace-1
 L1:    lda     sp,x
-       sta     zpsave,x
-       dex
-               bpl     L1
+       sta     zpsave,x
+       dex
+       bpl     L1
 
 ; Switch to second charset
 
@@ -43,65 +41,38 @@ L1: lda     sp,x
 
 ; Save system stuff and setup the stack
 
-               tsx
-               stx     spsave          ; save system stk ptr
+       tsx
+       stx     spsave          ; save system stk ptr
 
        sec
        jsr     MEMTOP          ; Get top memory
-       cpy     #$80            ; We can only use the low 32K :-(
+       cpy     #$80            ; We can only use the low 32K :-(
        bcc     MemOk
        ldy     #$80
        ldx     #$00
 MemOk: stx     sp
-       sty     sp+1            ; set argument stack ptr
-
-; If we have IRQ functions, chain our stub into the IRQ vector
-
-        lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ1
-       lda     IRQVec
-               ldx     IRQVec+1
-       sta     IRQInd+1
-       stx     IRQInd+2
-       lda     #<IRQStub
-       ldx     #>IRQStub
-       sei
-       sta     IRQVec
-       stx     IRQVec+1
-       cli
+       sty     sp+1            ; set argument stack ptr
 
 ; Call module constructors
 
-NoIRQ1: jsr     initlib
+       jsr     initlib
 
 ; Push arguments and call main()
 
-               jsr     callmain
+       jsr     callmain
 
 ; Call module destructors. This is also the _exit entry.
 
 _exit:         pha                     ; Save the return code on stack
        jsr     donelib         ; Run module destructors
 
-; Reset the IRQ vector if we chained it.
-
-        pha                    ; Save the return code on stack
-       lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ2
-       lda     IRQInd+1
-       ldx     IRQInd+2
-       sei
-       sta     IRQVec
-       stx     IRQVec+1
-       cli
-
 ; Copy back the zero page stuff
 
-NoIRQ2: ldx     #zpspace-1
+       ldx     #zpspace-1
 L2:    lda     zpsave,x
        sta     sp,x
        dex
-               bpl     L2
+       bpl     L2
 
 ; Store the return code into ST
 
@@ -118,26 +89,13 @@ L2:        lda     zpsave,x
        rts
 
 ; ------------------------------------------------------------------------
-; The IRQ vector jumps here, if condes routines are defined with type 2.
-
-IRQStub:
-       cld                             ; Just to be sure
-               jsr     callirq                 ; Call the functions
-               jmp     IRQInd                  ; Jump to the saved IRQ vector
-
-; ------------------------------------------------------------------------
-; Data
-
-.data
 
-IRQInd: jmp     $0000
-
-.segment        "ZPSAVE"
+.segment       "ZPSAVE"
 
 zpsave:        .res    zpspace
 
+; ------------------------------------------------------------------------
+
 .bss
 
 spsave:        .res    1
-
-
diff --git a/libsrc/c16/irq.s b/libsrc/c16/irq.s
new file mode 100644 (file)
index 0000000..c50daf7
--- /dev/null
@@ -0,0 +1,53 @@
+;
+; IRQ handling (C16 version)
+;
+
+       .export         _exit
+       .import         callirq
+
+       .include        "plus4.inc"
+
+; ------------------------------------------------------------------------
+
+.segment       "INIT"
+
+initirq:
+       lda     IRQVec
+       ldx     IRQVec+1
+       sta     IRQInd+1
+       stx     IRQInd+2
+       lda     #<IRQStub
+       ldx     #>IRQStub
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+       rts
+
+; ------------------------------------------------------------------------
+
+.code
+
+doneirq:
+       lda     IRQInd+1
+       ldx     IRQInd+2
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+       rts
+
+; ------------------------------------------------------------------------
+
+.segment       "LOWCODE"
+
+IRQStub:
+       cld                             ; Just to be sure
+       jsr     callirq                 ; Call the functions
+       jmp     IRQInd                  ; Jump to the saved IRQ vector
+
+; ------------------------------------------------------------------------
+
+.data
+
+IRQInd:        jmp     $0000
index 5443a63e73b747962d8552f35d4d29a0a36afcfd..31ed042825a9984e102691619f60bec35582e95c 100644 (file)
@@ -76,6 +76,7 @@ OBJS =  _scrsize.o              \
         devnum.o                \
         get_ostype.o            \
         get_tv.o                \
+        irq.o                   \
         joy_stat_stddrv.o       \
         joy_stddrv.o            \
         kbhit.o                 \
index 16d2fb367f0fc6ae27afd82477f6e73cc18bc667..b3cacfd40be23dbd7f4c77354f760b61f5f1f70e 100644 (file)
@@ -3,34 +3,33 @@
 ;
 
        .export         _exit
-        .export         __STARTUP__ : absolute = 1      ; Mark as startup
-       .import         initlib, donelib, callirq
-               .import         zerobss
-       .import         callmain
-        .import         RESTOR, BSOUT, CLRCH
-       .import         __INTERRUPTOR_COUNT__
+       .export         __STARTUP__ : absolute = 1      ; Mark as startup
+       .import         initlib, donelib
+       .import         zerobss
+       .import         callmain
+       .import         RESTOR, BSOUT, CLRCH
        .import         __RAM_START__, __RAM_SIZE__     ; Linker generated
        .import         __STACKSIZE__                   ; Linker generated
-       .importzp       ST
+       .importzp       ST
 
-        .include        "zeropage.inc"
-       .include        "c64.inc"
+       .include        "zeropage.inc"
+       .include        "c64.inc"
 
 
 ; ------------------------------------------------------------------------
 ; Startup code
 
-.segment               "STARTUP"
+.segment       "STARTUP"
 
 Start:
 
 ; Save the zero page locations we need
 
-        ldx            #zpspace-1
+       ldx     #zpspace-1
 L1:    lda     sp,x
-               sta     zpsave,x
+       sta     zpsave,x
        dex
-               bpl     L1
+       bpl     L1
 
 ; Switch to second charset
 
@@ -40,9 +39,9 @@ L1:   lda     sp,x
 ; Switch off the BASIC ROM
 
        lda     $01
-               pha                     ; Remember the value
+       pha                     ; Remember the value
        and     #$F8
-               ora     #$06            ; Enable kernal+I/O, disable basic
+       ora     #$06            ; Enable kernal+I/O, disable basic
        sta     $01
 
 ; Clear the BSS data
@@ -51,64 +50,37 @@ L1: lda     sp,x
 
 ; Save system settings and setup the stack
 
-        pla
-        sta    mmusave         ; Save the memory configuration
+       pla
+       sta     mmusave         ; Save the memory configuration
 
-               tsx
-               stx     spsave          ; Save the system stack ptr
+       tsx
+       stx     spsave          ; Save the system stack ptr
 
-       lda     #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
+       lda     #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
        sta     sp
        lda     #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
-               sta     sp+1            ; Set argument stack ptr
-
-; If we have IRQ functions, chain our stub into the IRQ vector
-
-        lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ1
-       lda     IRQVec
-               ldx     IRQVec+1
-       sta     IRQInd+1
-       stx     IRQInd+2
-       lda     #<IRQStub
-       ldx     #>IRQStub
-       sei
-       sta     IRQVec
-       stx     IRQVec+1
-       cli
+       sta     sp+1            ; Set argument stack ptr
 
 ; Call module constructors
 
-NoIRQ1:        jsr     initlib
+       jsr     initlib
 
 ; Push arguments and call main
 
-        jsr     callmain
+       jsr     callmain
 
 ; Back from main (This is also the _exit entry). Run module destructors
 
-_exit:  jsr    donelib
-
-
-; Reset the IRQ vector if we chained it.
-
-        pha                    ; Save the return code on stack
-       lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ2
-       lda     IRQInd+1
-       ldx     IRQInd+2
-       sei
-       sta     IRQVec
-       stx     IRQVec+1
-       cli
+_exit: pha                     ; Save the return code on stack
+       jsr     donelib
 
 ; Copy back the zero page stuff
 
-NoIRQ2: ldx    #zpspace-1
-L2:    lda     zpsave,x
-       sta     sp,x
-       dex
-               bpl     L2
+       ldx     #zpspace-1
+L2:    lda     zpsave,x
+       sta     sp,x
+       dex
+       bpl     L2
 
 ; Place the program return code into ST
 
@@ -117,31 +89,19 @@ L2:        lda     zpsave,x
 
 ; Restore system stuff
 
-       ldx     spsave
-       txs                     ; Restore stack pointer
-               ldx     mmusave
-       stx     $01             ; Restore memory configuration
+       ldx     spsave
+       txs                     ; Restore stack pointer
+       ldx     mmusave
+       stx     $01             ; Restore memory configuration
 
 ; Back to basic
 
-        rts
-
-; ------------------------------------------------------------------------
-; The IRQ vector jumps here, if condes routines are defined with type 2.
-
-IRQStub:
-       cld                             ; Just to be sure
-               jsr     callirq                 ; Call the functions
-               jmp     IRQInd                  ; Jump to the saved IRQ vector
+       rts
 
 ; ------------------------------------------------------------------------
 ; Data
 
-.data
-
-IRQInd: jmp     $0000
-
-.segment        "ZPSAVE"
+.segment       "ZPSAVE"
 
 zpsave:        .res    zpspace
 
diff --git a/libsrc/c64/irq.s b/libsrc/c64/irq.s
new file mode 100644 (file)
index 0000000..bab4624
--- /dev/null
@@ -0,0 +1,53 @@
+;
+; IRQ handling (C64 version)
+;
+
+       .export         initirq, doneirq
+       .import         callirq
+
+       .include        "c64.inc"
+
+; ------------------------------------------------------------------------
+
+.segment       "INIT"
+
+initirq:
+       lda     IRQVec
+       ldx     IRQVec+1
+       sta     IRQInd+1
+       stx     IRQInd+2
+       lda     #<IRQStub
+       ldx     #>IRQStub
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+       rts
+
+; ------------------------------------------------------------------------
+
+.code
+
+doneirq:
+       lda     IRQInd+1
+       ldx     IRQInd+2
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+       rts
+
+; ------------------------------------------------------------------------
+
+.segment       "LOWCODE"
+
+IRQStub:
+       cld                             ; Just to be sure
+       jsr     callirq                 ; Call the functions
+       jmp     IRQInd                  ; Jump to the saved IRQ vector
+
+; ------------------------------------------------------------------------
+
+.data
+
+IRQInd:        jmp     $0000
index 2b8f2bf9d607eea5b7880057056e378775766912..69cea06b7de928794d8861aa1f3069e4779695f1 100644 (file)
@@ -68,6 +68,7 @@ OBJS =  _scrsize.o              \
         crt0.o                  \
         devnum.o                \
         extzp.o                 \
+        irq.o                   \
         joy_stat_stddrv.o       \
         joy_stddrv.o            \
         kbhit.o                 \
diff --git a/libsrc/cbm510/irq.s b/libsrc/cbm510/irq.s
new file mode 100644 (file)
index 0000000..34294b8
--- /dev/null
@@ -0,0 +1,9 @@
+;
+; IRQ handling (CBM 500 version)
+;
+
+       .export         initirq, doneirq
+
+initirq:
+doneirq:
+       rts
index 34fe1c9ec78709e87f3df7a887ec7ae1a3943c4b..f4f26af78f031740403ff0e99440862bcb510c99 100644 (file)
@@ -70,6 +70,7 @@ OBJS =  _scrsize.o              \
         devnum.o                \
         extzp.o                 \
         get_tv.o                \
+        irq.o                   \
         kbhit.o                 \
         kclose.o                \
         kernal.o                \
diff --git a/libsrc/cbm610/irq.s b/libsrc/cbm610/irq.s
new file mode 100644 (file)
index 0000000..7b57088
--- /dev/null
@@ -0,0 +1,9 @@
+;
+; IRQ handling (CBM 600/700 version)
+;
+
+       .export         initirq, doneirq
+
+initirq:
+doneirq:
+       rts
index 399a456c339d249c45f3fd2dda86eff188fd6e23..c901aba6652376a0978ed612535fff6a43e9850a 100644 (file)
@@ -79,6 +79,7 @@ OBJS =  bllhdr.o                \
         exec.o                  \
         exehdr.o                \
         extzp.o                 \
+        irq.o                   \
         joy_stat_stddrv.o       \
         joy_stddrv.o            \
         kbhit.o                 \
index a7252f84792400b771de3c972f685994fe5296cf..804165c0dc2dc280087d3106284162b4d3198285 100644 (file)
 ; on the front of the fully linked binary (see EXEHDR segment.)
 ;
 
-       .include        "lynx.inc"
-       .export         _exit
-        .export         __STARTUP__ : absolute = 1      ; Mark as startup
+       .export         _exit
+       .export         __STARTUP__ : absolute = 1      ; Mark as startup
 
-       .import         callirq, initlib, donelib
-       .import         zerobss
-       .import         callmain
-       .import         _main
-       .import         __INTERRUPTOR_COUNT__
-       .import         __RAM_START__, __RAM_SIZE__, __STACKSIZE__
+       .import         initlib, donelib
+       .import         zerobss
+       .import         callmain
+       .import         _main
+       .import         __RAM_START__, __RAM_SIZE__, __STACKSIZE__
 
-       .include        "zeropage.inc"
-        .include        "extzp.inc"
+       .include        "zeropage.inc"
+       .include        "extzp.inc"
+       .include        "lynx.inc"
 
 ; ------------------------------------------------------------------------
 ; Mikey and Suzy init data, reg offsets and data
 
        .rodata
 
-SuzyInitReg:    .byte $28,$2a,$04,$06,$92,$83,$90
-SuzyInitData:   .byte $7f,$7f,$00,$00,$24,$f3,$01
-
-MikeyInitReg:   .byte $00,$01,$08,$09,$20,$28,$30,$38,$44,$50,$8a,$8b,$8c,$92,$93
-MikeyInitData:  .byte $9e,$18,$68,$1f,$00,$00,$00,$00,$00,$ff,$1a,$1b,$04,$0d,$29
+SuzyInitReg:   .byte $28,$2a,$04,$06,$92,$83,$90
+SuzyInitData:  .byte $7f,$7f,$00,$00,$24,$f3,$01
 
+MikeyInitReg:  .byte $00,$01,$08,$09,$20,$28,$30,$38,$44,$50,$8a,$8b,$8c,$92,$93
+MikeyInitData: .byte $9e,$18,$68,$1f,$00,$00,$00,$00,$00,$ff,$1a,$1b,$04,$0d,$29
 
 ; ------------------------------------------------------------------------
 ; Actual code
@@ -50,116 +48,89 @@ MikeyInitData:  .byte $9e,$18,$68,$1f,$00,$00,$00,$00,$00,$ff,$1a,$1b,$04,$0d,$2
 
        sei
        cld
-       ldx     #$FF
+       ldx     #$FF
        txs
 
 ; init bank switching
 
-               lda     #$C
-               sta     MAPCTL                  ; $FFF9
+       lda     #$C
+       sta     MAPCTL          ; $FFF9
 
 ; disable all timer interrupts
 
-               lda     #$80
-               trb     TIM0CTLA
-               trb     TIM1CTLA
-               trb     TIM2CTLA
-               trb     TIM3CTLA
-               trb     TIM5CTLA
-               trb     TIM6CTLA
-               trb     TIM7CTLA
+       lda     #$80
+       trb     TIM0CTLA
+       trb     TIM1CTLA
+       trb     TIM2CTLA
+       trb     TIM3CTLA
+       trb     TIM5CTLA
+       trb     TIM6CTLA
+       trb     TIM7CTLA
 
 ; disable TX/RX IRQ, set to 8E1
 
-               lda     #%11101
-               sta     SERCTL
+       lda     #%11101
+       sta     SERCTL
 
 ; clear all pending interrupts
 
-               lda     INTSET
-               sta     INTRST
+       lda     INTSET
+       sta     INTRST
 
 ; setup the stack
 
-       lda     #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
-       sta     sp
-       lda     #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
-       sta     sp+1
+       lda     #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
+       sta     sp
+       lda     #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
+       sta     sp+1
 
 ; Init Mickey
 
-       ldx     #.sizeof(MikeyInitReg)-1
-mloop:  ldy     MikeyInitReg,x
-       lda     MikeyInitData,x
-       sta     $fd00,y
+       ldx     #.sizeof(MikeyInitReg)-1
+mloop: ldy     MikeyInitReg,x
+       lda     MikeyInitData,x
+       sta     $fd00,y
        dex
-       bpl     mloop
+       bpl     mloop
 
 ; these are RAM-shadows of read only regs
 
-       ldx     #$1b
-       stx     __iodat
-       dex                             ; $1A
-               stx     __iodir
-       ldx     #$d
-       stx     __viddma
+       ldx     #$1b
+       stx     __iodat
+       dex                     ; $1A
+       stx     __iodir
+       ldx     #$d
+       stx     __viddma
 
 ; Init Suzy
 
-       ldx     #.sizeof(SuzyInitReg)-1
-sloop:  ldy     SuzyInitReg,x
-       lda     SuzyInitData,x
-       sta     $fc00,y
+       ldx     #.sizeof(SuzyInitReg)-1
+sloop: ldy     SuzyInitReg,x
+       lda     SuzyInitData,x
+       sta     $fc00,y
        dex
-       bpl     sloop
+       bpl     sloop
 
-       lda     #$24
-       sta     __sprsys
+       lda     #$24
+       sta     __sprsys
+       cli
 
 ; Clear the BSS data
 
-       jsr     zerobss
-
-; If we have IRQ functions, set the IRQ vector
-; as Lynx is a console there is not much point in releasing the IRQ
-
-        lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ1
-       lda     #<IRQStub
-       ldx     #>IRQStub
-       sei
-       sta     INTVECTL
-       stx     INTVECTH
-       cli
+       jsr     zerobss
 
 ; Call module constructors
 
-NoIRQ1: jsr     initlib
+       jsr     initlib
 
 ; Push arguments and call main
 
-        jsr     callmain
+       jsr     callmain
 
 ; Call module destructors. This is also the _exit entry.
 
-_exit:  jsr     donelib         ; Run module destructors
+_exit: jsr     donelib         ; Run module destructors
 
 ; Endless loop
 
-noret:  bra     noret
-
-
-       .segment "CODE"
-IRQStub:
-       phy
-       phx
-       pha
-       cld
-               jsr     callirq
-       lda     INTSET
-       sta     INTRST
-       pla
-       plx
-       ply
-       rti
-
+noret: bra     noret
diff --git a/libsrc/lynx/irq.s b/libsrc/lynx/irq.s
new file mode 100644 (file)
index 0000000..b22b69a
--- /dev/null
@@ -0,0 +1,46 @@
+;
+; IRQ handling (Lynx version)
+;
+
+       .export         initirq, doneirq
+       .import         callirq
+
+       .include        "lynx.inc"
+
+; ------------------------------------------------------------------------
+
+.segment       "INIT"
+
+initirq:
+       lda     #<IRQStub
+       ldx     #>IRQStub
+       sei
+       sta     INTVECTL
+       stx     INTVECTH
+       cli
+       rts
+
+; ------------------------------------------------------------------------
+
+.code
+
+doneirq:
+       ; as Lynx is a console there is not much point in releasing the IRQ
+       rts
+
+; ------------------------------------------------------------------------
+
+.segment       "LOWCODE"
+
+IRQStub:
+       phy
+       phx
+       pha
+       cld
+       jsr     callirq
+       lda     INTSET
+       sta     INTRST
+       pla
+       plx
+       ply
+       rti
index 23f5892421956e7e74ee7ce655d6321d782684dd..4243d1942f80b4c84b1cf9d548653f2ba65e5213 100644 (file)
@@ -62,6 +62,7 @@ OBJS =        _scrsize.o              \
         crt0.o                  \
         devnum.o                \
         get_tv.o                \
+        irq.o                   \
         joy_stat_stddrv.o       \
         joy_stddrv.o            \
         kbhit.o                 \
index 121f4c492028bcfd01f9b1f5d8f5a759d324677a..b71c012ff44ec45c22d20250710cd57c6b999026 100644 (file)
@@ -2,33 +2,32 @@
 ; Startup code for cc65 (PET version)
 ;
 
-       .export         _exit
-        .export         __STARTUP__ : absolute = 1      ; Mark as startup
-       .import         initlib, donelib, callirq
-               .import         zerobss, push0
+       .export         _exit
+       .export         __STARTUP__ : absolute = 1      ; Mark as startup
+       .import         initlib, donelib
+       .import         zerobss, push0
        .import         callmain
-        .import         CLRCH, BSOUT
-       .import         __INTERRUPTOR_COUNT__
-       .importzp       ST
+       .import         CLRCH, BSOUT
+       .importzp       ST
 
-        .include        "zeropage.inc"
+       .include        "zeropage.inc"
        .include        "pet.inc"
        .include        "../cbm/cbm.inc"
 
 ; ------------------------------------------------------------------------
 ; Startup code
 
-.segment               "STARTUP"
+.segment       "STARTUP"
 
 Start:
 
 ; Save the zero page locations we need
 
-        ldx    #zpspace-1
+       ldx     #zpspace-1
 L1:    lda     sp,x
-               sta     zpsave,x
+       sta     zpsave,x
        dex
-               bpl     L1
+       bpl     L1
 
 ; Switch to second charset. The routine that is called by BSOUT to switch the
 ; character set will use FNLEN as temporary storage - YUCK! Since the
@@ -36,13 +35,13 @@ L1: lda     sp,x
 ; information, we need to save and restore it here.
 ; Thanks to Stefan Haubenthal for this information!
 
-        lda     FNLEN
-        pha                     ; Save FNLEN
+       lda     FNLEN
+       pha                     ; Save FNLEN
        lda     #14
 ;      sta     $E84C           ; See PET FAQ
        jsr     BSOUT
-        pla
-        sta     FNLEN           ; Restore FNLEN
+       pla
+       sta     FNLEN           ; Restore FNLEN
 
 ; Clear the BSS data
 
@@ -50,60 +49,34 @@ L1: lda     sp,x
 
 ; Save system stuff and setup the stack
 
-               tsx
-               stx     spsave          ; Save the system stack ptr
+       tsx
+       stx     spsave          ; Save the system stack ptr
 
-       lda     MEMSIZE
+       lda     MEMSIZE
        sta     sp
        lda     MEMSIZE+1
-               sta     sp+1            ; Set argument stack ptr
-
-; If we have IRQ functions, chain our stub into the IRQ vector
-
-       lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ1
-       lda     IRQVec
-       ldx     IRQVec+1
-       sta     IRQInd+1
-       stx     IRQInd+2
-       lda     #<IRQStub
-       ldx     #>IRQStub
-       sei
-       sta     IRQVec
-       stx     IRQVec+1
-       cli
+       sta     sp+1            ; Set argument stack ptr
 
 ; Call module constructors
 
-NoIRQ1: jsr     initlib
+       jsr     initlib
 
 ; Push arguments and call main()
 
-        jsr    callmain
+       jsr     callmain
 
 ; Call module destructors. This is also the _exit entry.
 
-_exit:  pha                    ; Save the return code on stack
-        jsr    donelib
-
-; Reset the IRQ vector if we chained it.
-
-       lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ2
-       lda     IRQInd+1
-       ldx     IRQInd+2
-       sei
-       sta     IRQVec
-       stx     IRQVec+1
-       cli
+_exit: pha                     ; Save the return code on stack
+       jsr     donelib
 
 ; Copy back the zero page stuff
 
-NoIRQ2: ldx     #zpspace-1
+       ldx     #zpspace-1
 L2:    lda     zpsave,x
        sta     sp,x
        dex
-               bpl     L2
+       bpl     L2
 
 ; Store the program return code into ST
 
@@ -113,33 +86,21 @@ L2:        lda     zpsave,x
 ; Restore the stack pointer
 
        ldx     spsave
-       txs                     ; Restore stack pointer
+       txs                     ; Restore stack pointer
 
 ; Back to basic
 
-               rts
-
-; ------------------------------------------------------------------------
-; The IRQ vector jumps here, if condes routines are defined with type 2.
-
-IRQStub:
-       cld                             ; Just to be sure
-       jsr     callirq                 ; Call the functions
-       jmp     IRQInd                  ; Jump to the saved IRQ vector
+       rts
 
 ; ------------------------------------------------------------------------
-; Data
 
-.data
-
-IRQInd: jmp    $0000
-
-.segment        "ZPSAVE"
+.segment       "ZPSAVE"
 
 zpsave:        .res    zpspace
 
+; ------------------------------------------------------------------------
+
 .bss
 
 spsave:        .res    1
 mmusave:.res   1
-
diff --git a/libsrc/pet/irq.s b/libsrc/pet/irq.s
new file mode 100644 (file)
index 0000000..5effd70
--- /dev/null
@@ -0,0 +1,53 @@
+;
+; IRQ handling (PET version)
+;
+
+       .export         initirq, doneirq
+       .import         callirq
+
+       .include        "pet.inc"
+
+; ------------------------------------------------------------------------
+
+.segment       "INIT"
+
+initirq:
+       lda     IRQVec
+       ldx     IRQVec+1
+       sta     IRQInd+1
+       stx     IRQInd+2
+       lda     #<IRQStub
+       ldx     #>IRQStub
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+       rts
+
+; ------------------------------------------------------------------------
+
+.code
+
+doneirq:
+       lda     IRQInd+1
+       ldx     IRQInd+2
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+       rts
+
+; ------------------------------------------------------------------------
+
+.segment       "LOWCODE"
+
+IRQStub:
+       cld                             ; Just to be sure
+       jsr     callirq                 ; Call the functions
+       jmp     IRQInd                  ; Jump to the saved IRQ vector
+
+; ------------------------------------------------------------------------
+
+.data
+
+IRQInd:        jmp     $0000
index 838c67a58f8e95be01fbffa8f41bb173b5961e50..eeff3b91242148789aab3405f0f34994aa6aa653 100644 (file)
@@ -68,6 +68,7 @@ OBJS =        _scrsize.o              \
         crt0.o                  \
         devnum.o                \
         get_tv.o                \
+        irq.o                   \
         joy_stat_stddrv.o       \
         joy_stddrv.o            \
         kacptr.o                \
diff --git a/libsrc/plus4/irq.s b/libsrc/plus4/irq.s
new file mode 100644 (file)
index 0000000..490d5f6
--- /dev/null
@@ -0,0 +1,9 @@
+;
+; IRQ handling (Plus/4 version)
+;
+
+       .export         initirq, doneirq
+
+initirq:
+doneirq:
+       rts
index 618f80f8db81268d745cdfb5bef2991b13f7ae6f..74a12c4db4f5f58b9e42f5a7534e948bea9cd90a 100644 (file)
 ; entries.
 ;
 
-               .export callirq
-        .export callirq_y       ; Same but with Y preloaded
-                                                            
-        .export __CALLIRQ__: absolute = 1
-               .import __INTERRUPTOR_TABLE__, __INTERRUPTOR_COUNT__
+        .export         callirq
+        .export         callirq_y       ; Same but with Y preloaded
+        .export         __CALLIRQ__ : absolute = 1
+        .constructor    irq_init, 10
+        .destructor     irq_done, 10
 
-.code
+        .import         __INTERRUPTOR_TABLE__, __INTERRUPTOR_COUNT__
+        .import         initirq
+        .import         doneirq
+
+        irq_init :=     initirq
+        irq_done :=     doneirq
 
 ; --------------------------------------------------------------------------
 ; Call all IRQ routines. The function needs to use self modifying code and
@@ -51,14 +56,12 @@ callirq_y:
 loop:   dey
         lda     __INTERRUPTOR_TABLE__,y
         sta     jmpvec+2                ; Modify code below
-       dey
+        dey
         lda     __INTERRUPTOR_TABLE__,y
         sta     jmpvec+1                ; Modify code below
-               sty     index+1                 ; Modify code below
-jmpvec: jsr            $FFFF                   ; Patched at runtime
+        sty     index+1                 ; Modify code below
+jmpvec: jsr     $FFFF                   ; Patched at runtime
         bcs     done                    ; Bail out if interrupt handled
-index:         ldy     #$FF                    ; Patched at runtime
-               bne     loop
+index:  ldy     #$FF                    ; Patched at runtime
+        bne     loop
 done:   rts
-
-
index 14a45709d16f0905c4009168179326d1af71f619..2e9e88ef484aa9e39ed58e7b0e04e2560846cb03 100644 (file)
@@ -61,6 +61,7 @@ OBJS =        _scrsize.o              \
         cputc.o                 \
         devnum.o                \
         get_tv.o                \
+        irq.o                   \
         joy_stat_stddrv.o       \
         joy_stddrv.o            \
         kbhit.o                 \
index 170ac3a39c72038d666e3e26f560c42a233d1a18..24b879e238cc7a90a6076fe89ca72aa8161ceb00 100644 (file)
@@ -3,33 +3,32 @@
 ;
 
        .export         _exit
-        .export         __STARTUP__ : absolute = 1      ; Mark as startup
-       .import         initlib, donelib, callirq
-               .import         zerobss, push0
-       .import         callmain
-        .import         RESTOR, BSOUT, CLRCH
-       .import         __INTERRUPTOR_COUNT__
-       .import         __RAM_START__, __RAM_SIZE__     ; Linker generated
-        .import                __STACKSIZE__                   ; Linker generated
-       .importzp       ST
-
-        .include        "zeropage.inc"
-       .include        "vic20.inc"
+       .export         __STARTUP__ : absolute = 1      ; Mark as startup
+       .import         initlib, donelib
+       .import         zerobss, push0
+       .import         callmain
+       .import         RESTOR, BSOUT, CLRCH
+       .import         __RAM_START__, __RAM_SIZE__     ; Linker generated
+       .import         __STACKSIZE__                   ; Linker generated
+       .importzp       ST
+
+       .include        "zeropage.inc"
+       .include        "vic20.inc"
 
 ; ------------------------------------------------------------------------
 ; Startup code
 
-.segment               "STARTUP"
+.segment       "STARTUP"
 
 Start:
 
 ; Save the zero page locations we need
 
-        ldx            #zpspace-1
+       ldx     #zpspace-1
 L1:    lda     sp,x
-       sta     zpsave,x
+       sta     zpsave,x
        dex
-               bpl     L1
+       bpl     L1
 
 ; Switch to second charset
 
@@ -42,60 +41,34 @@ L1: lda     sp,x
 
 ; Save system stuff and setup the stack
 
-               tsx
-               stx     spsave          ; Save the system stack ptr
+       tsx
+       stx     spsave          ; Save the system stack ptr
 
-       lda     #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
+       lda     #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
        sta     sp
        lda     #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
-               sta     sp+1            ; Set argument stack ptr
-
-; If we have IRQ functions, chain our stub into the IRQ vector
-
-        lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ1
-       lda     IRQVec
-               ldx     IRQVec+1
-       sta     IRQInd+1
-       stx     IRQInd+2
-       lda     #<IRQStub
-       ldx     #>IRQStub
-       sei
-       sta     IRQVec
-       stx     IRQVec+1
-       cli
+       sta     sp+1            ; Set argument stack ptr
 
 ; Call module constructors
 
-NoIRQ1: jsr     initlib
+       jsr     initlib
 
 ; Push arguments and call main()
 
-        jsr     callmain
+       jsr     callmain
 
 ; Back from main (This is also the _exit entry). Run module destructors
 
-_exit:  jsr     donelib
-
-; Reset the IRQ vector if we chained it.
-
-        pha                    ; Save the return code on stack
-       lda     #<__INTERRUPTOR_COUNT__
-       beq     NoIRQ2
-       lda     IRQInd+1
-       ldx     IRQInd+2
-       sei
-       sta     IRQVec
-       stx     IRQVec+1
-       cli
+_exit: pha                     ; Save the return code on stack
+       jsr     donelib
 
 ; Copy back the zero page stuff
 
-NoIRQ2: ldx    #zpspace-1
+       ldx     #zpspace-1
 L2:    lda     zpsave,x
        sta     sp,x
        dex
-               bpl     L2
+       bpl     L2
 
 ; Place the program return code into ST
 
@@ -104,33 +77,21 @@ L2:        lda     zpsave,x
 
 ; Restore the stack pointer
 
-       ldx     spsave
+       ldx     spsave
        txs
 
 ; Back to basic
 
-        rts
-
-
-; ------------------------------------------------------------------------
-; The IRQ vector jumps here, if condes routines are defined with type 2.
-
-IRQStub:
-       cld                             ; Just to be sure
-               jsr     callirq                 ; Call the functions
-               jmp     IRQInd                  ; Jump to the saved IRQ vector
+       rts
 
 ; ------------------------------------------------------------------------
-; Data
-
-.data
-
-IRQInd: jmp     $0000
 
-.segment        "ZPSAVE"
+.segment       "ZPSAVE"
 
 zpsave:        .res    zpspace
 
+; ------------------------------------------------------------------------
+
 .bss
 
 spsave:        .res    1
diff --git a/libsrc/vic20/irq.s b/libsrc/vic20/irq.s
new file mode 100644 (file)
index 0000000..c6bc137
--- /dev/null
@@ -0,0 +1,53 @@
+;
+; IRQ handling (Vic20 version)
+;
+
+       .export         initirq, doneirq
+       .import         callirq
+
+       .include        "vic20.inc"
+
+; ------------------------------------------------------------------------
+
+.segment       "INIT"
+
+initirq:
+       lda     IRQVec
+       ldx     IRQVec+1
+       sta     IRQInd+1
+       stx     IRQInd+2
+       lda     #<IRQStub
+       ldx     #>IRQStub
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+       rts
+
+; ------------------------------------------------------------------------
+
+.code
+
+doneirq:
+       lda     IRQInd+1
+       ldx     IRQInd+2
+       sei
+       sta     IRQVec
+       stx     IRQVec+1
+       cli
+       rts
+
+; ------------------------------------------------------------------------
+
+.segment       "LOWCODE"
+
+IRQStub:
+       cld                             ; Just to be sure
+       jsr     callirq                 ; Call the functions
+       jmp     IRQInd                  ; Jump to the saved IRQ vector
+
+; ------------------------------------------------------------------------
+
+.data
+
+IRQInd:        jmp     $0000