Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
32f0b794
Commit
32f0b794
authored
Feb 13, 2015
by
Damien George
Browse files
py: Implement sdiv/udiv for inline Thumb assembler.
parent
0d967b8a
Changes
4
Hide whitespace changes
Inline
Side-by-side
py/emitinlinethumb.c
View file @
32f0b794
...
...
@@ -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
;
...
...
py/objfun.c
View file @
32f0b794
...
...
@@ -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
;
...
...
tests/inlineasm/asmdiv.py
0 → 100644
View file @
32f0b794
@
micropython
.
asm_thumb
def
sdiv
(
r0
,
r1
):
sdiv
(
r0
,
r0
,
r1
)
@
micropython
.
asm_thumb
def
udiv
(
r0
,
r1
):
udiv
(
r0
,
r0
,
r1
)
print
(
sdiv
(
1234
,
3
))
print
(
sdiv
(
-
1234
,
3
))
print
(
sdiv
(
1234
,
-
3
))
print
(
sdiv
(
-
1234
,
-
3
))
print
(
udiv
(
1234
,
3
))
print
(
udiv
(
0xffffffff
,
0x7fffffff
))
print
(
udiv
(
0xffffffff
,
0xffffffff
))
tests/inlineasm/asmdiv.py.exp
0 → 100644
View file @
32f0b794
411
-411
-411
411
411
2
1
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment