changeset 475:91c4c7d64f5e

From Joshua Phillips, fix dereferences used in inline assembly output.
author Rob Landley <rob@landley.net>
date Wed, 05 Sep 2007 18:08:08 -0500
parents 254e8668fb9d
children 70a99da12bb7
files tccasm.c tests/tcctest.c
diffstat 2 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/tccasm.c	Wed Sep 05 17:59:54 2007 -0500
+++ b/tccasm.c	Wed Sep 05 18:08:08 2007 -0500
@@ -806,7 +806,7 @@
             sv = *op->vt;
             if (op->reg >= 0) {
                 sv.r = op->reg;
-                if ((op->vt->r & VT_VALMASK) == VT_LLOCAL)
+                if ((op->vt->r & VT_VALMASK) == VT_LLOCAL && op->is_memory)
                     sv.r |= VT_LVAL;
             }
             subst_asm_operand(out_str, &sv, modifier);
--- a/tests/tcctest.c	Wed Sep 05 17:59:54 2007 -0500
+++ b/tests/tcctest.c	Wed Sep 05 18:08:08 2007 -0500
@@ -2069,6 +2069,12 @@
 
 unsigned int set;
 
+int asm_func(int *x)
+{
+  asm("xorl %0,%0":"=r"(*x));
+  return *x;
+}
+
 void asm_test(void)
 {
     char buf[128];
@@ -2078,6 +2084,8 @@
     /* test the no operand case */
     asm volatile ("xorl %eax, %eax");
 
+    printf("%d\n",asm_func(&val));
+
     memcpy1(buf, "hello", 6);
     strncat1(buf, " worldXXXXX", 3);
     printf("%s\n", buf);