diff options
Diffstat (limited to 'lib/arm/assemble.h')
-rw-r--r-- | lib/arm/assemble.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/arm/assemble.h b/lib/arm/assemble.h index 1d4250b..3066802 100644 --- a/lib/arm/assemble.h +++ b/lib/arm/assemble.h @@ -20,6 +20,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, 0x0000e92d | 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); @@ -120,4 +127,13 @@ static inline void LDR_PC(struct assemble_ctx ctx, uint32_t dpc) { else op32(ctx.codep, 0x051ff004 | ctx.cond << 28); op32(ctx.codep, (uint32_t) dpc); + if (ctx.pc & 2) // for alignment + op16(ctx.codep, 0xbf00); +} + +static inline void ADD_PC(struct assemble_ctx ctx, uint32_t Rd, uint32_t imm12) { + if (ctx.thumb) + op32(ctx.codep, 0x0000f20f | ((imm12 >> 11) << 10) | (((imm12 & 0x700) >> 8) << 28) | Rd << 24 | (imm12 & 0xff) << 16); + else + op32(ctx.codep, 0x028f0000 | Rd << 12 | imm12 << 0 | ctx.cond << 28); } |