From: Alan Cox Date: Sun, 18 Jan 2015 23:37:36 +0000 (+0000) Subject: 6502: C library workaround for cc65 bug X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=7f6267193bb1265b476b630e46735fd1bab59422;p=FUZIX.git 6502: C library workaround for cc65 bug --- diff --git a/Library/libs/atexit.c b/Library/libs/atexit.c index 816f5271..12914d11 100644 --- a/Library/libs/atexit.c +++ b/Library/libs/atexit.c @@ -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 */ diff --git a/Library/libs/crt0_6502.s b/Library/libs/crt0_6502.s index cfdc54e7..5a0ad8f4 100644 --- a/Library/libs/crt0_6502.s +++ b/Library/libs/crt0_6502.s @@ -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