Questions tagged [x87]

x87 is the legacy 80bit floating point subset of the x86 instruction set. It's obsoleted by SSE/SSE2 for float/double, but is still useful for 80bit extended precision. The 32bit x86 ABI also returns FP results in an x87 register. See the tag wiki for a tutorial link.

See the wiki for links, including the most useful one: http://www.ray.masmcode.com/tutorial/index.html.

249 questions
9
votes
4 answers

Free the x87 FPU Stack (ia32)

At my university we were just introduced to IA32 x87 FPU. But we weren't informed how to clear the FPU-Stack of no longer demanded elements. Imagine we're performing a simple calculation like (5.6 * 2.4) + (3.9 * 10.3). .data value1: .float…
tmuecksch
  • 6,222
  • 6
  • 40
  • 61
9
votes
1 answer

Why does .NET use SIMD and not x87 for math operations not intrinsic to SIMD?

This is a question of curiosity more than anything else. I was looking at this code disassembly (C#, 64 bit, Release mode, VS 2012 RC): double a = 10d * Math.Log(20d, 2d); 000000c8 movsd xmm1,mmword ptr [00000138h] 000000d0 …
IamIC
  • 17,747
  • 20
  • 91
  • 154
8
votes
1 answer

How to specify clobbered bottom of the x87 FPU stack with extended gcc assembly?

In a codebase of ours I found this snippet for fast, towards-negative-infinity1 rounding on x87: inline int my_int(double x) { int r; #ifdef _GCC_ asm ("fldl %1\n" "fistpl %0\n" :"=m"(r) :"m"(x)); #else // ... #endif …
Matteo Italia
  • 123,740
  • 17
  • 206
  • 299
8
votes
1 answer

How is the initial value of x87 floating point control word defined?

Value of x87 floating point control word can be checked with _control87. When a new thread starts, on my platform it seems to inherit value of floating point control word from the parent thread. Is this undefined behavior, or am I guaranteed that if…
VLL
  • 9,634
  • 1
  • 29
  • 54
8
votes
4 answers

Sine computation inconsistency in Visual C++ 2012?

Consider the following code: // Filename fputest.cpp #include #include int main() { double x; *(__int64 *) &x = 0xc01448ec3aaa278di64; // -5.0712136427263319 double sine1 = sin(x); printf("%016llX\n", sine1); …
Smi
  • 13,850
  • 9
  • 56
  • 64
7
votes
2 answers

80-bit floating point and subnormal numbers

I am trying to convert an 80-bit extended precision floating point number (in a buffer) to double. The buffer basically contains the content of an x87 register. This question helped me get started as I wasn't all that familiar with the IEEE…
pezcode
  • 5,490
  • 2
  • 24
  • 37
7
votes
1 answer

Accuracy of FSIN and other x87 trigonometric instructions on AMD processors

On Intel processors, x87 trigonometric instructions such as FSIN have limited accuracy due to the use of a 66-bit approximation of pi even though the computation itself is otherwise accurate to the full 64-bit mantissa of an 80-bit…
bwDraco
  • 2,514
  • 2
  • 33
  • 38
7
votes
1 answer

Do denormal flags like Denormals-Are-Zero (DAZ) affect comparisons for equality?

If I have 2 denormal floating point numbers with different bit patterns and compare them for equality, can the result be affected by the Denormals-Are-Zero flag, the Flush-to-Zero flag, or other flags on commonly used processors? Or do these flags…
Zachary Burns
  • 453
  • 2
  • 9
6
votes
1 answer

x87 FPOP and FCOM instructions - how do these work?

I've been tasked with writing a simple application in mixed C/ASM that has to use math coprocessor. There's the function cylinder(float x, float y, float z) that returns 1 if the given point is within the cylinder (the cylinder has a base at…
user905747
  • 613
  • 1
  • 9
  • 18
6
votes
3 answers

Convert a floating point to an integer with truncation instead of rounding using the x87 FPU

The FISTP instruction changes 0.75 to 1 (because of rounding) I want 0.75 to turn into 0, not 1. Is there an alternative to FIST/FISTP that truncates instead of rounds?
Zach Johnson
  • 152
  • 1
  • 8
6
votes
3 answers

What is the error of trigonometric instructions on x86?

Where can I find the information about error ranges for trigonometric function instructions on x86 processors, like fsincos?
mdakin
  • 1,310
  • 11
  • 17
6
votes
2 answers

gcc 4.x not supporting x87 FPU math?

I've been trying to compile gcc 4.x from the sources using --with-fpmath=387 but I'm getting this error: "Invalid --with-fpmath=387". I looked in the configs and found that it doesn't support this option (even though docs still mention it as a…
user1552175
  • 178
  • 10
6
votes
6 answers

Are there unsigned equivalents of the x87 FILD and SSE CVTSI2SD instructions?

I want to implement the equivalent of C's uint-to-double cast in the GHC Haskell compiler. We already implement int-to-double using FILD or CVTSI2SD. Is there unsigned versions of these operations or am I supposed to zero out the highest bit of the…
tibbe
  • 8,809
  • 7
  • 36
  • 64
6
votes
5 answers

Adding floating point/double numbers in assembly

I am trying to experiment with inline assembly, and I am trying to add decimal numbers (no, NOT integers) in inline assembly. Issue is, when I call the following function: inline double ADD(double num1, double num2) { double res; _asm{ push…
scrat101
  • 89
  • 1
  • 2
  • 8
5
votes
2 answers

How do you get maximal speed out of SSE?

What are the best settings for stuff like MXCSR? Which rounding mode is fastest? On what processors? Is it faster to enable signalling NaNs so I get informed when a computation results in a nan, or does this cause slowdowns in non-NaN…
FeepingCreature
  • 3,648
  • 2
  • 26
  • 25
1
2
3
16 17