Signed-off-by: Arthur HUILLET <[email protected]>
---
 arch/x86/insn-selector_32.brg            |   20 +++++++++++++++++++-
 regression/jamvm/LongArithmeticTest.java |    6 ++++--
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/arch/x86/insn-selector_32.brg b/arch/x86/insn-selector_32.brg
index d790b44..c1500d1 100644
--- a/arch/x86/insn-selector_32.brg
+++ b/arch/x86/insn-selector_32.brg
@@ -243,7 +243,25 @@ reg:       OP_MUL(reg, EXPR_LOCAL) 1
 
 reg:   OP_MUL_64(reg, reg) 1
 {
-       assert(!"todo mul64");
+       struct var_info *eax, *edx, *tmp1;
+
+       eax = get_fixed_var(s->b_parent, REG_EAX);
+       edx = get_fixed_var(s->b_parent, REG_EDX);
+
+       state->reg1 = eax;
+       state->reg2 = get_var(s->b_parent);
+
+       tmp1 = get_var(s->b_parent);
+       bb_add_insn(s, reg_reg_insn(INSN_MOV_REG_REG, state->right->reg2, 
tmp1));
+       bb_add_insn(s, reg_reg_insn(INSN_MUL_REG_REG, state->left->reg1, tmp1));
+       bb_add_insn(s, reg_reg_insn(INSN_MOV_REG_REG, state->left->reg2, 
state->reg2));
+       bb_add_insn(s, reg_reg_insn(INSN_MUL_REG_REG, state->right->reg1, 
state->reg2));
+       bb_add_insn(s, reg_reg_insn(INSN_ADD_REG_REG, tmp1, state->reg2));
+
+       bb_add_insn(s, reg_reg_insn(INSN_MOV_REG_REG, state->right->reg1, eax));
+       bb_add_insn(s, reg_reg_insn(INSN_MUL_REG_EAX, state->left->reg1, eax));
+
+       bb_add_insn(s, reg_reg_insn(INSN_ADD_REG_REG, edx, state->reg2));
 }
 
 reg:   OP_DIV(reg, EXPR_LOCAL) 1
diff --git a/regression/jamvm/LongArithmeticTest.java 
b/regression/jamvm/LongArithmeticTest.java
index 1f8c210..a9a3e10 100644
--- a/regression/jamvm/LongArithmeticTest.java
+++ b/regression/jamvm/LongArithmeticTest.java
@@ -52,6 +52,8 @@ public class LongArithmeticTest extends TestCase {
         assertEquals( 0, mul( 0,  1));
         assertEquals( 0, mul( 1,  0));
         assertEquals( 6, mul( 2,  3));
+        assertEquals(-0x200000000L, mul( 0x100000000L, -2L));
+        assertEquals(-0x400000000L, mul(-0x200000000L,  2L));
     }
 
     public static void testLongMultiplicationOverflow() {
@@ -227,8 +229,8 @@ public class LongArithmeticTest extends TestCase {
         testLongAdditionOverflow();
         testLongSubtraction();
         testLongSubtractionOverflow();
-        /*testLongMultiplication();
-        testLongMultiplicationOverflow();*/
+        testLongMultiplication();
+        testLongMultiplicationOverflow();
         testLongDivision();
         testLongRemainder();
         testLongNegation();
-- 
1.6.2.2


------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel

Reply via email to