binutils Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
mips

MIPS: Correct Toshiba TX39 MADD/MADDU HI/LO instruction flags

MIPS assembler correctly flags MADD/MADDU instructions on TX39 to prevent pipeline hazards with HI/LO registers.

The MIPS assembler’s handling of HI/LO register hazards for Toshiba TX39’s MADD and MADDU instructions has been corrected. Previously, these instructions were not flagged as reading HI/LO registers, causing the assembler to miss potential pipeline hazards. This change adds the necessary flags, ensuring that extra NOP instructions are emitted to maintain correct operation and avoid issues where subsequent division instructions could encounter undefined HI/LO register values.

In Details

This commit corrects the opcode flags for Toshiba TX39's MADD/MADDU instructions in opcodes/mips-opc.c. Previously, these instructions only had INSN_WRITE_HI/INSN_WRITE_LO flags set, failing to signal their read dependency on HI/LO registers, which is crucial for preventing hazards with subsequent DIV/DIVU instructions as per the architecture manual [1-3]. By adding INSN_READ_HI/INSN_READ_LO flags, the insns_between logic in GAS now correctly inserts NOPs to avoid undefined HI/LO register states, resolving test coverage issues in gas/testsuite/gas/mips/madd.*.

For Context
MIPS
A Reduced Instruction Set Computer (RISC) instruction set architecture developed by MIPS Technologies, widely used in embedded systems and high-performance computing.
Toshiba TX39
A specific family of MIPS-based microprocessors developed by Toshiba, often found in embedded applications.
MADD/MADDU
MIPS instructions for Multiply-Add and Multiply-Add Unsigned. They perform a multiplication and then add the result to an accumulator, typically using the HI/LO registers.
HI/LO registers
Special MIPS registers used to store the high and low 32-bit parts of the result from multiplication (MULT, MULTU) and division (DIV, DIVU) operations.
Pipeline hazard
A situation in a pipelined processor where an instruction cannot execute immediately because it depends on the result of a previous instruction that has not yet completed. This can lead to incorrect results if not managed.
NOP
No Operation. An instruction that does nothing. NOPs are often used for timing, padding, or to fill pipeline stages to resolve hazards.
Filed Under: mipsassemblerbugfixpipeline