+ if (ifx && /* !AOP_SIZE(result) */
+ OP_SYMBOL (result) &&
+ OP_SYMBOL (result)->regType == REG_CND)
+ {
+ symbol *tlbl;
+ /* if they are both bit variables */
+ if (AOP_TYPE (left) == AOP_CRY &&
+ ((AOP_TYPE (right) == AOP_CRY) || (AOP_TYPE (right) == AOP_LIT)))
+ {
+ if (AOP_TYPE (right) == AOP_LIT)
+ {
+ unsigned long lit = (unsigned long) floatFromVal (AOP (IC_RIGHT (ic))->aopu.aop_lit);
+ if (lit == 0L)
+ {
+ emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
+ emitcode ("cpl", "c");
+ }
+ else if (lit == 1L)
+ {
+ emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
+ }
+ else
+ {
+ emitcode ("clr", "c");
+ }
+ /* AOP_TYPE(right) == AOP_CRY */
+ }
+ else
+ {
+ symbol *lbl = newiTempLabel (NULL);
+ emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
+ emitcode ("jb", "%s,%05d$", AOP (right)->aopu.aop_dir, (lbl->key + 100));
+ emitcode ("cpl", "c");
+ emitcode ("", "%05d$:", (lbl->key + 100));
+ }
+ /* if true label then we jump if condition
+ supplied is true */
+ tlbl = newiTempLabel (NULL);
+ if (IC_TRUE (ifx))
+ {
+ emitcode ("jnc", "%05d$", tlbl->key + 100);
+ emitcode ("ljmp", "%05d$", IC_TRUE (ifx)->key + 100);
+ }
+ else
+ {
+ emitcode ("jc", "%05d$", tlbl->key + 100);
+ emitcode ("ljmp", "%05d$", IC_FALSE (ifx)->key + 100);
+ }
+ emitcode ("", "%05d$:", tlbl->key + 100);
+ }
+ else
+ {
+ tlbl = newiTempLabel (NULL);
+ gencjneshort (left, right, tlbl);
+ if (IC_TRUE (ifx))
+ {
+ emitcode ("ljmp", "%05d$", IC_TRUE (ifx)->key + 100);
+ emitcode ("", "%05d$:", tlbl->key + 100);
+ }
+ else
+ {
+ symbol *lbl = newiTempLabel (NULL);
+ emitcode ("sjmp", "%05d$", lbl->key + 100);
+ emitcode ("", "%05d$:", tlbl->key + 100);
+ emitcode ("ljmp", "%05d$", IC_FALSE (ifx)->key + 100);
+ emitcode ("", "%05d$:", lbl->key + 100);
+ }
+ }
+ /* mark the icode as generated */
+ ifx->generated = 1;
+
+ freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
+ freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
+ return;
+ }
+
+ /* if they are both bit variables */
+ if (AOP_TYPE (left) == AOP_CRY &&
+ ((AOP_TYPE (right) == AOP_CRY) || (AOP_TYPE (right) == AOP_LIT)))
+ {
+ if (AOP_TYPE (right) == AOP_LIT)
+ {
+ unsigned long lit = (unsigned long) floatFromVal (AOP (IC_RIGHT (ic))->aopu.aop_lit);
+ if (lit == 0L)
+ {
+ emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
+ emitcode ("cpl", "c");
+ }
+ else if (lit == 1L)
+ {
+ emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
+ }
+ else
+ {
+ emitcode ("clr", "c");
+ }
+ /* AOP_TYPE(right) == AOP_CRY */
+ }
+ else
+ {
+ symbol *lbl = newiTempLabel (NULL);
+ emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
+ emitcode ("jb", "%s,%05d$", AOP (right)->aopu.aop_dir, (lbl->key + 100));
+ emitcode ("cpl", "c");
+ emitcode ("", "%05d$:", (lbl->key + 100));
+ }
+
+ freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
+ freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
+
+ aopOp (result, ic, TRUE, FALSE);
+
+ /* c = 1 if egal */
+ if (AOP_TYPE (result) == AOP_CRY && AOP_SIZE (result))
+ {
+ outBitC (result);
+ goto release;
+ }
+ if (ifx)
+ {
+ genIfxJump (ifx, "c");
+ goto release;
+ }
+ /* if the result is used in an arithmetic operation
+ then put the result in place */
+ outBitC (result);
+ }
+ else
+ {
+ gencjne (left, right, newiTempLabel (NULL));
+
+ freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
+ freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
+
+ aopOp (result, ic, TRUE, FALSE);
+
+ if (AOP_TYPE (result) == AOP_CRY && AOP_SIZE (result))
+ {
+ aopPut (AOP (result), "a", 0);
+ goto release;
+ }
+ if (ifx)
+ {
+ genIfxJump (ifx, "a");
+ goto release;
+ }
+ /* if the result is used in an arithmetic operation
+ then put the result in place */
+ if (AOP_TYPE (result) != AOP_CRY)
+ outAcc (result);
+ /* leave the result in acc */
+ }
+
+release:
+ freeAsmop (result, NULL, ic, TRUE);
+}
+
+/*-----------------------------------------------------------------*/
+/* ifxForOp - returns the icode containing the ifx for operand */
+/*-----------------------------------------------------------------*/
+static iCode *
+ifxForOp (operand * op, iCode * ic)
+{
+ /* if true symbol then needs to be assigned */
+ if (IS_TRUE_SYMOP (op))
+ return NULL;
+
+ /* if this has register type condition and
+ the next instruction is ifx with the same operand
+ and live to of the operand is upto the ifx only then */
+ if (ic->next &&
+ ic->next->op == IFX &&
+ IC_COND (ic->next)->key == op->key &&
+ OP_SYMBOL (op)->liveTo <= ic->next->seq)
+ return ic->next;
+
+ return NULL;
+}
+/*-----------------------------------------------------------------*/
+/* genAndOp - for && operation */
+/*-----------------------------------------------------------------*/
+static void
+genAndOp (iCode * ic)
+{
+ operand *left, *right, *result;
+ symbol *tlbl;
+
+ D (emitcode (";", "genAndOp "););
+
+ /* note here that && operations that are in an
+ if statement are taken away by backPatchLabels
+ only those used in arthmetic operations remain */
+ AOP_OP_2 (ic);
+ AOP_SET_LOCALS (ic);
+
+ /* if both are bit variables */
+ if (AOP_TYPE (left) == AOP_CRY &&
+ AOP_TYPE (right) == AOP_CRY)
+ {
+ emitcode ("mov", "c,%s", AOP (left)->aopu.aop_dir);
+ emitcode ("anl", "c,%s", AOP (right)->aopu.aop_dir);
+ freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
+ freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
+
+ aopOp (result,ic,FALSE, FALSE);
+ outBitC (result);
+ }
+ else
+ {
+ tlbl = newiTempLabel (NULL);
+ toBoolean (left);
+ emitcode ("jz", "%05d$", tlbl->key + 100);
+ toBoolean (right);
+ emitcode ("", "%05d$:", tlbl->key + 100);
+ freeAsmop (left, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
+ freeAsmop (right, NULL, ic, (RESULTONSTACK (ic) ? FALSE : TRUE));
+
+ aopOp (result,ic,FALSE, FALSE);
+ outBitAcc (result);
+ }
+ freeAsmop (result, NULL, ic, TRUE);
+}
+