2 ; Startup code for cc65 (ATARI version)
4 ; Contributing authors:
12 .export __STARTUP__ : absolute = 1 ; Mark as startup
14 .import initlib, donelib
15 .import callmain, zerobss
16 .import __STARTUP_LOAD__, __ZPSAVE_LOAD__
17 .import __RESERVED_MEMORY__
19 .include "zeropage.inc"
22 ; ------------------------------------------------------------------------
28 .word __STARTUP_LOAD__
29 .word __ZPSAVE_LOAD__ - 1
31 ; ------------------------------------------------------------------------
36 rts ; fix for SpartaDOS / OS/A+
37 ; they first call the entry point from AUTOSTRT and
38 ; then the load addess (this rts here).
39 ; We point AUTOSTRT directly after the rts.
43 ; Save the zero page locations we need
63 sta appmsav ; remember old APPMHI value
69 sbc #<__RESERVED_MEMORY__
70 sta APPMHI ; initialize our APPMHI value
71 sta sp ; setup runtime stack part 1
73 sbc #>__RESERVED_MEMORY__
75 sta sp+1 ; setup runtime stack part 2
77 ; Call module constructors
81 ; Set left margin to 0
88 ; Set keyb to upper/lowercase mode
94 ; Initialize conio stuff
99 ; Push arguments and call main
103 ; Call module destructors. This is also the _exit entry.
105 _exit: jsr donelib ; Run module destructors
107 ; Restore system stuff
110 txs ; Restore stack pointer
112 ; Restore left margin
129 ; Copy back the zero page stuff
146 ; *** end of main startup code
148 ; ------------------------------------------------------------------------
154 ; ------------------------------------------------------------------------
164 .word RUNAD ; defined in atari.h
166 .word __STARTUP_LOAD__ + 1