News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

How to multiply 16 bit integer with 64 bit float?

Started by AeroASM, February 20, 2005, 09:43:20 PM

Previous topic - Next topic

AeroASM

I recently changed all my x87 code to SSE, except the following: I have a REAL8, which needs to be multiplied by a 16 bit integer.
The only way I can think to do this is:

fild my_integer
fmul my_float
fstp my_float


Is there a way to do this without the FPU?

raymond

You could always use the algorithms which were developed in the early days to emulate the x87. :eek

As you showed, using the FPU is very simple. Why don't you want to use the FPU???

Raymond
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

AeroASM

I wrote the whole program using the FPU, then I found out that the FPU is very slow, so I got rid of most of it and replaced it with SSE. I just don't want to rely on the FPU even for one little bit.

Mark_Larson

BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

AeroASM

Will SSE recognize that one number is an integer and the other is a float?

raymond

Converting an integer to one of the float formats is quite easy with CPU instructions. If you have been using the FPU in the past, you must be aware of those formats. Ask if you need to go that route and need help.

Raymond
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

Mark_Larson

Quote from: AeroASM on February 21, 2005, 06:26:46 PM
Will SSE recognize that one number is an integer and the other is a float?

You can convert the integer to a float and then treat it like a float.

BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm


raymond

Quote from: AeroASM on February 22, 2005, 07:46:38 AM
How do I convert it?

Look at the following description of the various floating point formats.

http://www.ray.masmcode.com/tutorial/fpuchap2.htm#floats

Once you understand it, try to convert an integer by yourself and compare it with the value which would be generated by your assembler. If you do succeed, you will remember how to do it for the rest of your life. If you need more help, I will be glad to provide it.

Raymond
When you assume something, you risk being wrong half the time
http://www.ray.masmcode.com

AeroASM


Farabi

If I dont made mistake, mul instruction is more fast than the fmul and fimul instruction.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

AeroASM

But mul doesn't work with floats, and I need to multiply an int by a float to get a float.

hutch--

Aero,

Rays suggestion is a good one, you can load the integer into a floating point register and do the rest using the other float value.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php