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__
12 .import __BSS_LOAD__, __STACKSIZE__
14 .include "zeropage.inc"
18 ; ------------------------------------------------------------------------
23 .byte $16, $16, $16 ; Sync bytes
24 .byte $24 ; End of header marker
28 .byte $80 ; $2AE Machine code flag
29 .byte $C7 ; $2AD Autoload flag
30 .dbyt __BSS_LOAD__ ; $2AB
31 .dbyt __RAM_START__ ; $2A9
33 .byte $00 ; Zero terminated name
35 ; ------------------------------------------------------------------------
36 ; Place the startup code in a special segment.
40 ; Save the zero page area we're about to use
44 sta zpsave,x ; Save the zero page locations we need
52 ; Unprotect columns 0 and 1
59 ; Save system stuff and setup the stack
62 stx spsave ; save system stk ptr
64 lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
66 lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
67 sta sp+1 ; Set argument stack ptr
69 ; Call module constructors
73 ; Push arguments and call main()
77 ; Call module destructors. This is also the _exit entry.
79 _exit: jsr donelib ; Run module destructors
81 ; Restore system stuff
88 ; Copy back the zero page stuff
100 ; ------------------------------------------------------------------------