2 ; Startup code for cc65 (ATARI version)
4 ; Contributing authors:
12 .export __STARTUP__ : absolute = 1 ; Mark as startup
14 .import initlib, donelib
15 .import callmain, zerobss
16 .import __STARTUP_LOAD__, __BSS_LOAD__
17 .import __RESERVED_MEMORY__
19 .include "zeropage.inc"
22 ; ------------------------------------------------------------------------
28 .word __STARTUP_LOAD__
29 .word __BSS_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.
55 sta appmsav ; remember old APPMHI value
61 sbc #<__RESERVED_MEMORY__
62 sta APPMHI ; initialize our APPMHI value
63 sta sp ; setup runtime stack part 1
65 sbc #>__RESERVED_MEMORY__
67 sta sp+1 ; setup runtime stack part 2
69 ; Call module constructors
73 ; Set left margin to 0
80 ; Set keyb to upper/lowercase mode
86 ; Initialize conio stuff
91 ; Push arguments and call main
95 ; Call module destructors. This is also the _exit entry.
97 _exit: jsr donelib ; Run module destructors
99 ; Restore system stuff
102 txs ; Restore stack pointer
104 ; Restore left margin
130 ; *** end of main startup code
132 ; ------------------------------------------------------------------------
143 .word RUNAD ; defined in atari.inc
145 .word __STARTUP_LOAD__ + 1