- /* if they are equivalent then do nothing */
-// if (operandsEqu(IC_RESULT(ic),IC_RIGHT(ic)))
-// return ;
-
- pic16_aopOp(result,ic,FALSE);
- pic16_aopOp(right,ic,FALSE) ;
-
- DEBUGpic16_pic16_AopType(__LINE__,NULL,right,result);
-
-
- /* if the result is a bit */
- if (AOP_TYPE(result) == AOP_CRY) {
-
- /* if the right size is a literal then
- * we know what the value is */
- DEBUGpic16_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
-
- if (AOP_TYPE(right) == AOP_LIT) {
- pic16_emitpcode( ( ((int) operandLitValue(right)) ? POC_BSF : POC_BCF),
- pic16_popGet(AOP(result),0));
-
- if (((int) operandLitValue(right)))
- pic16_emitcode("bsf","(%s >> 3), (%s & 7)",
- AOP(result)->aopu.aop_dir,
- AOP(result)->aopu.aop_dir);
- else
- pic16_emitcode("bcf","(%s >> 3), (%s & 7)",
- AOP(result)->aopu.aop_dir,
- AOP(result)->aopu.aop_dir);
- goto release;
- }
-
- /* the right is also a bit variable */
- if (AOP_TYPE(right) == AOP_CRY) {
- emitCLRC;
- pic16_emitpcode(POC_BTFSC, pic16_popGet(AOP(right),0));
-
- pic16_emitcode("clrc","");
- pic16_emitcode("btfsc","(%s >> 3), (%s & 7)",
- AOP(right)->aopu.aop_dir,
- AOP(right)->aopu.aop_dir);
- pic16_aopPut(AOP(result),"c",0);
- goto release ;
- }
-
- /* we need to or */
- if (AOP_TYPE(right) == AOP_REG) {
- pic16_emitpcode(POC_BCF, pic16_popGet(AOP(result),0));
- pic16_emitpcode(POC_BTFSC, pic16_newpCodeOpBit(pic16_aopGet(AOP(right),0,FALSE,FALSE),0,0, PO_GPR_REGISTER));
- pic16_emitpcode(POC_BSF, pic16_popGet(AOP(result),0));
- }
- pic16_toBoolean(right);
- pic16_aopPut(AOP(result),"a",0);
- goto release ;
- }
-
- if ((AOP_TYPE(right) == AOP_CRY) && (AOP_TYPE(result) == AOP_REG)) {
- int offset = 1;
-
- size = AOP_SIZE(result);
-
- DEBUGpic16_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
-
- pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result),0));
- pic16_emitpcode(POC_BTFSC, pic16_popGet(AOP(right),0));
- pic16_emitpcode(POC_INCF, pic16_popGet(AOP(result),0));
-
- while (size--)
- pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result),offset++));
-
- goto release;
- }
-
- if(IS_BITFIELD(getSpec(restype))
- && IS_BITFIELD(getSpec(rtype))) {
- DEBUGpic16_emitcode("***", "%d casting a bit to another bit", __LINE__);
- }
-
- /* port from pic14 to cope with generic pointers */
- if (PIC_IS_TAGGED(restype))
- {
- operand *result = IC_RESULT(ic);
- //operand *left = IC_LEFT(ic);
- operand *right = IC_RIGHT(ic);
- int tag = 0xff;
-
- /* copy common part */
- int max, size = AOP_SIZE(result);
- if (size > AOP_SIZE(right)) size = AOP_SIZE(right);
- DEBUGpic16_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
-
- max = size;
- while (size--)
- {
- pic16_mov2w (AOP(right), size);
- pic16_emitpcode(POC_MOVWF, pic16_popGet (AOP(result), size));
- } // while
-
- /* upcast into generic pointer type? */
- if (IS_GENPTR(restype)
- && !PIC_IS_TAGGED(rtype)
- && (AOP_SIZE(result) > max))
- {
- /* determine appropriate tag for right */
- if (PIC_IS_DATA_PTR(rtype))
- tag = GPTR_TAG_DATA;
- else if (IS_CODEPTR(rtype))
- tag = GPTR_TAG_CODE;
- else if (PIC_IS_DATA_PTR(ctype)) {
- //fprintf (stderr, "%s:%u: WARNING: casting `(generic*)(__data*)(non-pointer)'\n", ic->filename, ic->lineno);
- tag = GPTR_TAG_DATA;
- } else if (IS_CODEPTR(ctype)) {
- //fprintf (stderr, "%s:%u: WARNING: casting `(generic*)(__code*)(non-pointer)'\n", ic->filename, ic->lineno);
- tag = GPTR_TAG_CODE;
- } else if (IS_PTR(rtype)) {
- PERFORM_ONCE(weirdcast,
- fprintf (stderr, "%s:%u: WARNING: casting `(generic*)(unknown*)' -- assumimg __data space\n", ic->filename, ic->lineno);
- );
- tag = GPTR_TAG_DATA;
- } else {
- PERFORM_ONCE(weirdcast,
- fprintf (stderr, "%s:%u: WARNING: casting `(generic*)(non-pointer)' -- assumimg __data space\n", ic->filename, ic->lineno);
- );
- tag = GPTR_TAG_DATA;
- }
-
- assert (AOP_SIZE(result) == 3);
- /* zero-extend address... */
- for (size = max; size < AOP_SIZE(result)-1; size++)
- pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result),size));
- /* ...and add tag */
- pic16_movLit2f(pic16_popGet(AOP(result), AOP_SIZE(result)-1), tag);
- } else if (IS_CODEPTR(restype) && AOP_SIZE(result) > max) {
- //fprintf (stderr, "%s:%u: INFO: code pointer\n", ic->filename, ic->lineno);
- for (size = max; size < AOP_SIZE(result)-1; size++)
- pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result), size));
- /* add __code tag */
- pic16_movLit2f (pic16_popGet(AOP(result), AOP_SIZE(result)-1), GPTR_TAG_CODE);
- } else if (AOP_SIZE(result) > max) {
- /* extend non-pointers */
- //fprintf (stderr, "%s:%u: zero-extending value cast to pointer\n", ic->filename, ic->lineno);
- pic16_addSign(result, max, 0);
- } // if
- goto release;
- }
-
- /* if they are the same size : or less */
- if (AOP_SIZE(result) <= AOP_SIZE(right)) {
-
- /* if they are in the same place */
- if (pic16_sameRegs(AOP(right),AOP(result)))
- goto release;
-
- DEBUGpic16_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
+ /* if they are equivalent then do nothing */
+// if (operandsEqu(IC_RESULT(ic),IC_RIGHT(ic)))
+// return ;
+
+ pic16_aopOp(result,ic,FALSE);
+ pic16_aopOp(right,ic,FALSE) ;
+
+ DEBUGpic16_pic16_AopType(__LINE__,NULL,right,result);
+
+
+ /* if the result is a bit */
+ if (AOP_TYPE(result) == AOP_CRY) {
+
+ /* if the right size is a literal then
+ * we know what the value is */
+ DEBUGpic16_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
+
+ if (AOP_TYPE(right) == AOP_LIT) {
+ pic16_emitpcode( ( ((int) operandLitValue(right)) ? POC_BSF : POC_BCF),
+ pic16_popGet(AOP(result),0));
+
+ if (((int) operandLitValue(right)))
+ pic16_emitcode("bsf","(%s >> 3), (%s & 7)",
+ AOP(result)->aopu.aop_dir,
+ AOP(result)->aopu.aop_dir);
+ else
+ pic16_emitcode("bcf","(%s >> 3), (%s & 7)",
+ AOP(result)->aopu.aop_dir,
+ AOP(result)->aopu.aop_dir);
+ goto release;
+ }
+
+ /* the right is also a bit variable */
+ if (AOP_TYPE(right) == AOP_CRY) {
+ emitCLRC;
+ pic16_emitpcode(POC_BTFSC, pic16_popGet(AOP(right),0));
+
+ pic16_emitcode("clrc","");
+ pic16_emitcode("btfsc","(%s >> 3), (%s & 7)",
+ AOP(right)->aopu.aop_dir,
+ AOP(right)->aopu.aop_dir);
+ pic16_aopPut(AOP(result),"c",0);
+ goto release ;
+ }
+
+ /* we need to or */
+ if (AOP_TYPE(right) == AOP_REG) {
+ pic16_emitpcode(POC_BCF, pic16_popGet(AOP(result),0));
+ pic16_emitpcode(POC_BTFSC, pic16_newpCodeOpBit(pic16_aopGet(AOP(right),0,FALSE,FALSE),0,0, PO_GPR_REGISTER));
+ pic16_emitpcode(POC_BSF, pic16_popGet(AOP(result),0));
+ }
+ pic16_toBoolean(right);
+ pic16_aopPut(AOP(result),"a",0);
+ goto release ;
+ }
+
+ if ((AOP_TYPE(right) == AOP_CRY) && (AOP_TYPE(result) == AOP_REG)) {
+ int offset = 1;
+
+ size = AOP_SIZE(result);
+
+ DEBUGpic16_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
+
+ pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result),0));
+ pic16_emitpcode(POC_BTFSC, pic16_popGet(AOP(right),0));
+ pic16_emitpcode(POC_INCF, pic16_popGet(AOP(result),0));
+
+ while (size--)
+ pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result),offset++));
+
+ goto release;
+ }
+
+ if(IS_BITFIELD(getSpec(restype))
+ && IS_BITFIELD(getSpec(rtype))) {
+ DEBUGpic16_emitcode("***", "%d casting a bit to another bit", __LINE__);
+ }
+
+ /* port from pic14 to cope with generic pointers */
+ if (PIC_IS_TAGGED(restype))
+ {
+ operand *result = IC_RESULT(ic);
+ //operand *left = IC_LEFT(ic);
+ operand *right = IC_RIGHT(ic);
+ int tag = 0xff;
+
+ /* copy common part */
+ int max, size = AOP_SIZE(result);
+ if (size > AOP_SIZE(right)) size = AOP_SIZE(right);
+ DEBUGpic16_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);
+
+ max = size;
+ while (size--)
+ {
+ pic16_mov2w (AOP(right), size);
+ pic16_emitpcode(POC_MOVWF, pic16_popGet (AOP(result), size));
+ } // while
+
+ /* upcast into generic pointer type? */
+ if (IS_GENPTR(restype)
+ && !PIC_IS_TAGGED(rtype)
+ && (AOP_SIZE(result) > max))
+ {
+ /* determine appropriate tag for right */
+ if (PIC_IS_DATA_PTR(rtype))
+ tag = GPTR_TAG_DATA;
+ else if (IS_CODEPTR(rtype))
+ tag = GPTR_TAG_CODE;
+ else if (PIC_IS_DATA_PTR(ctype)) {
+ //fprintf (stderr, "%s:%u: WARNING: casting `(generic*)(__data*)(non-pointer)'\n", ic->filename, ic->lineno);
+ tag = GPTR_TAG_DATA;
+ } else if (IS_CODEPTR(ctype)) {
+ //fprintf (stderr, "%s:%u: WARNING: casting `(generic*)(__code*)(non-pointer)'\n", ic->filename, ic->lineno);
+ tag = GPTR_TAG_CODE;
+ } else if (IS_PTR(rtype)) {
+ PERFORM_ONCE(weirdcast,
+ fprintf (stderr, "%s:%u: WARNING: casting `(generic*)(unknown*)' -- assuming __data space\n", ic->filename, ic->lineno);
+ );
+ tag = GPTR_TAG_DATA;
+ } else {
+ PERFORM_ONCE(weirdcast,
+ fprintf (stderr, "%s:%u: WARNING: casting `(generic*)(non-pointer)' -- assuming __data space\n", ic->filename, ic->lineno);
+ );
+ tag = GPTR_TAG_DATA;
+ }
+
+ assert (AOP_SIZE(result) == 3);
+ /* zero-extend address... */
+ for (size = max; size < AOP_SIZE(result)-1; size++)
+ pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result),size));
+ /* ...and add tag */
+ pic16_movLit2f(pic16_popGet(AOP(result), AOP_SIZE(result)-1), tag);
+ } else if (IS_CODEPTR(restype) && AOP_SIZE(result) > max) {
+ //fprintf (stderr, "%s:%u: INFO: code pointer\n", ic->filename, ic->lineno);
+ for (size = max; size < AOP_SIZE(result)-1; size++)
+ pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result), size));
+ /* add __code tag */
+ pic16_movLit2f (pic16_popGet(AOP(result), AOP_SIZE(result)-1), GPTR_TAG_CODE);
+ } else if (AOP_SIZE(result) > max) {
+ /* extend non-pointers */
+ //fprintf (stderr, "%s:%u: zero-extending value cast to pointer\n", ic->filename, ic->lineno);
+ pic16_addSign(result, max, 0);
+ } // if
+ goto release;
+ }
+
+ /* if they are the same size : or less */
+ if (AOP_SIZE(result) <= AOP_SIZE(right)) {
+
+ /* if they are in the same place */
+ if (pic16_sameRegs(AOP(right),AOP(result)))
+ goto release;
+
+ DEBUGpic16_emitcode("; ***","%s %d",__FUNCTION__,__LINE__);