2 ; Startup code for cc65 (Apple2 version)
4 ; This must be the *first* file on the linker command line
9 .import zerobss, push0, doatexit
14 ; ------------------------------------------------------------------------
15 ; Define and export the ZP variables for the C64 runtime
17 .exportzp sp, sreg, regsave
18 .exportzp ptr1, ptr2, ptr3, ptr4
19 .exportzp tmp1, tmp2, tmp3, tmp4
20 .exportzp regbank, zpspace
22 ; These zero page entries overlap with the sweet-16 registers.
23 ; must be changed if sweet-16 is to be supported
24 sp = $00 ; stack pointer
25 sreg = $02 ; secondary register/high 16 bit for longs
26 regsave = $04 ; slot to save/restore (E)AX into
35 regbank = $14 ; 6 byte register bank
36 zpspace = $1A ; Zero page space allocated
38 ; ------------------------------------------------------------------------
43 sta zpsave,y ; Save the zero page locations we need
51 ; Save system stuff and setup the stack
54 stx spsave ; Save the system stack ptr
59 sta sp+1 ; Set argument stack ptr
65 ; Initialize conio stuff
70 ; Set up to use Apple ROM $C000-$CFFF
74 ; Pass an empty command line
79 ldy #4 ; Argument size
80 jsr _main ; call the users code
82 ; fall thru to exit...
88 jsr doatexit ; call exit functions
91 txs ; Restore stack pointer
93 ; Copy back the zero page stuff
101 ; Reset changed vectors, back to basic