X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fmcs51%2Fgen.c;h=1d64c504afc8a254c88a696617cdf77869d6468e;hb=c0d6d4907573f90342ec1acdd3b4f8d47cd33cbd;hp=22904127c5f20bb55cacf6b8ad69bd3e2a0a5009;hpb=eef64ace6f0890bc94f98158a77e2ea9ec3b77bd;p=fw%2Fsdcc 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)); }