2 ; Startup code for cc65 (Oric version)
4 ; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
5 ; 2016-03-18, Greg King
9 .export __STARTUP__ : absolute = 1 ; Mark as startup
11 .import initlib, donelib
12 .import callmain, zerobss
13 .import __MAIN_START__, __MAIN_SIZE__
15 .include "zeropage.inc"
18 ; ------------------------------------------------------------------------
19 ; Place the startup code in a special segment.
24 stx spsave ; Save system stk ptr
26 ; Save space by putting some of the start-up code in a segment
27 ; that will be re-used.
31 ; Clear the BSS variables (after the constructors have been run).
35 ; Push the command-line arguments; and, call main().
39 ; Call the module destructors. This is also the exit() entry.
43 ; Restore the system stuff.
50 ; Copy back the zero-page stuff.
62 ; ------------------------------------------------------------------------
63 ; Put this code in a place that will be re-used by BSS, the heap,
68 ; Save the zero-page area that we're about to use.
70 init: ldx #zpspace - 1
76 ; Currently, color isn't supported on the text screen.
77 ; Unprotect screen columns 0 and 1 (where each line's color codes would sit).
86 lda #<(__MAIN_START__ + __MAIN_SIZE__)
87 ldx #>(__MAIN_START__ + __MAIN_SIZE__)
89 stx sp+1 ; Set argument stack ptr
91 ; Call the module constructors.
95 ; ------------------------------------------------------------------------