AVX-512: Add a feature to generate a raw bytecode file
authorJin Kyu Song <jin.kyu.song@intel.com>
Sat, 24 Aug 2013 01:40:49 +0000 (18:40 -0700)
committerCyrill Gorcunov <gorcunov@gmail.com>
Wed, 28 Aug 2013 10:27:25 +0000 (14:27 +0400)
From gas testsuite file, a text file containing raw bytecodes
is useful when verifying the output of NASM.

Signed-off-by: Jin Kyu Song <jin.kyu.song@intel.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
test/gas2nasm.py

index de16745..a00af92 100755 (executable)
@@ -21,6 +21,9 @@ def setup():
     parser.add_option('-b', dest='bits', action='store',
             default="",
             help='Bits for output ASM file.')
+    parser.add_option('-r', dest='raw_output', action='store',
+            default="",
+            help='Name for raw output bytes in text')
     (options, args) =  parser.parse_args()
     return options
 
@@ -77,11 +80,19 @@ def write(data, options):
                 outstr = outstrfmt % tuple(insn)
                 out.write(outstr)
 
+def write_rawbytes(data, options):
+    if options.raw_output:
+        with open(options.raw_output, 'wb') as out:
+            for insn in data:
+                out.write(insn[0] + '\n')
+
 if __name__ == "__main__":
     options = setup()
     recs = read(options)
     print "AVX3.1 instructions"
 
+    write_rawbytes(recs, options)
+
     recs = commas(recs)
 
     write(recs, options)