[PATCH] csky: Fix BMASKI disassembly for immediate 32 on C-SKY v1

Jan Beulich jbeulich@suse.com
Wed Feb 11 13:11:29 GMT 2026


On 11.02.2026 12:59, Michal Sobon wrote:
> On Thu, Feb 5, 2026 at 12:23 PM Jan Beulich <jbeulich@suse.com> wrote:
>>
>> Short of them responding, I will: Unlike for your earlier M*Core change,
>> the situation doesn't look as clear here. This is what I found in what I
>> hope is the applicable doc:
>>
>> "When OIMM5 is 0 or 32, all bits of RX are set as 1."
>>
>> and later, after discussing immediates 1...16:
>>
>> "The range of immediate operand is 0 and 17-32."
>>
>> Hence 0 looks to be a spec-conforming representation in disassembly,
>> albeit perhaps not as human friendly as 32.
>>
>> Comparing with the v2 version of the insn also doesn't look quite fair:
>> That appears to take a 5-bit immediate in the range 16...31, with 1 then
>> added in.
> 
> While I agree that 0 is the literal value in the immediate field, I
> found a note in my documentation regarding the assembler behavior
> (translated from Chinese):
> 
> "Set the lower IMM5 bit of register RX to 1, and clear the remaining
> higher bits to 0. Register RX can be set from bit 1 to bit 32. When the
> IMM5 field is 00000, the assembler will interpret it as 32 bits."
> 
> My main motivation for the change is avoiding confusion. To someone not
> fully familiar with the ISA details, BMASKI 0 could give the impression
> that the instruction does not set any bits (or clears the register),
> whereas the actual behavior is setting all 32 bits.
> 
> Since the assembler interprets an input of 32 by encoding it as 0, I

This, I think, is a bogus representation of things. How a certain
"effective" number is encoded in an insn isn't meaningful to its
representation in human readable form (assembly source, disassembly).

> felt it was safer for the disassembler to close that loop and display
> 32.
> 
> However, I realize this is largely a matter of preference. If you think
> disassembling as 0 is better, I am totally fine with that too.

I find it hard to judge what is "better" here. It really should be the
arch maintainers to judge, but so far there has only been silence from
them. In the absence of any clear preference, my inclination is to
leave things as they are presently.

Jan


More information about the Binutils mailing list