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

@@ -22,7 +22,7 @@ FLAGS 1: .*
FLAGS 2: .*
Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 7aa2080b 0x7aa2080b
[0-9a-f]+ <[^>]*> 7aa2080b .word 0x7aa2080b
[0-9a-f]+ <[^>]*> 46c520c0 add\.ps \$f3,\$f4,\$f5
[0-9a-f]+ <[^>]*> 46c83998 addr\.ps \$f6,\$f7,\$f8
\.\.\.

View File

@@ -8,6 +8,6 @@
Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 40020800 mfc0 v0,c0_random
[0-9a-f]+ <[^>]*> 40420800 cfc0 v0,\$1
[0-9a-f]+ <[^>]*> 40620800 0x40620800
[0-9a-f]+ <[^>]*> 40620c00 0x40620c00
[0-9a-f]+ <[^>]*> 40620800 .word 0x40620800
[0-9a-f]+ <[^>]*> 40620c00 .word 0x40620c00
\.\.\.

View File

@@ -8,6 +8,6 @@
Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 40020800 mfc0 v0,c0_random
[0-9a-f]+ <[^>]*> 40420800 mfhc0 v0,c0_random
[0-9a-f]+ <[^>]*> 40620800 0x40620800
[0-9a-f]+ <[^>]*> 40620c00 0x40620c00
[0-9a-f]+ <[^>]*> 40620800 .word 0x40620800
[0-9a-f]+ <[^>]*> 40620c00 .word 0x40620c00
\.\.\.

View File

@@ -9,5 +9,5 @@ Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 40020800 mfc0 v0,c0_random
[0-9a-f]+ <[^>]*> 40420800 cfc0 v0,\$1
[0-9a-f]+ <[^>]*> 40620800 mfgc0 v0,c0_random
[0-9a-f]+ <[^>]*> 40620c00 0x40620c00
[0-9a-f]+ <[^>]*> 40620c00 .word 0x40620c00
\.\.\.

View File

@@ -12,6 +12,6 @@ Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 04100000 bltzal zero,[0-9a-f]+ <[^>]*>
[0-9a-f]+ <[^>]*> 10200000 beqz at,[0-9a-f]+ <[^>]*>
[0-9a-f]+ <[^>]*> 14200000 bnez at,[0-9a-f]+ <[^>]*>
[0-9a-f]+ <[^>]*> 50200000 0x50200000
[0-9a-f]+ <[^>]*> 54200000 0x54200000
[0-9a-f]+ <[^>]*> 50200000 .word 0x50200000
[0-9a-f]+ <[^>]*> 54200000 .word 0x54200000
\.\.\.

View File

@@ -12,6 +12,6 @@ Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 04100000 bltzal zero,[0-9a-f]+ <[^>]*>
[0-9a-f]+ <[^>]*> 10200000 beq at,zero,[0-9a-f]+ <[^>]*>
[0-9a-f]+ <[^>]*> 14200000 bne at,zero,[0-9a-f]+ <[^>]*>
[0-9a-f]+ <[^>]*> 50200000 0x50200000
[0-9a-f]+ <[^>]*> 54200000 0x54200000
[0-9a-f]+ <[^>]*> 50200000 .word 0x50200000
[0-9a-f]+ <[^>]*> 54200000 .word 0x54200000
\.\.\.

View File

@@ -17,22 +17,22 @@ Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 1c00 0000 jalx 00000000 <foo>
[0-9a-f]+ <[^>]*> 6500 nop
[0-9a-f]+ <[^>]*> f123 extend 0x123
[0-9a-f]+ <[^>]*> 6621 0x6621
[0-9a-f]+ <[^>]*> 6621 .short 0x6621
[0-9a-f]+ <[^>]*> f456 extend 0x456
[0-9a-f]+ <[^>]*> e935 0xe935
[0-9a-f]+ <[^>]*> e935 .short 0xe935
[0-9a-f]+ <[^>]*> f765 extend 0x765
[0-9a-f]+ <[^>]*> ea60 0xea60
[0-9a-f]+ <[^>]*> ea60 .short 0xea60
[0-9a-f]+ <[^>]*> f432 extend 0x432
[0-9a-f]+ <[^>]*> ece0 0xece0
[0-9a-f]+ <[^>]*> ece0 .short 0xece0
[0-9a-f]+ <[^>]*> f5aa extend 0x5aa
[0-9a-f]+ <[^>]*> e971 0xe971
[0-9a-f]+ <[^>]*> e971 .short 0xe971
[0-9a-f]+ <[^>]*> f655 extend 0x655
[0-9a-f]+ <[^>]*> ebf1 0xebf1
[0-9a-f]+ <[^>]*> 6621 0x6621
[0-9a-f]+ <[^>]*> e935 0xe935
[0-9a-f]+ <[^>]*> ea60 0xea60
[0-9a-f]+ <[^>]*> ece0 0xece0
[0-9a-f]+ <[^>]*> e971 0xe971
[0-9a-f]+ <[^>]*> ebf1 0xebf1
[0-9a-f]+ <[^>]*> ebf1 .short 0xebf1
[0-9a-f]+ <[^>]*> 6621 .short 0x6621
[0-9a-f]+ <[^>]*> e935 .short 0xe935
[0-9a-f]+ <[^>]*> ea60 .short 0xea60
[0-9a-f]+ <[^>]*> ece0 .short 0xece0
[0-9a-f]+ <[^>]*> e971 .short 0xe971
[0-9a-f]+ <[^>]*> ebf1 .short 0xebf1
[0-9a-f]+ <[^>]*> 6500 nop
\.\.\.

