From 329ec64a4b60215bb0a06b5a433ce0d999faa000 Mon Sep 17 00:00:00 2001 From: jedeoric Date: Fri, 18 Jul 2025 00:23:44 +0200 Subject: [PATCH] telestrat target : manage main return code --- libsrc/telestrat/crt0.s | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) 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