binutils Newspaper
NOVEMBER 30, 2026
opcodes — Proposed

opcodes: microblaze: tell bslli, bsrai and bsrli apart

Corrects MicroBlaze opcode mask to accurately distinguish between shift immediate instructions.

This patch corrects a flaw in the MicroBlaze opcode mask (OPCODE_MASK_H3B) that prevented the assembler and disassembler from distinguishing between bslli, bsrai, and bsrli instructions. The existing mask omitted critical bits, causing all immediate barrel shifts to be treated as bsrli. The updated mask includes these bits, enabling correct disassembly and simulation, and fixing a test case that previously failed due to this ambiguity.

In the Thread 1 participant
  1. Samuel Price proposer

    Proposes updating the MicroBlaze opcode mask to correctly differentiate immediate barrel shift instructions.

    “OPCODE_MASK_H3B, the mask of the immediate barrel shifts, leaves out bits 21:22 (0x600), the only bits that tell bslli, bsrai and bsrli apart. The bit_sequence of bslli and bsrai has bits outside the mask, so the opcode lookup never matches them, and every immediate barrel shift disassembles as bsrli.”

In Details

This patch addresses an opcode recognition issue for MicroBlaze immediate barrel shift instructions in opcodes/microblaze-opc.h. The OPCODE_MASK_H3B was insufficient, failing to account for bits 21:22, which differentiate bslli (shift left logical immediate), bsrai (shift right arithmetic immediate), and bsrli (shift right logical immediate). Consequently, all these instructions were being disassembled as bsrli. The patch updates the mask to 0xFC00FFE0, correctly covering these differentiating bits, aligning with QEMU's decoder and fixing failing test cases.

For Context
opcode mask
A bitmask used to isolate specific fields within an instruction's binary encoding for matching purposes.
bslli
MicroBlaze instruction: Shift Left Logical Immediate.
bsrai
MicroBlaze instruction: Shift Right Arithmetic Immediate.
bsrli
MicroBlaze instruction: Shift Right Logical Immediate.
MicroBlaze
A soft processor core from Xilinx, designed to be implemented in FPGAs. It has a RISC-like architecture.
QEMU
A popular open-source machine emulator and virtualizer that can emulate various hardware architectures, including MicroBlaze.
Filed Under: microblazeopcodesdisassemblermaskingbug fix