* src/mcs51/gen.c (genUnpackBits): initial, incomplete support for signed bitfields
authorbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 18 Nov 2005 12:27:11 +0000 (12:27 +0000)
committerbernhardheld <bernhardheld@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Fri, 18 Nov 2005 12:27:11 +0000 (12:27 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3955 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/mcs51/gen.c

index ceab0729c3a48d92fe8efa6232928a1f2bb62dc3..1d6890218b1ee84693efe54d4f0e3c7b9737ce63 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,9 @@
-2005-10-28 Bernhard Held <bernhard AT bernhardheld.de>
+2005-11-18 Bernhard Held <bernhard AT bernhardheld.de>
 
        * src/SDCCsymt.c (computeType): fixed bug 1358192: added missing else,
        reformatted for better readability
+       * src/mcs51/gen.c (genUnpackBits): initial, incomplete support for
+       signed bitfields
 
 2005-11-17 Borut Razem <borut.razem AT siol.net>
 
index 22904127c5f20bb55cacf6b8ad69bd3e2a0a5009..1d64c504afc8a254c88a696617cdf77869d6468e 100644 (file)
@@ -9307,6 +9307,15 @@ genUnpackBits (operand * result, char *rname, int ptype, iCode *ifx)
       emitPtrByteGet (rname, ptype, FALSE);
       AccRsh (bstr);
       emitcode ("anl", "a,#0x%02x", ((unsigned char) -1) >> (8 - blen));
+      if (!SPEC_USIGN (etype))
+        {
+          /* signed bitfield */
+          symbol *tlbl = newiTempLabel (NULL);
+
+          emitcode ("jnb", "acc.%d,%05d$", blen - 1, tlbl->key + 100);
+          emitcode ("orl", "a,#0x%02x", (unsigned char) (0xff << blen));
+          emitcode ("", "%05d$:", tlbl->key + 100);
+        }
       aopPut (result, "a", offset++, isOperandVolatile (result, FALSE));
       goto finish;
     }
@@ -9326,6 +9335,15 @@ genUnpackBits (operand * result, char *rname, int ptype, iCode *ifx)
     {
       emitPtrByteGet (rname, ptype, FALSE);
       emitcode ("anl", "a,#0x%02x", ((unsigned char) -1) >> (8-rlen));
+      if (!SPEC_USIGN (etype))
+        {
+          /* signed bitfield */
+          symbol *tlbl = newiTempLabel (NULL);
+
+          emitcode ("jnb", "acc.%d,%05d$", blen - 1, tlbl->key + 100);
+          emitcode ("orl", "a,#0x%02x", (unsigned char) (0xff << rlen));
+          emitcode ("", "%05d$:", tlbl->key + 100);
+        }
       aopPut (result, "a", offset++, isOperandVolatile (result, FALSE));
     }