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 ((.VERSION >> 8) & $0F) + '0'
34 .byte ((.VERSION >> 4) & $0F) + '0'
35 .byte (.VERSION & $0F) + '0'
36 .byte $00 ; Zero terminated compiler version
38 ; ------------------------------------------------------------------------
39 ; Place the startup code in a special segment.
43 ; Save the zero page area we're about to use
47 sta zpsave,x ; Save the zero page locations we need
55 ; Unprotect columns 0 and 1
62 ; Save system stuff and setup the stack
65 stx spsave ; Save system stk ptr
67 lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
69 lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
70 sta sp+1 ; Set argument stack ptr
72 ; Call module constructors
76 ; Push arguments and call main()
80 ; Call module destructors. This is also the _exit entry.
82 _exit: jsr donelib ; Run module destructors
84 ; Restore system stuff
91 ; Copy back the zero page stuff
103 ; ------------------------------------------------------------------------