added MAX and MIN on Alu2 ship
authoradam <adam@megacz.com>
Fri, 16 Feb 2007 14:50:18 +0000 (15:50 +0100)
committeradam <adam@megacz.com>
Fri, 16 Feb 2007 14:50:18 +0000 (15:50 +0100)
ships/Alu2.ship

index ea5ffcb..94e853b 100644 (file)
@@ -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)