Skip to content

Commit 3908658

Browse files
committed
opcodes: xtensa: implement styled disassembly
opcodes/ * xtensa-dis.c (print_xtensa_operand) (print_insn_xtensa): Replace fprintf_func with fprintf_styled_func.
1 parent a7d5fca commit 3908658

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

opcodes/xtensa-dis.c

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,24 +238,28 @@ print_xtensa_operand (bfd_vma memaddr,
238238
else
239239
{
240240
if ((signed_operand_val > -256) && (signed_operand_val < 256))
241-
(*info->fprintf_func) (info->stream, "%d", signed_operand_val);
241+
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
242+
"%d", signed_operand_val);
242243
else
243-
(*info->fprintf_func) (info->stream, "0x%x", signed_operand_val);
244+
(*info->fprintf_styled_func) (info->stream, dis_style_immediate,
245+
"0x%x", signed_operand_val);
244246
}
245247
}
246248
else
247249
{
248250
int i = 1;
249251
xtensa_regfile opnd_rf = xtensa_operand_regfile (isa, opc, opnd);
250-
(*info->fprintf_func) (info->stream, "%s%u",
251-
xtensa_regfile_shortname (isa, opnd_rf),
252-
operand_val);
252+
(*info->fprintf_styled_func) (info->stream, dis_style_register,
253+
"%s%u",
254+
xtensa_regfile_shortname (isa, opnd_rf),
255+
operand_val);
253256
while (i < xtensa_operand_num_regs (isa, opc, opnd))
254257
{
255258
operand_val++;
256-
(*info->fprintf_func) (info->stream, ":%s%u",
257-
xtensa_regfile_shortname (isa, opnd_rf),
258-
operand_val);
259+
(*info->fprintf_styled_func) (info->stream, dis_style_register,
260+
":%s%u",
261+
xtensa_regfile_shortname (isa, opnd_rf),
262+
operand_val);
259263
i++;
260264
}
261265
}
@@ -404,7 +408,13 @@ print_insn_xtensa (bfd_vma memaddr, struct disassemble_info *info)
404408
}
405409
else
406410
{
407-
(*info->fprintf_func) (info->stream, ".byte %#02x", priv.byte_buf[0]);
411+
(*info->fprintf_styled_func) (info->stream,
412+
dis_style_assembler_directive,
413+
".byte");
414+
(*info->fprintf_func) (info->stream, "\t");
415+
(*info->fprintf_styled_func) (info->stream,
416+
dis_style_immediate,
417+
"%#02x", priv.byte_buf[0]);
408418
return 1;
409419
}
410420
}
@@ -425,8 +435,9 @@ print_insn_xtensa (bfd_vma memaddr, struct disassemble_info *info)
425435

426436
xtensa_format_get_slot (isa, fmt, n, insn_buffer, slot_buffer);
427437
opc = xtensa_opcode_decode (isa, fmt, n, slot_buffer);
428-
(*info->fprintf_func) (info->stream, "%s",
429-
xtensa_opcode_name (isa, opc));
438+
(*info->fprintf_styled_func) (info->stream,
439+
dis_style_mnemonic, "%s",
440+
xtensa_opcode_name (isa, opc));
430441

431442
if (xtensa_opcode_is_branch (isa, opc))
432443
info->insn_type = dis_condbranch;

0 commit comments

Comments
 (0)