Skip to content

Commit

Permalink
Add missing EBB information in cbeqz and cbnez
Browse files Browse the repository at this point in the history
Set last_pc in emuation function cbeqz and cbnez.

Solve: sysprog21#134
  • Loading branch information
Yen-Fu Chen committed Jun 23, 2023
1 parent bc07e87 commit 0973aba
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/emulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -1148,12 +1148,15 @@ RVOP(cbeqz, {
if (!ir->branch_untaken)
goto nextop;
rv->PC += ir->insn_len;
last_pc = rv->PC;
return ir->branch_untaken->impl(rv, ir->branch_untaken);
}
branch_taken = true;
rv->PC += (uint32_t) ir->imm;
if (ir->branch_taken)
if (ir->branch_taken) {
last_pc = rv->PC;
return ir->branch_taken->impl(rv, ir->branch_taken);
}
return true;
})

Expand All @@ -1164,12 +1167,15 @@ RVOP(cbnez, {
if (!ir->branch_untaken)
goto nextop;
rv->PC += ir->insn_len;
last_pc = rv->PC;
return ir->branch_untaken->impl(rv, ir->branch_untaken);
}
branch_taken = true;
rv->PC += (uint32_t) ir->imm;
if (ir->branch_taken)
if (ir->branch_taken) {
last_pc = rv->PC;
return ir->branch_taken->impl(rv, ir->branch_taken);
}
return true;
})

Expand Down

0 comments on commit 0973aba

Please sign in to comment.