+ if(AOP_TYPE(left) == AOP_LIT) {
+ //symbol *lbl = newiTempLabel(NULL);
+
+ //EXPERIMENTAL lit = (unsigned long)(floatFromVal(AOP(left)->aopu.aop_lit));
+
+
+ DEBUGpic14_emitcode(";left lit","lit = 0x%x,sign=%d",lit,sign);
+
+ /* Special cases */
+ if((lit == 0) && (sign == 0)){
+
+ size--;
+ emitpcode(POC_MOVFW, popGet(AOP(right),size));
+ while(size)
+ emitpcode(POC_IORFW, 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)
+ emitpcode(POC_GOTO,popGetLabel(rFalseIfx.lbl->key));
+
+ if(ifx) ifx->generated = 1;
+ return;
+ }
+
+ if(sign) {
+ /* signed comparisons to a literal byte */
+
+ int lp1 = (lit+1) & 0xff;
+
+ DEBUGpic14_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:
+ emitpcode(POC_MOVFW, popGet(AOP(right),0));
+ emitpcode(POC_XORLW, popGetLit(0x7f));
+ genSkipz2(&rFalseIfx,1);
+ break;
+ default:
+ emitpcode(POC_MOVFW, popGet(AOP(right),0));
+ emitpcode(POC_ADDLW, popGetLit(0x80));
+ emitpcode(POC_ADDLW, popGetLit(((0-(lit+1)) & 0xff) ^ 0x80));
+ rFalseIfx.condition ^= 1;
+ genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+ break;
+ }
+ if(ifx) ifx->generated = 1;
+ } else {
+ /* unsigned comparisons to a literal byte */
+
+ switch(lit & 0xff ) {
+ case 0:
+ emitpcode(POC_MOVFW, popGet(AOP(right),0));
+ genSkipz2(&rFalseIfx,0);
+ if(ifx) ifx->generated = 1;
+ break;
+ case 0x7f:
+ genSkipCond(&rFalseIfx,right,0,7);
+ if(ifx) ifx->generated = 1;
+ break;
+
+ default:
+ emitpcode(POC_MOVLW, popGetLit((lit+1) & 0xff));
+ emitpcode(POC_SUBFW, popGet(AOP(right),0));
+ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+ rFalseIfx.condition ^= 1;
+ if (AOP_TYPE(result) == AOP_CRY) {
+ genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+ if(ifx) ifx->generated = 1;
+ } else {
+ DEBUGpic14_emitcode ("; ***","%s %d RFIfx.cond=%d",__FUNCTION__,__LINE__, rFalseIfx.condition);
+ emitpcode(POC_CLRF, popGet(AOP(result),0));
+ emitpcode(POC_RLF, popGet(AOP(result),0));
+ emitpcode(POC_MOVLW, popGetLit(0x01));
+ emitpcode(POC_XORWF, popGet(AOP(result),0));
+ }
+ break;
+ }
+ }
+
+ //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 */
+
+
+ DEBUGpic14_emitcode(";left lit = -1","line = %d ",__LINE__);
+ rFalseIfx.condition ^= 1;
+ genSkipCond(&rFalseIfx,right,size,7);
+ if(ifx) ifx->generated = 1;
+ return;
+ }
+
+ if(lit == 0) {
+ int s = size;
+
+ if(rFalseIfx.condition) {
+ emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(right),size,FALSE,FALSE),7,0));
+ emitpcode(POC_GOTO, popGetLabel(truelbl->key));
+ }
+
+ emitpcode(POC_MOVFW, popGet(AOP(right),size));
+ while(size--)
+ emitpcode(POC_IORFW, popGet(AOP(right),size));
+
+
+ emitSKPZ;
+ if(rFalseIfx.condition) {
+ emitpcode(POC_GOTO, popGetLabel(rFalseIfx.lbl->key));
+ emitpLabel(truelbl->key);
+ }else {
+ rFalseIfx.condition ^= 1;
+ genSkipCond(&rFalseIfx,right,s,7);
+ }
+
+ if(ifx) ifx->generated = 1;
+ return;
+ }
+
+ if((size == 1) && (0 == (lp1&0xff))) {
+ /* lower byte of signed word is zero */
+ DEBUGpic14_emitcode(";left lit","line = %d 0x%x+1 low byte is zero",__LINE__,lit);
+ i = ((lp1 >> 8) & 0xff) ^0x80;
+ emitpcode(POC_MOVFW, popGet(AOP(right),size));
+ emitpcode(POC_ADDLW, popGetLit( 0x80));
+ emitpcode(POC_ADDLW, popGetLit(0x100-i));
+ rFalseIfx.condition ^= 1;
+ genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+
+
+ if(ifx) ifx->generated = 1;
+ return;
+ }
+
+ if(lit & (0x80 << (size*8))) {
+ /* Lit is less than zero */
+ DEBUGpic14_emitcode(";left lit","line = %d 0x%x is less than 0",__LINE__,lit);
+ //rFalseIfx.condition ^= 1;
+ //genSkipCond(&rFalseIfx,left,size,7);
+ //rFalseIfx.condition ^= 1;
+ emitpcode(POC_BTFSS, newpCodeOpBit(aopGet(AOP(right),size,FALSE,FALSE),7,0));
+ //emitpcode(POC_GOTO, popGetLabel(truelbl->key));
+
+ if(rFalseIfx.condition)
+ emitpcode(POC_GOTO, popGetLabel(rFalseIfx.lbl->key));
+ else
+ emitpcode(POC_GOTO, popGetLabel(truelbl->key));
+
+
+ } else {
+ /* Lit is greater than or equal to zero */
+ DEBUGpic14_emitcode(";left lit","line = %d 0x%x is greater than 0",__LINE__,lit);
+ //rFalseIfx.condition ^= 1;
+ //genSkipCond(&rFalseIfx,right,size,7);
+ //rFalseIfx.condition ^= 1;
+
+ //emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(right),size,FALSE,FALSE),7,0));
+ //emitpcode(POC_GOTO, popGetLabel(rFalseIfx.lbl->key));
+
+ emitpcode(POC_BTFSC, newpCodeOpBit(aopGet(AOP(right),size,FALSE,FALSE),7,0));
+ if(rFalseIfx.condition)
+ emitpcode(POC_GOTO, popGetLabel(truelbl->key));
+ else
+ emitpcode(POC_GOTO, popGetLabel(rFalseIfx.lbl->key));
+
+ }
+
+
+ emitpcode(POC_MOVLW, popGetLit((lp1 >> (size*8)) & 0xff));
+ emitpcode(POC_SUBFW, popGet(AOP(right),size));
+
+ while(size--) {
+
+ emitpcode(POC_MOVLW, popGetLit((lp1 >> (size*8)) & 0xff));
+ emitSKPNZ;
+ emitpcode(POC_SUBFW, popGet(AOP(right),size));
+ }
+ rFalseIfx.condition ^= 1;
+ //rFalseIfx.condition = 1;
+ genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+
+ emitpLabel(truelbl->key);
+
+ if(ifx) ifx->generated = 1;
+ return;
+ // end of if (sign)
+ } else {
+
+ /* compare word or long to an unsigned literal on the right.*/
+
+
+ size--;
+ if(lit < 0xff) {
+ DEBUGpic14_emitcode ("; ***","%s %d lit =0x%x < 0xff",__FUNCTION__,__LINE__,lit);
+ switch (lit) {
+ case 0:
+ break; /* handled above */
+ /*
+ case 0xff:
+ emitpcode(POC_MOVFW, popGet(AOP(right),size));
+ while(size--)
+ emitpcode(POC_IORFW, popGet(AOP(right),size));
+ genSkipz2(&rFalseIfx,0);
+ break;
+ */
+ default:
+ emitpcode(POC_MOVFW, popGet(AOP(right),size));
+ while(--size)
+ emitpcode(POC_IORFW, popGet(AOP(right),size));
+
+ emitSKPZ;
+ if(rFalseIfx.condition)
+ emitpcode(POC_GOTO, popGetLabel(rFalseIfx.lbl->key));
+ else
+ emitpcode(POC_GOTO, popGetLabel(truelbl->key));
+
+
+ emitpcode(POC_MOVLW, popGetLit(lit+1));
+ emitpcode(POC_SUBFW, popGet(AOP(right),0));
+
+ rFalseIfx.condition ^= 1;
+ genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+ }
+
+ emitpLabel(truelbl->key);
+
+ if(ifx) ifx->generated = 1;
+ return;
+ }
+
+
+ lit++;
+ DEBUGpic14_emitcode ("; ***","%s %d lit =0x%x",__FUNCTION__,__LINE__,lit);
+ i = (lit >> (size*8)) & 0xff;
+
+ emitpcode(POC_MOVLW, popGetLit(i));
+ emitpcode(POC_SUBFW, popGet(AOP(right),size));
+
+ while(size--) {
+ i = (lit >> (size*8)) & 0xff;
+
+ if(i) {
+ emitpcode(POC_MOVLW, popGetLit(i));
+ emitSKPNZ;
+ emitpcode(POC_SUBFW, 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)
+ emitpcode(POC_IORFW, popGet(AOP(right),size));
+ }
+ }
+
+
+ emitpLabel(lbl->key);
+
+ rFalseIfx.condition ^= 1;
+ genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+ }
+
+ if(sign)
+ emitpLabel(truelbl->key);
+ if(ifx) ifx->generated = 1;
+ return;
+ }
+ }
+ /* Compare two variables */
+
+ DEBUGpic14_emitcode(";sign","%d",sign);
+
+ size--;
+ if(sign) {
+ /* Sigh. thus sucks... */
+ if(size) {
+ emitpcode(POC_MOVFW, popGet(AOP(left),size));
+ emitpcode(POC_MOVWF, popRegFromIdx(Gstack_base_addr));
+ emitpcode(POC_MOVLW, popGetLit(0x80));
+ emitpcode(POC_XORWF, popRegFromIdx(Gstack_base_addr));
+ emitpcode(POC_XORFW, popGet(AOP(right),size));
+ emitpcode(POC_SUBFW, popRegFromIdx(Gstack_base_addr));
+ } else {
+ /* Signed char comparison */
+ /* Special thanks to Nikolai Golovchenko for this snippet */
+ emitpcode(POC_MOVFW, popGet(AOP(right),0));
+ emitpcode(POC_SUBFW, popGet(AOP(left),0));
+ emitpcode(POC_RRFW, popGet(AOP(left),0)); /* could be any register */
+ emitpcode(POC_XORFW, popGet(AOP(left),0));
+ emitpcode(POC_XORFW, popGet(AOP(right),0));
+ emitpcode(POC_ADDLW, popGetLit(0x80));
+
+ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+ genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+
+ if(ifx) ifx->generated = 1;
+ return;
+ }
+
+ } else {
+
+ emitpcode(POC_MOVFW, popGet(AOP(right),size));
+ emitpcode(POC_SUBFW, popGet(AOP(left),size));
+ }
+
+
+ /* The rest of the bytes of a multi-byte compare */
+ while (size) {
+
+ emitSKPZ;
+ emitpcode(POC_GOTO, popGetLabel(lbl->key));
+ size--;
+
+ emitpcode(POC_MOVFW, popGet(AOP(right),size));
+ emitpcode(POC_SUBFW, popGet(AOP(left),size));
+
+
+ }
+
+ emitpLabel(lbl->key);
+
+ DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
+ if ((AOP_TYPE(result) == AOP_CRY && AOP_SIZE(result)) ||
+ (AOP_TYPE(result) == AOP_REG)) {
+ emitpcode(POC_CLRF, popGet(AOP(result),0));
+ emitpcode(POC_RLF, popGet(AOP(result),0));
+ } else {
+ genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+ }
+ //genSkipc(&rFalseIfx); assert ( !"genSkipc should have inverse logic" );
+ if(ifx) ifx->generated = 1;
+
+ return;
+