* src/mcs51/peeph.def: addded rule 262 to remove double cpl c, which could be emitted by genMinus
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3910
4a8a32a2-be11-0410-ad9d-
d568d2c75423
+2005-10-26 Bernhard Held <bernhard AT bernhardheld.de>
+
+ * src/mcs51/gen.c (genMinus): fixed bug 1270906: reverse subtraction,
+ carry must be complemented too
+ * src/mcs51/peeph.def: addded rule 262 to remove double cpl c, which
+ could be emitted by genMinus
+
2005-10-25 Bernhard Held <bernhard AT bernhardheld.de>
* src/SDCCast.c (addCast): added promotion for bit variables
2005-10-25 Bernhard Held <bernhard AT bernhardheld.de>
* src/SDCCast.c (addCast): added promotion for bit variables
emitcode ("subb", "a,b");
popB (pushedB);
} else {
emitcode ("subb", "a,b");
popB (pushedB);
} else {
+ /* reverse subtraction with 2's complement */
+ if (offset == 0)
+ emitcode( "setb", "c");
+ else
+ emitcode( "cpl", "c");
wassertl(!aopGetUsesAcc(leftOp, offset), "accumulator clash");
MOVA (aopGet(rightOp, offset, FALSE, TRUE));
wassertl(!aopGetUsesAcc(leftOp, offset), "accumulator clash");
MOVA (aopGet(rightOp, offset, FALSE, TRUE));
- if (offset == 0) {
- emitcode( "setb", "c");
- }
emitcode("subb", "a,%s", aopGet(leftOp, offset, FALSE, TRUE));
emitcode("cpl", "a");
emitcode("subb", "a,%s", aopGet(leftOp, offset, FALSE, TRUE));
emitcode("cpl", "a");
+ if (size) /* skip if last byte */
+ emitcode( "cpl", "c");
}
} else {
MOVA (aopGet (leftOp, offset, FALSE, FALSE));
}
} else {
MOVA (aopGet (leftOp, offset, FALSE, FALSE));
+replace {
+ cpl c
+ cpl c
+} by {
+ ; Peephole 262 removed redundant cpl c
+}
+
// should be one of the last peepholes
replace{
%1:
// should be one of the last peepholes
replace{
%1: