]> git.sur5r.net Git - cc65/blobdiff - libsrc/pet/crt0.s
interrupt flag is cleared/restored rather than cleared/set
[cc65] / libsrc / pet / crt0.s
index 6d1849d87c6f157be7b045960ca03e8246c41471..5d4ac73329e2aafc86ac84a4719b859ddabbb9c0 100644 (file)
@@ -5,7 +5,8 @@
 ;
 
        .export         _exit
-               .import         __hinit, initconio, zerobss, push0, doatexit
+       .import         initlib, donelib
+               .import         zerobss, push0
        .import         _main
 
        .include        "pet.inc"
@@ -54,10 +55,10 @@ Head:   .word   @Next
 ; ------------------------------------------------------------------------
 ; Actual code
 
-       ldy     #zpspace-1
-L1:    lda     sp,y
-       sta     zpsave,y        ; Save the zero page locations we need
-       dey
+               ldx     #zpspace-1
+L1:    lda     sp,x
+       sta     zpsave,x        ; Save the zero page locations we need
+       dex
                bpl     L1
 
 ; Close open files
@@ -84,13 +85,9 @@ L1:  lda     sp,y
        lda     MEMSIZE+1
                sta     sp+1            ; Set argument stack ptr
 
-; Initialize the heap
+; Call module constructors
 
-       jsr     __hinit
-
-; Initialize conio stuff
-
-       jsr     initconio
+       jsr     initlib
 
 ; Pass an empty command line
 
@@ -100,19 +97,21 @@ L1:        lda     sp,y
        ldy     #4              ; Argument size
                jsr     _main           ; call the users code
 
-; fall thru to exit...
+; Call module destructors. This is also the _exit entry.
+
+_exit: jsr     donelib         ; Run module destructors
 
-_exit: jsr     doatexit        ; call exit functions
+; Restore system stuff
 
        ldx     spsave
        txs                     ; Restore stack pointer
 
 ; Copy back the zero page stuff
 
-       ldy     #zpspace-1
-L2:    lda     zpsave,y
-       sta     sp,y
-       dey
+       ldx     #zpspace-1
+L2:    lda     zpsave,x
+       sta     sp,x
+       dex
                bpl     L2
 
 ; Back to basic