Fixed problem with fn returning a variable bigger than a char.
authorslade_rich <slade_rich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 12 Aug 2004 23:45:26 +0000 (23:45 +0000)
committerslade_rich <slade_rich@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 12 Aug 2004 23:45:26 +0000 (23:45 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@3438 4a8a32a2-be11-0410-ad9d-d568d2c75423

src/pic/gen.c

index 8c10f0ac5bf9a0bc3a4d560638f3b03e40e05a53..ea77e889b3c6f68757e64e0a32d3871752c3f4af 100644 (file)
@@ -2925,7 +2925,7 @@ registers :-) */
 /*-----------------------------------------------------------------*/
 static void genRet (iCode *ic)
 {
-       int size,offset = 0 , pushed = 0;
+       int size, pushed = 0;
        
        DEBUGpic14_emitcode ("; ***","%s  %d",__FUNCTION__,__LINE__);
        /* if we have no return value then
@@ -2933,7 +2933,7 @@ static void genRet (iCode *ic)
        if (!IC_LEFT(ic)) 
                goto jumpret;           
        
-               /* we have something to return then
+       /* we have something to return then
        move the return value into place */
        aopOp(IC_LEFT(ic),ic,FALSE);
        size = AOP_SIZE(IC_LEFT(ic));
@@ -2942,26 +2942,23 @@ static void genRet (iCode *ic)
                char *l ;
                if (AOP_TYPE(IC_LEFT(ic)) == AOP_DPTR) {
                        /* #NOCHANGE */
-                       l = aopGet(AOP(IC_LEFT(ic)),offset++,
-                               FALSE,TRUE);
+                       l = aopGet(AOP(IC_LEFT(ic)),size,FALSE,TRUE);
                        pic14_emitcode("push","%s",l);
                        pushed++;
                } else {
-                       l = aopGet(AOP(IC_LEFT(ic)),offset,
-                               FALSE,FALSE);
-                       if (strcmp(fReturn[offset],l)) {
+                       l = aopGet(AOP(IC_LEFT(ic)),size,FALSE,FALSE);
+                       if (strcmp(fReturn[size],l)) {
                                if ((((AOP(IC_LEFT(ic))->type) == AOP_PCODE) && 
                                        AOP(IC_LEFT(ic))->aopu.pcop->type == PO_IMMEDIATE) ||
                                        ( (AOP(IC_LEFT(ic))->type) == AOP_IMMD) ||
                                        ( (AOP(IC_LEFT(ic))->type) == AOP_LIT) ) {
-                                       emitpcode(POC_MOVLW, popGet(AOP(IC_LEFT(ic)),offset));
+                                       emitpcode(POC_MOVLW, popGet(AOP(IC_LEFT(ic)),size));
                                }else {
-                                       emitpcode(POC_MOVFW, popGet(AOP(IC_LEFT(ic)),offset));
+                                       emitpcode(POC_MOVFW, popGet(AOP(IC_LEFT(ic)),size));
                                }
                                if(size) {
                                        emitpcode(POC_MOVWF,popRegFromIdx(Gstack_base_addr+1-size));
                                }
-                               offset++;
                        }
                }
        }
@@ -2978,7 +2975,7 @@ static void genRet (iCode *ic)
        freeAsmop (IC_LEFT(ic),NULL,ic,TRUE);
        
 jumpret:
-/* generate a jump to the return label
+       /* generate a jump to the return label
        if the next is not the return statement */
        if (!(ic->next && ic->next->op == LABEL &&
                IC_LABEL(ic->next) == returnLabel)) {
@@ -4003,7 +4000,7 @@ static void genCmp (operand *left,operand *right,
                                        default:
                                                emitpcode(POC_MOVFW, popGet(AOP(right),0));
                                                emitpcode(POC_ADDLW, popGetLit(0x80));
-                                               emitpcode(POC_ADDLW, popGetLit(((-(lit+1)) & 0xff) ^ 0x80));
+                                               emitpcode(POC_ADDLW, popGetLit(((0-(lit+1)) & 0xff) ^ 0x80));
                                                rFalseIfx.condition ^= 1;
                                                genSkipc(&rFalseIfx);
                                                break;