diff --git a/riscv/insns/cs_cincoffset.h b/riscv/insns/cs_cincoffset.h index bd9a4f43..d8f4d1a1 100644 --- a/riscv/insns/cs_cincoffset.h +++ b/riscv/insns/cs_cincoffset.h @@ -8,7 +8,9 @@ cap_type_t tmp_type = READ_CAP(insn_rs1).type; if (tmp_type == CAP_TYPE_UNINITIALIZED || tmp_type == CAP_TYPE_SEALED) throw trap_capstone_unexpected_cap_type(insn.bits()); /*increment cursor*/ -if (NOT_ZERO_REG(insn_rs1)) { - READ_CAP(insn_rs1).cursor += RS2; -} +uint64_t val = RS2; MOVC(insn_rd, insn_rs1); +if (NOT_ZERO_REG(insn_rd)) { + READ_CAP(insn_rd).cursor += val; +} + diff --git a/riscv/insns/cs_cincoffsetimm.h b/riscv/insns/cs_cincoffsetimm.h index 9ba1fe88..0317b062 100644 --- a/riscv/insns/cs_cincoffsetimm.h +++ b/riscv/insns/cs_cincoffsetimm.h @@ -8,7 +8,7 @@ cap_type_t tmp_type = READ_CAP(insn_rs1).type; if (tmp_type == CAP_TYPE_UNINITIALIZED || tmp_type == CAP_TYPE_SEALED) throw trap_capstone_unexpected_cap_type(insn.bits()); /*increment cursor*/ -if (NOT_ZERO_REG(insn_rs1)) { - READ_CAP(insn_rs1).cursor += insn_i_imm; -} MOVC(insn_rd, insn_rs1); +if (NOT_ZERO_REG(insn_rd)) { + READ_CAP(insn_rd).cursor += insn_i_imm; +} diff --git a/riscv/insns/cs_init.h b/riscv/insns/cs_init.h index 8d076ee9..0de225ce 100644 --- a/riscv/insns/cs_init.h +++ b/riscv/insns/cs_init.h @@ -9,6 +9,7 @@ if (READ_CAP(insn_rs1).type != CAP_TYPE_UNINITIALIZED) if (READ_CAP(insn_rs1).cursor != READ_CAP(insn_rs1).end) throw trap_capstone_illegal_operand_value(insn.bits()); /*init an uninitialized capability*/ -READ_CAP(insn_rs1).type = CAP_TYPE_LINEAR; -READ_CAP(insn_rs1).cursor = READ_CAP(insn_rs1).base + RS2; +uint64_t val = RS2; MOVC(insn_rd, insn_rs1); +READ_CAP(insn_rd).type = CAP_TYPE_LINEAR; +READ_CAP(insn_rd).cursor = READ_CAP(insn_rs1).base + val; diff --git a/riscv/insns/cs_scc.h b/riscv/insns/cs_scc.h index 0a1aa210..29517cb9 100644 --- a/riscv/insns/cs_scc.h +++ b/riscv/insns/cs_scc.h @@ -7,7 +7,8 @@ if (!IS_CAP(insn_rs1) || !IS_DATA(insn_rs2)) if (READ_CAP(insn_rs1).type == CAP_TYPE_UNINITIALIZED || READ_CAP(insn_rs1).type == CAP_TYPE_SEALED) throw trap_capstone_unexpected_cap_type(insn.bits()); /*set current cursor*/ -if (NOT_ZERO_REG(insn_rs1)) { - READ_CAP(insn_rs1).cursor = RS2; -} +uint64_t val = RS2; MOVC(insn_rd, insn_rs1); +if (NOT_ZERO_REG(insn_rd)) { + READ_CAP(insn_rd).cursor = val; +} diff --git a/riscv/insns/cs_seal.h b/riscv/insns/cs_seal.h index 85280e6b..8b0a32ba 100644 --- a/riscv/insns/cs_seal.h +++ b/riscv/insns/cs_seal.h @@ -13,6 +13,6 @@ if (READ_CAP(insn_rs1).end - READ_CAP(insn_rs1).base < CLENBYTES * 33) if (READ_CAP(insn_rs1).base % CLENBYTES != 0) throw trap_capstone_illegal_operand_value(insn.bits()); /*seal a linear capability*/ -READ_CAP(insn_rs1).type = CAP_TYPE_SEALED; -READ_CAP(insn_rs1).async = CAP_ASYNC_SYNC; MOVC(insn_rd, insn_rs1); +READ_CAP(insn_rd).type = CAP_TYPE_SEALED; +READ_CAP(insn_rd).async = CAP_ASYNC_SYNC; diff --git a/riscv/insns/cs_tighten.h b/riscv/insns/cs_tighten.h index ade9f6d5..90d8cc64 100644 --- a/riscv/insns/cs_tighten.h +++ b/riscv/insns/cs_tighten.h @@ -10,12 +10,12 @@ if (tmp_type != CAP_TYPE_LINEAR && tmp_type != CAP_TYPE_NONLINEAR && tmp_type != if (insn_ri_imm < 7 && !CAP_PERM_GTE(insn_rs1, static_cast(insn_ri_imm))) throw trap_capstone_illegal_operand_value(insn.bits()); /*tighten the permission*/ -if (NOT_ZERO_REG(insn_rs1)) { +MOVC(insn_rd, insn_rs1); +if (NOT_ZERO_REG(insn_rd)) { if (insn_ri_imm > 7) { - READ_CAP(insn_rs1).perm = CAP_PERM_NA; + READ_CAP(insn_rd).perm = CAP_PERM_NA; } else { - READ_CAP(insn_rs1).perm = static_cast(insn_ri_imm); + READ_CAP(insn_rd).perm = static_cast(insn_ri_imm); } } -MOVC(insn_rd, insn_rs1);