Skip to content

Commit 8726cf4

Browse files
committed
change order of operations in CSR modification
1 parent c463d96 commit 8726cf4

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

include/insns/Zicsr.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,10 @@ class Zicsr : public RevExt {
5252
if( Inst.rd != 0 )
5353
R->SetX( Inst.rd, old );
5454

55-
// Advance PC
56-
R->AdvancePC( Inst );
57-
5855
// Handle CSRRS/CSRRC
5956
if( OP != CSROp::Write ) {
6057
if( Inst.rs1 == 0 ) {
61-
return true; // If CSRRS/CSRRC rs1 == 0, do not modify CSR
58+
goto end; // If CSRRS/CSRRC rs1 == 0, do not modify CSR
6259
} else if( OP == CSROp::Set ) {
6360
val = old | val;
6461
} else {
@@ -72,6 +69,11 @@ class Zicsr : public RevExt {
7269

7370
// Write the new CSR value
7471
R->SetCSR( Inst.imm, val );
72+
73+
end:
74+
// Advance PC
75+
R->AdvancePC( Inst );
76+
7577
return true;
7678
}
7779

0 commit comments

Comments
 (0)