Skip to content

Commit c458e9f

Browse files
committed
asmthumb: Fix ubsan diagnostics.
This fixes the diagnostic "runtime error: left shift of negative value -1" and ensures the correct instruction is assembled. Signed-off-by: Jeff Epler <jepler@gmail.com>
1 parent e78cbdd commit c458e9f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

py/asmthumb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ void asm_thumb_mov_reg_reg(asm_thumb_t *as, uint reg_dest, uint reg_src) {
246246
void asm_thumb_mov_reg_i16(asm_thumb_t *as, uint mov_op, uint reg_dest, int i16_src) {
247247
assert(reg_dest < ASM_THUMB_REG_R15);
248248
// mov[wt] reg_dest, #i16_src
249-
asm_thumb_op32(as, mov_op | ((i16_src >> 1) & 0x0400) | ((i16_src >> 12) & 0xf), ((i16_src << 4) & 0x7000) | (reg_dest << 8) | (i16_src & 0xff));
249+
asm_thumb_op32(as, mov_op | ((i16_src >> 1) & 0x0400) | ((i16_src >> 12) & 0xf), (((uint16_t)i16_src << 4) & 0x7000) | (reg_dest << 8) | (i16_src & 0xff));
250250
}
251251

252252
static void asm_thumb_mov_rlo_i16(asm_thumb_t *as, uint rlo_dest, int i16_src) {

0 commit comments

Comments
 (0)