diff options
author | comex | 2015-01-11 20:21:37 -0500 |
---|---|---|
committer | comex | 2015-01-11 20:21:37 -0500 |
commit | 3aa2ed88b4199cc571b9210927d5cd597501f5e9 (patch) | |
tree | 798b91f1718976b14941571fb95a3044cb854026 /lib/dis-thumb.inc.h | |
parent | generate all the transform-dis-*; should be more precise; can't just use make... (diff) | |
download | substitute-3aa2ed88b4199cc571b9210927d5cd597501f5e9.tar.gz |
theoretically fix thumb
Diffstat (limited to '')
-rw-r--r-- | lib/dis-thumb.inc.h | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/lib/dis-thumb.inc.h b/lib/dis-thumb.inc.h index dd38147..8b41929 100644 --- a/lib/dis-thumb.inc.h +++ b/lib/dis-thumb.inc.h @@ -1,28 +1,43 @@ -static inline tdis_ret transform_dis_thumb_GPR_Rm_3_tADDhirr(tdis_ctx ctx, struct bitslice Rm) { +#include "dis.h" +static INLINE tdis_ret P(GPR_Rm_2_tADDhirr)(tdis_ctx ctx, struct bitslice Rm) { return P(regs)(ctx, Rm, 0, 3, Rm, 0, 0); } -static inline tdis_ret transform_dis_thumb_GPR_Rm_B_1_tBX(tdis_ctx ctx, struct bitslice Rm) { - if(bs_get(Rm, ctx->op) == 15) // bx pc? +static INLINE tdis_ret P(GPR_Rm_B_1_tBX)(tdis_ctx ctx, struct bitslice Rm) { + unsigned val = bs_get(Rm, ctx->op); + if (val == 15) /* bx pc */ return P(bad)(ctx); + else if (val == 14) /* bx lr */ + return P(ret)(ctx); return P(unidentified)(ctx); } -static inline tdis_ret transform_dis_thumb_t_addrmode_pc_addr_unk_Rt_1_tLDRpci(tdis_ctx ctx, struct bitslice addr, struct bitslice Rt) { - return P(adr)(ctx, ((ctx->pc + 4) & ~2) + bs_get(addr, ctx->op)); +static INLINE tdis_ret P(GPR_Rm_unk_Rd_1_tMOVr)(tdis_ctx ctx, struct bitslice Rd, struct bitslice Rm) { + unsigned Rd_val = bs_get(Rd, ctx->op); + unsigned Rm_val = bs_get(Rm, ctx->op); + /* does anyone do this? */ + if (Rd_val == 15) + return P(bad)(ctx); + if (Rm_val == 15) + return P(pcrel)(ctx, ctx->pc + 4, Rd_val); + return P(unidentified)(ctx); } -static inline tdis_ret transform_dis_thumb_t_adrlabel_addr_1_tADR(tdis_ctx ctx, struct bitslice addr) { - return P(adr)(ctx, ((ctx->pc + 4) & ~2) + bs_get(addr, ctx->op)); +static INLINE tdis_ret P(t_addrmode_pc_addr_1_tLDRpci)(tdis_ctx ctx, struct bitslice addr, struct bitslice Rt) { + return P(pcrel)(ctx, ((ctx->pc + 4) & ~2) + bs_get(addr, ctx->op), bs_get(Rt, ctx->op), true); } -static inline tdis_ret transform_dis_thumb_t_brtarget_target_B_1_tB(tdis_ctx ctx, struct bitslice target) { - return P(branch)(ctx->pc + 2 + sext(bs_get(target, ctx->op), 11); +static INLINE tdis_ret P(t_adrlabel_addr_1_tADR)(tdis_ctx ctx, struct bitslice addr, struct bitslice Rd) { + return P(pcrel)(ctx, ((ctx->pc + 4) & ~2) + bs_get(addr, ctx->op), bs_get(Rd, ctx->op), false); } -static inline tdis_ret transform_dis_thumb_t_bcctarget_target_B_1_tBcc(tdis_ctx ctx, struct bitslice target) { +static INLINE tdis_ret P(t_bcctarget_target_B_1_tBcc)(tdis_ctx ctx, struct bitslice target) { return P(branch)(ctx->pc + 2 + sext(bs_get(target, ctx->op), 8); } -static inline tdis_ret transform_dis_thumb_t_cbtarget_target_B_2_tCBNZ(tdis_ctx ctx, struct bitslice target) { +static INLINE tdis_ret P(t_brtarget_target_B_1_tB)(tdis_ctx ctx, struct bitslice target) { + return P(branch)(ctx->pc + 2 + sext(bs_get(target, ctx->op), 11); +} +static INLINE tdis_ret P(t_cbtarget_target_B_2_tCBNZ)(tdis_ctx ctx, struct bitslice target) { return P(branch)(ctx->pc + 2 + bs_get(target, ctx->op); } -static inline tdis_ret P(dis_thumb)(tdis_ctx ctx) { +static tdis_ret P(dis_thumb)(tdis_ctx ctx) { unsigned op = ctx->op; #include "../generated/transform-dis-thumb.inc" } + |