]> git.sur5r.net Git - cc65/blobdiff - libsrc/geos/devel/crt0.s
Fixed problems that were introduced with r4287.
[cc65] / libsrc / geos / devel / crt0.s
index 788a0aeb8e08f3fdccec235776a30df5b84bfd45..6d85a963107cb3d2f1cb154df3b7940b30290eb8 100644 (file)
@@ -1,48 +1,23 @@
 ;
-; This must be the *second* file on the linker command line
-; (.cvt header must be the *first* one)
-
-; Maciej 'YTM/Alliance' Witkowiak
-; 26.10.99, 10.3.2000
+; Startup code for geos
+;
+; Maciej 'YTM/Elysium' Witkowiak
+; 26.10.99, 10.3.2000, 15.8.2001, 23.12.2002
 
-; no __hinit
+       .export         _exit
+        .export         __STARTUP__ : absolute = 1      ; Mark as startup
 
-       .export         _exit  
+       .import         __RAM_START__, __RAM_SIZE__     ; Linker generated
        .import         initlib, donelib
-               .import         pushax
-       .import         _main
+       .import         callmain
        .import         zerobss
+       .importzp       sp
+       .include        "../inc/jumptab.inc"
 
 ; ------------------------------------------------------------------------
-; Define and export the ZP variables for the C64 runtime
-
-       .exportzp       sp, sreg, regsave, regbank
-       .exportzp       ptr1, ptr2, ptr3, ptr4
-       .exportzp       tmp1, tmp2, tmp3, tmp4
+; Place the startup code in a special segment.
 
-sp             =       $72             ; stack pointer
-sreg   =       $74             ; secondary register/high 16 bit for longs
-regsave        =       $76             ; slot to save/restore (E)AX into
-ptr1   =       $7A             ;
-ptr2   =       $7C
-ptr3   =       $7E
-ptr4   =       $70
-tmp1   =       $fb
-tmp2   =       $fc
-tmp3   =       $fd
-tmp4   =       $fe
-
-regbank =      $a3             ; 6 bytes hopefully not used by Kernal
-
-; ------------------------------------------------------------------------
-
-;      .org $0400-508          ; $0400 - length of .cvt header
-;      .include "cvthead.s"
-
-       .reloc
-
-; ------------------------------------------------------------------------
-; Actual code
+.segment               "STARTUP"
 
 ; Clear the BSS data
 
@@ -50,30 +25,22 @@ regbank =   $a3             ; 6 bytes hopefully not used by Kernal
 
 ; Setup stack
 
-       lda     #<$7900
+       lda     #<(__RAM_START__ + __RAM_SIZE__)
        sta     sp
-       lda     #>$7900
+       lda     #>(__RAM_START__ + __RAM_SIZE__)
                sta     sp+1            ; Set argument stack ptr
 
 ; Call module constructors
 
        jsr     initlib
 
-; Pass an empty command line
-
-       lda     #0
-       tax
-       jsr     pushax          ; argc
-       jsr     pushax          ; argv
+; Push arguments and call main()
 
-       ldy     #4              ; Argument size
-               jsr     _main           ; call the users code
-       jmp     $c1c3           ; jump to GEOS MainLoop
+       cli
+               jsr     callmain
 
-; Call module destructors. This is also the _exit entry which must be called
-; explicitly by the code.
+; Call module destructors.
 
 _exit: jsr     donelib         ; Run module destructors
 
-       jmp     $c22c           ; EnterDeskTop
-                        
+       jmp     EnterDeskTop    ; return control to the system