aboutsummaryrefslogtreecommitdiffstats
path: root/capstone/arch/WASM/WASMInstPrinter.c
diff options
context:
space:
mode:
Diffstat (limited to 'capstone/arch/WASM/WASMInstPrinter.c')
-rw-r--r--capstone/arch/WASM/WASMInstPrinter.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/capstone/arch/WASM/WASMInstPrinter.c b/capstone/arch/WASM/WASMInstPrinter.c
new file mode 100644
index 000000000..6cd76fa3f
--- /dev/null
+++ b/capstone/arch/WASM/WASMInstPrinter.c
@@ -0,0 +1,47 @@
+/* Capstone Disassembly Engine */
+/* By Spike, xwings 2019 */
+
+#include "WASMInstPrinter.h"
+#include "WASMMapping.h"
+
+
+void WASM_printInst(MCInst *MI, struct SStream *O, void *PrinterInfo)
+{
+ SStream_concat(O, WASM_insn_name((csh)MI->csh, MI->Opcode));
+
+ switch (MI->wasm_data.type) {
+ default:
+ break;
+
+ case WASM_OP_VARUINT32:
+ SStream_concat(O, "\t0x%x", MI->wasm_data.varuint32);
+ break;
+
+ case WASM_OP_VARUINT64:
+ SStream_concat(O, "\t0x%lx", MI->wasm_data.varuint64);
+ break;
+
+ case WASM_OP_UINT32:
+ SStream_concat(O, "\t0x%2" PRIx32, MI->wasm_data.uint32);
+ break;
+
+ case WASM_OP_UINT64:
+ SStream_concat(O, "\t0x%2" PRIx64, MI->wasm_data.uint64);
+ break;
+
+ case WASM_OP_IMM:
+ SStream_concat(O, "\t0x%x, 0x%x", MI->wasm_data.immediate[0], MI->wasm_data.immediate[1]);
+ break;
+
+ case WASM_OP_INT7:
+ SStream_concat(O, "\t%d", MI->wasm_data.int7);
+ break;
+
+ case WASM_OP_BRTABLE:
+ SStream_concat(O, "\t0x%x, [", MI->wasm_data.brtable.length);
+ SStream_concat(O, "0x%x", MI->wasm_data.brtable.address);
+ SStream_concat(O, "], 0x%x", MI->wasm_data.brtable.default_target);
+
+ break;
+ }
+}