NASM - The Netwide Assembler

NASM Forum => Using NASM => Topic started by: Logman on October 18, 2014, 02:44:44 AM

Title: Floating Point Constants
Post by: Logman on October 18, 2014, 02:44:44 AM
I am attempting to write some software to operate on 128-bit quadruple precision floating point numbers. I could use some additional clarification on how to implement __float128l__, __float128h__, __infinity__, __float80m__, float80e__, and __NaN__.

How do you define, declare, and setup these tokens for use in NASM? How do I get the values defined by __float128l__ and __128h__ into an XMM register?

Thanks in advance.
Logman
Title: Re: Floating Point Constants
Post by: encryptor256 on October 18, 2014, 06:31:31 AM
Hi!

How do you define, declare, and setup these tokens for use in NASM? How do I get the values defined by __float128l__ and __128h__ into an XMM register?

Well I don't know... what if you try to read NASM documentation?

I think to define 128 float number we have to do like this:

Code: [Select]
section .data
                  ...
                  myfloat128: dq __float128l__(234234.4355644565644), __float128h__(234234.4355644565644)
                  ...
                  ...

section .code
                  ...
                  movdqu xmm0,[myfloat128]
                  ...
                  ...

OR

NASM Doc: 3.4.6 Floating-Point Constants (http://www.nasm.us/xdoc/2.11.05/html/nasmdoc3.html#section-3.4.6)

There is examples how to define various floating point types.

How to load into xmm register, find "AMD64 Architecture Programmer’s Manual Volume 1: Application Programming",
128-Bit Media and Scientific Programming

I could use some additional clarification on how to implement __float128l__, __float128h__, __infinity__, __float80m__, float80e__, and __NaN__.
Yes you could.

In documentation there is examples how to "implement" __infinity__, __NaN__.
Title: Re: Floating Point Constants
Post by: Logman on October 18, 2014, 12:17:29 PM
Thanks for the example encryptor256. I wasn't exactly sure how NASM implemented these commands. BTW, it doesn't do anybody any good to tell them to read the documentation. I probably have the most ear-bent and note-cluttered copy of the NASM documentation. I just needed some clarification because what I was doing wasn't working correctly.

Up to now, I haven't used these tokens but have a need to perform some operations on some pretty large numbers in a simulation I'm producing. I tried several times to get these instructions to work, but to no avail. I know there is no direct hardware support for 128-bit quadruple precision floating point operations, hence my need to do these in software. Maybe someday Intel will support 128-bit scalar instructions for scientific calculations (SSE 6 perhaps?).

Thank you for the help. It put me on the right track.

Logman
Title: Re: Floating Point Constants
Post by: encryptor256 on October 18, 2014, 01:41:30 PM
Hi!

4x128bit could be one ZMM register.

Maybe someday Intel will support 128-bit scalar instructions for scientific calculations (SSE 6 perhaps?)

Heh, :D  Well, Intel is just a business, I think there is no need to count on Intel.
For science we need to use software managed math libraries, calculus.
There was some sort of MathLab or Wolfram Mathematics studio or something like that, what can be used for scientific calculations.

Also you can build your own floating point arithmetic.

For me, I don't like floating points.
I like, "Remainder mathematics", so, there is always two integers, without error, one is number and one is remainder(remaining value) or division or else.
Well, that's one for me.

Why do you need such big calculations in assembly? Are you planning to build a space ship and you need to calculate precise distance between galaxies? Or you need to calculate how long it will take to navigate around galaxy with speed of light? :)

Title: Re: Floating Point Constants
Post by: InfinitelyManic on November 16, 2014, 06:40:26 AM
enryptor256:

I'm curious as to how you solve problems such as sqrt(), etc. without using the FPU or any other floating point regs?  If you are only using RAX:RDX then that would truly be "hardcore" as they say. You may be using libriares; which is probably wiser in the long run.

David a/k/a @InfinitelyManic

Title: Re: Floating Point Constants
Post by: Logman on May 16, 2015, 04:01:43 PM
I am working on weather pattern simulations and need to execute some pretty large values I.e., 1.2e7000 and larger.

I am doing these calculations by developing software solutions, but 512 bit non-vector hardware solutions would be better (faster).

Logman
Title: Re: Floating Point Constants
Post by: encryptor256 on May 17, 2015, 05:29:01 PM
I am working on weather pattern simulations and need to execute some pretty large values I.e., 1.2e7000 and larger.

Well... As you can see "1.2e7000" is pretty small, only eight characters.  :D

Code: [Select]
char buff[8] = {"1.2e7000"};

Best wishes,
Ingredient Mr. E256.
Title: Re: Floating Point Constants
Post by: shaynox on May 17, 2015, 05:48:52 PM
Post your question on https://software.intel.com/en-us/ too ^^