Skip to content

Commit

Permalink
Fix build with ENABLE_COMPUTED_GOTO=0 (sysprog21#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
LambertWSJ authored Jun 23, 2022
1 parent 7435261 commit 0167e1a
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1414,28 +1414,32 @@ void rv_step(struct riscv_t *rv, int32_t cycles)

// standard uncompressed instruction
if ((inst & 3) == 3) {
index = (inst & INST_6_2) >> 2;
uint32_t index = (inst & INST_6_2) >> 2;

// dispatch this opcode
TABLE_TYPE op = jump_table[index];
assert(op);
if (!op(rv, inst))
break;
rv->inst_len = INST_32;

} else {
// standard compressed instruction
inst &= 0x0000FFFF;
const uint16_t c_index =
(inst & FR_C_15_13 >> 11) | (inst & FR_C_1_0);
(inst & FC_FUNC3 >> 11) | (inst & FC_OPCODE);

// dispactch c_opcode (compressed instructions)
TABLE_TYPE_RVC op = jump_tablec[c_index];
TABLE_TYPE_RVC op = jump_table_rvc[c_index];
assert(op);
if (!op(rv, inst))
break;
rv->inst_len = INST_16;
}

if (!op(rv, inst))
break;

// increment the cycles csr
rv->csr_cycle++;
}
#endif // ENABLE_COMPUTED_GOTO
}

Expand Down

0 comments on commit 0167e1a

Please sign in to comment.