use Mask.signExtend()
authoradam <adam@megacz.com>
Sun, 13 Apr 2008 02:28:12 +0000 (03:28 +0100)
committeradam <adam@megacz.com>
Sun, 13 Apr 2008 02:28:12 +0000 (03:28 +0100)
src/edu/berkeley/fleet/ies44/InstructionEncoder.java
src/edu/berkeley/fleet/util/Mask.java

index 2a726ee..c533f7c 100644 (file)
@@ -120,8 +120,7 @@ public abstract class InstructionEncoder {
             else if (LITERAL_LOW_ONE.get(inst))   literal = BOT_HALF_ONE.set(TOP_HALF_LITERAL.setval(0, literal));
             else if (LITERAL_HIGH_ZERO.get(inst)) literal = BOT_HALF_LITERAL.setval(0, literal);
             else if (LITERAL_HIGH_ONE.get(inst))  literal = TOP_HALF_ONE.set(BOT_HALF_LITERAL.setval(0, literal));
-            if ((literal & (1L<<(WIDTH_WORD-1))) != 0) literal |= (-1L << WIDTH_WORD);
-            return new Instruction.Literal(name, dl, predicate, literal);
+            return new Instruction.Literal(name, dl, predicate, Mask.signExtend(literal, WIDTH_WORD));
         }  
         if (FLAGS.get(inst))       return new Instruction.SetFlags(name, dl, predicate, (int)FLAGS_A.getval(inst), (int)FLAGS_B.getval(inst));
 
index 4ed743c..6b9d7e0 100644 (file)
@@ -62,4 +62,10 @@ public class Mask {
         this.valmaskmin = valmaskmin;
     }
 
+    public static long signExtend(long input, int wordWidth) {
+        if ((input & (1L << (wordWidth-1)))!=0)
+            input |= (-1L) << wordWidth;
+        return input;
+    }
+
 }
\ No newline at end of file