diff options
author | comex | 2015-01-11 02:28:37 -0500 |
---|---|---|
committer | comex | 2015-01-11 02:28:37 -0500 |
commit | c14ecd8759c2b84e9c82fdf27b70f5847aa9a82d (patch) | |
tree | be432adb27ab9d5d5a6e323fbacc05d03fcbace6 /test | |
parent | *sigh* (diff) | |
download | substitute-c14ecd8759c2b84e9c82fdf27b70f5847aa9a82d.tar.gz |
yay?
Diffstat (limited to 'test')
-rw-r--r-- | test/test-tdarm-simple.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/test-tdarm-simple.c b/test/test-tdarm-simple.c new file mode 100644 index 0000000..99a5d4a --- /dev/null +++ b/test/test-tdarm-simple.c @@ -0,0 +1,52 @@ +#include <stdint.h> +#include <stdlib.h> +#include <stdio.h> +#include "dis.h" + +typedef void tdis_ret; +typedef struct tc { + uint32_t pc; + uint32_t op; + +} *tdis_ctx; +#define P(x) P_##x + +static void P_data(struct tc *ctx, struct dis_data_operand *ops, size_t nops) { + printf("data: %08x\n", ctx->op); + for(size_t i = 0; i < nops; i++) { + unsigned val = bs_get(ops[i].n, ctx->op); + printf(" {"); + for(int j = 0; j < ops[i].n.nruns; j++) { + struct bitslice_run run = ops[i].n.runs[j]; + printf(" %d:%d:%d", run.inpos, run.outpos, run.len); + } + printf(" } =>\n"); + printf(" reg %x: %s\n", val, ops[i].out ? "out" : "in"); + } + unsigned newop = ctx->op; + for(size_t i = 0; i < nops; i++) + newop = bs_set(ops[i].n, i, newop); + printf("modified: %x\n", newop); +} + +static void P_adr(struct tc *ctx, UNUSED uint32_t dpc) { + printf("adr: %08x\n", ctx->op); +} + +static void P_branch(struct tc *ctx, UNUSED uint32_t dpc) { + printf("branch: %08x\n", ctx->op); +} + +static void P_unidentified(struct tc *ctx) { + printf("unidentified: %08x\n", ctx->op); + +} +#include "dis-arm.inc.h" + +int main(UNUSED int argc, char **argv) { + struct tc ctx; + ctx.pc = 0xdead0000; + ctx.op = (uint32_t) strtoll(argv[1] ? argv[1] : "deadbeef", NULL, 16); + P_dis_arm(&ctx); + +} |