* device/include/pic16/pic18f1220.h,
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 21 Sep 2005 11:26:13 +0000 (11:26 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 21 Sep 2005 11:26:13 +0000 (11:26 +0000)
  device/lib/pic16/libdev/pic18f1220.c: added ECCPAS sfr and bitfield
* device/lib/pic16/Makefile.rules: added missing opening paren
* src/pic16/gen.c (pic16_genNot,pic16_genCpl): removed as these
  are provided in genutils.c,
  (genUminusFloat,genUminus,genCmpEq): added asserts on different
  operand/result sizes,
  (genCmp): assert on NULL pointers first, then check deref'ed values
* src/pic16/genutils.c (pic16_genCpl): fixed for different operand/
  result size

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

ChangeLog
device/include/pic16/pic18f1220.h
device/lib/pic16/Makefile.rules
device/lib/pic16/libdev/pic18f1220.c
src/pic16/gen.c
src/pic16/genutils.c

index 64563ccac518744792ba75aef859ff0ac1fec9e3..2885d07d39937a33ae92314b4cec12ce24a7fc16 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2005-09-21 Raphael Neider <rneider AT web.de>
+
+       * device/include/pic16/pic18f1220.h,
+         device/lib/pic16/libdev/pic18f1220.c: added ECCPAS sfr and bitfield
+       * device/lib/pic16/Makefile.rules: added missing opening paren
+       * src/pic16/gen.c (pic16_genNot,pic16_genCpl): removed as these
+         are provided in genutils.c,
+         (genUminusFloat,genUminus,genCmpEq): added asserts on different
+         operand/result sizes,
+         (genCmp): assert on NULL pointers first, then check deref'ed values
+       * src/pic16/genutils.c (pic16_genCpl): fixed for different operand/
+         result size
+
 2005-09-18 Raphael Neider <rneider AT web.de>
 
        * src/pic16/gen.c (genFarPointerGet,genFarPointerSet): removed
index bb097368a540db97d5ea0de318749332d206409a..5ed97df200cda5009249e46be2c4bb062127a76b 100644 (file)
@@ -325,6 +325,22 @@ extern volatile __T3CONbits_t __at (0xfb1) T3CONbits;
 
 extern __sfr __at (0xfb2) TMR3L;
 extern __sfr __at (0xfb3) TMR3H;
+extern __sfr __at (0xfb6) ECCPAS;
+typedef union {
+       struct {
+               unsigned PSSBD0:1;
+               unsigned PSSBD1:1;
+               unsigned PSSAC0:1;
+               unsigned PSSAC1:1;
+               unsigned ECCPAS0:1;
+               unsigned ECCPAS1:1;
+               unsigned ECCPAS2:1;
+               unsigned ECCPASE:1;
+       };
+} __ECCPASbits_t;
+
+extern volatile __ECCPASbits_t __at (0xfb6) ECCPASbits;
+
 extern __sfr __at (0xfbd) CCP1CON;
 typedef union {
        struct {
index 42aaef907412ee32a03f83a8c0d3ed1571985224..61316ad6fef2e133773ab1d1f2965b5348bd0fe1 100644 (file)
@@ -19,7 +19,7 @@
 # update dependencies
 $(topsrcdir)/$(builddir)/%.d : %.c
        @echo "[  CPP  ] ==> $(patsubst $(topsrcdir)/%,%,$@)";
-       $(Q)$(CPP) $CPPFLAGS) -o "$@" "$<";
+       $(Q)$(CPP) $(CPPFLAGS) -o "$@" "$<";
 
 # assemble
 $(topsrcdir)/$(builddir)/%.o : %.S
index e56cdbf8eeec3c1d513f9863cb0f4922c33748e8..506573fb388049e37f5d2eab6235db710141aea9 100644 (file)
@@ -72,6 +72,9 @@ volatile __T3CONbits_t __at (0xfb1) T3CONbits;
 
 __sfr __at (0xfb2) TMR3L;
 __sfr __at (0xfb3) TMR3H;
+__sfr __at (0xfb6) ECCPAS;
+volatile __ECCPASbits_t __at (0xfb6) ECCPASbits;
+
 __sfr __at (0xfbd) CCP1CON;
 volatile __CCP1CONbits_t __at (0xfbd) CCP1CONbits;
 
index 00d5cd1bd2b70aeb126b0150ca7f9ab28a7ba708..4bcf34a23bb2fc3afdda1544d96580360d9e1990 100644 (file)
@@ -2678,108 +2678,6 @@ void pic16_toBoolean(operand *oper)
     }
 }
 
