• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 639
  • Last Modified:

How to use Floating Point Multiplication Algorithm?

I need some help on a program using Floating Point Multiplication and I am fairly new to spim assembly language.   Using two signed numbers how do you multiply them using the floating point multiplication algorithm?  I know there is the mul instruction however, I wanted to know how this process actualyl works.
0
elberath
Asked:
elberath
1 Solution
 
aib_42Commented:
The mul instruction only works on integer values. To do floating-point arithmetic, you will have to utilize the FPU, or one of its successors (MMX, SSE, SSE2, SSE3). Here is some simple code:

.data
num1    dd    1.5
num2    dd    2.5
num3    dd    0

.code
...
fld    num1    ;load 1.5 into the FPU stack
fmul    num2    ;multiply and replace the top of the stack by 2.5
fstp    num3    ;pop the stack, storing the top value of 1.5 x 2.5 in num3
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now