]> git.sur5r.net Git - cc65/blobdiff - libsrc/cbm510/crt0.s
Place the return code into ST
[cc65] / libsrc / cbm510 / crt0.s
index da0ef0ab2191db3d7bbc8438dc7a339689f76ad7..936d67c614f5076c8b0e5a5c6511f5f4ae9a6996 100644 (file)
@@ -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