This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

ARM MUL instruction

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.

(The bolded part)

Parents
  • 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.

Reply
  • 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.

Children