From 0532ba2a5ff4c6513ccac1d8a82d8259669b8aa3 Mon Sep 17 00:00:00 2001 From: epetrich Date: Sat, 4 Dec 2004 06:12:32 +0000 Subject: [PATCH] * src/z80/gen.c (genLeftShift, genRightShift): fixed second part of bug #1074377 * src/hc08/gen.c (genrshFour, shiftRLong, shiftLLong), * src/mcs51/gen.c (shiftLLong): Fixed some shifting bugs Frieder found git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3599 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 7 +++++++ src/hc08/gen.c | 5 ++++- src/mcs51/gen.c | 2 +- src/z80/gen.c | 12 ++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 427fc603..df234ac5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-12-03 Erik Petrich + + * src/z80/gen.c (genLeftShift, genRightShift): fixed second part of + bug #1074377 + * src/hc08/gen.c (genrshFour, shiftRLong, shiftLLong), + * src/mcs51/gen.c (shiftLLong): Fixed some shifting bugs Frieder found + 2004-12-02 Slade Rich * src/pic/pcode.c : fixed a problem where banksel was not being inserted. diff --git a/src/hc08/gen.c b/src/hc08/gen.c index b144bf60..b101c25b 100644 --- a/src/hc08/gen.c +++ b/src/hc08/gen.c @@ -6234,6 +6234,7 @@ shiftLLong (operand * left, operand * result, int offr) loadRegFromAop (hc08_reg_a, AOP (left), MSB24); rmwWithReg ("rol", hc08_reg_a); storeRegToAop (hc08_reg_a, AOP (result), offr+2); + storeConstToAop (zero, AOP (result), 0); } pullOrFreeReg (hc08_reg_x, needpulx); @@ -6561,6 +6562,7 @@ shiftRLong (operand * left, int offl, else rmwWithReg ("lsr", hc08_reg_a); storeRegToAop (hc08_reg_a, AOP (result), MSB24); + storeRegSignToUpperAop (hc08_reg_a, AOP (result), MSB32, sign); } loadRegFromAop (hc08_reg_xa, AOP (left), offl); @@ -6624,7 +6626,8 @@ genrshFour (operand * result, operand * left, loadRegFromConst (hc08_reg_a, zero); XAccRsh (shCount-8, sign); accopWithAop ("ora", AOP (result), 1); - storeRegToFullAop (hc08_reg_xa, AOP (result), 1); + storeRegToAop (hc08_reg_xa, AOP (result), 1); + storeRegSignToUpperAop (hc08_reg_x, AOP(result), 3, sign); } } else diff --git a/src/mcs51/gen.c b/src/mcs51/gen.c index 97218f07..c5ffcd85 100644 --- a/src/mcs51/gen.c +++ b/src/mcs51/gen.c @@ -7409,7 +7409,7 @@ shiftLLong (operand * left, operand * result, int offr) if (size >= MSB24 + offr) { - if (!(sameRegs (AOP (left), AOP (left)) && size >= MSB24 + offr && offr != LSB)) + if (!(sameRegs (AOP (result), AOP (left)) && size >= MSB24 + offr && offr != LSB)) { l = aopGet (AOP (left), MSB24, FALSE, FALSE); MOVA (l); diff --git a/src/z80/gen.c b/src/z80/gen.c index 95327d25..97776615 100644 --- a/src/z80/gen.c +++ b/src/z80/gen.c @@ -6043,6 +6043,9 @@ genLeftShift (iCode * ic) aopOp (left, ic, FALSE, FALSE); aopOp (result, ic, FALSE, FALSE); + if (AOP_TYPE (left) != AOP_REG || AOP_TYPE (result) != AOP_REG) + _push (PAIR_AF); + /* now move the left to the result if they are not the same */ @@ -6064,6 +6067,9 @@ genLeftShift (iCode * ic) offset = 0; tlbl1 = newiTempLabel (NULL); + if (AOP_TYPE (left) != AOP_REG || AOP_TYPE (result) != AOP_REG) + _pop (PAIR_AF); + emit2 ("!shortjp !tlabel", tlbl1->key + 100); emitLabel (tlbl->key + 100); l = aopGet (AOP (result), offset, FALSE); @@ -6317,6 +6323,9 @@ genRightShift (iCode * ic) aopOp (left, ic, FALSE, FALSE); aopOp (result, ic, FALSE, FALSE); + if (AOP_TYPE (left) != AOP_REG || AOP_TYPE (result) != AOP_REG) + _push (PAIR_AF); + /* now move the left to the result if they are not the same */ if (!sameRegs (AOP (left), AOP (result))) @@ -6336,6 +6345,9 @@ genRightShift (iCode * ic) tlbl1 = newiTempLabel (NULL); size = AOP_SIZE (result); offset = size - 1; + + if (AOP_TYPE (left) != AOP_REG || AOP_TYPE (result) != AOP_REG) + _pop (PAIR_AF); emit2 ("!shortjp !tlabel", tlbl1->key + 100); emitLabel (tlbl->key + 100); -- 2.30.2