aboutsummaryrefslogtreecommitdiff
path: root/lib/arm64/dis-arm64.inc.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arm64/dis-arm64.inc.h')
-rw-r--r--lib/arm64/dis-arm64.inc.h31
1 files changed, 22 insertions, 9 deletions
diff --git a/lib/arm64/dis-arm64.inc.h b/lib/arm64/dis-arm64.inc.h
index 14a3a92..04349f2 100644
--- a/lib/arm64/dis-arm64.inc.h
+++ b/lib/arm64/dis-arm64.inc.h
@@ -8,15 +8,32 @@ static INLINE void P(adrplabel_label_unk_Xd_1_ADRP)(tdis_ctx ctx, struct bitslic
}
static INLINE void P(am_b_target_addr_B_1_B)(tdis_ctx ctx, struct bitslice addr) {
return P(branch)(ctx, ctx->pc + sext(bs_get(addr, ctx->op), 26) * 4,
- /*cond*/ false);
+ /*cc*/ 0);
}
static INLINE void P(am_bl_target_addr_1_BL)(tdis_ctx ctx, struct bitslice addr) {
return P(branch)(ctx, ctx->pc + sext(bs_get(addr, ctx->op), 26) * 4,
- /*cond*/ false);
+ /*cc*/ 0);
}
-static INLINE void P(am_brcond_target_B_5_Bcc)(tdis_ctx ctx, struct bitslice target) {
- return P(branch)(ctx, ctx->pc + sext(bs_get(target, ctx->op), 19) * 4,
- /*cond*/ true);
+static INLINE void P(ccode_cond_am_brcond_target_B_1_Bcc)(tdis_ctx ctx, struct bitslice cond, struct bitslice target) {
+ int bits = bs_get(cond, ctx->op);
+ /* Bcc with AL/NV (which is actually just another AL) is useless but possible. */
+ int cc = bits >= 0xe ? 0 : (CC_ARMCC | bits);
+ return P(branch)(ctx, ctx->pc + sext(bs_get(target, ctx->op), 19) * 4, cc);
+}
+static INLINE void P(am_tbrcond_target_B_4_TBNZW)(tdis_ctx ctx, struct bitslice target) {
+ P(branch)(ctx, ctx->pc + sext(bs_get(target, ctx->op), 14) * 4, CC_XBXZ);
+ if (TDIS_CTX_MODIFY(ctx)) {
+ /* ditto CBNZ on ARM */
+ int new_target = (TDIS_CTX_NEWVAL(ctx, 0) - ctx->pc) / 4;
+ unsigned new = bs_set(target, new_target, ctx->op);
+ if (TDIS_CTX_NEWVAL(ctx, 1))
+ new ^= 1 << 24;
+ TDIS_CTX_SET_NEWOP(ctx, new);
+ }
+}
+static INLINE void P(am_brcond_target_B_4_CBNZW)(tdis_ctx ctx, struct bitslice target) {
+ /* both have the same bit to control Z/NZ */
+ return P(am_tbrcond_target_B_4_TBNZW)(ctx, target);
}
static INLINE void P(am_ldrlit_label_unk_Rt_6_LDRDl)(tdis_ctx ctx, struct bitslice Rt, struct bitslice label) {
enum pcrel_load_mode mode;
@@ -38,10 +55,6 @@ static INLINE void P(am_ldrlit_label_unk_Rt_6_LDRDl)(tdis_ctx ctx, struct bitsli
return P(pcrel)(ctx, ctx->pc + sext(bs_get(label, ctx->op), 19) * 4,
bs_get(Rt, ctx->op), mode);
}
-static INLINE void P(am_tbrcond_target_B_4_TBNZW)(tdis_ctx ctx, struct bitslice target) {
- return P(branch)(ctx, ctx->pc + sext(bs_get(target, ctx->op), 14) * 4,
- /*cond*/ true);
-}
static INLINE void P(GPR64_Rn_1_RET)(tdis_ctx ctx, UNUSED struct bitslice Rn) {
return P(ret)(ctx);
}