From: bernhardheld Date: Fri, 18 Nov 2005 12:27:11 +0000 (+0000) Subject: * src/mcs51/gen.c (genUnpackBits): initial, incomplete support for signed bitfields X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=c0d6d4907573f90342ec1acdd3b4f8d47cd33cbd;p=fw%2Fsdcc * src/mcs51/gen.c (genUnpackBits): initial, incomplete support for signed bitfields git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3955 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- diff --git a/ChangeLog b/ChangeLog index ceab0729..1d689021 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,9 @@ -2005-10-28 Bernhard Held +2005-11-18 Bernhard Held * 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 diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 22904127..1d64c504 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -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)); }