2 ; Startup code for cc65 (ATARI version)
4 ; Contributing authors:
9 ; This must be the *first* file on the linker command line
13 .constructor initsp, 26
15 .import initlib, donelib, callmain
16 .import zerobss, pushax
17 .import _main, __filetab, getfd
18 .import __CODE_LOAD__, __BSS_LOAD__
20 .include "zeropage.inc"
24 ; ------------------------------------------------------------------------
30 .word __BSS_LOAD__ - 1
32 ; ------------------------------------------------------------------------
37 rts ; fix for SpartaDOS / OS/A+
38 ; they first call the entry point from AUTOSTRT and
39 ; then the load addess (this rts here).
40 ; We point AUTOSTRT directly after the rts.
44 ; Save the zero page locations we need
64 sta appmsav ; remember old APPMHI value
69 sta APPMHI ; initialize our APPMHI value
73 ; Call module constructors
77 ; set left margin to 0
84 ; set keyb to upper/lowercase mode
90 ; Initialize conio stuff
95 ; set stdio stream handles
99 sta __filetab + (0 * _FILE_size) ; setup stdin
102 sta __filetab + (1 * _FILE_size) ; setup stdout
105 sta __filetab + (2 * _FILE_size) ; setup stderr
107 ; Push arguments and call main
111 ; Call module destructors. This is also the _exit entry.
113 _exit: jsr donelib ; Run module destructors
115 ; Restore system stuff
118 txs ; Restore stack pointer
120 ; restore left margin
137 ; Copy back the zero page stuff
154 ; *** end of main startup code
179 .word __CODE_LOAD__ + 1