From c0bc3bd736a3442d6fecaf54bd09139f3801551f Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Sun, 14 Dec 2014 03:24:17 +0200 Subject: asmarm: Fix bug with encoding small negative ints using MVN instruction. --- py/asmarm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'py') diff --git a/py/asmarm.c b/py/asmarm.c index 60286d55c..51852df5f 100644 --- a/py/asmarm.c +++ b/py/asmarm.c @@ -282,8 +282,9 @@ void asm_arm_mov_reg_i32(asm_arm_t *as, uint rd, int imm) { // TODO: There are more variants of immediate values if ((imm & 0xFF) == imm) { emit_al(as, asm_arm_op_mov_imm(rd, imm)); - } else if (imm < 0 && ((-imm) & 0xFF) == -imm) { - emit_al(as, asm_arm_op_mvn_imm(rd, -imm)); + } else if (imm < 0 && imm >= -256) { + // mvn is "move not", not "move negative" + emit_al(as, asm_arm_op_mvn_imm(rd, ~imm)); } else { //Insert immediate into code and jump over it emit_al(as, 0x59f0000 | (rd << 12)); // ldr rd, [pc] -- cgit v1.2.3