summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-02-15 00:45:28 +0000
committerDamien George <damien.p.george@gmail.com>2015-02-15 00:45:28 +0000
commitd1c37883756045fb92d58592181bf53481d7693d (patch)
tree73b794459b85e8765da632b8ae4ac67ac13b2f2c
parent0868942e7722f73f53fe9c8b730fd3acc9f2d2e7 (diff)
downloadmicropython-d1c37883756045fb92d58592181bf53481d7693d.tar.gz
micropython-d1c37883756045fb92d58592181bf53481d7693d.zip
py: Fix loading of immediate pointer in Thumb assembler.
Addresses issue #1117.
-rw-r--r--py/asmthumb.c4
-rw-r--r--tests/micropython/native_const.py13
-rw-r--r--tests/micropython/native_const.py.exp2
3 files changed, 17 insertions, 2 deletions
diff --git a/py/asmthumb.c b/py/asmthumb.c
index 7182d52fad..854f455455 100644
--- a/py/asmthumb.c
+++ b/py/asmthumb.c
@@ -375,8 +375,8 @@ void asm_thumb_mov_reg_i32_aligned(asm_thumb_t *as, uint reg_dest, int i32) {
if ((as->code_offset & 3) == 0) {
asm_thumb_op16(as, ASM_THUMB_OP_NOP);
}
- // jump over the i32 value (instruction prefect adds 4 to PC)
- asm_thumb_op16(as, OP_B_N(0));
+ // jump over the i32 value (instruction prefetch adds 2 to PC)
+ asm_thumb_op16(as, OP_B_N(2));
// store i32 on machine-word aligned boundary
asm_thumb_data(as, 4, i32);
// do the actual load of the i32 value
diff --git a/tests/micropython/native_const.py b/tests/micropython/native_const.py
new file mode 100644
index 0000000000..f2db82ca41
--- /dev/null
+++ b/tests/micropython/native_const.py
@@ -0,0 +1,13 @@
+# check loading constants
+
+@micropython.native
+def f():
+ return 123456789012345678901234567890
+
+print(f())
+
+@micropython.native
+def g():
+ return 1.2
+
+print(g())
diff --git a/tests/micropython/native_const.py.exp b/tests/micropython/native_const.py.exp
new file mode 100644
index 0000000000..eea238e6f5
--- /dev/null
+++ b/tests/micropython/native_const.py.exp
@@ -0,0 +1,2 @@
+123456789012345678901234567890
+1.2