2 ; Startup code for cc65 (ATARI version)
4 ; Contributing authors:
11 .export __STARTUP__ : absolute = 1 ; Mark as startup
12 .constructor initsp, 26
14 .import initlib, donelib, callmain
15 .import zerobss, pushax
16 .import _main, __filetab, getfd
17 .import __STARTUP_LOAD__, __ZPSAVE_LOAD__
18 .import __RESERVED_MEMORY__
23 .include "zeropage.inc"
26 ; ------------------------------------------------------------------------
31 .word __STARTUP_LOAD__
32 .word __ZPSAVE_LOAD__ - 1
34 ; ------------------------------------------------------------------------
39 rts ; fix for SpartaDOS / OS/A+
40 ; they first call the entry point from AUTOSTRT and
41 ; then the load addess (this rts here).
42 ; We point AUTOSTRT directly after the rts.
46 ; Save the zero page locations we need
66 sta appmsav ; remember old APPMHI value
72 sbc #<__RESERVED_MEMORY__
73 sta APPMHI ; initialize our APPMHI value
75 sbc #>__RESERVED_MEMORY__
78 ; Call module constructors
85 ; set left margin to 0
92 ; set keyb to upper/lowercase mode
98 ; Initialize conio stuff
103 ; Push arguments and call main
107 ; Call module destructors. This is also the _exit entry.
109 _exit: jsr donelib ; Run module destructors
111 ; Restore system stuff
114 txs ; Restore stack pointer
116 ; restore left margin
133 ; Copy back the zero page stuff
150 ; *** end of main startup code
175 .word RUNAD ; defined in atari.h
177 .word __STARTUP_LOAD__ + 1