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 callmain, zerobss
12 .import __RAM_START__, __RAM_SIZE__, __RAM_LAST__
14 .include "zeropage.inc"
18 ; ------------------------------------------------------------------------
19 ; Create an empty LOWCODE segment to avoid linker warnings
23 ; ------------------------------------------------------------------------
28 .byte $16, $16, $16 ; Sync bytes
29 .byte $24 ; End of header marker
33 .byte $80 ; $2AE Machine code flag
34 .byte $C7 ; $2AD Autoload flag
35 .dbyt __RAM_START__ + __RAM_LAST__ ; $2AB
36 .dbyt __RAM_START__ ; $2A9
38 .byte $00 ; Zero terminated name
40 ; ------------------------------------------------------------------------
41 ; Place the startup code in a special segment.
45 ; Save the zero page area we're about to use
49 sta zpsave,x ; Save the zero page locations we need
57 ; Unprotect columns 0 and 1
64 ; Save system stuff and setup the stack
67 stx spsave ; save system stk ptr
69 lda #<(__RAM_START__ + __RAM_SIZE__)
71 lda #>(__RAM_START__ + __RAM_SIZE__)
72 sta sp+1 ; Set argument stack ptr
74 ; Call module constructors
78 ; Push arguments and call main()
82 ; Call module destructors. This is also the _exit entry.
84 _exit: jsr donelib ; Run module destructors
86 ; Restore system stuff
93 ; Copy back the zero page stuff
105 ; ------------------------------------------------------------------------