-
-#if !defined(GEN_Not)
-/*-----------------------------------------------------------------*/
-/* genNot - generate code for ! operation                          */
-/*-----------------------------------------------------------------*/
-static void pic16_genNot (iCode *ic)
-{
-  symbol *tlbl;
-  int size;
-
-  FENTRY;
-  /* assign asmOps to operand & result */
-  pic16_aopOp (IC_LEFT(ic),ic,FALSE);
-  pic16_aopOp (IC_RESULT(ic),ic,TRUE);
-
-  DEBUGpic16_pic16_AopType(__LINE__,IC_LEFT(ic),NULL,IC_RESULT(ic));
-  /* if in bit space then a special case */
-  if (AOP_TYPE(IC_LEFT(ic)) == AOP_CRY) {
-    if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY) {
-      pic16_emitpcode(POC_MOVLW,pic16_popGet(AOP(IC_LEFT(ic)),0));
-      pic16_emitpcode(POC_XORWF,pic16_popGet(AOP(IC_RESULT(ic)),0));
-    } else {
-      pic16_emitpcode(POC_CLRF,pic16_popGet(AOP(IC_RESULT(ic)),0));
-      pic16_emitpcode(POC_BTFSS,pic16_popGet(AOP(IC_LEFT(ic)),0));
-      pic16_emitpcode(POC_INCF,pic16_popGet(AOP(IC_RESULT(ic)),0));
-    }
-    goto release;
-  }
-
-  size = AOP_SIZE(IC_LEFT(ic));
-  if(size == 1) {
-    pic16_emitpcode(POC_COMFW,pic16_popGet(AOP(IC_LEFT(ic)),0));
-    pic16_emitpcode(POC_ANDLW,pic16_popGetLit(1));
-    pic16_emitpcode(POC_MOVWF,pic16_popGet(AOP(IC_RESULT(ic)),0));
-    goto release;
-  }
-  pic16_toBoolean(IC_LEFT(ic));
-
-  tlbl = newiTempLabel(NULL);
-  pic16_emitcode("cjne","a,#0x01,%05d_DS_",tlbl->key+100);
-  pic16_emitcode("","%05d_DS_:",tlbl->key+100);
-  pic16_outBitC(IC_RESULT(ic));
-
- release:    
-  /* release the aops */
-  pic16_freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? 0 : 1));
-  pic16_freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
-}
-#endif
-
-
-#if !defined(GEN_Cpl)
-/*-----------------------------------------------------------------*/
-/* genCpl - generate code for complement                           */
-/*-----------------------------------------------------------------*/
-static void pic16_genCpl (iCode *ic)
-{
-  int offset = 0;
-  int size ;
-
-    FENTRY;
-    /* assign asmOps to operand & result */
-    pic16_aopOp (IC_LEFT(ic),ic,FALSE);
-    pic16_aopOp (IC_RESULT(ic),ic,TRUE);
-
-    /* if both are in bit space then 
-    a special case */
-    if (AOP_TYPE(IC_RESULT(ic)) == AOP_CRY &&
-        AOP_TYPE(IC_LEFT(ic)) == AOP_CRY ) { 
-
-        pic16_emitcode("mov","c,%s",IC_LEFT(ic)->aop->aopu.aop_dir); 
-        pic16_emitcode("cpl","c"); 
-        pic16_emitcode("mov","%s,c",IC_RESULT(ic)->aop->aopu.aop_dir); 
-        goto release; 
-    } 
-
-    size = AOP_SIZE(IC_RESULT(ic));
-    while (size--) {
-/*
-        char *l = pic16_aopGet(AOP(IC_LEFT(ic)),offset,FALSE,FALSE);
-        MOVA(l);       
-        pic16_emitcode("cpl","a");
-        pic16_aopPut(AOP(IC_RESULT(ic)),"a",offset++);
-*/
-       if (pic16_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
-             pic16_emitpcode(POC_COMF,  pic16_popGet(AOP(IC_LEFT(ic)), offset));
-       } else {
-               pic16_emitpcode(POC_COMFW, pic16_popGet(AOP(IC_LEFT(ic)),offset));
-               pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(IC_RESULT(ic)),offset));
-       }
-       offset++;
-
-    }
-
-
-release:
-    /* release the aops */
-    pic16_freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? 0 : 1));
-    pic16_freeAsmop(IC_RESULT(ic),NULL,ic,TRUE);
-}
-#endif
-
 /*-----------------------------------------------------------------*/
 /* genUminusFloat - unary minus for floating points                */
 /*-----------------------------------------------------------------*/
