diff options
author | Damien <damien.p.george@gmail.com> | 2013-11-03 14:25:43 +0000 |
---|---|---|
committer | Damien <damien.p.george@gmail.com> | 2013-11-03 14:25:43 +0000 |
commit | 9b9e996df616e8ba3b175b87783d3a34bc357c6d (patch) | |
tree | 7b3c74ee4fa0e6016e9bb3fdefc63287dc708e31 /py/asmthumb.c | |
parent | 1a6633a74d686cdbc4609875713019b8530e3da7 (diff) |
Support for for-loop in native thumb.
Diffstat (limited to 'py/asmthumb.c')
-rw-r--r-- | py/asmthumb.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/py/asmthumb.c b/py/asmthumb.c index 18be05bd8..7cfb479b5 100644 --- a/py/asmthumb.c +++ b/py/asmthumb.c @@ -349,10 +349,13 @@ void asm_thumb_mov_reg_local(asm_thumb_t *as, uint rlo_dest, int local_num) { asm_thumb_write_op16(as, OP_LDR_FROM_SP_OFFSET(rlo_dest, word_offset)); } -void asm_thumb_mov_reg_local_addr(asm_thumb_t *as, uint reg_dest, int local_num) { - assert(0); - // see format 12, load address - asm_thumb_write_op16(as, 0x0000); +#define OP_ADD_REG_SP_OFFSET(rlo_dest, word_offset) (0xa800 | ((rlo_dest) << 8) | ((word_offset) & 0x00ff)) + +void asm_thumb_mov_reg_local_addr(asm_thumb_t *as, uint rlo_dest, int local_num) { + assert(rlo_dest < REG_R8); + int word_offset = as->num_locals - local_num - 1; + assert(as->pass < ASM_THUMB_PASS_3 || word_offset >= 0); + asm_thumb_write_op16(as, OP_ADD_REG_SP_OFFSET(rlo_dest, word_offset)); } #define OP_ADD_REG_REG_REG(rlo_dest, rlo_src_a, rlo_src_b) (0x1800 | ((rlo_src_b) << 6) | ((rlo_src_a) << 3) | (rlo_dest)) |