13 "UNCHANGED",
"READ",
"WRITE",
"READ | WRITE",
18 static final String M6805_CODE =
"047f00172228002e0040425a708e979ca015ad00c31000da1234e57ffe";
19 static final String M6808_CODE =
"31220035224510004b005110525e226265123472848586878a8b8c9495a710af109e607f9e6b7f009ed610009ee67f";
21 static final String M6809_CODE =
"0610191a551e0123e931063455a681a7897fffa69d1000a791a69f100011ac99100039A607A627A647A667A60FA610A680A681A682A683A684A685A686A6887FA68880A6897FFFA6898000A68BA68C10A68D1000A691A693A694A695A696A6987FA69880A6997FFFA6998000A69BA69C10A69D1000A69F1000";
22 static final String M6811_CODE =
"0203127f100013990800147f02157f011e7f20008fcf18081830183c1867188c1000188f18ce100018ff10001aa37f1aac1aee7f1aef7fcdac7f";
23 static final String CPU12_CODE =
"000401000c00800e008000111e100080003b4a1000044b01044f7f80008f1000b752b7b1a667a6fea6f71802e23039e21000180c30391000181118121000181900181e00183e183f00";
24 static final String HD6309_CODE =
"0110106210107b101000cd499602d21030231038103b1053105d1130431011372510113812113923113b34118e100011af1011ab1011f68000";
25 static final String HCS08_CODE =
"3210009eae9ece7f9ebe10009efe7f3e10009ef37f9610009eff7f82";
30 byte[] data =
new byte[
len / 2];
31 for (
int i = 0;
i <
len;
i += 2) {
32 data[
i / 2] = (byte) ((Character.digit(
s.charAt(
i), 16) << 4)
33 + Character.digit(
s.charAt(
i+1), 16));
39 StringBuilder
buf =
new StringBuilder(800);
43 return buf.toString();
47 StringBuilder
buf =
new StringBuilder(800);
51 return buf.toString();
54 public static Capstone
cs;
66 System.out.printf(
"0x%04x:\t%s\t%s\t%s\n", ins.address,
bytes, ins.mnemonic, ins.opStr);
71 System.out.printf(
"\top_count: %d\n",
operands.op.length);
78 comment =
" (in mnemonic)";
79 System.out.printf(
"\t\toperands[%d].type: REGISTER = %s%s\n",
c, ins.regName(
i.value.reg), comment);
82 System.out.printf(
"\t\toperands[%d].type: CONSTANT = %d\n",
c,
i.value.const_val);
84 System.out.printf(
"\t\toperands[%d].type: IMMEDIATE = #%d\n",
c,
i.value.imm);
86 System.out.printf(
"\t\toperands[%d].type: DIRECT = 0x%02x\n",
c,
i.value.direct_addr);
88 System.out.printf(
"\t\toperands[%d].type: EXTENDED %s = 0x%04x\n",
c,
89 i.value.ext.indirect != 0 ?
"INDIRECT" :
"",
i.value.ext.address);
91 System.out.printf(
"\t\toperands[%d].type: RELATIVE = 0x%04x\n",
c,
i.value.rel.address );
93 System.out.printf(
"\t\toperands[%d].type: INDEXED%s\n",
c,
96 String regName = ins.regName(
i.value.idx.base_reg);
98 System.out.printf(
"\t\t\tbase register: %s\n", regName);
101 String regName = ins.regName(
i.value.idx.offset_reg);
103 System.out.printf(
"\t\t\toffset register: %s\n", regName);
105 if ((
i.value.idx.offset_bits != 0) &&
107 (
i.value.idx.inc_dec == 0)) {
108 System.out.printf(
"\t\t\toffset: %d\n",
i.value.idx.offset);
110 System.out.printf(
"\t\t\toffset address: 0x%04x\n",
i.value.idx.offset_addr);
111 System.out.printf(
"\t\t\toffset bits: %d\n",
i.value.idx.offset_bits);
113 if (
i.value.idx.inc_dec != 0) {
118 i.value.idx.inc_dec > 0 ?
"increment" :
"decrement";
120 System.out.printf(
"\t\t\t%s %s: %d\n", post_pre, inc_dec,
121 Math.abs(
i.value.idx.inc_dec));
125 System.out.printf(
"\t\t\tsize: %d\n",
i.size);
126 if (
i.access != Capstone.CS_AC_INVALID)
127 System.out.printf(
"\t\t\taccess: %s\n",
sAccess[
i.access]);
131 if (ins.regsRead.length > 0) {
132 System.out.printf(
"\tRegisters read:");
133 for (
int c = 0;
c < ins.regsRead.length;
c++) {
134 System.out.printf(
" %s", ins.regName(ins.regsRead[
c]));
136 System.out.printf(
"\n");
139 if (ins.regsWrite.length > 0) {
140 System.out.printf(
"\tRegisters modified:");
141 for (
int c = 0;
c < ins.regsWrite.length;
c++) {
142 System.out.printf(
" %s", ins.regName(ins.regsWrite[
c]));
144 System.out.printf(
"\n");
147 if (ins.groups.length > 0)
148 System.out.printf(
"\tgroups_count: %d\n", ins.groups.length);
155 Capstone.CS_MODE_M680X_6301,
158 Capstone.CS_MODE_M680X_6309,
161 Capstone.CS_MODE_M680X_6800,
164 Capstone.CS_MODE_M680X_6801,
167 Capstone.CS_MODE_M680X_6805,
170 Capstone.CS_MODE_M680X_6808,
173 Capstone.CS_MODE_M680X_6809,
176 Capstone.CS_MODE_M680X_6811,
179 Capstone.CS_MODE_M680X_CPU12,
182 Capstone.CS_MODE_M680X_HCS08,
188 System.out.println(
new String(
new char[20]).
replace(
"\0",
"*"));
189 System.out.println(
"Platform: " +
test.comment);
191 System.out.println(
"Disasm:");
194 cs.setDetail(Capstone.CS_OPT_ON);
195 Capstone.CsInsn[] all_ins =
cs.disasm(
test.code, 0x1000);
197 for (
int j = 0; j < all_ins.length; j++) {
199 System.out.println();
static void print_ins_detail(Capstone.CsInsn ins)
static final String M6809_CODE
static String stringToHexShortUc(byte[] code)
static final String HCS08_CODE
static final String M6811_CODE
static final String M6801_CODE
static final String HD6301_CODE
static byte[] hexString2Byte(String s)
static void main(String argv[])
static final String CPU12_CODE
static final String sAccess[]
static final String M6800_CODE
static String stringToHexUc(byte[] code)
static final String M6808_CODE
static final String HD6309_CODE
static final String M6805_CODE
static static fork const void static count static fd const char const char static newpath char char argv
#define M680X_IDX_INDIRECT
#define M680X_FIRST_OP_IN_MNEM
@ M680X_REG_PC
M6800/1/2/3/9, M6301/9.
#define M680X_IDX_POST_INC_DEC
@ M680X_OP_EXTENDED
= Extended addressing operand.
@ M680X_OP_INDEXED
= Indexed addressing operand.
@ M680X_OP_CONSTANT
Used e.g. for a bit index or page number.
@ M680X_OP_IMMEDIATE
= Immediate operand.
@ M680X_OP_REGISTER
= Register operand.
@ M680X_OP_RELATIVE
= Relative addressing operand.
@ M680X_OP_DIRECT
= Direct addressing operand.
#define M680X_SECOND_OP_IN_MNEM
int replace(char *string, const char *token, const char *fmt,...)
if(dbg->bits==RZ_SYS_BITS_64)