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
3
votes
2 answers

Return a float from a 64-bit assembly function that uses x87 FPU

I am trying to make a program that calculates equations (what equation doesn't matter currently) that use 64-bit registers, floats, and coprocessor instructions. Unfortunately I don't know how to access the final outcome of the equation as a float.…
sweetsm
  • 47
  • 1
  • 6
3
votes
2 answers

How can I operate with float point numbers in assembly?

I need to send two real numbers from C (using extern 'C' double (double num1,double num2)) to a assembly procedure that returns the addition of these numbers. I don't know how to do this yet. I tried this but it didn't work. .data res dq…
3
votes
1 answer

Floating point assembly on intel processor

I have been studying how floating point operations are performed on a 32 bit intel machine. I have disassembled the following lines of C code to obtain how the compiler translates these lines on assembly. a = 13; b = 5; d = (float) a / (float)…
MykelXIII
  • 1,085
  • 1
  • 8
  • 16
3
votes
1 answer

Double performance a lot faster than floats in C

I was trying to figure out if using floats in some code in C would be precise enough for my needs, but after searching and not really understanding how bits of precision translated to actual numbers, I decided just to write a bit of code for my test…
Jason White
  • 666
  • 4
  • 10
  • 23
3
votes
1 answer

What does the following x86 assembly code with the FLDCW instruction do?

I was following this compiled code (I don't know the compiler nor having the source code). Sub1: mov edx,[esp+04h] and edx,00000300h or edx,0000007Fh mov [esp+06h],dx fldcw word ptr [esp+06h] retn My understanding: Sub1(4byte…
barej
  • 1,330
  • 3
  • 25
  • 56
3
votes
1 answer

How does an 80386/80287 combination behave in 32-bit mode?

I'm interested in retrocomputing and emulation of old computers and have a question about the 80287: Using a modern FPU the FNSAVE instruction writes 94 bytes of data when the CPU executes 16-bit code and 108 bytes of data when the CPU executes…
Martin Rosenau
  • 17,897
  • 3
  • 19
  • 38
3
votes
1 answer

how x87 precision affects square roots?

I wrote some code to test the fsqrt function and the result doesn't make complete sense to me. Here's the code (in delphi): uses mmsystem; var rand:longint=123456789; function rng:longint; asm imul eax,[rand],$08088405 inc eax mov…
Marladu
  • 545
  • 5
  • 11
3
votes
1 answer

Porting old compiler ftol (float to long) function to C

I'm relying on an old implementation that does some calculations and converts float's to int. However, after replicating the calculations some values are off due different rounding results. It boils down that the binary is using the following code…
Steve
  • 738
  • 1
  • 9
  • 30
3
votes
3 answers

Are x87 FPU instructions deterministic?

We are writing an emulator and want to know that for a given FPU state, is the state of the the FPU deterministic after running an FPU instruction eg. FDIV? There are many Intel compatible CPU architectures, that implement x87 instruction set.…
Calmarius
  • 18,570
  • 18
  • 110
  • 157
3
votes
2 answers

Did the Streaming SIMD Extensions replace x87 instruction set?

I know that the SSEs are an alternative to the x87 floating point instruction, but is the x87 FPU still implemented in modern CPUs like Ivy-Bridge or Haswell? Did SSEs replace the x87 instruction set?
Sean Lim
  • 33
  • 2
3
votes
2 answers

x86: latency and throughput of transcendental functions

Intel® 64 and IA-32 Architectures Optimization Reference Manual lists latency and throughput figures for various CPU instructions. For transcendental functions (FSIN etc) some of the figures are listed as ranges (page C-29). Footnote 4…
NPE
  • 486,780
  • 108
  • 951
  • 1,012
3
votes
2 answers

switching fpu to single precision

I have read that on older fpu a couple a years before fpu when switched to single precision mode did divisions and sqr twice as fast as in normal mode. (check the source of it http://stereopsis.com/FPU.html) Is it still the case, and switching like…
grunge fightr
  • 1,360
  • 2
  • 19
  • 38
3
votes
2 answers

How to move ST(0) to EAX?

Hullo, I am learning x86 FPU assembly, and I have got a simple question I cannot find answer for: How to move value from ST(0) ( top of the FPU stack ) to EAX ? also: is this code correct: ; multiply (dot) two vectors of 3 floats passed by pointers…
grunge fightr
  • 1,360
  • 2
  • 19
  • 38
3
votes
1 answer

floating point instruction anomaly -- FLDZ malfunctioning?

I am trying to debug the problem I posted earlier here: C++ and pin tool -- very weird DOUBLE variable issue with IF statement. I tracked down the moment when the weird behavior occurred using gdb. What I found is shown in the figure below that…
ray
  • 51
  • 4
3
votes
2 answers

is this a bug in sqrt function

I create an application to compute the primes numbers in 64-bit range so when i tried to compute the square root of 64-bit number using sqrt function from math.h i found the answer is not accurate for example when the input is ~0ull the answer…
Muhammad
  • 1,598
  • 3
  • 19
  • 31