changeset 894:989bdd85e8af

a little better zfill
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 06 Apr 2014 16:02:30 +0900
parents 1408a5f1676f
children e9ba80b0827d
files mc-codegen.c
diffstat 1 files changed, 9 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/mc-codegen.c	Sun Apr 06 15:12:10 2014 +0900
+++ b/mc-codegen.c	Sun Apr 06 16:02:30 2014 +0900
@@ -3973,20 +3973,21 @@
     if (fill>63) {
         // call bzero 
     }
+    int ass = list2(CONST,0);
     while(fill>0) {   // should consider alignment
         int t = UCHAR;
         if (fill>=size_of_longlong) t = ULONGLONG;
         else if (fill>=size_of_int) t = UNSIGNED;
         else if (fill>=size_of_short) t = USHORT;
         fill -= size(t);
-        int ass = assign_expr0(
-            (offset+fill)?
-                lp64?list3(LADD,var,llist2(LCONST,offset+fill)):    // binop?
-                     list3(ADD,var,list2(CONST,offset+fill)):
-                var,
-            list2(CONST,0),t,t); // already correct_typed
-        init_vars = list2(ass,init_vars);
-    }
+        int dest =  (offset+fill)?( 
+                (car(var)==LVAR) ?  ( lp64? list3n(LVAR,cadr(var)+offset+fill,ncaddr(var)) : list3n(LVAR,cadr(var)+offset+fill,ncaddr(var)) ) :
+                                    ( lp64?list3(LADD,var,llist2(LCONST,offset+fill)): list3(ADD,var,list2(CONST,offset+fill)))) :
+                var
+        ;
+        ass = assign_expr0(dest, ass,t,t); 
+    }
+    init_vars = list2(ass,init_vars);
 }