From c8322ba9e7bdbe77dc6346ae510cb87d4b01bf3f Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Thu, 22 Apr 2021 20:50:11 -0400 Subject: [PATCH] V850: Fixed multiply by immediate Multiply by immediate (mul imm9, reg2, reg3) used a signed token for the lower 5 bits of the immediate value imm9. This resulted in any immediate value in which the 5th bit was set to be calculated incorrectly. imm9 = 0x18 ( 0b000011000 ) OLD: f8 0f 40 52 mul -0x8, r1, r10 NEW: f8 0f 40 52 mul 0x18, r1, r10 imm9 = -0xF0 ( 0b100010000 ) OLD: f0 0f 60 52 mul -0x10, r1, r10 NEW: f0 0f 60 52 mul -0xf0, r1, r10 --- .../V850/data/languages/Instructions/Arithmetic.sinc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ghidra/Processors/V850/data/languages/Instructions/Arithmetic.sinc b/Ghidra/Processors/V850/data/languages/Instructions/Arithmetic.sinc index cc2af2adb6..a546e24284 100644 --- a/Ghidra/Processors/V850/data/languages/Instructions/Arithmetic.sinc +++ b/Ghidra/Processors/V850/data/languages/Instructions/Arithmetic.sinc @@ -21,8 +21,8 @@ } # MUL imm9, reg2, reg3 - rrrrr111111iiiii|wwwww01001IIII00 -:mul imm9, R1115, R2731 is op0510=0x3F & s0004 & R1115; op2226=0x9 & op1617=0x0 & s1821 & R2731 -[ imm9 = (s1821 << 5) | s0004; ] +:mul imm9, R1115, R2731 is op0510=0x3F & op0004 & R1115; op2226=0x9 & op1617=0x0 & s1821 & R2731 +[ imm9 = (s1821 << 5) | op0004; ] { local res:8 = sext(R1115) * imm9; R1115 = res:4;