Skip to content

Commit 5c49d7c

Browse files
committed
Fix successful branches not incrementing instret
1 parent 0c11e22 commit 5c49d7c

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/main.mlog

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ end_instruction__no_overflow:
284284
end_instruction_preserve_instret:
285285
op add pc pc 4
286286

287-
end_instruction_preserve_pc:
288287
# halt if the reset switch was manually enabled
289288
sensor enabled RESET_SWITCH @enabled
290289
jump main notEqual enabled true
@@ -672,9 +671,9 @@ jump_to_target:
672671
write result REGISTERS arg1
673672

674673
jump_to_target__no_write:
675-
set pc target
674+
op sub pc target 4 # HACK: end_instruction always increments the pc, so set the new pc to target - 4
676675
set opcache_var null
677-
jump end_instruction_preserve_pc always
676+
jump end_instruction always
678677

679678
JALR:
680679
# I-type: arg1=rd, arg2=rs1, arg3=imm

0 commit comments

Comments
 (0)