Still more instruction things giving me head ache.
This time it's the MUL-instruction.
What the heck means:
Multiply multiplies two register values. The least significant 32 bits of the result are written to the destination register. These 32 bits do not depend on whether the source register values are considered to be signed values or unsigned values.
Multiply multiplies two register values. The least significant 32 bits of the result are written to the destination
register. These 32 bits do not depend on whether the source register values are considered to be signed values or
unsigned values.
(The bolded part)
Hello,
the MUL instruction is very dangerous because ARM architecture does not consider the signed or unsigned for MUL.
The explanation shows that just lower 32 bit value of multiplication is stored into the destination register.
Therefore the result of each signed or unsigned multiplication is the same.
In other words, the result is not valid in the case overflow in the 32 bit range.
For example, 0x12345678 * 0x8 produces the negative number of 0x91A2B3C0.
I think we should use SMULL or UMULL instead of MUL, if we want the correct result.
Best regards,
Yasuhiko Koumoto.
So it's basically unsigned?
It's still mystery for me, though, what this:
if x<N-1> == '1' then result = result - 2^N;
in the pseudocode of SInt(bits(N) x) is supposed to mean.
'2^N - result' would be 2's complement, but 'result - 2^N' should be negative of that.
I.e. result (or - -result)