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
4 answers

FSTENV? Can barely find any info about this instruction

I've got this instruction in a program: FSTENV (28-BYTE) PTR SS:[ESP-1C] What does it do? Which registers does it use and updates? Thank you!
Taru
  • 2,562
  • 4
  • 22
  • 30
2
votes
1 answer

Asm. How to set RC bits of CW?

How to set in control word of FPU bits in RC to 3? answer (editor's note: don't post answers as part of the question, but for now it's here) fstcw word ptr cw or word ptr cw, 110000000000b fldcw word ptr cw
Kovpaev Alexey
  • 1,725
  • 6
  • 19
  • 38
2
votes
1 answer

Can the x87 perform exact division on UNsigned QUADword integers?

The 8086/8087/8088 MACRO ASSEMBLY LANGUAGE REFERENCE MANUAL (c) 1980 Intel Corporation mentions (Emphasis mine): ... the 8087 provides a very good approximation of the real number system. It is important to remember, however, that it is not an…
Sep Roland
  • 33,889
  • 7
  • 43
  • 76
2
votes
0 answers

"A2070: invalid instruction operands" error in assembly when trying to use faddp/fsubp instructions

I need to write a program in MASM32 assembly to compute some expression as an assignment. However when I try to compile the code, I get "error A2070: invalid instruction operands" on lines with faddp and fsubp instructions. My code is: .686 .model…
2
votes
0 answers

Calculating an expression in assembly code

I have written an assembly code for calculating area mentioned in the following formula I feel I have overcomplicated the code. Need suggestions if the same could be done in a simpler way. I am calculating sqrt of 5 than mul by 2. Each thing is…
rohit sharma
  • 171
  • 1
  • 9
2
votes
1 answer

Delphi's Round() appears to be non-deterministic

I'm facing the bizarre situation that the same program on the same machine doing a Round() of the same floating point value does not always give the same result. At first I thought it has to be glitch because of a bit flip or something, but it keeps…
Thijs van Dien
  • 6,516
  • 1
  • 29
  • 48
2
votes
1 answer

Comparing 80 bit floats in FASM with given accuracy

I am writing a program that calculates Pi using the Nilakantha Series in a loop with an accuracy of at least 0.05%. The exit condition for this loop should be when the current calculated value res and the previously calculated value prev fit |res -…
DuckMaster
  • 23
  • 1
  • 3
2
votes
2 answers

Assembly x86 quaternion to euler angles outputs wrong order

I'm having some troubles converting quaternions into euler angles. I've followed this C++ code found on Wikipedia and I think I did a pretty good job replicating it in assembly, the problem is that my code converts the WXYZ values to ZYX instead of…
Germ
  • 117
  • 6
2
votes
0 answers

fnstenv on 64 bit returning wrong value?

I'm using fnstenv FPU instruction to get the EIP in a 64 bit shellcode. Running it in GDB everything looks fine: 0x0000000000400080 ? fldz 0x0000000000400082 ? fnstenv [rsp-0xc] After running these instructions by stepping in with si I get…
cips
  • 95
  • 1
  • 8
2
votes
0 answers

Why is floating-point comparison working if internally it's not as described or documented? Is this a quirk of gdb?

I've been working through Richard Blum's Professional Assembly Language and its initial floating-point comparison program works but, when run through gdb on Linux, some of the intermediate steps are unexpected. To experiment: Here's the program (my…
muodostus
  • 151
  • 1
  • 7
2
votes
1 answer

Why does FLD m80fp not raise an exception for SNaN inputs while FLD of double or float can?

Here are possible exception when using FLD: #IS Stack underflow or overflow occurred. #IA Source operand is an SNaN. Does not occur if the source operand is in double extended-precision floating-point format (FLD m80fp or FLD ST(i)). #D …
hai ha
  • 35
  • 4
2
votes
2 answers

Storing a general purpose register in st0

If I have some value (bit pattern, let's say all zeros) in rax, can I store it in st0 without storing and loading from memory?
BeeOnRope
  • 60,350
  • 16
  • 207
  • 386
2
votes
1 answer

i find expression syntax error if i use fsin in program to find sin for the value

if i use fsin to find the sin value of real number. im find and expression syntax error. i#m using turbo c++ 3.0 on dos. i have looked for the instruction listing in x87 fpu. i tried to google some information. and also changed my intruction set…
Madhu
  • 55
  • 1
  • 5
2
votes
1 answer

Understanding GCC inline assembly code that uses memory source operands and x87 fcomi / fcmov

I'm reading the research paper Privado: Practical and Secure DNN Inference to hide the input-dependent branch. I am trying to understand the following GCC assembly code in that paper: float temp; asm volatile("fld %2 \n" "fld %3 \n" …
idunno
  • 21
  • 1
2
votes
1 answer

Why the cos function in math.h faster than x86 fcos instruction

The cos() in math.h run faster than the x86 asm fcos. The following code is compare between the x86 fcos and the cos() in math.h. In this code, 1000000 times asm fcos cost 150ms; 1000000 times cos() call cost only 80ms. How is the fcos implemented…
TBD
  • 81
  • 4