blob: 4d914be7c79b744c08d66e28acea509d7f520481 [file] [log] [blame]
YUHANG TANG08da0c02016-10-14 20:47:29 +08001/* Capstone Disassembler Engine */
2/* By Nguyen Anh Quynh <aquynh@gmail.com>, 2013-2014 */
3
4#include <stdio.h>
5
Nguyen Anh Quynh2897a802016-10-21 17:03:27 +08006#include <capstone/capstone.h>
YUHANG TANG08da0c02016-10-14 20:47:29 +08007
Nguyen Anh Quynh32238dc2016-10-21 16:42:47 +08008void print_string_hex(char *comment, unsigned char *str, size_t len);
YUHANG TANG08da0c02016-10-14 20:47:29 +08009
10void print_insn_detail_sparc(csh handle, cs_insn *ins)
11{
Nguyen Anh Quynh32238dc2016-10-21 16:42:47 +080012 cs_sparc *sparc;
13 int i;
14
15 // detail can be NULL on "data" instruction if SKIPDATA option is turned ON
16 if (ins->detail == NULL)
17 return;
18
19 sparc = &(ins->detail->sparc);
20 if (sparc->op_count)
21 printf("\top_count: %u\n", sparc->op_count);
22
23 for (i = 0; i < sparc->op_count; i++) {
24 cs_sparc_op *op = &(sparc->operands[i]);
25 switch((int)op->type) {
26 default:
27 break;
28 case SPARC_OP_REG:
29 printf("\t\toperands[%u].type: REG = %s\n", i, cs_reg_name(handle, op->reg));
30 break;
31 case SPARC_OP_IMM:
Nguyen Anh Quynhd19cedc2017-12-27 14:46:47 +080032 printf("\t\toperands[%u].type: IMM = 0x%" PRIx64 "\n", i, op->imm);
Nguyen Anh Quynh32238dc2016-10-21 16:42:47 +080033 break;
34 case SPARC_OP_MEM:
35 printf("\t\toperands[%u].type: MEM\n", i);
36 if (op->mem.base != X86_REG_INVALID)
37 printf("\t\t\toperands[%u].mem.base: REG = %s\n",
38 i, cs_reg_name(handle, op->mem.base));
39 if (op->mem.index != X86_REG_INVALID)
40 printf("\t\t\toperands[%u].mem.index: REG = %s\n",
41 i, cs_reg_name(handle, op->mem.index));
42 if (op->mem.disp != 0)
43 printf("\t\t\toperands[%u].mem.disp: 0x%x\n", i, op->mem.disp);
44
45 break;
46 }
47 }
48
49 if (sparc->cc != 0)
50 printf("\tCode condition: %u\n", sparc->cc);
51
52 if (sparc->hint != 0)
53 printf("\tHint code: %u\n", sparc->hint);
YUHANG TANG08da0c02016-10-14 20:47:29 +080054}