1

I have to multiply two 64Bit fixed point numbers in x86 assembly. I get the numbers over the Stack, for the Example of 653.456 x 498.224 it would look like this:

push dword 653 ;32Bit
push dword 456 ;32Bit
push dword 498 ;32Bit
push dword 224 ;32Bit

How can I multiply them, to get an 64Bit result, like (325567) for this example, stored in edx:eax.

  • 1
    First figure out the formula by using high school algebra. Then write code to implement that formula. Not clear whether you are stuck on part 1 or part 2. – Raymond Chen Dec 31 '20 at 13:29
  • Hi, i'm not shure how I can multiply those numbers with the limitations of the x86 architecture. – PeterMueller Dec 31 '20 at 13:52
  • 2
    In school, you learned how to multiply two-digit numbers (say, 39 x 74) despite having memorized the multiplication tables only up to 9 x 9. – Raymond Chen Dec 31 '20 at 14:31
  • The `mul` instruction when used to multiply two 32-bit values will yield a 64-bit result in two registers. So think of your 64-bit values as 2-digit numbers where the digits are 32-bit values. Then, as Raymond says, you just cross multiply and add like you learned in school. Be mindful of the carry, which x86 will provide when you do an arithmetic operation. – lurker Dec 31 '20 at 15:21
  • Note that this is trickier than your usual multiprecision arithmetic since the fractional portion appears to be in thousandths instead of units of 1/2^32. – Raymond Chen Jan 01 '21 at 04:05

0 Answers0