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
9 .import initlib, donelib
10 .import callmain, zerobss
11 .import __RAM_START__, __RAM_SIZE__, __BSS_LOAD__
13 .include "zeropage.inc"
17 ; ------------------------------------------------------------------------
22 .byte $16, $16, $16 ; Sync bytes
23 .byte $24 ; End of header marker
27 .byte $80 ; $2AE Machine code flag
28 .byte $C7 ; $2AD Autoload flag
29 .dbyt __BSS_LOAD__ ; $2AB
30 .dbyt __RAM_START__ ; $2A9
32 .byte $00 ; Zero terminated name
34 ; ------------------------------------------------------------------------
35 ; Place the startup code in a special segment.
39 ; Save the zero page area we're about to use
43 sta zpsave,x ; Save the zero page locations we need
51 ; Unprotect columns 0 and 1
58 ; Save system stuff and setup the stack
61 stx spsave ; save system stk ptr
63 lda #<(__RAM_START__ + __RAM_SIZE__)
65 lda #>(__RAM_START__ + __RAM_SIZE__)
66 sta sp+1 ; Set argument stack ptr
68 ; Call module constructors
72 ; Push arguments and call main()
76 ; Call module destructors. This is also the _exit entry.
78 _exit: jsr donelib ; Run module destructors
80 ; Restore system stuff
87 ; Copy back the zero page stuff
99 ; ------------------------------------------------------------------------