- emitSKPZ;
- emitcode("goto","_%05d_DS_",lbl->key+100+labelOffset);
- offset++;
-/*
- MOVA(aopGet(AOP(left),offset,FALSE,FALSE));
- if((AOP_TYPE(left) == AOP_DIR && AOP_TYPE(right) == AOP_LIT) &&
- ((unsigned int)((lit >> (offset*8)) & 0x0FFL) == 0))
- emitcode("jnz","%05d_DS_",lbl->key+100);
- else
- emitcode("cjne","a,%s,%05d_DS_",
- aopGet(AOP(right),offset,FALSE,TRUE),
- lbl->key+100);
- offset++;
-*/
- }
- } else {
- /* right is a pointer reg need both a & b */
- while(size--) {
- char *l = aopGet(AOP(left),offset,FALSE,FALSE);
- if(strcmp(l,"b"))
- emitcode("mov","b,%s",l);
- MOVA(aopGet(AOP(right),offset,FALSE,FALSE));
- emitcode("cjne","a,b,%05d_DS_",lbl->key+100);
- offset++;
- }
- }
-}
-
-/*-----------------------------------------------------------------*/
-/* gencjne - compare and jump if not equal */
-/*-----------------------------------------------------------------*/
-static void gencjne(operand *left, operand *right, symbol *lbl)
-{
- symbol *tlbl = newiTempLabel(NULL);
-
- DEBUGemitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- gencjneshort(left, right, lbl);
-
- emitcode("mov","a,%s",one);
- emitcode("sjmp","%05d_DS_",tlbl->key+100);
- emitcode("","%05d_DS_:",lbl->key+100);
- emitcode("clr","a");
- emitcode("","%05d_DS_:",tlbl->key+100);
-}
-
-
-/*-----------------------------------------------------------------*/
-/* genCmpEq - generates code for equal to */
-/*-----------------------------------------------------------------*/
-static void genCmpEq (iCode *ic, iCode *ifx)
-{
- operand *left, *right, *result;
- unsigned long lit = 0L;
- int size,offset=0;
-
- DEBUGemitcode ("; ***","%s %d",__FUNCTION__,__LINE__);
- if(ifx)
- DEBUGemitcode ("; ifx is non-null","");
- else
- DEBUGemitcode ("; 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));
-
- /* if literal, literal on the right or
- if the right is in a pointer register and left
- is not */
- if ((AOP_TYPE(IC_LEFT(ic)) == AOP_LIT) ||
- (IS_AOP_PREG(right) && !IS_AOP_PREG(left))) {
- operand *t = IC_RIGHT(ic);
- IC_RIGHT(ic) = IC_LEFT(ic);
- IC_LEFT(ic) = t;
- }
-
- 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(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_DS_",AOP(right)->aopu.aop_dir,(lbl->key+100));
- emitcode("cpl","c");
- emitcode("","%05d_DS_:",(lbl->key+100));
- }
- /* if true label then we jump if condition
- supplied is true */
- tlbl = newiTempLabel(NULL);
- if ( IC_TRUE(ifx) ) {
- emitcode("jnc","%05d_DS_",tlbl->key+100);
- emitcode("ljmp","%05d_DS_",IC_TRUE(ifx)->key+100);
- } else {
- emitcode("jc","%05d_DS_",tlbl->key+100);
- emitcode("ljmp","%05d_DS_",IC_FALSE(ifx)->key+100);
- }
- emitcode("","%05d_DS_:",tlbl->key+100+labelOffset);
- } 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);
- while (size--) {
-
- if(size >= 1) {
- int l = lit & 0xff;
- int h = (lit>>8) & 0xff;
- int optimized=0;
-
- /* Check special cases for integers */
- switch(lit & 0xffff) {
- case 0x0000:
- emitpcode(POC_MOVFW,popGet(AOP(left),offset,FALSE,FALSE));
- emitpcode(POC_IORFW,popGet(AOP(left),offset+1,FALSE,FALSE));
- //emitcode("movf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
- //emitcode("iorwf","%s,w",aopGet(AOP(left),offset+1,FALSE,FALSE));
- genSkip(ifx,'z');
- optimized++;
- break;
- case 0x0001:
- emitpcode(POC_DECFW,popGet(AOP(left),offset,FALSE,FALSE));
- emitpcode(POC_IORFW,popGet(AOP(left),offset+1,FALSE,FALSE));
- emitcode("decf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
- emitcode("iorwf","%s,w",aopGet(AOP(left),offset+1,FALSE,FALSE));
- genSkip(ifx,'z');
- optimized++;
- break;
- case 0x0100:
- emitpcode(POC_DECFW,popGet(AOP(left),offset+1,FALSE,FALSE));
- emitpcode(POC_IORFW,popGet(AOP(left),offset,FALSE,FALSE));
- emitcode("decf","%s,w",aopGet(AOP(left),offset+1,FALSE,FALSE));
- emitcode("iorwf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
- genSkip(ifx,'z');
- optimized++;
- break;
- case 0x00ff:
- emitpcode(POC_INCFW,popGet(AOP(left),offset,FALSE,FALSE));
- emitpcode(POC_IORFW,popGet(AOP(left),offset+1,FALSE,FALSE));
- emitcode("incf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
- emitcode("iorwf","%s,w",aopGet(AOP(left),offset+1,FALSE,FALSE));
- genSkip(ifx,'z');
- optimized++;
- break;
- case 0xff00:
- emitpcode(POC_INCFW,popGet(AOP(left),offset+1,FALSE,FALSE));
- emitpcode(POC_IORFW,popGet(AOP(left),offset,FALSE,FALSE));
- emitcode("incf","%s,w",aopGet(AOP(left),offset+1,FALSE,FALSE));
- emitcode("iorwf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
- genSkip(ifx,'z');
- optimized++;
- break;
- default:
- if(h == 0) {
- emitpcode(POC_MOVFW,popGet(AOP(left),offset,FALSE,FALSE));
- emitpcode(POC_XORLW,popGetLit(l));
- emitpcode(POC_IORFW,popGet(AOP(left),offset+1,FALSE,FALSE));
-
- emitcode("movf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
- emitcode("xorlw","0x%x",l);
- emitcode("iorwf","%s,w",aopGet(AOP(left),offset+1,FALSE,FALSE));
- optimized++;
- genSkip(ifx,'z');
- } else if (l == 0) {
- emitpcode(POC_MOVFW,popGet(AOP(left),offset+1,FALSE,FALSE));
- emitpcode(POC_XORLW,popGetLit(h));
- emitpcode(POC_IORFW,popGet(AOP(left),offset,FALSE,FALSE));
-
- emitcode("movf","%s,w",aopGet(AOP(left),offset+1,FALSE,FALSE));
- emitcode("xorlw","0x%x",h);
- emitcode("iorwf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
- optimized++;
- genSkip(ifx,'z');
- } else {
- emitpcode(POC_MOVFW,popGet(AOP(left),offset,FALSE,FALSE));
- emitpcode(POC_XORLW,popGetLit(l));
- emitpcode(POC_MOVLW,popGetLit(h));
- emitSKPZ;
- emitpcode(POC_XORFW,popGet(AOP(left),offset+1,FALSE,FALSE));
-/*
- emitcode("movf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
- emitcode("xorlw","0x%x",l);
- emitcode("movlw","0x%x",h);
- emitSKPZ;
- emitcode("xorwf","%s,w",aopGet(AOP(left),offset+1,FALSE,FALSE));
-*/
- optimized++;
- genSkip(ifx,'z');
- }
-
- }
- if(optimized) {
- size--;
- offset+=2;
- lit>>=16;
-
- continue;
- }
-
- }
-
- switch(lit & 0xff) {
- case 1:
- if ( IC_TRUE(ifx) ) {
-
- emitcode("decf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
-
- emitpcode(POC_DECFW,popGet(AOP(left),offset,FALSE,FALSE));
- emitSKPNZ;
- emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
-
- emitcode("goto","_%05d_DS_",IC_TRUE(ifx)->key+100+labelOffset);
- } else {
- emitpcode(POC_DECFSZW,popGet(AOP(left),offset,FALSE,FALSE));
- emitpcode(POC_GOTO,popGetLabel(IC_FALSE(ifx)->key));
-
- emitcode("decfsz","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
- emitcode("goto","_%05d_DS_",IC_FALSE(ifx)->key+100+labelOffset);
- }
- break;
- case 0xff:
- if ( IC_TRUE(ifx) ) {
- emitcode("incf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
-
- emitpcode(POC_INCFW,popGet(AOP(left),offset,FALSE,FALSE));
- emitSKPNZ;
- emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
-
- emitcode("goto","_%05d_DS_",IC_TRUE(ifx)->key+100+labelOffset);
- } else {
- emitpcode(POC_INCFSZW,popGet(AOP(left),offset,FALSE,FALSE));
- emitpcode(POC_GOTO,popGetLabel(IC_FALSE(ifx)->key));
-
- emitcode("incfsz","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
- emitcode("goto","_%05d_DS_",IC_FALSE(ifx)->key+100+labelOffset);
- }
- break;
- default:
- emitpcode(POC_MOVFW,popGet(AOP(left),offset,FALSE,FALSE));
- //emitcode("movf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
- if(lit)
- emitpcode(POC_XORLW,popGetLit(lit & 0xff));
- //emitcode("xorlw","0x%x",lit & 0xff);
- genSkip(ifx,'z');
- }
-
-
- // emitcode("goto","_%05d_DS_",tlbl->key+100+labelOffset);
- //emitcode("","_%05d_DS_:",tlbl->key+100+labelOffset);
- offset++;
- lit >>= 8;
- }
-
- } 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,FALSE,FALSE));
- emitpcode( ( (IC_TRUE(ifx)) ? POC_BTFSC : POC_BTFSS),
- popGet(AOP(right),offset,FALSE,FALSE));
- emitpcode(POC_XORLW,popGetLit(1));
-
- emitcode("movf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
- if ( IC_TRUE(ifx) )
- emitcode("btfsc","(%s >> 3), (%s & 7)",
- AOP(right)->aopu.aop_dir,
- AOP(right)->aopu.aop_dir);
- else
- emitcode("btfss","(%s >> 3), (%s & 7)",
- AOP(right)->aopu.aop_dir,
- AOP(right)->aopu.aop_dir);
-
- emitcode("xorlw","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,FALSE,FALSE));
- //emitcode("iorwf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
-
- if ( IC_TRUE(ifx) ) {
- emitSKPNZ;
- emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
- emitcode(" goto","_%05d_DS_",IC_TRUE(ifx)->key+100+labelOffset);
- } else {
- emitSKPZ;
- emitpcode(POC_GOTO,popGetLabel(IC_FALSE(ifx)->key));
- 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,FALSE,FALSE));
- emitpcode(POC_XORFW,popGet(AOP(right),offset,FALSE,FALSE));
-
- emitcode("movf","%s,w",aopGet(AOP(left),offset,FALSE,FALSE));
- emitcode("xorwf","%s,w",aopGet(AOP(right),offset,FALSE,FALSE));
-
- if ( IC_TRUE(ifx) ) {
- if(size) {
- emitSKPZ;
- emitpcode(POC_GOTO,popGetLabel(tlbl->key));
- emitcode(" goto","_%05d_DS_",tlbl->key+100+labelOffset);
- } else {
- emitSKPNZ;
- emitpcode(POC_GOTO,popGetLabel(IC_TRUE(ifx)->key));
- emitcode(" goto","_%05d_DS_",IC_TRUE(ifx)->key+100+labelOffset);
- }
- } else {
- emitSKPZ;
- emitpcode(POC_GOTO,popGetLabel(IC_FALSE(ifx)->key));
- emitcode(" goto","_%05d_DS_",IC_FALSE(ifx)->key+100+labelOffset);
- }
- offset++;
- }
- if(s>1 && IC_TRUE(ifx)) {
- emitpLabel(tlbl->key+100+labelOffset);
- 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(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_DS_",AOP(right)->aopu.aop_dir,(lbl->key+100));
- emitcode("cpl","c");
- emitcode("","%05d_DS_:",(lbl->key+100));
- }
- /* 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));
- 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 */
- }