Skip to content

Commit

Permalink
Move instruction length checking
Browse files Browse the repository at this point in the history
  • Loading branch information
qwe661234 committed Dec 9, 2022
1 parent 1f36f8b commit 0c39344
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,9 +551,11 @@ static bool emulate(riscv_t *rv, rv_insn_t *ir)
rv->X[ir->rd] = rv->X[ir->rs1] & rv->X[ir->rs2];
break;
case rv_insn_ecall: /* ECALL: Environment Call */
rv->compressed = false;
rv->io.on_ecall(rv);
return true;
case rv_insn_ebreak: /* EBREAK: Environment Break */
rv->compressed = false;
rv->io.on_ebreak(rv);
return true;
case rv_insn_wfi: /* WFI: Wait for Interrupt */
Expand Down Expand Up @@ -1103,6 +1105,7 @@ static bool emulate(riscv_t *rv, rv_insn_t *ir)
rv->X[ir->rd] = rv->X[ir->rs2];
break;
case rv_insn_cebreak: /* C.EBREAK */
rv->compressed = true;
rv->io.on_ebreak(rv);
/* can branch */
return true;
Expand Down Expand Up @@ -1354,14 +1357,12 @@ void rv_step(riscv_t *rv, int32_t cycles)
void ebreak_handler(riscv_t *rv)
{
assert(rv);
rv->compressed = false;
rv_except_breakpoint(rv, rv->PC);
}

void ecall_handler(riscv_t *rv)
{
assert(rv);
rv->compressed = false;
rv_except_ecall_M(rv, 0);
syscall_handler(rv);
}

0 comments on commit 0c39344

Please sign in to comment.