a cleaner way to fix the shift bug
[fw/sdcc] / src / ds390 / gen.c
index ecf14b949e292db5ae3efc28e73d1703de44495d..37147cfab2bedc7a4b9118996a0763171658fecd 100644 (file)
@@ -8568,11 +8568,11 @@ genRightShiftLiteral (operand * left,
        default:
          break;
        }
-
-      freeAsmop (left, NULL, ic, TRUE);
-      freeAsmop (result, NULL, ic, TRUE);
     }
-    return TRUE;
+  freeAsmop (left, NULL, ic, TRUE);
+  freeAsmop (result, NULL, ic, TRUE);
+  
+  return TRUE;
 }
 #endif
 
@@ -9510,29 +9510,32 @@ genGenPointerGet (operand * left,
 
   /* if bit then unpack */
   if (IS_BITVAR (retype) || IS_BITVAR (letype))
+  {
     genUnpackBits (result, "dptr", GPOINTER);
+  }
   else
     {
-      size = AOP_SIZE (result);
-      offset = 0;
+       size = AOP_SIZE (result);
+       offset = 0;
 
-      while (size--)
+       while (size--)
        {
-// Whoops; uncooked experimental code which was accidentally committed.
-// Kevin should either finish cooking this or yank it soon.
-#if 0
            if (size)
            {
-               emitcode("push", "b");
+               // Get two bytes at a time, results in _AP & A.
+               // dptr will be incremented ONCE by __gptrgetWord.
+               //
+               // Note: any change here must be coordinated
+               // with the implementation of __gptrgetWord
+               // in device/lib/_gptrget.c
                emitcode ("lcall", "__gptrgetWord");
-               aopPut (AOP (result), "b", offset++);
+               aopPut (AOP (result), DP2_RESULT_REG, offset++);
                aopPut (AOP (result), "a", offset++);
-               emitcode("pop", "b");
                size--;
            }
            else
-#endif         
            {
+               // Only one byte to get.
                emitcode ("lcall", "__gptrget");
                aopPut (AOP (result), "a", offset++);
            }
@@ -12540,10 +12543,15 @@ gen390Code (iCode * lic)
                        ic->level, ic->block);
              _G.debugLine = 0;
            }
-         emitcode ("", ";\t%s:%d: %s", ic->filename, ic->lineno, 
-                   printCLine(ic->filename, ic->lineno));
+         if (!options.noCcodeInAsm) {
+           emitcode ("", ";\t%s:%d: %s", ic->filename, ic->lineno, 
+                     printCLine(ic->filename, ic->lineno));
+         }
          cln = ic->lineno;
        }
+      if (options.iCodeInAsm) {
+       emitcode("", ";ic:%d: %s", ic->key, printILine(ic));
+      }
       /* if the result is marked as
          spilt and rematerializable or code for
          this has already been generated then