]> git.gag.com Git - fw/sdcc/commitdiff
* src/pic16/gen.c (pic16_storeForReturn): fragile fix for
authortecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 22 May 2006 21:50:06 +0000 (21:50 +0000)
committertecodev <tecodev@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Mon, 22 May 2006 21:50:06 +0000 (21:50 +0000)
  bug #1492360 (problematic due to generic pointers, see code)

git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4186 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/pic16/gen.c

index 9cd477a968bf45ef09d747025c9b5a51e0e706a6..73ab4758082658a778b6b072d791c1e9a5a69346 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-05-22 Raphael Neider <rneider AT web.de>
+
+       * src/pic16/gen.c (pic16_storeForReturn): fragile fix for
+         bug #1492360 (problematic due to generic pointers, see code)
+
 2006-05-22 Borut Razem <borut.razem AT siol.net>
 
        * support/regression/ports/pic16/specs.mk: removed stack size linker
index 7d58f40030e7aa79666aef838d393bc61b2d5280..14a0af8d777f04a0fb731e475b820ce9835790fa 100644 (file)
@@ -4012,15 +4012,28 @@ void pic16_storeForReturn(iCode *ic, /*operand *op,*/ int offset, pCodeOp *dest)
       }
     }
 
-    if(is_LitOp(op)) {
-      pic16_movLit2f(dest, lit);
+    if (AOP_TYPE(op) == AOP_LIT) {
+      /* FIXME: broken for
+       *   char __at(0x456) foo;
+       *   return &foo;
+       * (upper byte is 0x00 (__code space) instead of 0x80 (__data) */
+      pic16_movLit2f(dest, (lit >> (8ul*offset)));
+    } else if (AOP_TYPE(op) == AOP_PCODE
+               && AOP(op)->aopu.pcop->type == PO_IMMEDIATE) {
+      /* char *s= "aaa"; return s; */
+      /* XXX: Using UPPER(__str_0) will yield 0b00XXXXXX, so
+       *      that the generic pointer is interpreted correctly
+       *      as referring to __code space, but this is fragile! */
+      pic16_emitpcode(POC_MOVLW, pic16_popGet( AOP(op), offset ));
+      /* XXX: should check that dest != WREG */
+      pic16_emitpcode(POC_MOVWF, dest);
     } else {
       if(dest->type == PO_WREG && (offset == 0)) {
-        pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(op), offset));
-      return;
+       pic16_emitpcode(POC_MOVFW, pic16_popGet(AOP(op), offset));
+       return;
+      }
+      pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(op), offset), dest));
     }
-    pic16_emitpcode(POC_MOVFF, pic16_popGet2p(pic16_popGet(AOP(op), offset), dest));
-  }
 }
 
 /*-----------------------------------------------------------------*/