-
- if(ifx && !AOP_SIZE(result)){
- 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(right)->aopu.aop_lit);
- if(lit == 0L){
- pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
- pic14_emitcode("cpl","c");
- } else if(lit == 1L) {
- pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
- } else {
- pic14_emitcode("clr","c");
- }
- /* AOP_TYPE(right) == AOP_CRY */
- } else {
- symbol *lbl = newiTempLabel(NULL);
- pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
- pic14_emitcode("jb","%s,%05d_DS_",AOP(right)->aopu.aop_dir,(lbl->key+100));
- pic14_emitcode("cpl","c");
- pic14_emitcode("","%05d_DS_:",(lbl->key+100));
- }
- /* if true label then we jump if condition
- supplied is true */
- tlbl = newiTempLabel(NULL);
- if ( IC_TRUE(ifx) ) {
- pic14_emitcode("jnc","%05d_DS_",tlbl->key+100);
- pic14_emitcode("ljmp","%05d_DS_",IC_TRUE(ifx)->key+100);
- } else {
- pic14_emitcode("jc","%05d_DS_",tlbl->key+100);
- pic14_emitcode("ljmp","%05d_DS_",IC_FALSE(ifx)->key+100);
- }
- pic14_emitcode("","%05d_DS_:",tlbl->key+100+labelOffset);
-
- {
- /* left and right are both bit variables, result is carry */
- resolvedIfx rIfx;
-
- resolveIfx(&rIfx,ifx);
-
- emitpcode(POC_MOVLW,popGet(AOP(left),0));
- emitpcode(POC_ANDFW,popGet(AOP(left),0));
- emitpcode(POC_BTFSC,popGet(AOP(right),0));
- emitpcode(POC_ANDLW,popGet(AOP(left),0));
- genSkipz2(&rIfx,0);
- }
- } else {
-
- /* They're not both bit variables. Is the right a literal? */
- if(AOP_TYPE(right) == AOP_LIT) {
- lit = (unsigned long)floatFromVal(AOP(right)->aopu.aop_lit);
-
- switch(size) {
-
- case 1:
- switch(lit & 0xff) {
- case 1:
- if ( IC_TRUE(ifx) ) {
- emitpcode(POC_DECFW,popGet(AOP(left),offset));
- emitSKPNZ;
- emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
- } else {
- emitpcode(POC_DECFSZW,popGet(AOP(left),offset));
- emitpcode(POC_GOTO,popGetLabel(IC_FALSE(ifx)->key));
- }
- break;
- case 0xff:
- if ( IC_TRUE(ifx) ) {
- emitpcode(POC_INCFW,popGet(AOP(left),offset));
- emitSKPNZ;
- emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
- } else {
- emitpcode(POC_INCFSZW,popGet(AOP(left),offset));
- emitpcode(POC_GOTO,popGetLabel(IC_FALSE(ifx)->key));
- }
- break;
- default:
- emitpcode(POC_MOVFW,popGet(AOP(left),offset));
- if(lit)
- emitpcode(POC_XORLW,popGetLit(lit & 0xff));
- genSkip(ifx,'z');
- }
-
-
- /* end of size == 1 */
- break;
-
- case 2:
- genc16bit2lit(left,lit,offset);
- genSkip(ifx,'z');
- break;
- /* end of size == 2 */
-
- default:
- /* size is 4 */
- if(lit==0) {
- emitpcode(POC_MOVFW,popGet(AOP(left),0));
- emitpcode(POC_IORFW,popGet(AOP(left),1));
- emitpcode(POC_IORFW,popGet(AOP(left),2));
- emitpcode(POC_IORFW,popGet(AOP(left),3));
-
- } else {
-
- /* search for patterns that can be optimized */
-
- genc16bit2lit(left,lit,0);
- lit >>= 16;
- if(lit) {
- genSkipz(ifx,IC_TRUE(ifx) == NULL);
- //genSkip(ifx,'z');
- genc16bit2lit(left,lit,2);
- } else {
- emitpcode(POC_IORFW,popGet(AOP(left),2));
- emitpcode(POC_IORFW,popGet(AOP(left),3));
-
- }
-
- }
-
- genSkip(ifx,'z');
- }
-
- ifx->generated = 1;
- goto release ;
-
-
- } else if(AOP_TYPE(right) == AOP_CRY ) {
- /* we know the left is not a bit, but that the right is */
- emitpcode(POC_MOVFW,popGet(AOP(left),offset));
- emitpcode( ( (IC_TRUE(ifx)) ? POC_BTFSC : POC_BTFSS),
- popGet(AOP(right),offset));
- emitpcode(POC_XORLW,popGetLit(1));
-
- /* if the two are equal, then W will be 0 and the Z bit is set
- * we could test Z now, or go ahead and check the high order bytes if
- * the variable we're comparing is larger than a byte. */
-
- while(--size)
- emitpcode(POC_IORFW,popGet(AOP(left),offset));
-
- if ( IC_TRUE(ifx) ) {
- emitSKPNZ;
- emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
- pic14_emitcode(" goto","_%05d_DS_",IC_TRUE(ifx)->key+100+labelOffset);
- } else {
- emitSKPZ;
- emitpcode(POC_GOTO,popGetLabel(IC_FALSE(ifx)->key));
- pic14_emitcode(" goto","_%05d_DS_",IC_FALSE(ifx)->key+100+labelOffset);
- }
-
- } else {
- /* They're both variables that are larger than bits */
- int s = size;
-
- tlbl = newiTempLabel(NULL);
-
- while(size--) {
- emitpcode(POC_MOVFW,popGet(AOP(left),offset));
- emitpcode(POC_XORFW,popGet(AOP(right),offset));
-
- if ( IC_TRUE(ifx) ) {
- if(size) {
- emitSKPZ;
- emitpcode(POC_GOTO,popGetLabel(tlbl->key));
- pic14_emitcode(" goto","_%05d_DS_",tlbl->key+100+labelOffset);
- } else {
- emitSKPNZ;
- emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
- pic14_emitcode(" goto","_%05d_DS_",IC_TRUE(ifx)->key+100+labelOffset);
- }
- } else {
- emitSKPZ;
- emitpcode(POC_GOTO,popGetLabel(IC_FALSE(ifx)->key));
- pic14_emitcode(" goto","_%05d_DS_",IC_FALSE(ifx)->key+100+labelOffset);
- }
- offset++;
- }
- if(s>1 && IC_TRUE(ifx)) {
- emitpLabel(tlbl->key);
- pic14_emitcode("","_%05d_DS_:",tlbl->key+100+labelOffset);
- }
- }
- }
- /* mark the icode as generated */
- ifx->generated = 1;
- goto release ;
- }
-
- /* 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(right)->aopu.aop_lit);
- if(lit == 0L){
- pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
- pic14_emitcode("cpl","c");
- } else if(lit == 1L) {
- pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
- } else {
- pic14_emitcode("clr","c");
- }
- /* AOP_TYPE(right) == AOP_CRY */
- } else {
- symbol *lbl = newiTempLabel(NULL);
- pic14_emitcode("mov","c,%s",AOP(left)->aopu.aop_dir);
- pic14_emitcode("jb","%s,%05d_DS_",AOP(right)->aopu.aop_dir,(lbl->key+100));
- pic14_emitcode("cpl","c");
- pic14_emitcode("","%05d_DS_:",(lbl->key+100));
- }
- /* c = 1 if egal */
- if (AOP_TYPE(result) == AOP_CRY && AOP_SIZE(result)){
- pic14_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 */
- pic14_outBitC(result);
- } else {
-
- DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- gencjne(left,right,result,ifx);
- /*
- if(ifx)
- gencjne(left,right,newiTempLabel(NULL));
- else {
- if(IC_TRUE(ifx)->key)
- gencjne(left,right,IC_TRUE(ifx)->key);
- else
- gencjne(left,right,IC_FALSE(ifx)->key);
- ifx->generated = 1;
- goto release ;
- }
- 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)
- pic14_outAcc(result);
- */
- /* leave the result in acc */
- }
-
-release:
- freeAsmop(left,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
- freeAsmop(right,NULL,ic,(RESULTONSTACK(ic) ? FALSE : TRUE));
- 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 */
- DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- 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;
-
- if (ic->next &&
- ic->next->op == IFX &&
- IC_COND(ic->next)->key == op->key) {
- DEBUGpic14_emitcode ("; WARNING ","%d IGNORING liveTo range in %s",__LINE__,__FUNCTION__);
- return ic->next;
- }
-
- DEBUGpic14_emitcode ("; NULL :(","%d",__LINE__);
- if (ic->next &&
- ic->next->op == IFX)
- DEBUGpic14_emitcode ("; ic-next"," is an IFX");