2 ; Startup code for cc65 (Oric version)
4 ; By Debrune Jérôme <jede@oric.org> and Ullrich von Bassewitz <uz@cc65.org>
5 ; 2014-08-22, Greg King
9 .export __STARTUP__ : absolute = 1 ; Mark as startup
10 .import initlib, donelib
11 .import callmain, zerobss
12 .import __RAM_START__, __RAM_SIZE__
13 .import __ZPSAVE_LOAD__, __STACKSIZE__
15 .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 __ZPSAVE_LOAD__ - 1 ; $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 that we're about to use.
55 ; Unprotect screen columns 0 and 1.
62 ; Save some system stuff; and, set up 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 the module constructors.
76 ; Push the command-line arguments; and, call main().
80 ; Call the module destructors. This is also the exit() entry.
82 _exit: jsr donelib ; Run module destructors
84 ; Restore the system stuff.
91 ; Copy back the zero-page stuff.
103 ; ------------------------------------------------------------------------
109 ; ------------------------------------------------------------------------