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__
20 .include "zeropage.inc"
23 ; ------------------------------------------------------------------------
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
72 sbc #>__RESERVED_MEMORY__
75 ; Call module constructors
79 ; set left margin to 0
86 ; set keyb to upper/lowercase mode
92 ; Initialize conio stuff
97 ; Push arguments and call main
101 ; Call module destructors. This is also the _exit entry.
103 _exit: jsr donelib ; Run module destructors
105 ; Restore system stuff
108 txs ; Restore stack pointer
110 ; restore left margin
127 ; Copy back the zero page stuff
144 ; *** end of main startup code
169 .word RUNAD ; defined in atari.h
171 .word __STARTUP_LOAD__ + 1