* src/pic16/genarith.c (genAddLit): simplified and fixed case where
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 16 Mar 2006 09:32:20 +0000 (09:32 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 16 Mar 2006 09:32:20 +0000 (09:32 +0000)
  the left operand is shorter than the result (c* = lit-c* + int),
  fixes bug #1450796
* src/pic16/gen.c (genRightShift): check IS_SYMOP before accessing
  OP_SYMBOL

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4064 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/pic16/gen.c
src/pic16/genarith.c

index 1fc24424f921e2c96ba8768dae3d16967a3abbdb..b4c509cab39c4bfec44d3145d4d1f323b14ed4b0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2006-03-16 Raphael Neider <rneider AT web.de>
+
+       * src/pic16/genarith.c (genAddLit): simplified and fixed case where
+         the left operand is shorter than the result (c* = lit-c* + int),
+         fixes bug #1450796
+       * src/pic16/gen.c (genRightShift): check IS_SYMOP before accessing
+         OP_SYMBOL
+
 2006-03-14 Vangelis Rokas <vrokas AT users.sourceforge.net>
 
        * src/.version: increased version number to 2.5.5
index 2e76a461853c312efecb5ce6d7aa8d6992a4105a..d2c7f0363d811bc6bd04037e712be068cd1db0eb 100644 (file)
@@ -10511,10 +10511,10 @@ static void genRightShift (iCode *ic) {
 /* load FSR0 with address of/from op according to is_LitOp() or if lit is 1 */
 void pic16_loadFSR0(operand *op, int lit)
 {
-  if(OP_SYMBOL(op)->remat || is_LitOp( op )) {
+  if((IS_SYMOP(op) && OP_SYMBOL(op)->remat) || is_LitOp( op )) {
     pic16_emitpcode(POC_LFSR, pic16_popGetLit2(0, pic16_popGet(AOP(op), 0)));
   } else {
-    assert (!OP_SYMBOL(op)->remat);
+    assert (!IS_SYMOP(op) || !OP_SYMBOL(op)->remat);
     // set up FSR0 with address of result
     pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(op),0), pic16_popCopyReg(&pic16_pc_fsr0l)));
     pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(op),1), pic16_popCopyReg(&pic16_pc_fsr0h)));
index e8ada618971f403f027081a5860d4d16bcc3b1b0..7766ae7d1e5db660997f778d897cc9da481c987e 100644 (file)
@@ -654,7 +654,6 @@ static void genAddLit (iCode *ic, int lit)
 
        } 
       } 
-    }
 
 */
     }
@@ -716,30 +715,21 @@ static void genAddLit (iCode *ic, int lit)
       //pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(result),0,FALSE,FALSE));
       emitMOVWF(result,0);
       while(--size) {
-      
        lit >>= 8;
-       if(lit & 0xff) {
-         if(clear_carry) {
-           /* The ls byte of the lit must've been zero - that 
-              means we don't have to deal with carry */
-
-           pic16_emitpcode(POC_MOVLW, pic16_popGetLit(lit & 0xff));
-           pic16_emitpcode(POC_ADDFW,  pic16_popGet(AOP(left),offset));
-           pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(result),offset));
-
-           clear_carry = 0;
-
-         } else {
-           pic16_emitpcode(POC_MOVLW, pic16_popGetLit(lit & 0xff));
-           pic16_emitpcode(POC_ADDFWC, pic16_popGet(AOP(left),offset));
-           pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(result),offset));
-         }
-
+       pic16_emitpcode(POC_MOVLW, pic16_popGetLit(lit & 0xff));
+       if (offset < AOP_SIZE(left)) {
+         pic16_emitpcode(clear_carry ? POC_ADDFW : POC_ADDFWC, pic16_popGet(AOP(left),offset));
+         pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(result),offset));
        } else {
-         pic16_emitpcode(POC_CLRF,  pic16_popGet(AOP(result),offset));
-         pic16_mov2w(AOP(left),offset);
-         pic16_emitpcode(POC_ADDWFC, pic16_popGet(AOP(result),offset));
+         pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result),offset));
+         if (!SPEC_USIGN(operandType(IC_LEFT(ic)))) {
+           /* sign-extend left (in result) */
+            pic16_emitpcode (POC_BTFSC, pic16_newpCodeOpBit_simple(AOP(left),AOP_SIZE(left)-1,7));
+           pic16_emitpcode(POC_SETF, pic16_popGet(AOP(result),offset));
+         }
+         pic16_emitpcode(clear_carry ? POC_ADDWF : POC_ADDWFC, pic16_popGet(AOP(result),offset));
        }
+       clear_carry = 0;
        offset++;
       }
     }