* link/z80/lkmain.c,
[fw/sdcc] / src / mcs51 / gen.c
index c9b86b9725967ccc04255d6728639214d3f45a9e..6b8eeefb45187dd78cc2e56bd37bac78103e5938 100644 (file)
@@ -3584,7 +3584,7 @@ genEndFunction (iCode * ic)
   /* restore the register bank  */
   if ( /* FUNC_REGBANK (sym->type) || */ IFFUNC_ISISR (sym->type))
   {
-    if (/* !FUNC_REGBANK (sym->type) || */ !IFFUNC_ISISR (sym->type)
+    if (!FUNC_REGBANK (sym->type) || !IFFUNC_ISISR (sym->type)
      || !options.useXstack)
     {
         /* Special case of ISR using non-zero bank with useXstack
@@ -9305,7 +9305,7 @@ genUnpackBits (operand * result, char *rname, int ptype, iCode *ifx)
   if (blen < 8)
     {
       emitPtrByteGet (rname, ptype, FALSE);
-      AccRsh (bstr);
+      AccRol (8 - bstr);
       emitcode ("anl", "a,#0x%02x", ((unsigned char) -1) >> (8 - blen));
       if (!SPEC_USIGN (etype))
         {
@@ -9340,7 +9340,7 @@ genUnpackBits (operand * result, char *rname, int ptype, iCode *ifx)
           /* signed bitfield */
           symbol *tlbl = newiTempLabel (NULL);
 
-          emitcode ("jnb", "acc.%d,%05d$", blen - 1, tlbl->key + 100);
+          emitcode ("jnb", "acc.%d,%05d$", rlen - 1, tlbl->key + 100);
           emitcode ("orl", "a,#0x%02x", (unsigned char) (0xff << rlen));
           emitcode ("", "%05d$:", tlbl->key + 100);
         }
@@ -10866,8 +10866,8 @@ genCast (iCode * ic)
 
   /* if the result is a bit (and not a bitfield) */
   // if (AOP_TYPE (result) == AOP_CRY)
-  if (IS_BITVAR (OP_SYMBOL (result)->type)
-      && !IS_BITFIELD (OP_SYMBOL (result)->type) )
+  if (IS_BIT (OP_SYMBOL (result)->type))
+    /* not for bitfields */
     {
       /* if the right size is a literal then
          we know what the value is */
@@ -11391,11 +11391,21 @@ gen51Code (iCode * lic)
         char regsInUse[80];
         int i;
 
+        #if 0
         for (i=0; i<8; i++) {
           sprintf (&regsInUse[i],
-                   "%c", ic->riu & (1<<i) ? i+'0' : '-');
-        }
+                   "%c", ic->riu & (1<<i) ? i+'0' : '-'); /* show riu */
         regsInUse[i]=0;
+        #else
+        strcpy (regsInUse, "--------");
+        for (i=0; i < 8; i++) {
+          if (bitVectBitValue (ic->rMask, i))
+            {
+              int offset = regs8051[i].offset;
+              regsInUse[offset] = offset + '0'; /* show rMask */
+            }
+        #endif
+        }
         emitcode("", "; [%s] ic:%d: %s", regsInUse, ic->seq, printILine(ic));
       }
       /* if the result is marked as