final pass to update instruction encoding; should now match the spec
[fleet.git] / ships / Alu2.ship
index 081b4a5..1020acf 100644 (file)
@@ -4,14 +4,13 @@ ship: Alu2
 data  in:   in1
 data  in:   in2
 data  in:   inOp
+  constant ADD: 0
+  constant SUB: 1
+  constant MAX: 2
+  constant MIN: 3
 
 data  out:  out
 
-== Constants ========================================================
-ADD: add the two arguments; treat link as carry
-SUB: subtract the two arguments; treat link as carry
-MAX:
-MIN:
 
 == TeX ==============================================================
 This ship is a two-input arithmetic unit.  It features several
@@ -24,13 +23,6 @@ Use carry-in bit to create a selector?  Perhaps a waste of an ALU.
 
 Flags: zero, negative, overflow, ?
 
-\begin{verbatim}
-move elsewhere:
-//MUL:
-//DIV:
-//MOD:
-\end{verbatim}
-
 == Fleeterpreter ====================================================
 public long resolveLiteral(String literal) {
   if (literal.equals("ADD")) return 0;
@@ -101,8 +93,31 @@ public void service() {
   end
 
 == Test ==============================================================================
-#skip
-
+// expected output
+#ship debug : Debug
+#ship alu   : Alu2
+
+#expect 17
+#expect 1
+#expect 8
+#expect 9
+
+debug.in:   [*] take, deliver;
+alu.in1:
+  literal 9; [4] deliver;
+
+alu.in2:
+  literal 8; [4] deliver;
+
+alu.in1:    [*] take, deliver;
+alu.in2:    [*] take, deliver;
+alu.out:    [*] take, sendto debug.in;
+
+alu.inOp:
+ literal Alu2.inOp[ADD]; deliver;
+ literal Alu2.inOp[SUB]; deliver;
+ literal Alu2.inOp[MIN]; deliver;
+ literal Alu2.inOp[MAX]; deliver;