+ //rFalseIfx.condition ^= 1;
+ //genSkipCond(&rFalseIfx,left,size,7);
+ //rFalseIfx.condition ^= 1;
+
+ pic16_emitpcode(POC_BTFSC, pic16_newpCodeOpBit(pic16_aopGet(AOP(left),size,FALSE,FALSE),7,0, PO_GPR_REGISTER));
+ if(rFalseIfx.condition)
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(rFalseIfx.lbl->key));
+ else
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(truelbl->key));
+
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit(0x100-lit));
+ pic16_emitpcode(POC_ADDFW, pic16_popGet(AOP(left),0));
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(left),1));
+
+ while(size > 1)
+ pic16_emitpcode(POC_IORFW, pic16_popGet(AOP(left),size--));
+
+ if(rFalseIfx.condition) {
+ emitSKPZ;
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(truelbl->key));
+
+ } else {
+ emitSKPNZ;
+ }
+
+ genSkipc(&rFalseIfx);
+ pic16_emitpLabel(truelbl->key);
+ if(ifx) ifx->generated = 1;
+ return;
+
+ }
+
+ if(size == 1) {
+
+ if( (lit & 0xff) == 0) {
+ /* lower byte is zero */
+ DEBUGpic16_emitcode(";right lit","line = %d signed compare to 0x%x",__LINE__,lit);
+ i = ((lit >> 8) & 0xff) ^0x80;
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(left),size));
+ pic16_emitpcode(POC_ADDLW, pic16_popGetLit( 0x80));
+ pic16_emitpcode(POC_ADDLW, pic16_popGetLit(0x100-i));
+ genSkipc(&rFalseIfx);
+
+
+ if(ifx) ifx->generated = 1;
+ return;
+
+ }
+ } else {
+ /* Special cases for signed longs */
+ if( (lit & 0xffffff) == 0) {
+ /* lower byte is zero */
+ DEBUGpic16_emitcode(";right lit","line = %d signed compare to 0x%x",__LINE__,lit);
+ i = ((lit >> 8*3) & 0xff) ^0x80;
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(left),size));
+ pic16_emitpcode(POC_ADDLW, pic16_popGetLit( 0x80));
+ pic16_emitpcode(POC_ADDLW, pic16_popGetLit(0x100-i));
+ genSkipc(&rFalseIfx);
+
+
+ if(ifx) ifx->generated = 1;
+ return;
+
+ }
+
+ }
+
+
+ if(lit & (0x80 << (size*8))) {
+ /* lit is negative */
+ DEBUGpic16_emitcode(";right lit","line = %d signed compare to 0x%x",__LINE__,lit);
+
+ //genSkipCond(&rFalseIfx,left,size,7);
+
+ pic16_emitpcode(POC_BTFSS, pic16_newpCodeOpBit(pic16_aopGet(AOP(left),size,FALSE,FALSE),7,0, PO_GPR_REGISTER));
+
+ if(rFalseIfx.condition)
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(truelbl->key));
+ else
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(rFalseIfx.lbl->key));
+
+
+ } else {
+ /* lit is positive */
+ DEBUGpic16_emitcode(";right lit","line = %d signed compare to 0x%x",__LINE__,lit);
+ pic16_emitpcode(POC_BTFSC, pic16_newpCodeOpBit(pic16_aopGet(AOP(left),size,FALSE,FALSE),7,0, PO_GPR_REGISTER));
+ if(rFalseIfx.condition)
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(rFalseIfx.lbl->key));
+ else
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(truelbl->key));
+
+ }
+
+ /*
+ This works, but is only good for ints.
+ It also requires a "known zero" register.
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit(mlit & 0xff));
+ pic16_emitpcode(POC_ADDFW, pic16_popGet(AOP(left),0));
+ pic16_emitpcode(POC_RLCFW, pic16_popCopyReg(&pic16_pc_kzero));
+ pic16_emitpcode(POC_ADDLW, pic16_popGetLit( ((mlit>>8) & 0xff)));
+ pic16_emitpcode(POC_ADDFW, pic16_popGet(AOP(left),1));
+ genSkipc(&rFalseIfx);
+
+ pic16_emitpLabel(truelbl->key);
+ if(ifx) ifx->generated = 1;
+ return;
+ **/
+
+ /* There are no more special cases, so perform a general compare */
+
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit((lit >> (size*8)) & 0xff));
+ pic16_emitpcode(POC_SUBFW, pic16_popGet(AOP(left),size));
+
+ while(size--) {
+
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit((lit >> (size*8)) & 0xff));
+ emitSKPNZ;
+ pic16_emitpcode(POC_SUBFW, pic16_popGet(AOP(left),size));
+ }
+ //rFalseIfx.condition ^= 1;
+ genSkipc(&rFalseIfx);
+
+ pic16_emitpLabel(truelbl->key);
+
+ if(ifx) ifx->generated = 1;
+ return;
+
+
+ }
+
+
+ /* sign is out of the way. So now do an unsigned compare */
+ DEBUGpic16_emitcode(";right lit","line = %d unsigned compare to 0x%x",__LINE__,lit);
+
+
+ /* General case - compare to an unsigned literal on the right.*/
+
+ i = (lit >> (size*8)) & 0xff;
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit(i));
+ pic16_emitpcode(POC_SUBFW, pic16_popGet(AOP(left),size));
+ while(size--) {
+ i = (lit >> (size*8)) & 0xff;
+
+ if(i) {
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit(i));
+ emitSKPNZ;
+ pic16_emitpcode(POC_SUBFW, pic16_popGet(AOP(left),size));
+ } else {
+ /* this byte of the lit is zero,
+ *if it's not the last then OR in the variable */
+ if(size)
+ pic16_emitpcode(POC_IORFW, pic16_popGet(AOP(left),size));
+ }
+ }
+
+
+ pic16_emitpLabel(lbl->key);
+// pic16_emitpLabel(truelbl->key);
+ //if(emitFinalCheck)
+ genSkipc(&rFalseIfx);
+ if(sign)
+ pic16_emitpLabel(truelbl->key);
+
+ if(ifx) ifx->generated = 1;
+ return;
+
+
+ }
+#endif // _swapp
+
+ if(AOP_TYPE(left) == AOP_LIT) {
+ //symbol *lbl = newiTempLabel(NULL);
+
+ //EXPERIMENTAL lit = (unsigned long)(floatFromVal(AOP(left)->aopu.aop_lit));
+
+
+ DEBUGpic16_emitcode(";left lit","lit = 0x%x,sign=%d",lit,sign);
+
+ /* Special cases */
+ if((lit == 0) && (sign == 0)){
+
+ size--;
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(right),size));
+ while(size)
+ pic16_emitpcode(POC_IORFW, pic16_popGet(AOP(right),--size));
+
+ genSkipz2(&rFalseIfx,0);
+ if(ifx) ifx->generated = 1;
+ return;
+ }
+
+ if(size==1) {
+ /* Special cases */
+ lit &= 0xff;
+ if(((lit == 0xff) && !sign) || ((lit==0x7f) && sign)) {
+ /* degenerate compare can never be true */
+ if(rFalseIfx.condition == 0)
+ pic16_emitpcode(POC_GOTO,pic16_popGetLabel(rFalseIfx.lbl->key));
+
+ if(ifx) ifx->generated = 1;
+ return;
+ }
+
+ if(sign) {
+ /* signed comparisons to a literal byte */
+
+ int lp1 = (lit+1) & 0xff;
+
+ DEBUGpic16_emitcode(";left lit","line = %d lit = 0x%x",__LINE__,lit);
+ switch (lp1) {
+ case 0:
+ rFalseIfx.condition ^= 1;
+ genSkipCond(&rFalseIfx,right,0,7);
+ break;
+ case 0x7f:
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(right),0));
+ pic16_emitpcode(POC_XORLW, pic16_popGetLit(0x7f));
+ genSkipz2(&rFalseIfx,1);
+ break;
+ default:
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(right),0));
+ pic16_emitpcode(POC_ADDLW, pic16_popGetLit(0x80));
+ pic16_emitpcode(POC_ADDLW, pic16_popGetLit(((-(lit+1)) & 0xff) ^ 0x80));
+ rFalseIfx.condition ^= 1;
+ genSkipc(&rFalseIfx);
+ break;
+ }
+ } else {
+ /* unsigned comparisons to a literal byte */
+
+ switch(lit & 0xff ) {
+ case 0:
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(right),0));
+ genSkipz2(&rFalseIfx,0);
+ break;
+ case 0x7f:
+ rFalseIfx.condition ^= 1;
+ genSkipCond(&rFalseIfx,right,0,7);
+ break;
+
+ default:
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit((lit+1) & 0xff));
+ pic16_emitpcode(POC_SUBFW, pic16_popGet(AOP(right),0));
+ DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+ rFalseIfx.condition ^= 1;
+ if (AOP_TYPE(result) == AOP_CRY)
+ genSkipc(&rFalseIfx);
+ else {
+ pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result),0));
+ pic16_emitpcode(POC_RLCF, pic16_popGet(AOP(result),0));
+ }
+ break;
+ }
+ }
+
+ if(ifx) ifx->generated = 1;
+ if ((AOP_TYPE(result) != AOP_CRY) && (AOP_SIZE(result)))
+ goto check_carry;
+ return;
+
+ } else {
+
+ /* Size is greater than 1 */
+
+ if(sign) {
+ int lp1 = lit+1;
+
+ size--;
+
+ if(lp1 == 0) {
+ /* this means lit = 0xffffffff, or -1 */
+
+
+ DEBUGpic16_emitcode(";left lit = -1","line = %d ",__LINE__);
+ rFalseIfx.condition ^= 1;
+ genSkipCond(&rFalseIfx,right,size,7);
+ if(ifx) ifx->generated = 1;
+
+ if ((AOP_TYPE(result) != AOP_CRY) && (AOP_SIZE(result)))
+ goto check_carry;
+
+ return;
+ }
+
+ if(lit == 0) {
+ int s = size;
+
+ if(rFalseIfx.condition) {
+ pic16_emitpcode(POC_BTFSC, pic16_newpCodeOpBit(pic16_aopGet(AOP(right),size,FALSE,FALSE),7,0, PO_GPR_REGISTER));
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(truelbl->key));
+ }
+
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(right),size));
+ while(size--)
+ pic16_emitpcode(POC_IORFW, pic16_popGet(AOP(right),size));
+
+
+ emitSKPZ;
+ if(rFalseIfx.condition) {
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(rFalseIfx.lbl->key));
+ pic16_emitpLabel(truelbl->key);
+ }else {
+ rFalseIfx.condition ^= 1;
+ genSkipCond(&rFalseIfx,right,s,7);
+ }
+
+ if(ifx) ifx->generated = 1;
+
+ if ((AOP_TYPE(result) != AOP_CRY) && (AOP_SIZE(result)))
+ goto check_carry;
+
+ return;
+ }
+
+ if((size == 1) && (0 == (lp1&0xff))) {
+ /* lower byte of signed word is zero */
+ DEBUGpic16_emitcode(";left lit","line = %d 0x%x+1 low byte is zero",__LINE__,lit);
+ i = ((lp1 >> 8) & 0xff) ^0x80;
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(right),size));
+ pic16_emitpcode(POC_ADDLW, pic16_popGetLit( 0x80));
+ pic16_emitpcode(POC_ADDLW, pic16_popGetLit(0x100-i));
+
+ if ((AOP_TYPE(result) != AOP_CRY) && (AOP_SIZE(result))) {
+ emitTOGC;
+ if(ifx) ifx->generated = 1;
+ goto check_carry;
+ } else {
+ rFalseIfx.condition ^= 1;
+ genSkipc(&rFalseIfx);
+ if(ifx) ifx->generated = 1;
+ }
+
+ return;
+ }
+
+ if(lit & (0x80 << (size*8))) {
+ /* Lit is less than zero */
+ DEBUGpic16_emitcode(";left lit","line = %d 0x%x is less than 0",__LINE__,lit);
+ //rFalseIfx.condition ^= 1;
+ //genSkipCond(&rFalseIfx,left,size,7);
+ //rFalseIfx.condition ^= 1;
+ pic16_emitpcode(POC_BTFSS, pic16_newpCodeOpBit(pic16_aopGet(AOP(right),size,FALSE,FALSE),7,0, PO_GPR_REGISTER));
+ //pic16_emitpcode(POC_GOTO, pic16_popGetLabel(truelbl->key));
+
+ if(rFalseIfx.condition)
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(rFalseIfx.lbl->key));
+ else
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(truelbl->key));
+
+
+ } else {
+ /* Lit is greater than or equal to zero */
+ DEBUGpic16_emitcode(";left lit","line = %d 0x%x is greater than 0",__LINE__,lit);
+ //rFalseIfx.condition ^= 1;
+ //genSkipCond(&rFalseIfx,right,size,7);
+ //rFalseIfx.condition ^= 1;
+
+ //pic16_emitpcode(POC_BTFSC, pic16_newpCodeOpBit(pic16_aopGet(AOP(right),size,FALSE,FALSE),7,0));
+ //pic16_emitpcode(POC_GOTO, pic16_popGetLabel(rFalseIfx.lbl->key));
+
+ pic16_emitpcode(POC_BTFSC, pic16_newpCodeOpBit(pic16_aopGet(AOP(right),size,FALSE,FALSE),7,0, PO_GPR_REGISTER));
+ if(rFalseIfx.condition)
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(truelbl->key));
+ else
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(rFalseIfx.lbl->key));
+
+ }
+
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit((lp1 >> (size*8)) & 0xff));
+ pic16_emitpcode(POC_SUBFW, pic16_popGet(AOP(right),size));
+
+ while(size--) {
+
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit((lp1 >> (size*8)) & 0xff));
+ emitSKPNZ;
+ pic16_emitpcode(POC_SUBFW, pic16_popGet(AOP(right),size));
+ }
+ rFalseIfx.condition ^= 1;
+ //rFalseIfx.condition = 1;
+ genSkipc(&rFalseIfx);
+
+ pic16_emitpLabel(truelbl->key);
+
+ if(ifx) ifx->generated = 1;
+
+
+ if ((AOP_TYPE(result) != AOP_CRY) && (AOP_SIZE(result)))
+ goto check_carry;
+
+ return;
+ // end of if (sign)
+ } else {
+
+ /* compare word or long to an unsigned literal on the right.*/
+
+
+ size--;
+ if(lit < 0xff) {
+ DEBUGpic16_emitcode ("; ***","%s %d lit =0x%x < 0xff",__FUNCTION__,__LINE__,lit);
+ switch (lit) {
+ case 0:
+ break; /* handled above */
+/*
+ case 0xff:
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(right),size));
+ while(size--)
+ pic16_emitpcode(POC_IORFW, pic16_popGet(AOP(right),size));
+ genSkipz2(&rFalseIfx,0);
+ break;
+*/
+ default:
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(right),size));
+ while(--size)
+ pic16_emitpcode(POC_IORFW, pic16_popGet(AOP(right),size));
+
+ emitSKPZ;
+ if(rFalseIfx.condition)
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(rFalseIfx.lbl->key));
+ else
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(truelbl->key));
+
+
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit(lit+1));
+ pic16_emitpcode(POC_SUBFW, pic16_popGet(AOP(right),0));
+
+ rFalseIfx.condition ^= 1;
+ genSkipc(&rFalseIfx);
+ }
+
+ pic16_emitpLabel(truelbl->key);
+
+ if(ifx) ifx->generated = 1;
+
+ if ((AOP_TYPE(result) != AOP_CRY) && (AOP_SIZE(result)))
+ goto check_carry;
+
+ return;
+ }
+
+
+ lit++;
+ DEBUGpic16_emitcode ("; ***","%s %d lit =0x%x",__FUNCTION__,__LINE__,lit);
+ i = (lit >> (size*8)) & 0xff;
+
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit(i));
+ pic16_emitpcode(POC_SUBFW, pic16_popGet(AOP(right),size));
+
+ while(size--) {
+ i = (lit >> (size*8)) & 0xff;
+
+ if(i) {
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit(i));
+ emitSKPNZ;
+ pic16_emitpcode(POC_SUBFW, pic16_popGet(AOP(right),size));
+ } else {
+ /* this byte of the lit is zero,
+ * if it's not the last then OR in the variable */
+ if(size)
+ pic16_emitpcode(POC_IORFW, pic16_popGet(AOP(right),size));
+ }
+ }
+
+
+ pic16_emitpLabel(lbl->key);
+
+ rFalseIfx.condition ^= 1;
+
+ genSkipc(&rFalseIfx);
+ }
+
+ if(sign)
+ pic16_emitpLabel(truelbl->key);
+ if(ifx) ifx->generated = 1;
+
+ if ((AOP_TYPE(result) != AOP_CRY) && (AOP_SIZE(result)))
+ goto check_carry;
+
+ return;
+ }
+ }
+ /* Compare two variables */
+
+ DEBUGpic16_emitcode(";sign","%d",sign);
+
+ size--;
+ if(sign) {
+ /* Sigh. thus sucks... */
+ if(size) {
+ pCodeOp *pctemp;
+
+ pctemp = pic16_popGetTempReg(1);
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(left),size));
+ pic16_emitpcode(POC_MOVWF, pctemp); //pic16_pic16_popRegFromIdx(pic16_Gstack_base_addr));
+ pic16_emitpcode(POC_MOVLW, pic16_popGetLit(0x80));
+ pic16_emitpcode(POC_XORWF, pctemp); //pic16_popRegFromIdx(pic16_Gstack_base_addr));
+ pic16_emitpcode(POC_XORFW, pic16_popGet(AOP(right),size));
+ pic16_emitpcode(POC_SUBFW, pctemp); //pic16_popRegFromIdx(pic16_Gstack_base_addr));
+ pic16_popReleaseTempReg(pctemp, 1);
+ } else {
+ /* Signed char comparison */
+ /* Special thanks to Nikolai Golovchenko for this snippet */
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(right),0));
+ pic16_emitpcode(POC_SUBFW, pic16_popGet(AOP(left),0));
+ pic16_emitpcode(POC_RRCFW, pic16_popGet(AOP(left),0)); /* could be any register */
+ pic16_emitpcode(POC_XORFW, pic16_popGet(AOP(left),0));
+ pic16_emitpcode(POC_XORFW, pic16_popGet(AOP(right),0));
+ pic16_emitpcode(POC_ADDLW, pic16_popGetLit(0x80));
+
+ DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+ genSkipc(&rFalseIfx);
+
+ if(ifx) ifx->generated = 1;
+
+ if ((AOP_TYPE(result) != AOP_CRY) && (AOP_SIZE(result)))
+ goto check_carry;
+
+ return;
+ }
+
+ } else {
+
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(right),size));
+ pic16_emitpcode(POC_SUBFW, pic16_popGet(AOP(left),size));
+ }
+
+
+ /* The rest of the bytes of a multi-byte compare */
+ while (size) {
+
+ emitSKPZ;
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(lbl->key));
+ size--;
+
+ pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(right),size));
+ pic16_emitpcode(POC_SUBFW, pic16_popGet(AOP(left),size));
+
+
+ }
+
+ pic16_emitpLabel(lbl->key);
+
+ DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+ if ((AOP_TYPE(result) == AOP_CRY && AOP_SIZE(result)) ||
+ (AOP_TYPE(result) == AOP_REG)) {
+ pic16_emitpcode(POC_CLRF, pic16_popGet(AOP(result),0));
+ pic16_emitpcode(POC_RLCF, pic16_popGet(AOP(result),0));
+ } else {
+ genSkipc(&rFalseIfx);
+ }
+ //genSkipc(&rFalseIfx);
+ if(ifx) ifx->generated = 1;
+
+
+ if ((AOP_TYPE(result) != AOP_CRY) && (AOP_SIZE(result)))
+ goto check_carry;
+
+ return;
+
+ }
+
+check_carry:
+ if ((AOP_TYPE(result) != AOP_CRY)
+ && AOP_SIZE(result)) {
+ DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+
+ if(!ifx)pic16_emitpLabel( rFalseIfx.lbl->key );
+
+ pic16_outBitC(result);
+ } else {
+ DEBUGpic16_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+ /* if the result is used in the next
+ ifx conditional branch then generate
+ code a little differently */
+ if (ifx )
+ genIfxJump (ifx,"c");
+ else
+ pic16_outBitC(result);
+ /* leave the result in acc */
+ }
+
+}
+
+#else /* old version of genCmp() */ /* } else { */
+
+/* check all condition and return appropriate instruction, POC_CPFSGT or POC_CPFFSLT */
+static int selectCompareOp(resolvedIfx *rIfx, iCode *ifx,
+ operand *result, int offset, int invert_op)
+{
+ /* add code here */
+
+ /* check condition, > or < ?? */
+ if(rIfx->condition != 0)invert_op ^= 1;
+
+ if(ifx && IC_FALSE(ifx))invert_op ^= 1;
+
+ if(!ifx)invert_op ^= 1;
+
+ DEBUGpic16_emitcode("; +++", "%s:%d %s] rIfx->condition= %d, ifx&&IC_FALSE(ifx)= %d, invert_op = %d",
+ __FILE__, __LINE__, __FUNCTION__, rIfx->condition, (ifx && IC_FALSE(ifx)), invert_op);
+
+ /* do selection */
+ if(!invert_op)return POC_CPFSGT;
+ else return POC_CPFSLT;
+}
+
+static int compareAopfirstpass=1;
+
+static void compareAop(resolvedIfx *resIfx, iCode *ifx, symbol *falselbl,
+ operand *oper, int offset, operand *result,
+ int sign, int invert_op, pCodeOp *pcop, pCodeOp *pcop2,
+ symbol *tlbl)
+{
+ int op;
+ symbol *truelbl;
+
+ /* invert if there is a result to be loaded, in order to fit,
+ * SETC/CLRC sequence */
+ if(AOP_SIZE(result))invert_op ^= 1;
+
+// if(sign && !offset)invert_op ^= 1;
+
+// if(sign)invert_op ^= 1;
+
+ op = selectCompareOp(resIfx, ifx, result, offset, invert_op);
+
+ if(AOP_SIZE(result) && compareAopfirstpass) {
+ if(!ifx) {
+ if(pcop2)
+ pic16_emitpcode(POC_SETF, pcop2);
+ else
+ emitSETC;
+ } else {
+ if(pcop2)
+ pic16_emitpcode(POC_CLRF, pcop2);
+ else
+ emitCLRC;
+ }
+ }
+
+ compareAopfirstpass = 0;
+
+ /* there is a bug when comparing operands with size > 1,
+ * because higher bytes can be equal and test should be performed
+ * to the next lower byte, current algorithm, considers operands
+ * inequal in these cases! -- VR 20041107 */
+
+
+ if(pcop)
+ pic16_emitpcode(op, pcop);
+ else
+ pic16_emitpcode(op, pic16_popGet(AOP(oper), offset));
+
+
+ if((!sign || !offset) && AOP_SIZE(result)) {
+ if(!ifx) {
+ if(pcop2)
+ pic16_emitpcode(POC_CLRF, pcop2);
+ else
+ emitCLRC;
+ } else {
+ if(pcop2)
+ pic16_emitpcode(POC_SETF, pcop2);
+ else
+ emitSETC;
+ }
+
+ /* don't emit final branch (offset == 0) */
+ if(offset) {
+
+ if(pcop2)
+ pic16_emitpcode(POC_RRCF, pcop2);
+
+ pic16_emitpcode(POC_BNC, pic16_popGetLabel(falselbl->key));
+ }
+ } else {
+ if((ifx && (IC_TRUE(ifx)!=NULL)) || (sign && !offset)) {
+ DEBUGpic16_emitcode ("; +++","%s: %d: ifx = %p, IC_TRUE(ifx) = %d, sign = %d, offset = %d",
+ __FUNCTION__, __LINE__, ifx, (ifx&&IC_TRUE(ifx)), sign, offset);
+
+ truelbl = newiTempLabel( NULL );
+ pic16_emitpcode(POC_BRA, pic16_popGetLabel(truelbl->key));
+ if((!ifx || !IC_TRUE(ifx)) && (sign && !offset))
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(tlbl->key));
+ else
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(resIfx->lbl->key));
+ pic16_emitpLabel(truelbl->key);
+ } else {
+ pic16_emitpcode(POC_GOTO, pic16_popGetLabel(resIfx->lbl->key));
+ }
+ }
+}
+
+
+
+
+#if 1 /* { */
+static void genCmp (operand *left, operand *right,
+ operand *result, iCode *ifx, int sign)
+{
+ int size, cmpop=1;
+ long lit = 0L;
+ resolvedIfx rFalseIfx;
+ symbol *falselbl, *tlbl;