From 30c89a257c87c86afdf286f23d2dd42ab704ae9b Mon Sep 17 00:00:00 2001 From: Nguyen Anh Quynh <aquynh@gmail.com> Date: Tue, 10 May 2016 00:50:29 +0800 Subject: [PATCH] regress: add x86_nasm_directives.py for 'bits' directive for NASM syntax --- suite/regress/x86_nasm_directives.py | 29 ++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 suite/regress/x86_nasm_directives.py diff --git a/suite/regress/x86_nasm_directives.py b/suite/regress/x86_nasm_directives.py new file mode 100755 index 0000000..df2f622 --- /dev/null +++ b/suite/regress/x86_nasm_directives.py @@ -0,0 +1,29 @@ +#!/usr/bin/python +# Nguyen Anh Quynh, 2016 + +# This is to test NASM directives + +# Fill in the information in the form below when you create a new regression + +# Github issue: #xxx +# Author: Nguyen Anh Quynh + +from keystone import * + +import regress + +class TestX86(regress.RegressTest): + def runTest(self): + # Initialize Keystone engine + ks = Ks(KS_ARCH_X86, KS_MODE_32) + # change the syntax to NASM + ks.syntax = KS_OPT_SYNTAX_NASM + + # compile an instruction in NASM syntax + #encoding, count = ks.asm(b"bits 32\n add eax, ebx\nbits 16\nadd eax, ebx") + encoding, count = ks.asm(b"bits 32\n add eax, ebx\nbits 16\nadd eax, ebx") + # Assert the result + self.assertEqual(encoding, [ 0x01, 0xd8, 0x66, 0x01, 0xd8 ]) + +if __name__ == '__main__': + regress.main() -- GitLab