about summary refs log tree commit diff stats
path: root/test/arch/mep/ir/test_logical.py
diff options
context:
space:
mode:
authorGuillaume Valadon <guillaume@valadon.net>2018-06-15 12:10:10 +0200
committerGuillaume Valadon <guillaume@valadon.net>2018-07-12 22:50:51 +0200
commitb8e5038798b0dece628846acb5ad25d9d4e60395 (patch)
tree932dd2676afcf0c4ba6bf0c57d3b574954461ad2 /test/arch/mep/ir/test_logical.py
parent82eb5f6eb197fc59d2e9ae21cfda05a1868e462e (diff)
downloadmiasm-b8e5038798b0dece628846acb5ad25d9d4e60395.tar.gz
miasm-b8e5038798b0dece628846acb5ad25d9d4e60395.zip
Toshiba MeP support
Diffstat (limited to 'test/arch/mep/ir/test_logical.py')
-rw-r--r--test/arch/mep/ir/test_logical.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/test/arch/mep/ir/test_logical.py b/test/arch/mep/ir/test_logical.py
new file mode 100644
index 00000000..61cbbf0a
--- /dev/null
+++ b/test/arch/mep/ir/test_logical.py
@@ -0,0 +1,65 @@
+# Toshiba MeP-c4 - Logical instructions unit tests
+# Guillaume Valadon <guillaume@valadon.net>
+
+from ut_helpers_ir import exec_instruction
+
+from miasm2.expression.expression import ExprId, ExprInt, ExprCond, ExprOp
+
+
+class TestLogical:
+
+    def test_or(self):
+        """Test OR execution"""
+
+        # OR Rn, Rm
+        exec_instruction("OR R1, R2",
+                         [(ExprId("R1", 32), ExprInt(1, 32)), (ExprId("R2", 32), ExprInt(1, 32))],
+                         [(ExprId("R1", 32), ExprInt(1, 32))])
+
+    def test_or3(self):
+        """Test OR3 execution"""
+
+        # OR3 Rn,Rm,imm16
+        exec_instruction("OR3 R1, R2, 1",
+                         [(ExprId("R2", 32), ExprInt(1, 32))],
+                         [(ExprId("R1", 32), ExprInt(1, 32))])
+
+    def test_and(self):
+        """Test AND  execution"""
+
+        # AND Rn, Rm
+        exec_instruction("AND R1, R2",
+                         [(ExprId("R1", 32), ExprInt(1, 32)), (ExprId("R2", 32), ExprInt(0, 32))],
+                         [(ExprId("R1", 32), ExprInt(0, 32))])
+
+    def test_and3(self):
+        """Test AND3 execution"""
+
+        # AND3 Rn,Rm,imm16
+        exec_instruction("AND3 R1, R2, 0",
+                         [(ExprId("R2", 32), ExprInt(1, 32))],
+                         [(ExprId("R1", 32), ExprInt(0, 32))])
+
+    def test_xor(self):
+        """Test XOR execution"""
+
+        # XOR Rn, Rm
+        exec_instruction("XOR R1, R2",
+                         [(ExprId("R1", 32), ExprInt(1, 32)), (ExprId("R2", 32), ExprInt(0, 32))],
+                         [(ExprId("R1", 32), ExprInt(1, 32))])
+
+    def test_xor3(self):
+        """Test XOR3 execution"""
+
+        # XOR3 Rn,Rm,imm16
+        exec_instruction("XOR3 R1, R2, 1",
+                         [(ExprId("R2", 32), ExprInt(0, 32))],
+                         [(ExprId("R1", 32), ExprInt(1, 32))])
+
+    def test_nor(self):
+        """Test NOR execution"""
+
+        # NOR Rn, Rm
+        exec_instruction("NOR R1, R2",
+                         [(ExprId("R1", 32), ExprInt(1, 32)), (ExprId("R2", 32), ExprInt(0, 32))],
+                         [(ExprId("R1", 32), ExprInt(0xFFFFFFFE, 32))])