Re: [cc65] "Code generation messed up"

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2013-10-06 21:39:37
On Sat, Oct 05, 2013 at 09:03:59PM +0200, Oliver Schmidt wrote:
>   Internal compiler error:
>   Code generation messed up: StackPtr is -4, should be -2

The code from revision 5721 seems to be broken. The problem does not only
appear for the '*' operator, but also for '&', '^' and '|'.

A workaround that is easy to apply is to remove the "GEN_COMM" flag from the
following tables in expr.c:

----------------------------------------------------------------------------
Index: expr.c
===================================================================
--- expr.c      (revision 6223)
+++ expr.c      (working copy)
@@ -2328,7 +2328,7 @@
 /* Process * and / operators. */
 {
     static const GenDesc hie9_ops[] = {
-        { TOK_STAR,     GEN_NOPUSH | GEN_COMM,  g_mul   },
+        { TOK_STAR,     GEN_NOPUSH,             g_mul   },
         { TOK_DIV,      GEN_NOPUSH,             g_div   },
         { TOK_MOD,      GEN_NOPUSH,             g_mod   },
         { TOK_INVALID,  0,                      0       }
@@ -2792,7 +2792,7 @@
 /* Handle & (bitwise and) */
 {
     static const GenDesc hie4_ops[] = {
-        { TOK_AND,      GEN_NOPUSH | GEN_COMM,  g_and   },
+        { TOK_AND,      GEN_NOPUSH,             g_and   },
         { TOK_INVALID,  0,                      0       }
     };
     int UsedGen;
@@ -2806,7 +2806,7 @@
 /* Handle ^ (bitwise exclusive or) */
 {
     static const GenDesc hie3_ops[] = {
-        { TOK_XOR,      GEN_NOPUSH | GEN_COMM,  g_xor   },
+        { TOK_XOR,      GEN_NOPUSH,             g_xor   },
         { TOK_INVALID,  0,                      0       }
     };
     int UsedGen;
@@ -2820,7 +2820,7 @@
 /* Handle | (bitwise or) */
 {
     static const GenDesc hie2_ops[] = {
-        { TOK_OR,       GEN_NOPUSH | GEN_COMM,  g_or    },
+        { TOK_OR,       GEN_NOPUSH,             g_or    },
         { TOK_INVALID,  0,                      0       }
     };
     int UsedGen;
----------------------------------------------------------------------------

The patch disables the code from revision 5721 for the operators named above.
Alternatively, revision 5721 could be reverted as a whole. I haven't tried
that, however. Because of later changes, this has probably to be done
manually.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
Encrypted email preferred                          PGP Key-Id: 29D93B10
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Oct 6 21:39:46 2013

This archive was generated by hypermail 2.1.8 : 2013-10-06 21:39:49 CEST