diff --git a/libsrc/telestrat/crt0.s b/libsrc/telestrat/crt0.s index aa32ed0d0..f4b67a008 100644 --- a/libsrc/telestrat/crt0.s +++ b/libsrc/telestrat/crt0.s @@ -1,7 +1,7 @@ ; ; Startup code for cc65 (Oric version) ; -; By Debrune Jérôme and Ullrich von Bassewitz +; By Debrune Jérôme and Ullrich von Bassewitz ; .export _exit @@ -36,12 +36,12 @@ ; Call the module destructors. This is also the exit() entry. -_exit: jsr donelib +_exit: -; Restore the system stuff. +; Save return code on stack - ldx spsave - txs + pha + jsr donelib ; Copy back the zero-page stuff. @@ -51,6 +51,16 @@ L2: lda zpsave,x dex bpl L2 +; Restore the return code. +; The return code is on the stack, so we can just pop it. +; This is the return code from main(). + pla + +; Restore the system stuff. + + ldx spsave + txs + ; Back to BASIC. rts