]> git.sur5r.net Git - cc65/commitdiff
First condes feature test
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 20 Nov 2000 23:05:52 +0000 (23:05 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Mon, 20 Nov 2000 23:05:52 +0000 (23:05 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@463 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/c64/crt0.s
libsrc/common/Makefile
libsrc/common/atexit.s
libsrc/common/doatexit.s [deleted file]
libsrc/runtime/condes.s

index 885775414374210dedb822f878aef657760b0e8d..5730fd758edb12c5ab300bbc6341ae97eab6a95a 100644 (file)
@@ -5,9 +5,12 @@
 ;
 
        .export         _exit
-               .import         __hinit, initconio, zerobss, push0, doatexit
+               .import         __hinit, initconio, zerobss, push0, condes
        .import         _main
 
+               .import         __CONSTRUCTOR_TABLE__, __CONSTRUCTOR_COUNT__
+       .import         __DESTRUCTOR_TABLE__, __DESTRUCTOR_COUNT__
+
        .include        "c64.inc"
        .include        "../cbm/cbm.inc"
 
@@ -105,11 +108,16 @@ L1:       lda     sp,x
        ldy     #4              ; Argument size
                jsr     _main           ; call the users code
 
-; fall thru to exit...
+; Call module destructors
+
+_exit: lda     #<__DESTRUCTOR_TABLE__
+       ldx     #>__DESTRUCTOR_TABLE__
+       ldy     #<(__DESTRUCTOR_COUNT__*2)
+       jsr     condes
 
-_exit: jsr     doatexit        ; call exit functions
+; Restore system stuff
 
-       ldx     spsave
+       ldx     spsave
        txs                     ; Restore stack pointer
                lda     mmusave
        sta     $01             ; Restore memory configuration
index dd6c2963b66ec140454d9bfeacf495b48e412dfc..1e64b0b8a3169622fb4a51c92215aa884f9d1e7d 100644 (file)
@@ -33,7 +33,6 @@ S_OBJS =      _fdesc.o        \
                atexit.o        \
                atoi.o          \
                copydata.o      \
-               doatexit.o      \
                errno.o         \
                fmisc.o         \
                free.o          \
index 14ba9c26d86f3121801b57368d6937efd5ada158..74190886be1613e1d2d16b38a7081815945959ec 100644 (file)
@@ -5,12 +5,13 @@
 ;
 
        .export         _atexit
-       .import         exitfunc_table, exitfunc_index
-       .importzp       exitfunc_max
+               .destructor     doatexit, 16
        .import         __errno
+       .import         jmpvec
 
        .include        "errno.inc"
 
+; ---------------------------------------------------------------------------
 
 .proc  _atexit
 
 
 
 
+; ---------------------------------------------------------------------------
+
+.code
+
+.proc  doatexit
+
+               ldy     exitfunc_index          ; Get index
+               beq     @L9                     ; Jump if done
+       dey
+       lda     exitfunc_table,y
+       sta     jmpvec+2
+       dey
+       lda     exitfunc_table,y
+       sta     jmpvec+1
+       sty     exitfunc_index
+       jsr     jmpvec                  ; Call the function
+       jmp     doatexit                ; Next one
+
+@L9:   rts
+
+.endproc
+
+
+
+; ---------------------------------------------------------------------------
+
+.bss
+exitfunc_index:        .res    1       ; Index into table, inc'ed by 2
+exitfunc_table:        .res    10      ; 5 exit functions
+exitfunc_max   = <(* - exitfunc_table)
+
 
diff --git a/libsrc/common/doatexit.s b/libsrc/common/doatexit.s
deleted file mode 100644 (file)
index 39265cf..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-;
-; Ullrich von Bassewitz, 26.10.2000
-;
-; Handle exit functions
-;
-
-       .export         doatexit, exitfunc_index, exitfunc_table
-               .exportzp       exitfunc_max
-       .import         jmpvec
-
-.bss
-exitfunc_index:        .res    1       ; Index into table, inc'ed by 2
-exitfunc_table:        .res    10      ; 5 exit functions
-exitfunc_max   = <(* - exitfunc_table)
-
-
-.code
-
-.proc  doatexit
-
-               ldy     exitfunc_index          ; Get index
-               beq     @L9                     ; Jump if done
-       dey
-       lda     exitfunc_table,y
-       sta     jmpvec+2
-       dey
-       lda     exitfunc_table,y
-       sta     jmpvec+1
-       sty     exitfunc_index
-       jsr     jmpvec                  ; Call the function
-       jmp     doatexit                ; Next one
-
-@L9:   rts
-
-.endproc
-
-
-
index f0a1fabb72fdcc92a5eb36b7cfedb91965dc2065..099c3e4bf8049fd992c85fb79bfef6f5d4598329 100644 (file)
@@ -26,6 +26,7 @@ loop: ldy     index
        dey
        jsr     getbyt
        sta     jmpvec+1
+       sty     index
        jsr     jmpvec
        jmp     loop