Skip to content

Commit d1c3788

Browse files
committed
py: Fix loading of immediate pointer in Thumb assembler.
Addresses issue adafruit#1117.
1 parent 0868942 commit d1c3788

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

py/asmthumb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ void asm_thumb_mov_reg_i32_aligned(asm_thumb_t *as, uint reg_dest, int i32) {
375375
if ((as->code_offset & 3) == 0) {
376376
asm_thumb_op16(as, ASM_THUMB_OP_NOP);
377377
}
378-
// jump over the i32 value (instruction prefect adds 4 to PC)
379-
asm_thumb_op16(as, OP_B_N(0));
378+
// jump over the i32 value (instruction prefetch adds 2 to PC)
379+
asm_thumb_op16(as, OP_B_N(2));
380380
// store i32 on machine-word aligned boundary
381381
asm_thumb_data(as, 4, i32);
382382
// do the actual load of the i32 value

tests/micropython/native_const.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# check loading constants
2+
3+
@micropython.native
4+
def f():
5+
return 123456789012345678901234567890
6+
7+
print(f())
8+
9+
@micropython.native
10+
def g():
11+
return 1.2
12+
13+
print(g())
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
123456789012345678901234567890
2+
1.2

0 commit comments

Comments
 (0)