From 321001351558a2d8261c85294913c4bc94c00c88 Mon Sep 17 00:00:00 2001 From: adam Date: Fri, 16 Feb 2007 15:50:18 +0100 Subject: [PATCH] added MAX and MIN on Alu2 ship --- ships/Alu2.ship | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ships/Alu2.ship b/ships/Alu2.ship index ea5ffcb..94e853b 100644 --- a/ships/Alu2.ship +++ b/ships/Alu2.ship @@ -10,7 +10,6 @@ data out: out == Constants ======================================================== ADD: add the two arguments; treat link as carry SUB: subtract the two arguments; treat link as carry -REM: MAX: MIN: SORT: output min(in1,in2) followed by max(in1,in2) (FIXME: redundant?) @@ -47,6 +46,10 @@ public void service() { break; case 1: box_out.addDataFromShip(a-b); // SUB break; + case 2: box_out.addDataFromShip(Math.max(a,b)); // ADD + break; + case 3: box_out.addDataFromShip(Math.min(a,b)); // SUB + break; default: box_out.addDataFromShip(0); break; } @@ -79,6 +82,8 @@ public void service() { case (reg_op) 0: out_d = reg_a + reg_b; 1: out_d = reg_a - reg_b; + 2: out_d = reg_a > reg_b ? reg_a : reg_b; + 3: out_d = reg_a > reg_b ? reg_b : reg_a; default: out_d = 0; endcase `onwrite(out_r, out_a) -- 1.7.10.4