2 ; Startup code for cc65 (ATARI version)
4 ; Contributing authors:
11 .export __STARTUP__ : absolute = 1 ; Mark as startup
13 .import initlib, donelib, callmain
14 .import zerobss, pushax
15 .import _main, __filetab, getfd
16 .import __STARTUP_LOAD__, __ZPSAVE_LOAD__
17 .import __RESERVED_MEMORY__
19 .include "zeropage.inc"
22 ; ------------------------------------------------------------------------
27 .word __STARTUP_LOAD__
28 .word __ZPSAVE_LOAD__ - 1
30 ; ------------------------------------------------------------------------
35 rts ; fix for SpartaDOS / OS/A+
36 ; they first call the entry point from AUTOSTRT and
37 ; then the load addess (this rts here).
38 ; We point AUTOSTRT directly after the rts.
42 ; Save the zero page locations we need
62 sta appmsav ; remember old APPMHI value
68 sbc #<__RESERVED_MEMORY__
69 sta APPMHI ; initialize our APPMHI value
70 sta sp ; setup runtime stack part 1
72 sbc #>__RESERVED_MEMORY__
74 sta sp+1 ; setup runtime stack part 2
76 ; Call module constructors
80 ; set left margin to 0
87 ; set keyb to upper/lowercase mode
93 ; Initialize conio stuff
98 ; Push arguments and call main
102 ; Call module destructors. This is also the _exit entry.
104 _exit: jsr donelib ; Run module destructors
106 ; Restore system stuff
109 txs ; Restore stack pointer
111 ; restore left margin
128 ; Copy back the zero page stuff
145 ; *** end of main startup code
159 .word RUNAD ; defined in atari.h
161 .word __STARTUP_LOAD__ + 1