fix bugs in handling of DecrLoop operation
authoradam <adam@megacz.com>
Mon, 11 Feb 2008 13:17:33 +0000 (14:17 +0100)
committeradam <adam@megacz.com>
Mon, 11 Feb 2008 13:17:33 +0000 (14:17 +0100)
src/edu/berkeley/fleet/api/Instruction.java
src/edu/berkeley/fleet/interpreter/InstructionPump.java

index 039021e..9a1cb08 100644 (file)
@@ -76,6 +76,7 @@ public abstract class Instruction {
     public static class DecrLoop extends Instruction {
         public DecrLoop(Pump pump) { super(pump); }
         public boolean isDL() { return true; }
+        public boolean isLooping() { return true; }
     }
 
     public static class Counter extends Instruction {
index b5b0960..498a14c 100644 (file)
@@ -86,7 +86,7 @@ abstract class InstructionPump extends InterpreterPump {
         if (executing instanceof Instruction.Counter) {
             Instruction.Counter ic = (Instruction.Counter)executing;
             if (ic.source == Instruction.Counter.LOOP_COUNTER && ic.dest == Instruction.Counter.DATA_LATCH) {
-                setDataLatch(loopCounter);
+                setDataLatch(oldLoopCounter); /* FIXME: which is correct here? */
             } else if (ic.dest == Instruction.Counter.LOOP_COUNTER && ic.source == Instruction.Counter.DATA_LATCH) {
                 loopCounter = (int)peekDataLatch();
             } else if (ic.dest == Instruction.Counter.REPEAT_COUNTER && ic.source == Instruction.Counter.DATA_LATCH) {
@@ -96,9 +96,9 @@ abstract class InstructionPump extends InterpreterPump {
             } else if (ic.dest == Instruction.Counter.REPEAT_COUNTER) {
                 repeatCounter = ic.source;
             }
+
         } else if (executing instanceof Instruction.DecrLoop) {
-            executing = null;
-            return;
+
         } else if (executing instanceof Instruction.SetFlags) {
             Instruction.SetFlags sf = (Instruction.SetFlags)executing;
             boolean old_s = ((peekDataLatch() >> (getInterpreter().getWordSize()-1)) & 1) != 0;