Re: [cc65] "Code generation messed up"

From: Greg King <greg.king51verizon.net>
Date: 2013-10-07 18:45:48
From: "Ullrich von Bassewitz"; on Sun., Oct. 06, 2013; at 3:39 PM -0400
>
> 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
> appear for only the '*' operator; but, also for '&', '^', and '|'.

We are lucky that the bug is simple -- a missing "else".  The result is 
that the compiler thinks that it does the opposite of what it actually 
does:  It thinks that it pushes the non-constant expression onto the stack. 
It doesn't; so, cc65's stack pointer is wrong.

I will send a Git pull request to Oliver.  Here is patch text for Uz:

Index: src/cc65/expr.c
===================================================================
--- src/cc65/expr.c (revision 5990)
+++ src/cc65/expr.c (working copy)
@@ -1952,6 +1952,7 @@ static void hie_internal (const GenDesc* Ops,   /*
      type = CF_CONST;
             if ((Gen->Flags & GEN_NOPUSH) == 0) {
                 g_push (ltype, 0);
+            } else {
                 ltype |= CF_REG;    /* Value is in register */
             }

---------------------------------------------------

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Mon Oct 7 19:49:40 2013

This archive was generated by hypermail 2.1.8 : 2013-10-07 19:49:42 CEST