Skip to content

Commit 0c39344

Browse files
committed
Move instruction length checking
1 parent 1f36f8b commit 0c39344

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/emulate.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,11 @@ static bool emulate(riscv_t *rv, rv_insn_t *ir)
551551
rv->X[ir->rd] = rv->X[ir->rs1] & rv->X[ir->rs2];
552552
break;
553553
case rv_insn_ecall: /* ECALL: Environment Call */
554+
rv->compressed = false;
554555
rv->io.on_ecall(rv);
555556
return true;
556557
case rv_insn_ebreak: /* EBREAK: Environment Break */
558+
rv->compressed = false;
557559
rv->io.on_ebreak(rv);
558560
return true;
559561
case rv_insn_wfi: /* WFI: Wait for Interrupt */
@@ -1103,6 +1105,7 @@ static bool emulate(riscv_t *rv, rv_insn_t *ir)
11031105
rv->X[ir->rd] = rv->X[ir->rs2];
11041106
break;
11051107
case rv_insn_cebreak: /* C.EBREAK */
1108+
rv->compressed = true;
11061109
rv->io.on_ebreak(rv);
11071110
/* can branch */
11081111
return true;
@@ -1354,14 +1357,12 @@ void rv_step(riscv_t *rv, int32_t cycles)
13541357
void ebreak_handler(riscv_t *rv)
13551358
{
13561359
assert(rv);
1357-
rv->compressed = false;
13581360
rv_except_breakpoint(rv, rv->PC);
13591361
}
13601362

13611363
void ecall_handler(riscv_t *rv)
13621364
{
13631365
assert(rv);
1364-
rv->compressed = false;
13651366
rv_except_ecall_M(rv, 0);
13661367
syscall_handler(rv);
13671368
}

0 commit comments

Comments
 (0)