aboutsummaryrefslogtreecommitdiffstats
path: root/capstone/suite/synctools/disassemblertables.py
diff options
context:
space:
mode:
authorAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
committerAngelos Mouzakitis <a.mouzakitis@virtualopensystems.com>2023-10-10 14:33:42 +0000
commitaf1a266670d040d2f4083ff309d732d648afba2a (patch)
tree2fc46203448ddcc6f81546d379abfaeb323575e9 /capstone/suite/synctools/disassemblertables.py
parente02cda008591317b1625707ff8e115a4841aa889 (diff)
Add submodule dependency filesHEADmaster
Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec
Diffstat (limited to 'capstone/suite/synctools/disassemblertables.py')
-rwxr-xr-xcapstone/suite/synctools/disassemblertables.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/capstone/suite/synctools/disassemblertables.py b/capstone/suite/synctools/disassemblertables.py
new file mode 100755
index 000000000..1816121b4
--- /dev/null
+++ b/capstone/suite/synctools/disassemblertables.py
@@ -0,0 +1,45 @@
+#!/usr/bin/python
+# convert LLVM GenDisassemblerTables.inc for Capstone disassembler.
+# for X86, this separate ContextDecision tables into another file
+# by Nguyen Anh Quynh, 2019
+
+import sys
+
+if len(sys.argv) == 1:
+ print("Syntax: %s <GenDisassemblerTables.inc> <X86GenDisassemblerTables.inc> <X86GenDisassemblerTables2.inc>" %sys.argv[0])
+ sys.exit(1)
+
+f = open(sys.argv[1])
+lines = f.readlines()
+f.close()
+
+f1 = open(sys.argv[2], 'w+')
+
+f2 = open(sys.argv[3], 'w+')
+
+f1.write("/* Capstone Disassembly Engine, http://www.capstone-engine.org */\n")
+f1.write("/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */\n")
+f1.write("\n")
+
+f2.write("/* Capstone Disassembly Engine, http://www.capstone-engine.org */\n")
+f2.write("/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2019 */\n")
+f2.write("\n")
+
+# static const struct ContextDecision x86DisassemblerOneByteOpcodes = {
+
+# static const struct ContextDecision x86DisassemblerXOP8Opcodes = {
+
+write_to_f2 = False
+
+for line in lines:
+ if 'ContextDecision x86DisassemblerOneByteOpcodes = {' in line:
+ # done with f1, start writing to f2
+ write_to_f2 = True
+
+ if write_to_f2:
+ f2.write(line)
+ else:
+ f1.write(line)
+
+f1.close()
+f2.close()