about summary refs log tree commit diff stats
path: root/test/arch/x86/unit/mn_strings.py
diff options
context:
space:
mode:
authorFabrice Desclaux <fabrice.desclaux@cea.fr>2014-09-19 15:26:05 +0200
committerFabrice Desclaux <fabrice.desclaux@cea.fr>2014-09-19 15:26:05 +0200
commit032263e8f58573c5cbb61928b9edcc62855c989d (patch)
treeba70f018dba7eb76c6cc122e38ba228f4681f659 /test/arch/x86/unit/mn_strings.py
parent8538d98b35837e540b8a6d576bed7c93d86fda86 (diff)
downloadmiasm-032263e8f58573c5cbb61928b9edcc62855c989d.tar.gz
miasm-032263e8f58573c5cbb61928b9edcc62855c989d.zip
test: add mnemonic tests
Diffstat (limited to 'test/arch/x86/unit/mn_strings.py')
-rw-r--r--test/arch/x86/unit/mn_strings.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/arch/x86/unit/mn_strings.py b/test/arch/x86/unit/mn_strings.py
new file mode 100644
index 00000000..db52fa74
--- /dev/null
+++ b/test/arch/x86/unit/mn_strings.py
@@ -0,0 +1,48 @@
+#! /usr/bin/env python
+from asm_test import Asm_Test
+
+class Test_SCAS(Asm_Test):
+    MYSTRING = "test string"
+    TXT = '''
+    main:
+       LEA EDI, DWORD PTR [mystr]
+       XOR  ECX, ECX
+       DEC  ECX
+       REPNE SCASB
+       NOT ECX
+       DEC ECX
+       RET
+
+    mystr:
+    .string "%s"
+    ''' % MYSTRING
+
+    def check(self):
+        assert(self.myjit.cpu.ECX == len(self.MYSTRING))
+        assert(self.myjit.cpu.EDI == self.myjit.ir_arch.symbol_pool.getby_name('mystr').offset + len(self.MYSTRING)+1)
+
+
+class Test_MOVS(Asm_Test):
+    MYSTRING = "test string"
+    TXT = '''
+    main:
+       LEA ESI, DWORD PTR [mystr]
+       LEA EDI, DWORD PTR [buffer]
+       MOV ECX, %d
+       REPE  MOVSB
+       RET
+
+    mystr:
+    .string "%s"
+    buffer:
+    .string "%s"
+    ''' % (len(MYSTRING), MYSTRING, " "*len(MYSTRING))
+
+    def check(self):
+        assert(self.myjit.cpu.ECX == 0)
+        assert(self.myjit.cpu.EDI == self.myjit.ir_arch.symbol_pool.getby_name('buffer').offset + len(self.MYSTRING))
+        assert(self.myjit.cpu.ESI == self.myjit.ir_arch.symbol_pool.getby_name('mystr').offset + len(self.MYSTRING))
+
+
+if __name__ == "__main__":
+    [test()() for test in [Test_SCAS, Test_MOVS]]