aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Lu2016-11-03 23:34:15 -0700
committerYifan Lu2016-11-03 23:34:15 -0700
commit158a0d4007fa8f92992f95607dc8f96a0ab4e472 (patch)
treef59816c6c5af270d7efd6df325ce1c98d4645a43
parentImplemented call rewrite support, fixes #3 (diff)
downloadsubstitute-158a0d4007fa8f92992f95607dc8f96a0ab4e472.tar.gz
Added ARM PUSH multi instruction assembly
-rw-r--r--lib/arm/arch-transform-dis.inc.h2
-rw-r--r--lib/arm/assemble.h7
2 files changed, 8 insertions, 1 deletions
diff --git a/lib/arm/arch-transform-dis.inc.h b/lib/arm/arch-transform-dis.inc.h
index b3efc77..1b8e3d5 100644
--- a/lib/arm/arch-transform-dis.inc.h
+++ b/lib/arm/arch-transform-dis.inc.h
@@ -177,7 +177,7 @@ void transform_dis_branch(struct transform_dis_ctx *ctx, uint_tptr dpc, int cc)
/* If it's a call, we should jump back after the call */
actx.cond = 0xe;
if ((cc & CC_CALL)) {
- POPmulti(actx, 1 << 7 | 1 << 14); // save lr, r7 (for stack alignment, chosen arbitary)
+ PUSHmulti(actx, 1 << 7 | 1 << 14); // save lr, r7 (for stack alignment, chosen arbitary)
ADD_PC(actx, 14, actx.thumb ? (actx.pc & 2 ? 12 : 8) | 1 : 4);
LDR_PC(actx, dpc | ctx->arch.pc_low_bit);
POPmulti(actx, 1 << 7 | 1 << 14); // restore lr, r7 (for stack alignment)
diff --git a/lib/arm/assemble.h b/lib/arm/assemble.h
index e6a72d0..bf1ad03 100644
--- a/lib/arm/assemble.h
+++ b/lib/arm/assemble.h
@@ -15,6 +15,13 @@ static inline void PUSHone(struct assemble_ctx ctx, int Rt) {
op32(ctx.codep, 0x052d0004 | Rt << 12 | ctx.cond << 28);
}
+static inline void PUSHmulti(struct assemble_ctx ctx, uint16_t mask) {
+ if (ctx.thumb)
+ op32(ctx.codep, 0x0000e8ad | mask << 16);
+ else
+ op32(ctx.codep, 0x092d0000 | mask | ctx.cond << 28);
+}
+
static inline void POPone(struct assemble_ctx ctx, int Rt) {
if (ctx.thumb)
op32(ctx.codep, 0x0b04f85d | Rt << 28);