about summary refs log tree commit diff stats
path: root/test/arch/mep/ir/test_repeat.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_repeat.py
parent82eb5f6eb197fc59d2e9ae21cfda05a1868e462e (diff)
downloadmiasm-b8e5038798b0dece628846acb5ad25d9d4e60395.tar.gz
miasm-b8e5038798b0dece628846acb5ad25d9d4e60395.zip
Toshiba MeP support
Diffstat (limited to 'test/arch/mep/ir/test_repeat.py')
-rw-r--r--test/arch/mep/ir/test_repeat.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/arch/mep/ir/test_repeat.py b/test/arch/mep/ir/test_repeat.py
new file mode 100644
index 00000000..252764b1
--- /dev/null
+++ b/test/arch/mep/ir/test_repeat.py
@@ -0,0 +1,29 @@
+# Toshiba MeP-c4 - Repeat 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 TestRepeat:
+
+    def test_repeat(self):
+        """Test REPEAT execution"""
+
+        # REPEAT Rn, disp17.align2
+        exec_instruction("REPEAT R0, 0x42",
+                         [(ExprId("PC", 32), ExprInt(2, 32)),
+                          (ExprId("R0", 32), ExprInt(0x28, 32))],
+                         [(ExprId("RPB", 32), ExprInt(6, 32)),
+                          (ExprId("RPE", 32), ExprInt(0x44, 32)),
+                          (ExprId("RPC", 32), ExprInt(0x28, 32))])
+
+    def test_erepeat(self):
+        """Test EREPEAT execution"""
+
+        # EREPEAT disp17.align2
+        exec_instruction("EREPEAT 0x42",
+                         [(ExprId("PC", 32), ExprInt(0, 32))],
+                         [(ExprId("RPB", 32), ExprInt(4, 32)),
+                          (ExprId("RPE", 32), ExprInt(0x43, 32))])