;
.export __STARTUP__ : absolute = 1 ; Mark as startup
- .export _exit, start
+ .export _exit, start, excexit, SP_save
.import initlib, donelib
.import callmain, zerobss
.import __RESERVED_MEMORY__
.import __MAIN_START__, __MAIN_SIZE__
+ .import __LOWCODE_RUN__, __LOWCODE_SIZE__
.ifdef __ATARIXL__
.import __STACKSIZE__
.import sram_init
; Call the module destructors. This is also the exit() entry.
-_exit: jsr donelib ; Run module destructors
+_exit: ldx SP_save
+ txs ; Restore stack pointer
; Restore the system stuff.
- ldx SP_save
- txs ; Restore stack pointer
+excexit:jsr donelib ; Run module destructors; 'excexit' is called from the exec routine
; Restore the left margin.
.ifndef __ATARIXL__
APPMHI_save: .res 2
.endif
+
+; ------------------------------------------------------------------------
+
+.segment "LOWCODE" ; have at least one (empty) segment of LOWCODE, so that the next line works even if the program doesn't make use of this segment
+.assert (__LOWCODE_RUN__ + __LOWCODE_SIZE__ <= $4000 || __LOWCODE_RUN__ > $7FFF || __LOWCODE_SIZE__ = 0), warning, "'lowcode area' reaches into $4000..$7FFF bank memory window"
+; check for LOWBSS_SIZE = 0 not needed since the only file which uses LOWBSS (irq.s) also uses LOWCODE
+; check for LOWCODE_RUN > $7FFF is mostly for cartridges, where this segment is loaded high (into cart ROM)
+; there is a small chance that if the user loads the program really high, LOWCODE is above $7FFF, but LOWBSS is below -- no warning emitted in this case