opcodes/mips: use .word/.short for undefined instructions

While working on disassembler styling for MIPS, I noticed that
undefined instructions are printed by the disassembler as raw number
with no assembler directive prefix (e.g. without .word or .short).

I think adding something like .word, or .short, helps to make it
clearer the size of the value that is being displayed, and is inline
with what many of the other libopcode disassemblers do.

In this commit I've added the .word and .short directives, and updated
all the tests that I spotted that failed as a result.
This commit is contained in:
Andrew Burgess
2022-11-02 15:53:43 +00:00
parent 47afa56ee2
commit 2438b771ee
24 changed files with 554 additions and 551 deletions

View File

@@ -2020,7 +2020,7 @@ print_insn_mips (bfd_vma memaddr,
/* Handle undefined instructions. */
info->insn_type = dis_noninsn;
infprintf (is, "0x%x", word);
infprintf (is, ".word\t0x%x", word);
return INSNLEN;
}
@@ -2398,7 +2398,7 @@ print_insn_mips16 (bfd_vma memaddr, struct disassemble_info *info)
}
#undef GET_OP
infprintf (is, "0x%x", first);
infprintf (is, ".short\t0x%x", first);
info->insn_type = dis_noninsn;
return 2;
@@ -2515,7 +2515,10 @@ print_insn_micromips (bfd_vma memaddr, struct disassemble_info *info)
}
}
infprintf (is, "0x%x", insn);
if (length == 2)
infprintf (is, ".short\t0x%x", insn);
else
infprintf (is, ".word\t0x%x", insn);
info->insn_type = dis_noninsn;
return length;