Fixed problems with the startup code (Greg King): Interrupts must be hooked
before calling initlib because initlib calls contructors and may install drivers, which enable hardware interrupts. Similar for donelib. See also R3897 where this change was done for other platforms. git-svn-id: svn://svn.cc65.org/cc65/trunk@3951 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -70,10 +70,6 @@ L1: lda sp,x
|
|||||||
lda MEMSIZE+1
|
lda MEMSIZE+1
|
||||||
sta sp+1 ; Set argument stack ptr
|
sta sp+1 ; Set argument stack ptr
|
||||||
|
|
||||||
; Call module constructors
|
|
||||||
|
|
||||||
jsr initlib
|
|
||||||
|
|
||||||
; If we have IRQ functions, chain our stub into the IRQ vector
|
; If we have IRQ functions, chain our stub into the IRQ vector
|
||||||
|
|
||||||
lda #<__INTERRUPTOR_COUNT__
|
lda #<__INTERRUPTOR_COUNT__
|
||||||
@@ -89,13 +85,21 @@ L1: lda sp,x
|
|||||||
stx IRQVec+1
|
stx IRQVec+1
|
||||||
cli
|
cli
|
||||||
|
|
||||||
|
; Call module constructors
|
||||||
|
|
||||||
|
NoIRQ1: jsr initlib
|
||||||
|
|
||||||
; Push arguments and call main()
|
; Push arguments and call main()
|
||||||
|
|
||||||
NoIRQ1: jsr callmain
|
jsr callmain
|
||||||
|
|
||||||
; Call module destructors. This is also the _exit entry.
|
; Call module destructors. This is also the _exit entry.
|
||||||
|
|
||||||
_exit: pha ; Save the return code on stack
|
_exit: pha ; Save the return code on stack
|
||||||
|
jsr donelib
|
||||||
|
|
||||||
|
; Reset the IRQ vector if we chained it.
|
||||||
|
|
||||||
lda #<__INTERRUPTOR_COUNT__
|
lda #<__INTERRUPTOR_COUNT__
|
||||||
beq NoIRQ2
|
beq NoIRQ2
|
||||||
lda IRQInd+1
|
lda IRQInd+1
|
||||||
@@ -105,13 +109,9 @@ _exit: pha ; Save the return code on stack
|
|||||||
stx IRQVec+1
|
stx IRQVec+1
|
||||||
cli
|
cli
|
||||||
|
|
||||||
; Run module destructors
|
|
||||||
|
|
||||||
NoIRQ2: jsr donelib ; Run module destructors
|
|
||||||
|
|
||||||
; Copy back the zero page stuff
|
; Copy back the zero page stuff
|
||||||
|
|
||||||
ldx #zpspace-1
|
NoIRQ2: ldx #zpspace-1
|
||||||
L2: lda zpsave,x
|
L2: lda zpsave,x
|
||||||
sta sp,x
|
sta sp,x
|
||||||
dex
|
dex
|
||||||
|
|||||||
@@ -80,16 +80,16 @@ L1: lda sp,x
|
|||||||
|
|
||||||
jsr zerobss
|
jsr zerobss
|
||||||
|
|
||||||
; Call module constructors
|
|
||||||
|
|
||||||
jsr initlib
|
|
||||||
|
|
||||||
; Initialize irqcount, which means that from now own custom linked in IRQ
|
; Initialize irqcount, which means that from now own custom linked in IRQ
|
||||||
; handlers (via condes) will be called.
|
; handlers (via condes) will be called.
|
||||||
|
|
||||||
lda #.lobyte(__INTERRUPTOR_COUNT__*2)
|
lda #.lobyte(__INTERRUPTOR_COUNT__*2)
|
||||||
sta irqcount
|
sta irqcount
|
||||||
|
|
||||||
|
; Call module constructors
|
||||||
|
|
||||||
|
jsr initlib
|
||||||
|
|
||||||
; Push arguments and call main()
|
; Push arguments and call main()
|
||||||
|
|
||||||
jsr callmain
|
jsr callmain
|
||||||
@@ -97,9 +97,12 @@ L1: lda sp,x
|
|||||||
; Back from main (this is also the _exit entry). Run module destructors.
|
; Back from main (this is also the _exit entry). Run module destructors.
|
||||||
|
|
||||||
_exit: pha ; Save the return code
|
_exit: pha ; Save the return code
|
||||||
|
jsr donelib ; Run module destructors
|
||||||
|
|
||||||
|
; Disable chained IRQ handlers
|
||||||
|
|
||||||
lda #0
|
lda #0
|
||||||
sta irqcount ; Disable custom IRQ handlers
|
sta irqcount ; Disable custom IRQ handlers
|
||||||
jsr donelib ; Run module destructors
|
|
||||||
|
|
||||||
; Copy back the zero page stuff
|
; Copy back the zero page stuff
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user