[PATCH] csky: Fix BMASKI disassembly for immediate 32 on C-SKY v1
Michal Sobon
msobon@hex-rays.com
Thu Jan 29 14:27:05 GMT 2026
The C-SKY v1 bmaski instruction uses a 5-bit immediate field where
a value of 0 represents a 32-bit mask (all ones). Update the
disassembler to display "bmaski rX, 32" instead of "bmaski rX, 0"
for this case. This is consistent with the C-SKY v2 disassembler
which already displays 32 for this encoding.
Add a test case for bmaski with immediate 32 in the v1 test suite.
opcodes/
* csky-dis.c (csky_output_operand): Display 32 instead of 0
for OPRND_TYPE_IMM5b_BMASKI when value is 0.
gas/testsuite/
* gas/csky/all.s: Add bmaski r4, 32 test.
* gas/csky/all.d: Add expected output for bmaski r4, 32.
Update branch instruction encodings affected by address shift.
---
gas/testsuite/gas/csky/all.d | 7 ++++---
gas/testsuite/gas/csky/all.s | 1 +
opcodes/csky-dis.c | 3 ++-
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/gas/testsuite/gas/csky/all.d b/gas/testsuite/gas/csky/all.d
index af9acb50da8..2e807fd588e 100644
--- a/gas/testsuite/gas/csky/all.d
+++ b/gas/testsuite/gas/csky/all.d
@@ -74,6 +74,7 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*2823\s*rsubi\s*r3, r3, 2
\s*[0-9a-f]*:\s*2a33\s*cmpnei\s*r3, 3
\s*[0-9a-f]*:\s*2c83\s*bmaski\s*r3, 8
+\s*[0-9a-f]*:\s*2c04\s*bmaski\s*r4, 32
\s*[0-9a-f]*:\s*2c13\s*divu\s*r3, r3, r1
\s*[0-9a-f]*:\s*2c22\s*mflos\s*r2
\s*[0-9a-f]*:\s*2c32\s*mfhis\s*r2
@@ -109,9 +110,9 @@ Disassembly of section \.text:
\s*[0-9a-f]*:\s*a210\s*ld.b\s*r2,\s*\(r0,\s*0x1\)
\s*[0-9a-f]*:\s*b200\s*st.b\s*r2,\s*\(r0,\s*0x0\)
\s*[0-9a-f]*:\s*b210\s*st.b\s*r2,\s*\(r0,\s*0x1\)
-\s*[0-9a-f]*:\s*e798\s*bt\s*0x0.*
-\s*[0-9a-f]*:\s*ef97\s*bf\s*0x0.*
-\s*[0-9a-f]*:\s*f796\s*br\s*0x0.*
+\s*[0-9a-f]*:\s*e797\s*bt\s*0x0.*
+\s*[0-9a-f]*:\s*ef96\s*bf\s*0x0.*
+\s*[0-9a-f]*:\s*f795\s*br\s*0x0.*
\s*[0-9a-f]*:\s*0c00\s*cmphs\s*r0, r0
\s*[0-9a-f]*:\s*0f00\s*cmpne\s*r0, r0
\s*[0-9a-f]*:\s*2205\s*cmplti\s*r5, 1
diff --git a/gas/testsuite/gas/csky/all.s b/gas/testsuite/gas/csky/all.s
index a21bd478988..9ac301e751b 100644
--- a/gas/testsuite/gas/csky/all.s
+++ b/gas/testsuite/gas/csky/all.s
@@ -67,6 +67,7 @@ all:
rsubi r3, 2
cmpnei r3, 3
bmaski r3, 8
+ bmaski r4, 32
divu r3, r1
mflos r2
mfhis r2
diff --git a/opcodes/csky-dis.c b/opcodes/csky-dis.c
index aaf6ffd1b85..c2cf0bac774 100644
--- a/opcodes/csky-dis.c
+++ b/opcodes/csky-dis.c
@@ -382,7 +382,8 @@ csky_output_operand (char *str, struct operand const *oprnd,
ret = -1;
break;
}
- sprintf (buf, "%d", (int)value);
+ /* IMM5 field of 0 represents 32 bits. */
+ sprintf (buf, "%d", (int)(value == 0 ? 32 : value));
strcat (str, buf);
ret = 0;
break;
--
2.43.0
More information about the Binutils
mailing list