2 ; Startup code for cc65 (Oric version)
4 ; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
6 ; This must be the *first* file on the linker command line
10 .import initlib, donelib
11 .import push0, callmain, zerobss
12 .import __RAM_START__, __RAM_SIZE__ ; Linker generated
16 ; ------------------------------------------------------------------------
17 ; Create an empty LOWCODE segment to avoid linker warnings
21 ; ------------------------------------------------------------------------
22 ; Place the startup code in a special segment.
30 ; Save system stuff and setup the stack
33 stx spsave ; save system stk ptr
35 lda #<(__RAM_START__ + __RAM_SIZE__)
37 lda #>(__RAM_START__ + __RAM_SIZE__)
38 sta sp+1 ; Set argument stack ptr
40 ; Call module constructors
44 ; Push arguments and call main()
48 ; Call module destructors. This is also the _exit entry.
50 _exit: jsr donelib ; Run module destructors
52 ; Restore system stuff
61 ; ------------------------------------------------------------------------