mirror of
https://github.com/cc65/cc65.git
synced 2026-04-22 01:16:54 +00:00
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:
+11
-11
@@ -70,10 +70,6 @@ L1: lda sp,x
|
||||
lda MEMSIZE+1
|
||||
sta sp+1 ; Set argument stack ptr
|
||||
|
||||
; Call module constructors
|
||||
|
||||
jsr initlib
|
||||
|
||||
; If we have IRQ functions, chain our stub into the IRQ vector
|
||||
|
||||
lda #<__INTERRUPTOR_COUNT__
|
||||
@@ -89,13 +85,21 @@ L1: lda sp,x
|
||||
stx IRQVec+1
|
||||
cli
|
||||
|
||||
; Call module constructors
|
||||
|
||||
NoIRQ1: jsr initlib
|
||||
|
||||
; Push arguments and call main()
|
||||
|
||||
NoIRQ1: jsr callmain
|
||||
jsr callmain
|
||||
|
||||
; 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__
|
||||
beq NoIRQ2
|
||||
lda IRQInd+1
|
||||
@@ -105,13 +109,9 @@ _exit: pha ; Save the return code on stack
|
||||
stx IRQVec+1
|
||||
cli
|
||||
|
||||
; Run module destructors
|
||||
|
||||
NoIRQ2: jsr donelib ; Run module destructors
|
||||
|
||||
; Copy back the zero page stuff
|
||||
|
||||
ldx #zpspace-1
|
||||
NoIRQ2: ldx #zpspace-1
|
||||
L2: lda zpsave,x
|
||||
sta sp,x
|
||||
dex
|
||||
|
||||
Reference in New Issue
Block a user