2 ; Startup code for cc65 (Oric version)
4 ; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
8 .export __STARTUP__ : absolute = 1 ; Mark as startup
10 .import initlib, donelib
11 .import callmain, zerobss
12 .import __MAIN_START__, __MAIN_SIZE__
14 .include "zeropage.inc"
15 .include "telestrat.inc"
17 ; ------------------------------------------------------------------------
18 ; Place the startup code in a special segment.
23 stx spsave ; Save system stk ptr
25 ; Save space by putting some of the start-up code in a segment
26 ; that will be re-used.
30 ; Clear the BSS variables (after the constructors have been run).
34 ; Push the command-line arguments; and, call main().
38 ; Call the module destructors. This is also the exit() entry.
42 ; Restore the system stuff.
47 ; Copy back the zero-page stuff.
59 ; ------------------------------------------------------------------------
60 ; Put this code in a place that will be re-used by BSS, the heap,
65 ; Save the zero-page area that we're about to use.
67 init: ldx #zpspace - 1
76 lda #<(__MAIN_START__ + __MAIN_SIZE__)
77 ldx #>(__MAIN_START__ + __MAIN_SIZE__)
79 stx sp+1 ; Set argument stack ptr
81 ; Call the module constructors.
85 ; ------------------------------------------------------------------------