From: cuz Date: Mon, 8 Mar 2004 20:38:58 +0000 (+0000) Subject: Fixed issues with the last change: The return code must be pulled from stack X-Git-Tag: V2.12.0~915 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7a5d4f3138f372b010db06b85f32ebf87ef2256f;p=cc65 Fixed issues with the last change: The return code must be pulled from stack before the stack pointer is reset. git-svn-id: svn://svn.cc65.org/cc65/trunk@2906 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/libsrc/c128/crt0.s b/libsrc/c128/crt0.s index bd9ca2dc7..dc31bae64 100644 --- a/libsrc/c128/crt0.s +++ b/libsrc/c128/crt0.s @@ -112,7 +112,7 @@ L1: lda sp,x NoIRQ1: jsr callmain -; Back from main (this is also the _exit entry). Reset the IRQ vector if we +; Back from main (this is also the _exit entry). Reset the IRQ vector if we ; chained it. _exit: pha ; Save the return code on stack @@ -129,11 +129,6 @@ _exit: pha ; Save the return code on stack NoIRQ2: jsr donelib -; Reset the stack - - ldx spsave - txs - ; Copy back the zero page stuff ldx #zpspace-1 @@ -142,16 +137,18 @@ L2: lda zpsave,x dex bpl L2 -; Reset the memory configuration - - lda mmusave - sta MMU_CR - ; Place the program return code into ST pla sta ST +; Reset the stack and the memory configuration + + ldx spsave + txs + ldx mmusave + stx MMU_CR + ; Done, restore kernal vectors in an attempt to cleanup jmp RESTOR diff --git a/libsrc/c16/crt0.s b/libsrc/c16/crt0.s index 172a9aa2e..7f38719f0 100644 --- a/libsrc/c16/crt0.s +++ b/libsrc/c16/crt0.s @@ -79,11 +79,6 @@ MemOk: stx sp _exit: pha ; Save the return code on stack jsr donelib ; Run module destructors -; Restore system stuff - - ldx spsave - txs - ; Copy back the zero page stuff ldx #zpspace-1 @@ -97,6 +92,11 @@ L2: lda zpsave,x pla sta ST +; Restore the stack pointer + + ldx spsave + txs + ; Reset changed vectors jmp RESTOR diff --git a/libsrc/c64/crt0.s b/libsrc/c64/crt0.s index 98f391c28..f75a5c46b 100644 --- a/libsrc/c64/crt0.s +++ b/libsrc/c64/crt0.s @@ -85,13 +85,6 @@ L1: lda sp,x _exit: pha ; Save the return code jsr donelib ; Run module destructors -; Restore system stuff - - ldx spsave - txs ; Restore stack pointer - lda mmusave - sta $01 ; Restore memory configuration - ; Copy back the zero page stuff ldx #zpspace-1 @@ -105,6 +98,13 @@ L2: lda zpsave,x pla sta ST +; Restore system stuff + + ldx spsave + txs ; Restore stack pointer + ldx mmusave + stx $01 ; Restore memory configuration + ; Reset changed vectors, back to basic jmp RESTOR diff --git a/libsrc/pet/crt0.s b/libsrc/pet/crt0.s index a30231268..fb0377677 100644 --- a/libsrc/pet/crt0.s +++ b/libsrc/pet/crt0.s @@ -74,11 +74,6 @@ L1: lda sp,x _exit: pha ; Save the return code on stack jsr donelib ; Run module destructors -; Restore system stuff - - ldx spsave - txs ; Restore stack pointer - ; Copy back the zero page stuff ldx #zpspace-1 @@ -92,6 +87,11 @@ L2: lda zpsave,x pla sta ST +; Restore the stack pointer + + ldx spsave + txs ; Restore stack pointer + ; Back to basic rts diff --git a/libsrc/plus4/crt0.s b/libsrc/plus4/crt0.s index 07b3631c0..b962abd96 100644 --- a/libsrc/plus4/crt0.s +++ b/libsrc/plus4/crt0.s @@ -101,11 +101,6 @@ _exit: pha ; Save the return code sta irqcount ; Disable custom IRQ handlers jsr donelib ; Run module destructors -; Restore system stuff - - ldx spsave - txs - ; Copy back the zero page stuff ldx #zpspace-1 @@ -119,6 +114,11 @@ L2: lda zpsave,x pla sta ST +; Restore the stack pointer + + ldx spsave + txs + ; Enable the ROM, reset changed vectors and return to BASIC sta ENABLE_ROM diff --git a/libsrc/vic20/crt0.s b/libsrc/vic20/crt0.s index ab3d11cff..a0425cee7 100644 --- a/libsrc/vic20/crt0.s +++ b/libsrc/vic20/crt0.s @@ -79,11 +79,6 @@ L1: lda sp,x _exit: pha ; Save the return code on stack jsr donelib ; Run module destructors -; Restore system stuff - - ldx spsave - txs ; Restore stack pointer - ; Copy back the zero page stuff ldx #zpspace-1 @@ -97,6 +92,11 @@ L2: lda zpsave,x pla sta ST +; Restore the stack pointer + + ldx spsave + txs + ; Reset changed vectors, back to basic jmp RESTOR