From fc3726b4e0bfccc3e13c1881a83e5e2766d0cc08 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 4 Mar 2007 12:51:48 +0100 Subject: [PATCH] add stride/count to fleeterpreter Memory ship --- ships/Memory.ship | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/ships/Memory.ship b/ships/Memory.ship index dc266c6..8cb7df9 100644 --- a/ships/Memory.ship +++ b/ships/Memory.ship @@ -51,6 +51,11 @@ data out: out dispatch(base, size); } + private long stride = 0; + private long count = 0; + private long addr = 0; + private boolean writing = false; + public void service() { if (box_inCBD.dataReadyForShip()) { long val = box_inCBD.removeDataForShip(); @@ -58,7 +63,22 @@ data out: out long size = val & 0x3f; dispatch((int)addr, (int)size); } - if (box_inAddr.dataReadyForShip() && box_out.readyForDataFromShip()) { + if (count > 0 && writing) { + if (box_inData.dataReadyForShip() && box_out.readyForDataFromShip()) { + writeMem((int)addr, box_inData.removeDataForShip()); + box_out.addDataFromShip(0); + count--; + addr += stride; + } + + } else if (count > 0 && !writing) { + if (box_out.readyForDataFromShip()) { + box_out.addDataFromShip(readMem((int)addr)); + count--; + addr += stride; + } + + } else if (box_inAddr.dataReadyForShip() && box_out.readyForDataFromShip()) { Packet packet = box_inAddr.peekPacketForShip(); if (packet.destination.getDestinationName().equals("read")) { box_out.addDataFromShip(readMem((int)box_inAddr.removeDataForShip())); @@ -66,6 +86,20 @@ data out: out writeMem((int)box_inAddr.removeDataForShip(), box_inData.removeDataForShip()); box_out.addDataFromShip(0); + } else if (packet.destination.getDestinationName().equals("writeMany") + && box_inStride.dataReadyForShip() + && box_inCount.dataReadyForShip()) { + addr = box_inAddr.removeDataForShip(); + stride = box_inStride.removeDataForShip(); + count = box_inCount.removeDataForShip(); + writing = true; + } else if (packet.destination.getDestinationName().equals("readMany") + && box_inStride.dataReadyForShip() + && box_inCount.dataReadyForShip()) { + addr = box_inAddr.removeDataForShip(); + stride = box_inStride.removeDataForShip(); + count = box_inCount.removeDataForShip(); + writing = false; } } } -- 1.7.10.4