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__
23 .include "zeropage.inc"
27 ; ------------------------------------------------------------------------
33 .word __BSS_LOAD__ - 1
35 ; ------------------------------------------------------------------------
40 rts ; fix for SpartaDOS / OS/A+
41 ; they first call the entry point from AUTOSTRT and
42 ; then the load addess (this rts here).
43 ; We point AUTOSTRT directly after the rts.
47 ; Save the zero page locations we need
67 sta appmsav ; remember old APPMHI value
72 sta APPMHI ; initialize our APPMHI value
76 ; Call module constructors
83 ; set left margin to 0
90 ; set keyb to upper/lowercase mode
96 ; Initialize conio stuff
101 ; set stdio stream handles
105 sta __filetab + (0 * .sizeof(_FILE)); setup stdin
108 sta __filetab + (1 * .sizeof(_FILE)); setup stdout
111 sta __filetab + (2 * .sizeof(_FILE)); setup stderr
113 ; Push arguments and call main
117 ; Call module destructors. This is also the _exit entry.
119 _exit: jsr donelib ; Run module destructors
121 ; Restore system stuff
124 txs ; Restore stack pointer
126 ; restore left margin
143 ; Copy back the zero page stuff
160 ; *** end of main startup code
185 .word __CODE_LOAD__ + 1