From 6a90e513dea2267372d8e94f1b83f9260141907d Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 27 Dec 2024 16:13:59 +1100 Subject: [PATCH] py/asmarm: Fix asm_arm_ldrh_reg_reg_offset to emit correct machine code. Prior to this fix, the assembler generated `LDRH Rd, [Rn, #imm]!`, so the second `LDRH` from the same origin would load from the wrong base. Co-authored-by: Alessandro Gatti Signed-off-by: Damien George --- py/asmarm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/py/asmarm.c b/py/asmarm.c index 600649070..634f2db4f 100644 --- a/py/asmarm.c +++ b/py/asmarm.c @@ -328,7 +328,7 @@ void asm_arm_ldrh_reg_reg(asm_arm_t *as, uint rd, uint rn) { void asm_arm_ldrh_reg_reg_offset(asm_arm_t *as, uint rd, uint rn, uint byte_offset) { // ldrh rd, [rn, #off] - emit_al(as, 0x1f000b0 | (rn << 16) | (rd << 12) | ((byte_offset & 0xf0) << 4) | (byte_offset & 0xf)); + emit_al(as, 0x1d000b0 | (rn << 16) | (rd << 12) | ((byte_offset & 0xf0) << 4) | (byte_offset & 0xf)); } void asm_arm_ldrb_reg_reg(asm_arm_t *as, uint rd, uint rn) {