# adding and multiplying floating points

Page 1 of 1

## 1 Replies - 758 Views - Last Post: 21 November 2012 - 11:55 AM

### #1 townerj

• New D.I.C Head

Reputation: 0
• Posts: 10
• Joined: 20-February 12

# adding and multiplying floating points

Posted 21 November 2012 - 10:13 AM

I am having trouble converting a floating point array into a logical 2-d array. I know its a number times the width plus the height but i am having trouble with the fpu register instructions for the stack. Can someone show me how to properly add and multiply floating point values i am new to floating point instructions and dont understand the fpu ST(0), ST(1) stack and how numbers are added or multiplied on the stack. Here is what i have, all three are real8 variables i created.

```fld randomFloat
fmul arrayWidth
fadd arrayHeight

```

Then after these instructions, where is the float stored ST(0)?

Thanks for the help

Is This A Good Question/Topic? 0

## Replies To: adding and multiplying floating points

### #2 ishkabible

• spelling expret

Reputation: 1702
• Posts: 5,861
• Joined: 03-August 09

## Re: adding and multiplying floating points

Posted 21 November 2012 - 11:55 AM

you load 'randomFloat' into st0 then you conceptually load 'arrayWidth' into st1. st1 is then multiplied by st0 and the result is stored in st0. you then conceptually load 'arrayHeight' into st1 and add it with st0 then store the result in st0. so what did looks right to me

this said, why are you trying to use floating point to index elements of an array? you should be using integers for that, something more like...

```mov eax, randomIndex
mul eax, arrayWidth
add eax, arrayHeight

```

Was This Post Helpful? 0

Page 1 of 1

 .related ul{list-style-type:circle;font-size:12px;font-weight:bold;}.related li{margin-bottom:5px;background-position:left 7px!important;margin-left:-35px;}.related h2{font-size:18px;font-weight:bold;}.related a{color:blue;}