aboutsummaryrefslogtreecommitdiff
path: root/lib/dis-thumb.inc.h
blob: 56b1129ceb22fcfaeeef5562247ee06f757399c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "dis.h"
static INLINE tdis_ret P(GPR_Rm_2_tADDhirr)(tdis_ctx ctx, struct bitslice Rm) {
    data(r(Rm));
}
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 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, PLM_ADR);
    return P(unidentified)(ctx);
}
static INLINE tdis_ret P(tGPR_Rn_reglist_regs_1_tLDMIA)(tdis_ctx ctx, UNUSED struct bitslice regs, UNUSED struct bitslice Rn) {
    return P(unidentified)(ctx);
}
static INLINE tdis_ret P(tGPR_Rn_reglist_regs_S_1_tSTMIA_UPD)(tdis_ctx ctx, UNUSED struct bitslice regs, UNUSED struct bitslice Rn) {
    return P(unidentified)(ctx);
}
static INLINE tdis_ret P(t_addrmode_pc_addr_unk_Rt_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), PLM_U32);
}
static INLINE tdis_ret P(t_adrlabel_addr_unk_Rd_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), PLM_ADR);
}
static INLINE tdis_ret P(t_bcctarget_target_B_1_tBcc)(tdis_ctx ctx, struct bitslice target) {
    return P(branch)(ctx, ctx->pc + 4 + 2 * sext(bs_get(target, ctx->op), 8));
}
static INLINE tdis_ret P(t_brtarget_target_B_1_tB)(tdis_ctx ctx, struct bitslice target) {
    return P(branch)(ctx, ctx->pc + 4 + 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, ctx->pc + 4 + 2 * bs_get(target, ctx->op));
}

#define GENERATED_HEADER "../generated/transform-dis-thumb.inc.h"