Skip to content

Commit de3b92b

Browse files
committed
Fix csrrc instruction behavior when rs1 is 0
According to the RISC-V specification, no write operation should occur when rs1 is equal to 0. The current implementation incorrectly clears all bits in the specified CSR. Introduces a fix that ensures the csrrc instruction refrains from performing any write operation when rs1 is 0.
1 parent bc54c7f commit de3b92b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/rv32_template.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ RVOP(
992992
csrrc,
993993
{
994994
uint32_t tmp = csr_csrrc(
995-
rv, ir->imm, (ir->rs1 == rv_reg_zero) ? ~0U : rv->X[ir->rs1]);
995+
rv, ir->imm, (ir->rs1 == rv_reg_zero) ? 0U : rv->X[ir->rs1]);
996996
rv->X[ir->rd] = ir->rd ? tmp : rv->X[ir->rd];
997997
},
998998
GEN({

0 commit comments

Comments
 (0)