projects
/
fleet.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
85ffbc5
)
added MAX and MIN on Alu2 ship
author
adam
<adam@megacz.com>
Fri, 16 Feb 2007 14:50:18 +0000
(15:50 +0100)
committer
adam
<adam@megacz.com>
Fri, 16 Feb 2007 14:50:18 +0000
(15:50 +0100)
ships/Alu2.ship
patch
|
blob
|
history
diff --git
a/ships/Alu2.ship
b/ships/Alu2.ship
index
ea5ffcb
..
94e853b
100644
(file)
--- 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
== 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?)
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;
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;
}
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;
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)
default: out_d = 0;
endcase
`onwrite(out_r, out_a)