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 __CODE_LOAD__, __BSS_LOAD__ ; Linker generated
13 .include "zeropage.inc"
16 ; ------------------------------------------------------------------------
17 ; The executable header
21 .word __CODE_LOAD__ ; Start address
22 .word __BSS_LOAD__ - __CODE_LOAD__ ; Size
24 ; ------------------------------------------------------------------------
31 sta zpsave,x ; Save the zero page locations we need
39 ; Save system stuff and setup the stack
42 stx spsave ; Save the system stack ptr
47 sta sp+1 ; Set argument stack ptr
49 ; Call module constructors
53 ; Initialize conio stuff
58 ; Set up to use Apple ROM $C000-$CFFF
62 ; Pass an empty command line
67 ldy #4 ; Argument size
68 jsr _main ; call the users code
70 ; Call module destructors. This is also the _exit entry.
74 ; Restore system stuff
76 lda #$ff ; Reset text mode
80 txs ; Restore stack pointer
82 ; Copy back the zero page stuff
90 ; Reset changed vectors, back to basic