asmarm: Fix bug with encoding small negative ints using MVN instruction.
This commit is contained in:
parent
83d27b0f0b
commit
c0bc3bd736
@ -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]
|
||||
|
9
tests/micropython/viper_binop_comp_imm.py
Normal file
9
tests/micropython/viper_binop_comp_imm.py
Normal file
@ -0,0 +1,9 @@
|
||||
# comparisons with immediate boundary values
|
||||
@micropython.viper
|
||||
def f(a: int):
|
||||
print(a == -1, a == -255, a == -256, a == -257)
|
||||
|
||||
f(-1)
|
||||
f(-255)
|
||||
f(-256)
|
||||
f(-257)
|
4
tests/micropython/viper_binop_comp_imm.py.exp
Normal file
4
tests/micropython/viper_binop_comp_imm.py.exp
Normal file
@ -0,0 +1,4 @@
|
||||
True False False False
|
||||
False True False False
|
||||
False False True False
|
||||
False False False True
|
Loading…
Reference in New Issue
Block a user