diff --git a/src/emulate.c b/src/emulate.c index 51bd77f6..b0ec91b9 100644 --- a/src/emulate.c +++ b/src/emulate.c @@ -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; }) @@ -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; })