6502: C library workaround for cc65 bug
authorAlan Cox <alan@linux.intel.com>
Sun, 18 Jan 2015 23:37:36 +0000 (23:37 +0000)
committerAlan Cox <alan@linux.intel.com>
Sun, 18 Jan 2015 23:37:36 +0000 (23:37 +0000)
Library/libs/atexit.c
Library/libs/crt0_6502.s

index 816f527..12914d1 100644 (file)
@@ -30,8 +30,11 @@ struct exit_table __on_exit_table[MAXONEXIT];
 
 void __do_exit(int rv)
 {
-       register int count = __on_exit_count - 1;
-       register vfuncp ptr;
+       /* Static to work around a bug in cc65 */
+       static int count;
+       vfuncp ptr;
+
+       count = __on_exit_count - 1;
        __on_exit_count = -1;   /* ensure no more will be added */
 
        /* In reverse order */
index cfdc54e..5a0ad8f 100644 (file)
@@ -64,7 +64,7 @@ l1:   sta     _environ
 
 ; Call the module destructors. This is also the exit() entry.
 
-       jmp     _exit           ; exit syscall, AX holds our return code
+       jmp     _exit           ; exit cleanup, AX holds our return code
                                ; for a fastcall return to nowhere.
 
 initmainargs:                  ; Hardcoded compiler dumbness