Skip to content

Commit 2d1777b

Browse files
nealfragereagerm
authored andcommitted
opcodes: microblaze: Fix bit masking bug
There is currently a bug in the bit masking for the barrel shift instructions because the bit mask is not including all of the register bits which must be zero. With this patch, the disassembler can be sure that the 32-bit value is indeed a barrel shift instruction and not a data value in memory. This fix can be verified by assembling and disassembling the following: .text .long 0x65005f5f With this patch, the bug is fixed, and the objdump will know that 0x65005f5f is not a barrel shift instruction. Signed-off-by: Neal Frager <[email protected]> Signed-off-by: Michael J. Eager <[email protected]>
1 parent 4781e16 commit 2d1777b

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

gas/testsuite/gas/microblaze/allinsn.d

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Disassembly of section .text:
4949
40: 900001e2 swaph r0, r0
5050

5151
00000044 <bsefi>:
52-
44: 64004041 bsrli r0, r0, 1
52+
44: 64004041 bsefi r0, r0, 1, 1
5353

5454
00000048 <bsifi>:
55-
48: 64008041 bsrli r0, r0, 1
55+
48: 64008041 bsifi r0, r0, 1, 1

opcodes/microblaze-dis.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#define get_int_field_imm(instr) ((instr & IMM_MASK) >> IMM_LOW)
3636
#define get_int_field_r1(instr) ((instr & RA_MASK) >> RA_LOW)
3737

38-
#define NUM_STRBUFS 3
38+
#define NUM_STRBUFS 4
3939
#define STRBUF_SIZE 25
4040

4141
struct string_buf
@@ -279,7 +279,7 @@ print_insn_microblaze (bfd_vma memaddr, struct disassemble_info * info)
279279
prev_insn_vma = curr_insn_vma;
280280

281281
if (op->name == NULL)
282-
print_func (stream, ".short 0x%04x", (unsigned int) inst);
282+
print_func (stream, ".long 0x%04x", (unsigned int) inst);
283283
else
284284
{
285285
print_func (stream, "%s", op->name);

opcodes/microblaze-opc.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,11 @@
9292
#define OPCODE_MASK_H124 0xFFFF07FF /* High 16, and low 11 bits. */
9393
#define OPCODE_MASK_H1234 0xFFFFFFFF /* All 32 bits. */
9494
#define OPCODE_MASK_H3 0xFC000600 /* High 6 bits and bits 21, 22. */
95+
#define OPCODE_MASK_H3B 0xFC00F9E0 /* High 6 bits and bits 16:20 and
96+
bits 23:26. */
9597
#define OPCODE_MASK_H32 0xFC00FC00 /* High 6 bits and bit 16-21. */
96-
#define OPCODE_MASK_H32B 0xFC00C000 /* High 6 bits and bit 16, 17. */
98+
#define OPCODE_MASK_H32B 0xFC00F820 /* High 6 bits and bits 16:20 and
99+
bit 26 */
97100
#define OPCODE_MASK_H34B 0xFC0000FF /* High 6 bits and low 8 bits. */
98101
#define OPCODE_MASK_H35B 0xFC0004FF /* High 6 bits and low 9 bits. */
99102
#define OPCODE_MASK_H34C 0xFC0007E0 /* High 6 bits and bits 21-26. */
@@ -160,9 +163,9 @@ const struct op_code_struct
160163
{"ncget", INST_TYPE_RD_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C006000, OPCODE_MASK_H32, ncget, anyware_inst },
161164
{"ncput", INST_TYPE_R1_RFSL, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x6C00E000, OPCODE_MASK_H32, ncput, anyware_inst },
162165
{"muli", INST_TYPE_RD_R1_IMM, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x60000000, OPCODE_MASK_H, muli, mult_inst },
163-
{"bslli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3, bslli, barrel_shift_inst },
164-
{"bsrai", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3, bsrai, barrel_shift_inst },
165-
{"bsrli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3, bsrli, barrel_shift_inst },
166+
{"bslli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000400, OPCODE_MASK_H3B, bslli, barrel_shift_inst },
167+
{"bsrai", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000200, OPCODE_MASK_H3B, bsrai, barrel_shift_inst },
168+
{"bsrli", INST_TYPE_RD_R1_IMM5, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64000000, OPCODE_MASK_H3B, bsrli, barrel_shift_inst },
166169
{"bsefi", INST_TYPE_RD_R1_IMMW_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64004000, OPCODE_MASK_H32B, bsefi, barrel_shift_inst },
167170
{"bsifi", INST_TYPE_RD_R1_IMMW_IMMS, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x64008000, OPCODE_MASK_H32B, bsifi, barrel_shift_inst },
168171
{"or", INST_TYPE_RD_R1_R2, INST_NO_OFFSET, NO_DELAY_SLOT, IMMVAL_MASK_NON_SPECIAL, 0x80000000, OPCODE_MASK_H4, microblaze_or, logical_inst },

0 commit comments

Comments
 (0)