1 /* Capstone Disassembly Engine */
2 /* By Spike, xwings 2019 */
3
4 #include "WASMInstPrinter.h"
5 #include "WASMMapping.h"
6
7
WASM_printInst(MCInst * MI,struct SStream * O,void * PrinterInfo)8 void WASM_printInst(MCInst *MI, struct SStream *O, void *PrinterInfo)
9 {
10 SStream_concat(O, WASM_insn_name((csh)MI->csh, MI->Opcode));
11
12 switch (MI->wasm_data.type) {
13 default:
14 break;
15
16 case WASM_OP_VARUINT32:
17 SStream_concat(O, "\t0x%x", MI->wasm_data.varuint32);
18 break;
19
20 case WASM_OP_VARUINT64:
21 SStream_concat(O, "\t0x%lx", MI->wasm_data.varuint64);
22 break;
23
24 case WASM_OP_UINT32:
25 SStream_concat(O, "\t0x%2" PRIx32, MI->wasm_data.uint32);
26 break;
27
28 case WASM_OP_UINT64:
29 SStream_concat(O, "\t0x%2" PRIx64, MI->wasm_data.uint64);
30 break;
31
32 case WASM_OP_IMM:
33 SStream_concat(O, "\t0x%x, 0x%x", MI->wasm_data.immediate[0], MI->wasm_data.immediate[1]);
34 break;
35
36 case WASM_OP_INT7:
37 SStream_concat(O, "\t%d", MI->wasm_data.int7);
38 break;
39
40 case WASM_OP_BRTABLE:
41 SStream_concat(O, "\t0x%x, [", MI->wasm_data.brtable.length);
42 SStream_concat(O, "0x%x", MI->wasm_data.brtable.address);
43 SStream_concat(O, "], 0x%x", MI->wasm_data.brtable.default_target);
44
45 break;
46 }
47 }
48