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

Question for Assembly function "LMUL"。

Dear sir, i use lmul to do "0x12345678 * 0xff = 0x12,22,22,21,88"

if i need the overflow value "0x12" what can i do ?

thanks a lot .

Sincerely,

Luke.

  • You will probably need to stop using lmul and roll your own multiplication function.

    lmul does a 32x32 multiplication and returns the 32 lowest bits of the result.

    If you want a 32x8 multiplication and all 40 bits of the result, you will need to split the operation into several smaller multiplications and additions using the commutative, distributive and associative principles:

    en.wikipedia.org/.../Multiplication

    For example, if H is the upper 16 bits of the 32 bit multiplicand, L is the lower 16 bits of the 32 bit multiplicand, and C is the 8 bit multiplicand, your 32x8 bit multiplication can be expressed as

    (65536*H + L) * C

    which can be split into two 16x8 -> 24 bit multiplications:

    H * C = RH
    L * C = RL

    Now you can calculate the 32 LSBs of the 40 bit end result as

    RL + 65536 * RH

    and the upper 8 bits of the result are in bits 16-23 of RH.