+ private static void buildIt(FleetProcess fp, Ship memory, Ship alu, Dock dest, long offset) {
+
+ CodeBag ctx = new CodeBag(fp.getFleet());
+
+ LoopFactory lf;
+ // alu.in1: receive and deliver
+ lf = ctx.loopFactory(alu.getDock("in1"), 0);
+ lf.abortLoopIfTorpedoPresent();
+ lf.recvWord();
+ lf.deliver();
+
+ // alu.in2: receive tokens, deliver 1's
+ lf = ctx.loopFactory(alu.getDock("in2"), 1);
+ lf.literal(1);
+ lf = lf.makeNext(0);
+ lf.abortLoopIfTorpedoPresent();
+ lf.recvToken();
+ lf.deliver();
+
+ // alu.inOp: receive tokens, deliver ADD's
+ lf = ctx.loopFactory(alu.getDock("inOp"), 1);
+ lf.literal("ADD");
+ lf = lf.makeNext(0);
+ lf.abortLoopIfTorpedoPresent();
+ lf.recvToken();
+ lf.deliver();
+
+ // alu.out: for each token, provide a word of count-data
+ lf = ctx.loopFactory(alu.getDock("out"), 1);
+ lf.literal(offset);
+ lf = lf.makeNext(0);
+ lf.abortLoopIfTorpedoPresent();
+ lf.recvToken();
+ lf.sendWord(dest);
+ lf.sendWord(alu.getDock("in1"));
+ lf.sendToken(alu.getDock("in2"));
+ lf.sendToken(alu.getDock("inOp"));
+ lf.collectWord();
+
+ lf = ctx.loopFactory(dest, 0);
+ lf.abortLoopIfTorpedoPresent();
+ lf.recvWord();
+ lf.deliver();