about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--miasm2/arch/mep/sem.py7
-rw-r--r--test/arch/mep/ir/test_divide.py24
2 files changed, 12 insertions, 19 deletions
diff --git a/miasm2/arch/mep/sem.py b/miasm2/arch/mep/sem.py
index e1d4c5fa..e779b970 100644
--- a/miasm2/arch/mep/sem.py
+++ b/miasm2/arch/mep/sem.py
@@ -912,7 +912,12 @@ def div(rn, rm):
 
     # Check if both numbers are positive or negative
     are_both_neg = sign_rn & sign_rm
-    are_both_pos = "=="(are_both_neg, sign_mask)
+    are_both_pos = ExprCond(
+        are_both_neg - sign_mask,
+        ExprInt(0, are_both_neg.size),
+        ExprInt(1, are_both_neg.size)
+    )
+
 
     # Invert both numbers
     rn_inv = ~rn + i32(1)
diff --git a/test/arch/mep/ir/test_divide.py b/test/arch/mep/ir/test_divide.py
index 04d5f6c5..a63d0c5e 100644
--- a/test/arch/mep/ir/test_divide.py
+++ b/test/arch/mep/ir/test_divide.py
@@ -39,33 +39,21 @@ class TestDivide:
         exec_instruction("DIV R0, R1",
                          [(ExprId("R0", 32), ExprInt(4, 32)),
                           (ExprId("R1", 32), ExprInt(2, 32))],
-                         [(ExprId("HI", 32), ExprCond(ExprOp("==",
-                                                             ExprInt(0, 32),
-                                                             ExprInt(0x80000000, 32)),
-                                                      ExprInt(0, 32),
-                                                      ExprInt(0xFFFFFFFC, 32))),
-                          (ExprId("LO", 32), ExprCond(ExprOp("==",
-                                                             ExprInt(0, 32),
-                                                             ExprInt(0x80000000, 32)),
-                                                       ExprInt(2, 32),
-                                                       ExprInt(0, 32)))])
+                         [(ExprId("HI", 32), ExprInt(0xFFFFFFFC, 32)),
+                          (ExprId("LO", 32), ExprInt(0, 32))])
 
         # Negative & positive numbers
         exec_instruction("DIV R0, R1",
                          [(ExprId("R0", 32), ExprInt(-5, 32)),
                           (ExprId("R1", 32), ExprInt(2, 32))],
-                         [(ExprId("HI", 32), ExprCond(ExprOp("==", ExprInt(0, 32), ExprInt(0x80000000, 32)),
-                                                      ExprInt(1, 32), ExprInt(0xFFFFFFFF, 32))),
-                          (ExprId("LO", 32), ExprCond(ExprOp("==", ExprInt(0, 32), ExprInt(0x80000000, 32)),
-                                                      ExprInt(0x7FFFFFFD, 32), ExprInt(0xFFFFFFFE, 32)))])
+                         [(ExprId("HI", 32), ExprInt(0xFFFFFFFF, 32)),
+                          (ExprId("LO", 32), ExprInt(0xFFFFFFFE, 32))])
 
         exec_instruction("DIV R0, R1",
                          [(ExprId("R0", 32), ExprInt(5, 32)),
                           (ExprId("R1", 32), ExprInt(-2, 32))],
-                         [(ExprId("HI", 32), ExprCond(ExprOp("==", ExprInt(0, 32), ExprInt(0x80000000, 32)),
-                                                      ExprInt(5, 32), ExprInt(0xFFFFFFFF, 32))),
-                          (ExprId("LO", 32), ExprCond(ExprOp("==", ExprInt(0, 32), ExprInt(0x80000000, 32)),
-                                                      ExprInt(0, 32), ExprInt(0xFFFFFFFE, 32)))])
+                         [(ExprId("HI", 32), ExprInt(0xFFFFFFFF, 32)),
+                          (ExprId("LO", 32), ExprInt(0xFFFFFFFE, 32))])
 
     def test_divu(self):
         """Test DIVU execution"""