@@ -2791,6 +2689,7 @@ static void genUminusFloat(operand *op,operand *result)
     /* for this we just need to flip the 
     first it then copy the rest in place */
     size = AOP_SIZE(op);
+    assert( size == AOP_SIZE(result) );
 
     while(size--) {
       pic16_mov2f(AOP(result), AOP(op), offset);
@@ -2842,6 +2741,7 @@ static void genUminus (iCode *ic)
 
     /* otherwise subtract from zero by taking the 2's complement */
     size = AOP_SIZE(IC_LEFT(ic));
+    assert( size == AOP_SIZE(IC_RESULT(ic)) );
     label = newiTempLabel ( NULL );
     
     if (pic16_sameRegs (AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic)))) {
@@ -4998,8 +4898,8 @@ static void genCmp (operand *left,operand *right,
 
   FENTRY;
   
-  assert (AOP_SIZE(left) == AOP_SIZE(right));
   assert (left && right);
+  assert (AOP_SIZE(left) == AOP_SIZE(right));
 
   size = AOP_SIZE(right) - 1;
   mask = (0x100UL << (size*8)) - 1;
@@ -6723,6 +6623,7 @@ static void genCmpEq (iCode *ic, iCode *ifx)
         pic16_emitpcode(POC_CLRF,pic16_popGet(AOP(result),i));
     }
 
+  assert( AOP_SIZE(left) == AOP_SIZE(right) );
   for(i=0; i < AOP_SIZE(left); i++)
     {
       if(AOP_TYPE(left) != AOP_ACC)
index 4e077b4dce4eb2921315b3adbf599ac37b19b4be..4913f94884bfc6fdc54bf1360e632fccde5f8cdc 100644 (file)
@@ -155,6 +155,8 @@ void pic16_genCpl (iCode *ic)
     } 
 
     size = AOP_SIZE(IC_RESULT(ic));
+    if (size >= AOP_SIZE(IC_LEFT(ic))) size = AOP_SIZE(IC_LEFT(ic));
+    
     while (size--) {
       if (pic16_sameRegs(AOP(IC_LEFT(ic)), AOP(IC_RESULT(ic))) ) {
         pic16_emitpcode(POC_COMF,  pic16_popGet(AOP(IC_LEFT(ic)), offset));
@@ -165,6 +167,34 @@ void pic16_genCpl (iCode *ic)
       offset++;
     }
 
+    /* handle implicit upcast */
+    size = AOP_SIZE(IC_RESULT(ic));
+    if (offset < size)
+    {
+      if (SPEC_USIGN(operandType(IC_LEFT(ic)))) {
+       while (offset < size) {
+         pic16_emitpcode(POC_SETF, pic16_popGet(AOP(IC_RESULT(ic)), offset));
+         offset++;
+       } // while
+      } else {
+       if ((offset + 1) == size) {
+         /* just one byte to fix */
+         pic16_emitpcode(POC_SETF, pic16_popGet(AOP(IC_RESULT(ic)), offset));
+         pic16_emitpcode(POC_BTFSC, pic16_newpCodeOpBit(pic16_aopGet(AOP(IC_RESULT(ic)),offset-1,FALSE,FALSE),7,0, PO_GPR_REGISTER));
+         pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(IC_RESULT(ic)), offset));
+       } else {
+         /* two or more byte to adjust */
+         pic16_emitpcode(POC_SETF, pic16_popCopyReg( &pic16_pc_wreg ));
+         pic16_emitpcode(POC_BTFSC, pic16_newpCodeOpBit(pic16_aopGet(AOP(IC_RESULT(ic)),offset-1,FALSE,FALSE),7,0, PO_GPR_REGISTER));
+         pic16_emitpcode(POC_CLRF, pic16_popCopyReg( &pic16_pc_wreg ));
+         while (offset < size) {
+           pic16_emitpcode(POC_MOVWF, pic16_popGet(AOP(IC_RESULT(ic)), offset));
+           offset++;
+         } // while
+       } // if
+      }
+    } // if
+
 release:
     /* release the aops */
     pic16_freeAsmop(IC_LEFT(ic),NULL,ic,(RESULTONSTACK(ic) ? 0 : 1));