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
0
votes
0 answers

How to get fractional part? ( modf() Intel assembly equivalent )

Is there a single assembly instruction that gets the fractional part of a double or float (or packed double or float)? (x87 x64 SSE)
0
votes
0 answers

Why FXSAVE on Intel stores abridged x87 tags

The FXSAVE IA32 instruction does not save x87 native two-bits tags into the FTW byte of the save area. Instead, 'an abridged tags', single bit inverted tags are saved. I.e. (00, 01, 10) -> 1, 11 -> 0 for full->abridged translation. I am asking for…
0
votes
0 answers

Visual Studio debug break on floating point register change

Is there a way in Visual Studio (2012\13\15, preferably in 2015) to add a debug condition to break when the STAT register changes? I'm referring to the register value of STAT which can be viewed by opening the "Register" window while debugging,…
ZivS
  • 2,094
  • 2
  • 27
  • 48
0
votes
1 answer

Assembly (i386): Math Coprocessor Stack

I was reading about the math coprocessor (Paul Carters PC Assembly Book) and its instructions to make floating point calculations (on ASM i386). Then I ran into the following code that is supposed to return the larger double of two given double…
murphsghost
  • 161
  • 1
  • 7
0
votes
2 answers

Truncate Floats and Doubles after user defined points in X87 and SSE FPUs

I have made a function g that is able to approximate a function to a certain degree, this function gives accurate results up to 5 decimals ( 1,23456xxxxxxxxxxxx where the x positions are just rounding errors / junk ) . To avoid spreading error to…
0
votes
1 answer

Using FPU return values in c++ code

I have an x86 NASM program which seems to work perfectly. I have problems using the values returned from it. This is 32-Bit Windows using MSVC++. I expect the return value in ST0. A minimal example demonstrating the problem with the returned values…
Hajaku
  • 39
  • 5
0
votes
2 answers

Prove trigonometric identities in nasm

Given to prove trigonometric identity: cos(fi+theta) = cos(theta)cos(fi)-sin(theta).sin(fi) The following program written in NASM should print 1 when the identity is verified else 0. I always get 0 as the output. According to me, I think my logic…
Sahay
  • 39
  • 1
  • 4
0
votes
1 answer

Why is this simple program outputting so many characters?

Here is my short assembly program: ; This code has been generated by the 7Basic ; compiler extern printf ; Initialized data SECTION .data f_0 dd 5.5 printf_f: db "%f",10,0 SECTION .text ; Code global…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
0
votes
0 answers

Linux NASM x86 64bit Code displays empty output

My nasm 64bit code running on linux is trying to print out a cosine wave on a 21x41 grid using horners method. However, whenever I print all I get is an empty 21x41 grid. Can anyone help me troubleshoot this issue? My code is below: SECTION…
0
votes
0 answers

TASM Math coprocessor FSUB not substracting

I encounter difficulties using the math coprocessor. I need to calculate the area of a triangle using Heron's formula (S=sqrt(p(p-a)(p-b)(p-c)), where p is the semiperimeter and a, b and c are the triangle's sides). I successfully read a, b, c and…
Vlad Silviu Farcas
  • 177
  • 1
  • 3
  • 15
0
votes
1 answer

Assembly: How does fld st(0) duplicates the top stack value in the following code?

In the following code, I am wondering about the role of fld ST(0). I have heard it duplicates the top value in the stack but I don't know where does it bring that value in the following code? fild dword ptr [L1000F140] fstp qword ptr…
barej
  • 1,330
  • 3
  • 25
  • 56
0
votes
0 answers

Computing tangent with x87 instructions FPTAN and FDIVR

I want to compute tan(pi) with X87 FPTAN and FDIVR: #include int main(){ double answer,angle=3.14; __asm__ ("FPTAN;" "FDIVR;" : "=t" (answer) : "0" (angle)); printf ("angle = %g\n",angle); printf ("answer =…
zell
  • 9,830
  • 10
  • 62
  • 115
0
votes
1 answer

NASM x87 FILD instruction

I was reading this and I noticed that their example shows fld loading values into different locations (st0, st1, then back to st0) without specifying where where to load to. I'm assuming fild works in a similar fashion as it's just the means of…
dlkulp
  • 2,204
  • 5
  • 32
  • 46
0
votes
1 answer

flds instruction fails on Mac OSX

The flds instruction should store the value in register st0. I am debugging a shared library I don't have code for. Sometimes the flds instruction doesn't have any effect on st0. Below is gdb output for a case when it works and a case when it fails.…
0
votes
2 answers

usage of fstp command

I have a question: let's say my stack of the Floating-point unit is as follows: ST0 = +1.5000000000000000e+0001 ST1 = +5.0000000000000000e+0000 ST2 = +2.5000000000000000e+0001 ST3 = +0.0000000000000000e+0000 ST4 = +0.0000000000000000e+0000 …
Simon
  • 2,643
  • 3
  • 40
  • 61