diff options
Diffstat (limited to 'src/crt0.s')
| -rw-r--r-- | src/crt0.s | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/crt0.s b/src/crt0.s new file mode 100644 index 0000000..6ffb2ce --- /dev/null +++ b/src/crt0.s @@ -0,0 +1,62 @@ +; +; Startup code for cc65 (ATARI version) +; +; Contributing authors: +; Mark Keates +; Freddy Offenga +; Christian Groessler +; Stefan Haubenthal +; + +; Hacked up, trimmed down version for fnchat. + + .export __STARTUP__ : absolute = 1 ; Mark as startup + .export _exit, start + + .import _main, zerobss + .import __RESERVED_MEMORY__ + .import __MAIN_START__, __MAIN_SIZE__ + .import __LOWCODE_RUN__, __LOWCODE_SIZE__ + .include "zeropage.inc" + .include "atari.inc" + +; ------------------------------------------------------------------------ + +.segment "STARTUP" + _exit = WARMSV ; nothing should be calling exit() anyway. + + rts ; fix for SpartaDOS / OS/A+ + ; They first call the entry point from AUTOSTRT; and + ; then, the load address (this rts here). + ; We point AUTOSTRT directly after the rts. + +; Real entry point: + +start: + +; Clear the BSS data. + jsr zerobss + +; Set up the stack + lda MEMTOP + sta sp + lda MEMTOP+1 + sta sp+1 + +; Set the keyboard to upper-/lower-case mode. + ldy #0 + sty SHFLOK + dey ; Set Y to $FF + sty CH ; remove keypress which might be in the input buffer + +; Go directly to main(). No support for CLI arguments, no saving +; any machine state for a clean exit, because we don't exit. + jmp _main + +; ------------------------------------------------------------------------ + +.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 |
