From 88525995d968a51fe19a7edbbac43c09efc84cd4 Mon Sep 17 00:00:00 2001 From: tecodev Date: Wed, 21 Sep 2005 11:26:13 +0000 Subject: [PATCH] * 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 git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3895 4a8a32a2-be11-0410-ad9d-d568d2c75423 --- ChangeLog | 13 ++++ device/include/pic16/pic18f1220.h | 16 ++++ device/lib/pic16/Makefile.rules | 2 +- device/lib/pic16/libdev/pic18f1220.c | 3 + src/pic16/gen.c | 107 +-------------------------- src/pic16/genutils.c | 30 ++++++++ 6 files changed, 67 insertions(+), 104 deletions(-) diff --git a/ChangeLog b/ChangeLog index 64563cca..2885d07d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2005-09-21 Raphael Neider + + * 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 * src/pic16/gen.c (genFarPointerGet,genFarPointerSet): removed diff --git a/device/include/pic16/pic18f1220.h b/device/include/pic16/pic18f1220.h index bb097368..5ed97df2 100644 --- a/device/include/pic16/pic18f1220.h +++ b/device/include/pic16/pic18f1220.h @@ -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 { diff --git a/device/lib/pic16/Makefile.rules b/device/lib/pic16/Makefile.rules index 42aaef90..61316ad6 100644 --- a/device/lib/pic16/Makefile.rules +++ b/device/lib/pic16/Makefile.rules @@ -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 diff --git a/device/lib/pic16/libdev/pic18f1220.c b/device/lib/pic16/libdev/pic18f1220.c index e56cdbf8..506573fb 100644 --- a/device/lib/pic16/libdev/pic18f1220.c +++ b/device/lib/pic16/libdev/pic18f1220.c @@ -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; diff --git a/src/pic16/gen.c b/src/pic16/gen.c index 00d5cd1b..4bcf34a2 100644 --- a/src/pic16/gen.c +++ b/src/pic16/gen.c @@ -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) diff --git a/src/pic16/genutils.c b/src/pic16/genutils.c index 4e077b4d..4913f948 100644 --- a/src/pic16/genutils.c +++ b/src/pic16/genutils.c @@ -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)); -- 2.47.2