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 __ZPSAVE_LOAD__, __STACKSIZE__
14 .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 __ZPSAVE_LOAD__ - 1 ; $2AB
30 .dbyt __RAM_START__ ; $2A9
32 .byte ((.VERSION >> 8) & $0F) + '0'
33 .byte ((.VERSION >> 4) & $0F) + '0'
34 .byte (.VERSION & $0F) + '0'
35 .byte $00 ; Zero terminated compiler version
37 ; ------------------------------------------------------------------------
38 ; Place the startup code in a special segment.
42 ; Save the zero page area we're about to use
46 sta zpsave,x ; Save the zero page locations we need
54 ; Unprotect columns 0 and 1
61 ; Save system stuff and setup the stack
64 stx spsave ; Save system stk ptr
66 lda #<(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
68 lda #>(__RAM_START__ + __RAM_SIZE__ + __STACKSIZE__)
69 sta sp+1 ; Set argument stack ptr
71 ; Call module constructors
75 ; Push arguments and call main()
79 ; Call module destructors. This is also the _exit entry.
81 _exit: jsr donelib ; Run module destructors
83 ; Restore system stuff
90 ; Copy back the zero page stuff
102 ; ------------------------------------------------------------------------
108 ; ------------------------------------------------------------------------