aboutsummaryrefslogtreecommitdiff
path: root/py/asmthumb.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-08-16 22:31:57 +0100
committerDamien George <damien.p.george@gmail.com>2014-08-16 22:31:57 +0100
commit7fe2191c9b72e16d271735ca24a9def7ba072217 (patch)
tree70def977a706546272b0f4237bec92598b95054b /py/asmthumb.c
parent86de21b810693bccdd88d53aacb6d8acf26f09e0 (diff)
py: Code clean-up in native emitter; improve thumb native calls.
Diffstat (limited to 'py/asmthumb.c')
-rw-r--r--py/asmthumb.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/py/asmthumb.c b/py/asmthumb.c
index a01599454..75ce168f7 100644
--- a/py/asmthumb.c
+++ b/py/asmthumb.c
@@ -496,17 +496,14 @@ void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp
asm_thumb_op16(as, 0x4780 | (REG_R9 << 3)); // blx reg
*/
- if (0) {
- // load ptr to function into register using immediate, then branch
- // not relocatable
- asm_thumb_mov_reg_i32(as, reg_temp, (mp_uint_t)fun_ptr);
- asm_thumb_op16(as, OP_BLX(reg_temp));
- } else if (1) {
+ if (fun_id < 32) {
+ // load ptr to function from table, indexed by fun_id (must be in range 0-31); 4 bytes
asm_thumb_op16(as, OP_FORMAT_9_10(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER, reg_temp, REG_R7, fun_id));
asm_thumb_op16(as, OP_BLX(reg_temp));
} else {
- // use SVC
- asm_thumb_op16(as, OP_SVC(fun_id));
+ // load ptr to function into register using immediate; 6 bytes
+ asm_thumb_mov_reg_i32(as, reg_temp, (mp_uint_t)fun_ptr);
+ asm_thumb_op16(as, OP_BLX(reg_temp));
}
}