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 getargs, argc, argv
16 .import initlib, donelib
17 .import zerobss, pushax
18 .import _main,__filetab,getfd
19 .import __CODE_LOAD__, __BSS_LOAD__
21 .include "zeropage.inc"
25 ; ------------------------------------------------------------------------
31 .word __BSS_LOAD__ - 1
33 ; ------------------------------------------------------------------------
38 rts ; fix for SpartaDOS / OS/A+
39 ; they first call the entry point from AUTOSTRT and
40 ; then the load addess (this rts here).
41 ; We point AUTOSTRT directly after the rts.
45 ; Save the zero page locations we need
65 sta appmsav ; remember old APPMHI value
70 sta APPMHI ; initialize our APPMHI value
74 ; Call module constructors
78 ; set left margin to 0
85 ; set keyb to upper/lowercase mode
91 ; Initialize conio stuff
96 ; set stdio stream handles
100 sta __filetab + (0 * _FILE_size) ; setup stdin
103 sta __filetab + (1 * _FILE_size) ; setup stdout
106 sta __filetab + (2 * _FILE_size) ; setup stderr
108 ; Pass command line if present
119 ldy #4 ; Argument size
120 jsr _main ; call the users code
122 ; Call module destructors. This is also the _exit entry.
124 _exit: jsr donelib ; Run module destructors
126 ; Restore system stuff
129 txs ; Restore stack pointer
131 ; restore left margin
148 ; Copy back the zero page stuff
165 ; *** end of main startup code
190 .word __CODE_LOAD__ + 1