beardypig / ghidra-emotionengine

Ghidra Processor for the Play Station 2's Emotion Engine MIPS based CPU
Apache License 2.0
200 stars 34 forks source link

Strange right shift after multiplication #12

Closed GenericMadScientist closed 5 years ago

GenericMadScientist commented 5 years ago

I came across the following code snippet (well, there was a bit more but I've trimmed it down):

li v0, 0x350
mult v1, side, v0
jr ra
addu v0, v0, v1

Ghidra incorrectly gives (iParam1 * 0x350) >> 0x20 + 0x350, where the correct result would not have the right shift.

I was able to reproduce this with a small file just containing the above four instructions, which I've given here: a-minimal-example.zip.