- operand *left, *right, *result;
- unsigned long lit = 0L;
- int size,offset=0;
-
- FENTRY;
- DEBUGpic14_emitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
-
- if(ifx)
- DEBUGpic14_emitcode ("; ifx is non-null","");
- else
- DEBUGpic14_emitcode ("; ifx is null","");
-
- aopOp((left=IC_LEFT(ic)),ic,FALSE);
- aopOp((right=IC_RIGHT(ic)),ic,FALSE);
- aopOp((result=IC_RESULT(ic)),ic,TRUE);
-
- size = max(AOP_SIZE(left),AOP_SIZE(right));
-
- DEBUGpic14_AopType(__LINE__,left,right,result);
-
- /* if literal, literal on the right or
- if the right is in a pointer register and left
- is not */
- if (aop_isLitLike (AOP(IC_LEFT(ic)))
- || (IS_AOP_PREG(right) && !IS_AOP_PREG(left))) {
- operand *tmp = right ;
- right = left;
- left = tmp;
- }
-
-
- 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--) {
- mov2w (AOP(right),offset); /* right might be litLike() */
- emitpcode(POC_XORFW,popGet(AOP(left),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 */