2 ; Startup code for cc65 (Apple2 version)
4 ; This must be the *first* file on the linker command line
8 .import initlib, donelib
10 .import __STARTUP_LOAD__, __BSS_LOAD__ ; Linker generated
13 .include "zeropage.inc"
16 ; ------------------------------------------------------------------------
17 ; The executable header
21 .word __STARTUP_LOAD__ ; Start address
22 .word __BSS_LOAD__ - __STARTUP_LOAD__ ; Size
24 ; ------------------------------------------------------------------------
25 ; Create an empty LOWCODE segment to avoid linker warnings
29 ; ------------------------------------------------------------------------
30 ; Place the startup code in a special segment.
36 sta zpsave,x ; Save the zero page locations we need
44 ; Save system stuff and setup the stack
47 stx spsave ; Save the system stack ptr
52 sta sp+1 ; Set argument stack ptr
54 ; Call module constructors
58 ; Initialize conio stuff
63 ; Set up to use Apple ROM $C000-$CFFF
67 ; Push arguments and call main()
71 ; Call module destructors. This is also the _exit entry.
75 ; Restore system stuff
77 lda #$ff ; Reset text mode
81 txs ; Restore stack pointer
83 ; Copy back the zero page stuff
91 ; Reset changed vectors, back to basic
95 ; ------------------------------------------------------------------------