]> git.sur5r.net Git - cc65/blobdiff - libsrc/atari/crt0.s
no TGI_ERR_NO_MEM or TGI_ERR_NO_IOCB anymore: replaced by TGI_ERR_NO_RES
[cc65] / libsrc / atari / crt0.s
index 5c5607e0c9518825361e1d8c897d4b88d2640f83..8edc4046f09841e2d14242272a54f58864ba6409 100644 (file)
@@ -5,17 +5,20 @@
 ;      Mark Keates
 ;      Freddy Offenga
 ;      Christian Groessler
-;
-; This must be the *first* file on the linker command line
 ;
 
        .export         _exit
+        .export         __STARTUP__ : absolute = 1      ; Mark as startup
        .constructor    initsp, 26
 
        .import         initlib, donelib, callmain
                .import         zerobss, pushax
        .import         _main, __filetab, getfd
-       .import         __CODE_LOAD__, __BSS_LOAD__
+       .import         __STARTUP_LOAD__, __ZPSAVE_LOAD__
+       .import         __RESERVED_MEMORY__
+.ifdef DYNAMIC_DD
+       .import         __getdefdev
+.endif
 
         .include        "zeropage.inc"
        .include        "atari.inc"
 
        .segment "EXEHDR"
        .word   $FFFF
-       .word   __CODE_LOAD__
-       .word   __BSS_LOAD__ - 1
+       .word   __STARTUP_LOAD__
+       .word   __ZPSAVE_LOAD__ - 1
 
 ; ------------------------------------------------------------------------
 ; Actual code
 
-.code
+       .segment        "STARTUP"
 
        rts     ; fix for SpartaDOS / OS/A+
                ; they first call the entry point from AUTOSTRT and
@@ -65,14 +68,20 @@ L1: lda     sp,x
        lda     APPMHI+1
        sta     appmsav+1
 
+       sec
        lda     MEMTOP
+       sbc     #<__RESERVED_MEMORY__
        sta     APPMHI                  ; initialize our APPMHI value
-       ldx     MEMTOP+1
-       stx     APPMHI+1
+       lda     MEMTOP+1
+       sbc     #>__RESERVED_MEMORY__
+       sta     APPMHI+1
 
 ; Call module constructors
 
        jsr     initlib
+.ifdef DYNAMIC_DD
+       jsr     __getdefdev
+.endif
 
 ; set left margin to 0
 
@@ -155,6 +164,8 @@ L2: lda     zpsave,x
 
 ; setup sp
 
+.segment        "INIT"
+
 initsp:
        lda     APPMHI
        sta     sp
@@ -162,7 +173,7 @@ initsp:
        sta     sp+1
        rts
 
-       .data
+.segment        "ZPSAVE"
 
 zpsave:        .res    zpspace
 
@@ -174,6 +185,6 @@ old_shflok: .res    1
 old_lmargin:   .res    1
 
        .segment "AUTOSTRT"
-       .word   $02E0
-       .word   $02E1
-       .word   __CODE_LOAD__ + 1
+       .word   RUNAD                   ; defined in atari.h
+       .word   RUNAD+1
+       .word   __STARTUP_LOAD__ + 1