]> git.sur5r.net Git - cc65/commitdiff
Move initialization code into the init segment
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 26 Feb 2005 09:06:46 +0000 (09:06 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 26 Feb 2005 09:06:46 +0000 (09:06 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@3404 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/common/_heap.s
libsrc/common/zerobss.s
libsrc/runtime/condes.s
libsrc/runtime/stkchk.s

index 30b89b81e3e3d8651408fafa3c6a5ae2112da781..5b45b85cc33051a2f92a68694b094be1f46c7f11 100644 (file)
@@ -27,7 +27,7 @@ __heaplast:
 
 ; Initialization. Will be called from startup!
 
-.code
+.segment        "INIT"
 
 initheap:
        sec
@@ -39,3 +39,4 @@ initheap:
        sta     __heapend+1
        rts
 
+                      
index 321a1f560a05231c91baec27114e41fd001ebb6c..321424efac8ab86d6a764d17a7688a7f3f3b19c2 100644 (file)
@@ -1,5 +1,5 @@
 ;
-; Ullrich von Bassewitz, 17.09.1998
+; Ullrich von Bassewitz, 1998-09-17, 2005-02-26.
 ;
 ; Zero the bss segment.
 ;
@@ -9,7 +9,7 @@
        .importzp       ptr1
 
 
-.code
+.segment "INIT"
 
 zerobss:
        lda     #<__BSS_RUN__
index 2a2692a7be51bd9f376da21a60eaf63d52d22b5d..c94e41252285292f8aac50e6d28e80ba0f05e6d3 100644 (file)
 
         .macpack        cpu
 
-.code
-
 ; --------------------------------------------------------------------------
 ; Initialize library modules
 
+.segment        "INIT"
+
 .proc  initlib
 
-       ldy     #<(__CONSTRUCTOR_COUNT__*2)
+       ldy     #<(__CONSTRUCTOR_COUNT__*2)
                beq     exit
-       lda     #<__CONSTRUCTOR_TABLE__
-       ldx     #>__CONSTRUCTOR_TABLE__
+       lda     #<__CONSTRUCTOR_TABLE__
+       ldx     #>__CONSTRUCTOR_TABLE__
         jmp     condes
 exit:   rts
 
@@ -40,13 +40,16 @@ exit:   rts
 ; --------------------------------------------------------------------------
 ; Cleanup library modules
 
+.code
+
 .proc  donelib
 
        ldy     #<(__DESTRUCTOR_COUNT__*2)
-       beq     initlib::exit
+       beq     exit
        lda     #<__DESTRUCTOR_TABLE__
        ldx     #>__DESTRUCTOR_TABLE__
        jmp     condes
+exit:   rts
 
 .endproc
 
index 40e70efbb4db2572dc688083b7164e634810c42b..40ccde3dc12ce2cd49ad98ed326a1b4be1ea6ad0 100644 (file)
        ; Use macros for better readability
        .macpack        generic
 
-.code
 
 ; ----------------------------------------------------------------------------
 ; Initialization code. This is a constructor, so it is called on startup if
 ; the linker has detected references to this module.
 
+.segment        "INIT"
+
 .proc  initstkchk
 
-       lda     sp
-       sta     initialsp
-       sub     #<__STACKSIZE__
-       sta     lowwater
-       lda     sp+1
-       sta     initialsp+1
-       sbc     #>__STACKSIZE__
-       add     #1                      ; Add 256 bytes safety area
-       sta     lowwater+1
-       rts
+       lda     sp
+       sta     initialsp
+       sub     #<__STACKSIZE__
+       sta     lowwater
+       lda     sp+1
+       sta     initialsp+1
+       sbc     #>__STACKSIZE__
+       add     #1                      ; Add 256 bytes safety area
+       sta     lowwater+1
+       rts
 
 .endproc
 
 ; 6502 stack checking routine. Does not need to save any registers.
 ; Safety zone for the hardware stack is 12 bytes.
 
+.code
+
 stkchk:        tsx
                cpx     #12
                bcc     Fail            ; Jump on stack overflow
-       rts                     ; Return if ok
+       rts                     ; Return if ok
 
 ; ----------------------------------------------------------------------------
 ; C stack checking routine. Does not need to save any registers.
 
+.code
+
 cstkchk:
 
 ; Check the high byte of the software stack
@@ -101,4 +106,4 @@ initialsp:  .word   0
 lowwater:      .word   0
 
 
-                  
+