View File

@@ -108,21 +108,21 @@ Disassembly of section \.text:
00005020 <[^>]*> fcbf ld a1,00005110 <foo5\+0x110>
\.\.\.
00006000 <[^>]*> 6500 nop
00006002 <[^>]*> e860 0xe860
00006002 <[^>]*> e860 .short 0xe860
00006004 <[^>]*> 0aff la v0,00006400 <foo6\+0x400>
00006006 <[^>]*> 6500 nop
00006008 <[^>]*> 6500 nop
0000600a <[^>]*> e860 0xe860
0000600a <[^>]*> e860 .short 0xe860
0000600c <[^>]*> b3ff lw v1,00006408 <foo6\+0x408>
0000600e <[^>]*> 6500 nop
00006010 <[^>]*> 6500 nop
00006012 <[^>]*> e860 0xe860
00006012 <[^>]*> e860 .short 0xe860
00006014 <[^>]*> fe9f dla a0,00006090 <foo6\+0x90>
00006016 <[^>]*> 6500 nop
00006018 <[^>]*> 6500 nop
0000601a <[^>]*> 6500 nop
0000601c <[^>]*> 6500 nop
0000601e <[^>]*> e860 0xe860
0000601e <[^>]*> e860 .short 0xe860
00006020 <[^>]*> fcbf ld a1,00006118 <foo6\+0x118>
\.\.\.
00007000 <[^>]*> 6500 nop
@@ -180,20 +180,20 @@ Disassembly of section \.text:
00009020 <[^>]*> fcbf ld a1,00009118 <foo9\+0x118>
\.\.\.
0000a000 <[^>]*> 6500 nop
0000a002 <[^>]*> e960 0xe960
0000a002 <[^>]*> e960 .short 0xe960
0000a004 <[^>]*> 0aff la v0,0000a400 <fooa\+0x400>
0000a006 <[^>]*> 6500 nop
0000a008 <[^>]*> 6500 nop
0000a00a <[^>]*> e960 0xe960
0000a00a <[^>]*> e960 .short 0xe960
0000a00c <[^>]*> b3ff lw v1,0000a408 <fooa\+0x408>
0000a00e <[^>]*> 6500 nop
0000a010 <[^>]*> 6500 nop
0000a012 <[^>]*> e960 0xe960
0000a012 <[^>]*> e960 .short 0xe960
0000a014 <[^>]*> fe9f dla a0,0000a090 <fooa\+0x90>
0000a016 <[^>]*> 6500 nop
0000a018 <[^>]*> 6500 nop
0000a01a <[^>]*> 6500 nop
0000a01c <[^>]*> 6500 nop
0000a01e <[^>]*> e960 0xe960
0000a01e <[^>]*> e960 .short 0xe960
0000a020 <[^>]*> fcbf ld a1,0000a118 <fooa\+0x118>
\.\.\.

View File

@@ -12,6 +12,6 @@ Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 04100000 nal
[0-9a-f]+ <[^>]*> 10200000 beqz at,[0-9a-f]+ <[^>]*>
[0-9a-f]+ <[^>]*> 14200000 bnez at,[0-9a-f]+ <[^>]*>
[0-9a-f]+ <[^>]*> 50200000 0x50200000
[0-9a-f]+ <[^>]*> 54200000 0x54200000
[0-9a-f]+ <[^>]*> 50200000 .word 0x50200000
[0-9a-f]+ <[^>]*> 54200000 .word 0x54200000
\.\.\.

View File

@@ -12,6 +12,6 @@ Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 04100000 nal
[0-9a-f]+ <[^>]*> 10200000 beq at,zero,[0-9a-f]+ <[^>]*>
[0-9a-f]+ <[^>]*> 14200000 bne at,zero,[0-9a-f]+ <[^>]*>
[0-9a-f]+ <[^>]*> 50200000 0x50200000
[0-9a-f]+ <[^>]*> 54200000 0x54200000
[0-9a-f]+ <[^>]*> 50200000 .word 0x50200000
[0-9a-f]+ <[^>]*> 54200000 .word 0x54200000
\.\.\.