finish overhaul of interpreter
[fleet.git] / ships / Memory.ship
index 8d86208..4718196 100644 (file)
@@ -94,15 +94,22 @@ sequence guarantee problem mentioned in the previous paragraph.
     private long addr = 0;
     private boolean writing = false;
 
+    private Queue<Long> toDispatch = new LinkedList<Long>();
     public void service() {
-/*
-        if (box_inCBD.dataReadyForShip()) {
+
+        if (toDispatch.size() > 0) {
+            //if (!box_out.readyForDataFromShip()) return;
+            //box_out.addDataFromShip(toDispatch.remove());
+            getInterpreter().dispatch(getInterpreter().readInstruction(toDispatch.remove(), getDock("out")));
+        }
+
+        if (box_inCBD.dataReadyForShip() && box_out.readyForDataFromShip()) {
             long val = box_inCBD.removeDataForShip();
             long addr = val >> 6;
             long size = val & 0x3f;
-            dispatch((int)addr, (int)size);
+            for(int i=0; i<size; i++)
+              toDispatch.add(readMem((int)(addr+i)));
         }
-*/
         if (count > 0) {
             if (writing) {
               if (box_inDataWrite.dataReadyForShip() && box_out.readyForDataFromShip()) {
@@ -126,8 +133,7 @@ sequence guarantee problem mentioned in the previous paragraph.
             writing = false;
 
         } else if (box_inAddrWrite.dataReadyForShip()) {
-//            addr = box_inAddrWrite.peekPacketForShip().value;
-            box_inAddrWrite.removeDataForShip();
+            addr = box_inAddrWrite.removeDataForShip();
             stride = 0;
             count = 1;
             writing = true;