Skip to content

Commit 6b2792a

Browse files
committed
py/asmthumb: Generate proper sequences for large register offsets.
This commit lets the Thumb native emitter generate a proper opcode sequence when calculating an indexed register offset for load/store operations with said offset beight both greater than 65535 and not able to be represented as a shifted 8-bit bitmask. The original code would assume the scaled index would always fit in 16 bits and silently discard upper bits of the offset. Now an optimised constant loading sequence is emitted instead, and the final offset is also stored in the correct register in all cases. Signed-off-by: Alessandro Gatti <[email protected]>
1 parent 2260fe0 commit 6b2792a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

py/asmthumb.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,12 @@ static void asm_thumb_add_reg_reg_offset(asm_thumb_t *as, uint reg_dest, uint re
450450
asm_thumb_lsl_rlo_rlo_i5(as, reg_dest, reg_dest, offset_shift);
451451
asm_thumb_add_rlo_rlo_rlo(as, reg_dest, reg_dest, reg_base);
452452
} else if (reg_dest != reg_base) {
453-
asm_thumb_mov_rlo_i16(as, reg_dest, offset << offset_shift);
454-
asm_thumb_add_rlo_rlo_rlo(as, reg_dest, reg_dest, reg_dest);
453+
asm_thumb_mov_reg_i32_optimised(as, reg_dest, offset << offset_shift);
454+
asm_thumb_add_rlo_rlo_rlo(as, reg_dest, reg_dest, reg_base);
455455
} else {
456456
uint reg_other = reg_dest ^ 7;
457457
asm_thumb_op16(as, OP_PUSH_RLIST((1 << reg_other)));
458-
asm_thumb_mov_rlo_i16(as, reg_other, offset << offset_shift);
458+
asm_thumb_mov_reg_i32_optimised(as, reg_other, offset << offset_shift);
459459
asm_thumb_add_rlo_rlo_rlo(as, reg_dest, reg_dest, reg_other);
460460
asm_thumb_op16(as, OP_POP_RLIST((1 << reg_other)));
461461
}

0 commit comments

Comments
 (0)