py/compile: Support large integers in inline-asm data directive.
Fixes issue #8956. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
0c45a28d24
commit
c0fa903d6b
@ -3286,12 +3286,13 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
|
|||||||
if (pass > MP_PASS_SCOPE) {
|
if (pass > MP_PASS_SCOPE) {
|
||||||
mp_int_t bytesize = MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0]);
|
mp_int_t bytesize = MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0]);
|
||||||
for (uint j = 1; j < n_args; j++) {
|
for (uint j = 1; j < n_args; j++) {
|
||||||
if (!MP_PARSE_NODE_IS_SMALL_INT(pn_arg[j])) {
|
mp_obj_t int_obj;
|
||||||
|
if (!mp_parse_node_get_int_maybe(pn_arg[j], &int_obj)) {
|
||||||
compile_syntax_error(comp, nodes[i], MP_ERROR_TEXT("'data' requires integer arguments"));
|
compile_syntax_error(comp, nodes[i], MP_ERROR_TEXT("'data' requires integer arguments"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mp_asm_base_data((mp_asm_base_t *)comp->emit_inline_asm,
|
mp_asm_base_data((mp_asm_base_t *)comp->emit_inline_asm,
|
||||||
bytesize, MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[j]));
|
bytesize, mp_obj_int_get_truncated(int_obj));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
16
tests/inlineasm/asmdata.py
Normal file
16
tests/inlineasm/asmdata.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# test the "data" directive
|
||||||
|
|
||||||
|
|
||||||
|
@micropython.asm_thumb
|
||||||
|
def ret_num(r0) -> uint:
|
||||||
|
lsl(r0, r0, 2)
|
||||||
|
mov(r1, pc)
|
||||||
|
add(r0, r0, r1)
|
||||||
|
ldr(r0, [r0, 4])
|
||||||
|
b(HERE)
|
||||||
|
data(4, 0x12345678, 0x20000000, 0x40000000, 0x7FFFFFFF + 1, (1 << 32) - 2)
|
||||||
|
label(HERE)
|
||||||
|
|
||||||
|
|
||||||
|
for i in range(5):
|
||||||
|
print(hex(ret_num(i)))
|
5
tests/inlineasm/asmdata.py.exp
Normal file
5
tests/inlineasm/asmdata.py.exp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
0x12345678
|
||||||
|
0x20000000
|
||||||
|
0x40000000
|
||||||
|
0x80000000
|
||||||
|
0xfffffffe
|
Loading…
Reference in New Issue
Block a user