8000 py: Code clean-up in native emitter; improve thumb native calls. · micropython/micropython@7fe2191 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 7fe2191

Browse files
committed
py: Code clean-up in native emitter; improve thumb native calls.
1 parent 86de21b commit 7fe2191

File tree

4 files changed

+74
-71
lines changed

4 files changed

+74
-71
lines changed

py/asmthumb.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -496,17 +496,14 @@ void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp
496496
asm_thumb_op16(as, 0x4780 | (REG_R9 << 3)); // blx reg
497497
*/
498498

499-
if (0) {
500-
// load ptr to function into register using immediate, then branch
501-
// not relocatable
502-
asm_thumb_mov_reg_i32(as, reg_temp, (mp_uint_t)fun_ptr);
503-
asm_thumb_op16(as, OP_BLX(reg_temp));
504-
} else if (1) {
499+
if (fun_id < 32) {
500+
// load ptr to function from table, indexed by fun_id (must be in range 0-31); 4 bytes
505501
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));
506502
asm_thumb_op16(as, OP_BLX(reg_temp));
507503
} else {
508-
// use SVC
509-
asm_thumb_op16(as, OP_SVC(fun_id));
504+
// load ptr to function into register using immediate; 6 bytes
505+
asm_thumb_mov_reg_i32(as, reg_temp, (mp_uint_t)fun_ptr);
506+
asm_thumb_op16(as, OP_BLX(reg_temp));
510507
}
511508
}
512509

0 commit comments

Comments
 (0)
0