Re: [cc65] Unexpected behaviour with equality

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2014-10-13 20:47:56
Hi!

On Sat, Oct 11, 2014 at 12:16:59PM +1300, Neil Stockbridge wrote:
> I seem to be getting different results from an equality comparison
> depending on whether the constant is on the left-hand side or not with
> cc65 V2.13.3.

The following patch for src/cc65/coptstop.c will fix the problem. It is
against the last snapshot version (release 5990), so you might need to apply
it manually to other versions.

------------------------------------------------------------------------------
--- coptstop.c  2014-10-13 20:14:03.620960243 +0200
+++ coptstop.new        2014-10-13 20:13:56.337197959 +0200
@@ -759,8 +759,12 @@
         InsertEntry (D, X, D->IP++);

         /* Lhs load entries can be removed */
-        D->Lhs.X.Flags |= LI_REMOVE;
-        D->Lhs.A.Flags |= LI_REMOVE;
+        if (LoadX->AM != AM65_IMM) {
+            D->Lhs.X.Flags |= LI_REMOVE;
+        }
+        if (LoadA->AM != AM65_IMM) {
+            D->Lhs.A.Flags |= LI_REMOVE;
+        }

     } else if ((D->Rhs.A.Flags & (LI_DIRECT | LI_RELOAD_Y)) == LI_DIRECT &&
                (D->Rhs.X.Flags & (LI_DIRECT | LI_RELOAD_Y)) == LI_DIRECT) {
@@ -783,8 +787,12 @@
         InsertEntry (D, X, D->IP++);

         /* Rhs load entries can be removed */
-        D->Rhs.X.Flags |= LI_REMOVE;
-        D->Rhs.A.Flags |= LI_REMOVE;
+        if (LoadX->AM != AM65_IMM) {
+            D->Rhs.X.Flags |= LI_REMOVE;
+        }
+        if (LoadA->AM != AM65_IMM) {
+            D->Rhs.A.Flags |= LI_REMOVE;
+        }

     } else if ((D->Rhs.A.Flags & LI_DIRECT) != 0 &&
                (D->Rhs.X.Flags & LI_DIRECT) != 0) {
------------------------------------------------------------------------------

Thanks for the report!

Best 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 Mon Oct 13 20:48:11 2014

This archive was generated by hypermail 2.1.8 : 2014-10-13 20:48:14 CEST