Skip to content

Commit 9a58316

Browse files
committed
py/objfun: Allow inline-asm functions to be called with 4 arguments.
1 parent be989be commit 9a58316

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

py/objfun.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ typedef mp_uint_t (*inline_asm_fun_0_t)(void);
459459
typedef mp_uint_t (*inline_asm_fun_1_t)(mp_uint_t);
460460
typedef mp_uint_t (*inline_asm_fun_2_t)(mp_uint_t, mp_uint_t);
461461
typedef mp_uint_t (*inline_asm_fun_3_t)(mp_uint_t, mp_uint_t, mp_uint_t);
462+
typedef mp_uint_t (*inline_asm_fun_4_t)(mp_uint_t, mp_uint_t, mp_uint_t, mp_uint_t);
462463

463464
// convert a Micro Python object to a sensible value for inline asm
464465
STATIC mp_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
@@ -527,8 +528,14 @@ STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
527528
} else if (n_args == 3) {
528529
ret = ((inline_asm_fun_3_t)fun)(convert_obj_for_inline_asm(args[0]), convert_obj_for_inline_asm(args[1]), convert_obj_for_inline_asm(args[2]));
529530
} else {
530-
assert(0);
531-
ret = 0;
531+
// compiler allows at most 4 arguments
532+
assert(n_args == 4);
533+
ret = ((inline_asm_fun_4_t)fun)(
534+
convert_obj_for_inline_asm(args[0]),
535+
convert_obj_for_inline_asm(args[1]),
536+
convert_obj_for_inline_asm(args[2]),
537+
convert_obj_for_inline_asm(args[3])
538+
);
532539
}
533540

534541
return mp_convert_native_to_obj(ret, self->type_sig);

0 commit comments

Comments
 (0)