Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion arch/M680X/M680XDisassembler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1758,7 +1758,7 @@ static void loop_hdlr(MCInst *MI, m680x_info *info, uint16_t *address)

if (info->insn == M680X_INS_ILLGL) {
fprintf(stderr, "Internal error: Unexpected post byte "
"in loop instruction %02X.\n", post_byte);
"in loop instruction %02x.\n", post_byte);
illegal_hdlr(MI, info, address);
};

Expand Down
20 changes: 10 additions & 10 deletions arch/M680X/M680XInstPrinter.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static void printOperand(MCInst *MI, SStream *O, m680x_info *info,
printRegName(MI->csh, O, op->idx.offset_reg);
else if (op->idx.offset_bits > 0) {
if (op->idx.base_reg == M680X_REG_PC)
SStream_concat(O, "$%04X", op->idx.offset_addr);
SStream_concat(O, "$%04x", op->idx.offset_addr);
else
SStream_concat(O, "%d", op->idx.offset);
}
Expand All @@ -188,7 +188,7 @@ static void printOperand(MCInst *MI, SStream *O, m680x_info *info,
SStream_concat(O, "%d", abs(op->idx.inc_dec));

if (!(op->idx.flags & M680X_IDX_NO_COMMA))
SStream_concat(O, ",");
SStream_concat(O, ", ");

printIncDec(false, O, info, op);

Expand All @@ -206,22 +206,22 @@ static void printOperand(MCInst *MI, SStream *O, m680x_info *info,
break;

case M680X_OP_RELATIVE:
SStream_concat(O, "$%04X", op->rel.address);
SStream_concat(O, "$%04x", op->rel.address);
break;

case M680X_OP_DIRECT:
SStream_concat(O, "$%02X", op->direct_addr);
SStream_concat(O, "$%02x", op->direct_addr);
break;

case M680X_OP_EXTENDED:
if (op->ext.indirect)
SStream_concat(O, "[$%04X]", op->ext.address);
SStream_concat(O, "[$%04x]", op->ext.address);
else {
if (op->ext.address < 256) {
SStream_concat(O, ">$%04X", op->ext.address);
SStream_concat(O, ">$%04x", op->ext.address);
}
else {
SStream_concat(O, "$%04X", op->ext.address);
SStream_concat(O, "$%04x", op->ext.address);
}
}

Expand All @@ -240,7 +240,7 @@ static const char *getDelimiter(m680x_info *info, cs_m680x *m680x)
int i;

if (info->insn == M680X_INS_TFM)
return ",";
return ", ";

if (m680x->op_count > 1) {
for (i = 0; i < m680x->op_count; ++i) {
Expand All @@ -252,7 +252,7 @@ static const char *getDelimiter(m680x_info *info, cs_m680x *m680x)
}
}

return (indexed && (count >= 1)) ? ";" : ",";
return (indexed && (count >= 1)) ? "; " : ", ";
};

void M680X_printInst(MCInst *MI, SStream *O, void *PrinterInfo)
Expand All @@ -269,7 +269,7 @@ void M680X_printInst(MCInst *MI, SStream *O, void *PrinterInfo)

if (info->insn == M680X_INS_INVLD || info->insn == M680X_INS_ILLGL) {
if (m680x->op_count)
SStream_concat(O, "fcb $%02X", m680x->operands[0].imm);
SStream_concat(O, "fcb $%02x", m680x->operands[0].imm);
else
SStream_concat(O, "fcb $<unknown>");

Expand Down
14 changes: 7 additions & 7 deletions bindings/java/TestM680x.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ static byte[] hexString2Byte(String s) {
static public String stringToHexUc(byte[] code) {
StringBuilder buf = new StringBuilder(800);
for (byte ch: code) {
buf.append(String.format(" 0x%02X", ch));
buf.append(String.format(" 0x%02x", ch));
}
return buf.toString();
}

static public String stringToHexShortUc(byte[] code) {
StringBuilder buf = new StringBuilder(800);
for (byte ch: code) {
buf.append(String.format("%02X", ch));
buf.append(String.format("%02x", ch));
}
return buf.toString();
}
Expand All @@ -63,7 +63,7 @@ private static String hex(long i) {
*/
public static void print_ins_detail(Capstone.CsInsn ins) {
String bytes = stringToHexShortUc(ins.bytes);
System.out.printf("0x%04X:\t%s\t%s\t%s\n", ins.address, bytes, ins.mnemonic, ins.opStr);
System.out.printf("0x%04x:\t%s\t%s\t%s\n", ins.address, bytes, ins.mnemonic, ins.opStr);

M680x.OpInfo operands = (M680x.OpInfo) ins.operands;

Expand All @@ -83,12 +83,12 @@ public static void print_ins_detail(Capstone.CsInsn ins) {
if (i.type == M680X_OP_IMMEDIATE)
System.out.printf("\t\toperands[%d].type: IMMEDIATE = #%d\n", c, i.value.imm);
if (i.type == M680X_OP_DIRECT)
System.out.printf("\t\toperands[%d].type: DIRECT = 0x%02X\n", c, i.value.direct_addr);
System.out.printf("\t\toperands[%d].type: DIRECT = 0x%02x\n", c, i.value.direct_addr);
if (i.type == M680X_OP_EXTENDED)
System.out.printf("\t\toperands[%d].type: EXTENDED %s = 0x%04X\n", c,
System.out.printf("\t\toperands[%d].type: EXTENDED %s = 0x%04x\n", c,
i.value.ext.indirect != 0 ? "INDIRECT" : "", i.value.ext.address);
if (i.type == M680X_OP_RELATIVE)
System.out.printf("\t\toperands[%d].type: RELATIVE = 0x%04X\n", c, i.value.rel.address );
System.out.printf("\t\toperands[%d].type: RELATIVE = 0x%04x\n", c, i.value.rel.address );
if (i.type == M680X_OP_INDEXED) {
System.out.printf("\t\toperands[%d].type: INDEXED%s\n", c,
(i.value.idx.flags & M680X_IDX_INDIRECT) != 0 ? " INDIRECT" : "");
Expand All @@ -107,7 +107,7 @@ public static void print_ins_detail(Capstone.CsInsn ins) {
(i.value.idx.inc_dec == 0)) {
System.out.printf("\t\t\toffset: %d\n", i.value.idx.offset);
if (i.value.idx.base_reg == M680X_REG_PC)
System.out.printf("\t\t\toffset address: 0x%04X\n", i.value.idx.offset_addr);
System.out.printf("\t\t\toffset address: 0x%04x\n", i.value.idx.offset_addr);
System.out.printf("\t\t\toffset bits: %d\n", i.value.idx.offset_bits);
}
if (i.value.idx.inc_dec != 0) {
Expand Down
14 changes: 7 additions & 7 deletions bindings/ocaml/test_m680x.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ open M680x_const


let print_char_hex ch =
printf " 0x%02X" (Char.code ch)
printf " 0x%02x" (Char.code ch)

let print_int_hex_short value =
printf "%02X" value
printf "%02x" value

let print_string_hex comment str =
printf "%s" comment;
Expand Down Expand Up @@ -74,15 +74,15 @@ let print_op handle flags i op =
| M680X_OP_IMMEDIATE imm ->
printf "\t\toperands[%d].type: IMMEDIATE = #%d\n" i imm;
| M680X_OP_DIRECT direct_addr ->
printf "\t\toperands[%d].type: DIRECT = 0x%02X\n" i direct_addr;
printf "\t\toperands[%d].type: DIRECT = 0x%02x\n" i direct_addr;
| M680X_OP_EXTENDED ext -> (
printf "\t\toperands[%d].type: EXTENDED " i;
if ext.indirect then
printf "INDIRECT";
printf " = 0x%04X\n" ext.addr_ext;
printf " = 0x%04x\n" ext.addr_ext;
);
| M680X_OP_RELATIVE rel ->
printf "\t\toperands[%d].type: RELATIVE = 0x%04X\n" i rel.addr_rel;
printf "\t\toperands[%d].type: RELATIVE = 0x%04x\n" i rel.addr_rel;
| M680X_OP_INDEXED idx -> (
printf "\t\toperands[%d].type: INDEXED" i;
if (bit_set idx.flags _M680X_IDX_INDIRECT) then
Expand All @@ -95,7 +95,7 @@ let print_op handle flags i op =
if idx.offset_bits != 0 && idx.offset_reg == 0 && idx.inc_dec == 0 then begin
printf "\t\t\toffset: %d\n" idx.offset;
if idx.base_reg == _M680X_REG_PC then
printf "\t\t\toffset address: 0x%X\n" idx.offset_addr;
printf "\t\t\toffset address: 0x%x\n" idx.offset_addr;
printf "\t\t\toffset bits: %u\n" idx.offset_bits;
end;
if idx.inc_dec != 0 then
Expand Down Expand Up @@ -128,7 +128,7 @@ let print_reg handle reg =
printf " %s" (cs_reg_name handle reg)

let print_insn handle insn =
printf "0x%04X:\t" insn.address;
printf "0x%04x:\t" insn.address;
print_array_hex_short insn.bytes;
printf "\t%s\t%s\n" insn.mnemonic insn.op_str;
print_detail handle insn;
Expand Down
16 changes: 8 additions & 8 deletions bindings/python/test_m680x.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,18 @@
# print hex dump from string all upper case
def to_hex_uc(string):
if _python3:
return " ".join("0x%02X" % c for c in string)
return " ".join("0x%02x" % c for c in string)
else:
return " ".join("0x%02X" % ord(c) for c in string)
return " ".join("0x%02x" % ord(c) for c in string)

# print short hex dump from byte array all upper case
def to_hex_short_uc(byte_array):
return "".join("%02X" % b for b in byte_array)
return "".join("%02x" % b for b in byte_array)

def print_insn_detail(insn):
# print address, mnemonic and operands
#print("0x%x:\t%s\t%s\t%s" % (insn.address, binascii.hexlify(bytearray(insn.bytes)), \
print("0x%04X: %s\t%s\t%s" % (insn.address, to_hex_short_uc(insn.bytes), \
print("0x%04x: %s\t%s\t%s" % (insn.address, to_hex_short_uc(insn.bytes), \
insn.mnemonic, insn.op_str))

# "data" instruction generated by SKIPDATA option has no detail
Expand All @@ -75,15 +75,15 @@ def print_insn_detail(insn):
if i.type == M680X_OP_IMMEDIATE:
print("\t\toperands[%u].type: IMMEDIATE = #%d" % (c, i.imm))
if i.type == M680X_OP_DIRECT:
print("\t\toperands[%u].type: DIRECT = 0x%02X" % (c, i.direct_addr))
print("\t\toperands[%u].type: DIRECT = 0x%02x" % (c, i.direct_addr))
if i.type == M680X_OP_EXTENDED:
if i.ext.indirect:
indirect = "INDIRECT"
else:
indirect = ""
print("\t\toperands[%u].type: EXTENDED %s = 0x%04X" % (c, indirect, i.ext.address))
print("\t\toperands[%u].type: EXTENDED %s = 0x%04x" % (c, indirect, i.ext.address))
if i.type == M680X_OP_RELATIVE:
print("\t\toperands[%u].type: RELATIVE = 0x%04X" % (c, i.rel.address))
print("\t\toperands[%u].type: RELATIVE = 0x%04x" % (c, i.rel.address))
if i.type == M680X_OP_INDEXED:
if (i.idx.flags & M680X_IDX_INDIRECT):
indirect = " INDIRECT"
Expand All @@ -97,7 +97,7 @@ def print_insn_detail(insn):
if (i.idx.offset_bits != 0) and (i.idx.offset_reg == M680X_REG_INVALID) and (i.idx.inc_dec == 0):
print("\t\t\toffset: %u" % i.idx.offset)
if i.idx.base_reg == M680X_REG_PC:
print("\t\t\toffset address: 0x%04X" % i.idx.offset_addr)
print("\t\t\toffset address: 0x%04x" % i.idx.offset_addr)
print("\t\t\toffset bits: %u" % i.idx.offset_bits)
if i.idx.inc_dec != 0:
if i.idx.flags & M680X_IDX_POST_INC_DEC:
Expand Down
8 changes: 4 additions & 4 deletions cstool/cstool_m680x.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ void print_insn_detail_m680x(csh handle, cs_insn *insn)
break;

case M680X_OP_DIRECT:
printf("\t\toperands[%u].type: DIRECT = 0x%02X\n", i,
printf("\t\toperands[%u].type: DIRECT = 0x%02x\n", i,
op->direct_addr);
break;

case M680X_OP_EXTENDED:
printf("\t\toperands[%u].type: EXTENDED %s = 0x%04X\n",
printf("\t\toperands[%u].type: EXTENDED %s = 0x%04x\n",
i, op->ext.indirect ? "INDIRECT" : "",
op->ext.address);
break;

case M680X_OP_RELATIVE:
printf("\t\toperands[%u].type: RELATIVE = 0x%04X\n", i,
printf("\t\toperands[%u].type: RELATIVE = 0x%04x\n", i,
op->rel.address);
break;

Expand All @@ -124,7 +124,7 @@ void print_insn_detail_m680x(csh handle, cs_insn *insn)
printf("\t\t\toffset: %d\n", op->idx.offset);

if (op->idx.base_reg == M680X_REG_PC)
printf("\t\t\toffset address: 0x%X\n",
printf("\t\t\toffset address: 0x%x\n",
op->idx.offset_addr);

printf("\t\t\toffset bits: %u\n",
Expand Down
8 changes: 4 additions & 4 deletions suite/cstest/src/m680x_detail.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ char *get_detail_m680x(csh *handle, cs_mode mode, cs_insn *insn)
break;

case M680X_OP_DIRECT:
add_str(&result, " ; operands[%u].type: DIRECT = 0x%02X", i, op->direct_addr);
add_str(&result, " ; operands[%u].type: DIRECT = 0x%02x", i, op->direct_addr);
break;

case M680X_OP_EXTENDED:
add_str(&result, " ; operands[%u].type: EXTENDED %s = 0x%04X", i, op->ext.indirect ? "INDIRECT" : "", op->ext.address);
add_str(&result, " ; operands[%u].type: EXTENDED %s = 0x%04x", i, op->ext.indirect ? "INDIRECT" : "", op->ext.address);
break;

case M680X_OP_RELATIVE:
add_str(&result, " ; operands[%u].type: RELATIVE = 0x%04X", i, op->rel.address);
add_str(&result, " ; operands[%u].type: RELATIVE = 0x%04x", i, op->rel.address);
break;

case M680X_OP_INDEXED:
Expand All @@ -107,7 +107,7 @@ char *get_detail_m680x(csh *handle, cs_mode mode, cs_insn *insn)
add_str(&result, " ; offset: %d", op->idx.offset);

if (op->idx.base_reg == M680X_REG_PC)
add_str(&result, " ; offset address: 0x%X", op->idx.offset_addr);
add_str(&result, " ; offset address: 0x%x", op->idx.offset_addr);

add_str(&result, " ; offset bits: %u", op->idx.offset_bits);
}
Expand Down
14 changes: 7 additions & 7 deletions tests/test_m680x.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void print_string_hex(const char *comment, unsigned char *str, size_t len
printf("%s", comment);

for (c = str; c < str + len; c++)
printf("0x%02X ", *c & 0xff);
printf("0x%02x ", *c & 0xff);

printf("\n");
}
Expand All @@ -36,7 +36,7 @@ static void print_string_hex_short(unsigned char *str, size_t len)
unsigned char *c;

for (c = str; c < str + len; c++)
printf("%02X", *c & 0xff);
printf("%02x", *c & 0xff);
}

static const char *s_access[] = {
Expand Down Expand Up @@ -115,18 +115,18 @@ static void print_insn_detail(csh handle, cs_insn *insn)
break;

case M680X_OP_DIRECT:
printf("\t\toperands[%u].type: DIRECT = 0x%02X\n", i,
printf("\t\toperands[%u].type: DIRECT = 0x%02x\n", i,
op->direct_addr);
break;

case M680X_OP_EXTENDED:
printf("\t\toperands[%u].type: EXTENDED %s = 0x%04X\n",
printf("\t\toperands[%u].type: EXTENDED %s = 0x%04x\n",
i, op->ext.indirect ? "INDIRECT" : "",
op->ext.address);
break;

case M680X_OP_RELATIVE:
printf("\t\toperands[%u].type: RELATIVE = 0x%04X\n", i,
printf("\t\toperands[%u].type: RELATIVE = 0x%04x\n", i,
op->rel.address);
break;

Expand All @@ -149,7 +149,7 @@ static void print_insn_detail(csh handle, cs_insn *insn)
printf("\t\t\toffset: %d\n", op->idx.offset);

if (op->idx.base_reg == M680X_REG_PC)
printf("\t\t\toffset address: 0x%X\n",
printf("\t\t\toffset address: 0x%x\n",
op->idx.offset_addr);

printf("\t\t\toffset bits: %u\n",
Expand Down Expand Up @@ -360,7 +360,7 @@ static void test()

for (j = 0; j < count; j++) {
int slen;
printf("0x%04X: ", (uint16_t)insn[j].address);
printf("0x%04x: ", (uint16_t)insn[j].address);
print_string_hex_short(insn[j].bytes,
insn[j].size);
printf("%.*s", 1 + ((5 - insn[j].size) * 2),
Expand Down