From: cuz Date: Tue, 2 Mar 2004 17:08:07 +0000 (+0000) Subject: Place the return code into ST X-Git-Tag: V2.12.0~936 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=220e5a38985b35623f11e8cb4662f2f401e0f730;p=cc65 Place the return code into ST git-svn-id: svn://svn.cc65.org/cc65/trunk@2884 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- diff --git a/libsrc/c128/crt0.s b/libsrc/c128/crt0.s index 46cfd93d2..bd9ca2dc7 100644 --- a/libsrc/c128/crt0.s +++ b/libsrc/c128/crt0.s @@ -112,11 +112,10 @@ L1: lda sp,x NoIRQ1: jsr callmain -; Back from main (this is also the _exit entry). Store the return code into -; ST, where it is accessible from BASIC. Reset the IRQ vector if we chained -; it. +; Back from main (this is also the _exit entry). Reset the IRQ vector if we +; chained it. -_exit: sta ST +_exit: pha ; Save the return code on stack lda #<__IRQFUNC_COUNT__ beq NoIRQ2 lda IRQInd+1 @@ -148,6 +147,11 @@ L2: lda zpsave,x lda mmusave sta MMU_CR +; Place the program return code into ST + + pla + sta ST + ; Done, restore kernal vectors in an attempt to cleanup jmp RESTOR diff --git a/libsrc/c16/crt0.s b/libsrc/c16/crt0.s index 7065be969..172a9aa2e 100644 --- a/libsrc/c16/crt0.s +++ b/libsrc/c16/crt0.s @@ -76,7 +76,8 @@ MemOk: stx sp ; Call module destructors. This is also the _exit entry. -_exit: jsr donelib ; Run module destructors +_exit: pha ; Save the return code on stack + jsr donelib ; Run module destructors ; Restore system stuff @@ -91,6 +92,11 @@ L2: lda zpsave,x dex bpl L2 +; Store the return code into ST + + pla + sta ST + ; Reset changed vectors jmp RESTOR diff --git a/libsrc/c64/crt0.s b/libsrc/c64/crt0.s index 7144d61ae..98f391c28 100644 --- a/libsrc/c64/crt0.s +++ b/libsrc/c64/crt0.s @@ -82,7 +82,7 @@ L1: lda sp,x ; Call module destructors. This is also the _exit entry. -_exit: sta ST ; Place return code into ST +_exit: pha ; Save the return code jsr donelib ; Run module destructors ; Restore system stuff @@ -100,6 +100,11 @@ L2: lda zpsave,x dex bpl L2 +; Place the program return code into ST + + pla + sta ST + ; Reset changed vectors, back to basic jmp RESTOR diff --git a/libsrc/cbm510/crt0.s b/libsrc/cbm510/crt0.s index da0ef0ab2..936d67c61 100644 --- a/libsrc/cbm510/crt0.s +++ b/libsrc/cbm510/crt0.s @@ -442,7 +442,8 @@ ccopy2: lda __VIDRAM_START__,y ; Call module destructors. This is also the _exit entry and the default entry ; point for the break vector. -_exit: lda #$00 +_exit: pha ; Save the return code on stack + lda #$00 sta irqcount ; Disable custom irq handlers jsr donelib ; Run module destructors @@ -481,6 +482,12 @@ _exit: lda #$00 bne @L0 .endif +; Place the program return code into ST + + pla + ldy #ST + sta (sysp0),y + ; Setup the welcome code at the stack bottom in the system bank. ldy #$FF diff --git a/libsrc/cbm610/crt0.s b/libsrc/cbm610/crt0.s index e6bdcb3d5..12e083d87 100644 --- a/libsrc/cbm610/crt0.s +++ b/libsrc/cbm610/crt0.s @@ -363,7 +363,8 @@ Init: jsr initlib ; Call module destructors. This is also the _exit entry and the default entry ; point for the break vector. -_exit: lda #$00 +_exit: pha ; Save the return code + lda #$00 sta irqcount ; Disable custom irq handlers jsr donelib ; Run module destructors @@ -388,6 +389,12 @@ _exit: lda #$00 bne @L0 .endif +; Place the program return code into ST + + pla + ldy #ST + sta (sysp0),y + ; Setup the welcome code at the stack bottom in the system bank. ldy #$FF diff --git a/libsrc/pet/crt0.s b/libsrc/pet/crt0.s index 69ff92eb7..a30231268 100644 --- a/libsrc/pet/crt0.s +++ b/libsrc/pet/crt0.s @@ -71,7 +71,8 @@ L1: lda sp,x ; Call module destructors. This is also the _exit entry. -_exit: jsr donelib ; Run module destructors +_exit: pha ; Save the return code on stack + jsr donelib ; Run module destructors ; Restore system stuff @@ -86,6 +87,11 @@ L2: lda zpsave,x dex bpl L2 +; Store the program return code into ST + + pla + sta ST + ; Back to basic rts diff --git a/libsrc/plus4/crt0.s b/libsrc/plus4/crt0.s index ea515fe64..07b3631c0 100644 --- a/libsrc/plus4/crt0.s +++ b/libsrc/plus4/crt0.s @@ -96,7 +96,8 @@ L1: lda sp,x ; Back from main (this is also the _exit entry). Run module destructors. -_exit: lda #0 +_exit: pha ; Save the return code + lda #0 sta irqcount ; Disable custom IRQ handlers jsr donelib ; Run module destructors @@ -113,6 +114,11 @@ L2: lda zpsave,x dex bpl L2 +; Place the program return code into ST + + pla + sta ST + ; 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 72d5799af..ab3d11cff 100644 --- a/libsrc/vic20/crt0.s +++ b/libsrc/vic20/crt0.s @@ -76,7 +76,8 @@ L1: lda sp,x ; Call module destructors. This is also the _exit entry. -_exit: jsr donelib ; Run module destructors +_exit: pha ; Save the return code on stack + jsr donelib ; Run module destructors ; Restore system stuff @@ -91,6 +92,11 @@ L2: lda zpsave,x dex bpl L2 +; Place the program return code into ST + + pla + sta ST + ; Reset changed vectors, back to basic jmp RESTOR