* src/hc08/gen.c (genAddrOf): fixed bug when offset on stack is >127
authorMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 6 Jul 2006 21:24:36 +0000 (21:24 +0000)
committerMaartenBrock <MaartenBrock@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Thu, 6 Jul 2006 21:24:36 +0000 (21:24 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4273 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
src/hc08/gen.c

index 58ba8339eaaeaec1d7f880dfb60e828e36cc5609..88260213c5d4595aa278d6a76bbd6ca4bdc22c54 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2006-07-06 Maarten Brock <sourceforge.brock AT dse.nl>
+
+       * src/hc08/gen.c (genAddrOf): fixed bug when offset on stack is >127
+
 2006-07-06 Borut Razem <borut.razem AT siol.net>
 
        * support/regression/tests/bitfields.c:
index 7b6009ed9db405edb252b718b269cac542decc8d..d1fdc98d073557aef1c5959f8de26a8d71aa5355 100644 (file)
@@ -7786,11 +7786,21 @@ genAddrOf (iCode * ic)
      variable */
   if (sym->onStack)
     {
-      /* if it has an offset then we need to compute
-         it */
+      /* if it has an offset then we need to compute it */
+      offset = _G.stackOfs + _G.stackPushes + sym->stack;
       hc08_useReg (hc08_reg_hx);
       emitcode ("tsx", "");
-      emitcode ("aix", "#%d", _G.stackOfs + _G.stackPushes +sym->stack);
+      while (offset > 127)
+        {
+          emitcode ("aix", "#127");
+          offset -= 127;
+        }
+      while (offset < -128)
+        {
+          emitcode ("aix", "#-128");
+          offset += 128;
+        }
+      emitcode ("aix", "#%d", offset);
       storeRegToFullAop (hc08_reg_hx, AOP (IC_RESULT (ic)), FALSE);
       hc08_freeReg (hc08_reg_hx);