summaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-02-13 10:43:05 +0000
committerDamien George <damien.p.george@gmail.com>2015-02-13 10:43:05 +0000
commit32f0b7942cf44b7a722db30c554cfc70d3f70289 (patch)
tree1215d637b956ce93d5c36dd2a4e2bd0bd6999882 /py
parent0d967b8ae4f26815549aa2fb301e7bbaa5e262c2 (diff)
py: Implement sdiv/udiv for inline Thumb assembler.
Diffstat (limited to 'py')
-rw-r--r--py/emitinlinethumb.c11
-rw-r--r--py/objfun.c2
2 files changed, 13 insertions, 0 deletions
diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c
index 737c03c10..d28e015cd 100644
--- a/py/emitinlinethumb.c
+++ b/py/emitinlinethumb.c
@@ -490,6 +490,17 @@ STATIC void emit_inline_thumb_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_a
src_b = get_arg_i(emit, op_str, pn_args[2], 0x7);
}
asm_thumb_format_2(emit->as, op_code, rlo_dest, rlo_src, src_b);
+ } else if (strcmp(op_str, "sdiv") == 0) {
+ op_code = 0xfb90; // sdiv high part
+ mp_uint_t rd, rn, rm;
+ op_sdiv_udiv:
+ rd = get_arg_reg(emit, op_str, pn_args[0], 15);
+ rn = get_arg_reg(emit, op_str, pn_args[1], 15);
+ rm = get_arg_reg(emit, op_str, pn_args[2], 15);
+ asm_thumb_op32(emit->as, op_code | rn, 0xf0f0 | (rd << 8) | rm);
+ } else if (strcmp(op_str, "udiv") == 0) {
+ op_code = 0xfbb0; // udiv high part
+ goto op_sdiv_udiv;
} else if (strcmp(op_str, "sub") == 0) {
op_code = ASM_THUMB_FORMAT_2_SUB;
goto op_format_2;
diff --git a/py/objfun.c b/py/objfun.c
index 28706cc68..75a326c12 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -431,6 +431,8 @@ STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
return 0;
} else if (obj == mp_const_true) {
return 1;
+ } else if (MP_OBJ_IS_TYPE(obj, &mp_type_int)) {
+ return mp_obj_int_get_truncated(obj);
} else if (MP_OBJ_IS_STR(obj)) {
// pointer to the string (it's probably constant though!)
mp_uint_t l;