about summary refs log tree commit diff stats
path: root/test/arch/mep/jit/test_jit_repeat.py
diff options
context:
space:
mode:
authorserpilliere <serpilliere@users.noreply.github.com>2018-07-13 10:20:21 +0200
committerGitHub <noreply@github.com>2018-07-13 10:20:21 +0200
commitcc9c0c70af3a91157226440ae3b64199711ee0db (patch)
tree932dd2676afcf0c4ba6bf0c57d3b574954461ad2 /test/arch/mep/jit/test_jit_repeat.py
parent82eb5f6eb197fc59d2e9ae21cfda05a1868e462e (diff)
parentb8e5038798b0dece628846acb5ad25d9d4e60395 (diff)
downloadmiasm-cc9c0c70af3a91157226440ae3b64199711ee0db.tar.gz
miasm-cc9c0c70af3a91157226440ae3b64199711ee0db.zip
Merge pull request #763 from guedou/Toshiba_MeP-c4
Toshiba MeP support
Diffstat (limited to 'test/arch/mep/jit/test_jit_repeat.py')
-rw-r--r--test/arch/mep/jit/test_jit_repeat.py99
1 files changed, 99 insertions, 0 deletions
diff --git a/test/arch/mep/jit/test_jit_repeat.py b/test/arch/mep/jit/test_jit_repeat.py
new file mode 100644
index 00000000..9fa64fa5
--- /dev/null
+++ b/test/arch/mep/jit/test_jit_repeat.py
@@ -0,0 +1,99 @@
+# Toshiba MeP-c4 - *REPEAT instructions JIT unit tests
+# Guillaume Valadon <guillaume@valadon.net>
+
+from ut_helpers_jit import jit_instructions
+
+
+class TestRepeat:
+    def test_repeat(self):
+        """Test REPEAT jit"""
+
+        # Instructions that will be jitted
+        instructions = "MOV R0, 8\n"
+        instructions += "REPEAT R0, 0x6\n"
+        instructions += "ADD R1, 1\n"
+        instructions += "ADD R2, 1\n"  # <-RPE
+        instructions += "ADD R3, 1"
+
+        # Jit
+        jitter = jit_instructions(instructions)
+
+        # Check expected results
+        assert(jitter.cpu.R0 == 8)
+        assert(jitter.cpu.R1 == 8)
+        assert(jitter.cpu.R2 == 8)
+        assert(jitter.cpu.R3 == 8)
+
+    def test_erepeat_0(self):
+        """Test EREPEAT jit"""
+
+        # Instructions that will be jitted
+        instructions = "EREPEAT 0xA\n"
+        instructions += "ADD R1, 1\n"
+        instructions += "BEQI R1, 0x6, 0x8\n"
+        instructions += "ADD R2, 1\n"
+        instructions += "ADD R3, 1"  # <- RPE
+
+        # Jit
+        jitter = jit_instructions(instructions)
+
+        # Check expected results
+        assert(jitter.cpu.R1 == 6)
+        assert(jitter.cpu.R2 == 5)
+        assert(jitter.cpu.R3 == 5)
+
+    def test_erepeat_1(self):
+        """Test EREPEAT jit"""
+
+        # Instructions that will be jitted
+        instructions = "EREPEAT 0x8\n"
+        instructions += "ADD R1, 1\n"
+        instructions += "ADD R2, 1\n"
+        instructions += "ADD R3, 1\n"
+        instructions += "BEQI R1, 0x6, 0x4\n"  # <- RPE
+        instructions += "ADD R2, 1\n"
+        instructions += "ADD R3, 1"
+
+        # Jit
+        jitter = jit_instructions(instructions)
+
+        # Check expected results
+        assert(jitter.cpu.R1 == 6)
+        assert(jitter.cpu.R2 == 7)
+        assert(jitter.cpu.R3 == 7)
+
+    def test_erepeat_2(self):
+        """Test EREPEAT jit"""
+
+        # Instructions that will be jitted
+        instructions = "EREPEAT 0x8\n"
+        instructions += "ADD R1, 1\n"
+        instructions += "ADD R2, 1\n"
+        instructions += "ADD R3, 1\n"  # <- RPE
+        instructions += "BEQI R3, 0x6, 0x4"
+
+        # Jit
+        jitter = jit_instructions(instructions)
+
+        # Check expected results
+        assert(jitter.cpu.R1 == 6)
+        assert(jitter.cpu.R2 == 6)
+        assert(jitter.cpu.R3 == 6)
+
+    def test_erepeat_3(self):
+        """Test EREPEAT jit"""
+
+        # Instructions that will be jitted
+        instructions = "EREPEAT 0x8\n"
+        instructions += "ADD R1, 1\n"
+        instructions += "ADD R2, 1\n"
+        instructions += "BEQI R1, 0x6, 0x6\n"  # <- RPE
+        instructions += "ADD R3, 1"
+
+        # Jit
+        jitter = jit_instructions(instructions)
+
+        # Check expected results
+        assert(jitter.cpu.R1 == 6)
+        assert(jitter.cpu.R2 == 6)
+        assert(jitter.cpu.R3 == 5)