capstone

Форк
0
/
cstool_tricore.c 
83 строки · 2.0 Кб
1
#include <stdio.h>
2

3
#include <capstone/capstone.h>
4
#include "cstool.h"
5

6
void print_insn_detail_tricore(csh handle, cs_insn *ins)
7
{
8
	cs_tricore *tricore;
9
	int i;
10
	cs_regs regs_read, regs_write;
11
	uint8_t regs_read_count, regs_write_count;
12

13
	// detail can be NULL on "data" instruction if SKIPDATA option is turned ON
14
	if (ins->detail == NULL)
15
		return;
16

17
	tricore = &(ins->detail->tricore);
18

19
	if (tricore->op_count)
20
		printf("\top_count: %u\n", tricore->op_count);
21

22
	for (i = 0; i < tricore->op_count; i++) {
23
		cs_tricore_op *op = &(tricore->operands[i]);
24
		switch ((int)op->type) {
25
		default:
26
			break;
27
		case TRICORE_OP_REG:
28
			printf("\t\toperands[%u].type: REG = %s\n", i,
29
			       cs_reg_name(handle, op->reg));
30
			break;
31
		case TRICORE_OP_IMM:
32
			printf("\t\toperands[%u].type: IMM = 0x%" PRIx64 "\n",
33
			       i, op->imm);
34
			break;
35
		case TRICORE_OP_MEM:
36
			printf("\t\toperands[%u].type: MEM\n"
37
			       "\t\t\t.mem.base: REG = %s\n"
38
			       "\t\t\t.mem.disp: 0x%" PRIx64 "\n",
39
			       i, cs_reg_name(handle, op->mem.base),
40
			       op->mem.disp);
41
			break;
42
		}
43

44
		switch (op->access) {
45
		default:
46
			break;
47
		case CS_AC_READ:
48
			printf("\t\t\t.access: READ\n");
49
			break;
50
		case CS_AC_WRITE:
51
			printf("\t\t\t.access: WRITE\n");
52
			break;
53
		case CS_AC_READ | CS_AC_WRITE:
54
			printf("\t\t\t.access: READ | WRITE\n");
55
			break;
56
		}
57
	}
58
	// Print out all registers accessed by this instruction (either implicit or
59
	// explicit)
60
	if (!cs_regs_access(handle, ins, regs_read, &regs_read_count,
61
			    regs_write, &regs_write_count)) {
62
		if (regs_read_count) {
63
			printf("\tRegisters read:");
64
			for (i = 0; i < regs_read_count; i++) {
65
				printf(" %s",
66
				       cs_reg_name(handle, regs_read[i]));
67
			}
68
			printf("\n");
69
		}
70

71
		if (regs_write_count) {
72
			printf("\tRegisters modified:");
73
			for (i = 0; i < regs_write_count; i++) {
74
				printf(" %s",
75
				       cs_reg_name(handle, regs_write[i]));
76
			}
77
			printf("\n");
78
		}
79
	}
80

81
	if (tricore->update_flags)
82
		printf("\tUpdate-flags: True\n");
83
}
84

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.