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
1 answer

Calculating tangent of a provided angle in 8086/8088 using 8087 coprocessor

I have a project that I'm supposed to finish, the project is to write a 8086/8087 based program using 8087 coprocessor to find the tangent of an angle. The angle should be in degrees and print an output of tan(angle) What I did so far is: .model…
0
votes
1 answer

Can't output coprocessor float from variable two times in a row

Good afternoon! In this example, I simply add two numbers with a comma, save the variable in tbyte and display the same variable two times in a row on the screen, but the first time I get 11.1, as it should be, and the second time 4.667261E-062. Why…
John
  • 345
  • 2
  • 14
0
votes
0 answers

finding surface area of hexgonal prism in assembly language

I am trying to find the surface area using this equation. A = 6*a*h+3*sqrt(3)*a^2 I do not fully understand how co-processor instructions actually work. Here is currently by subprogram enter 8,0 mov [ebp-4],dword 2 ; Coprocessor…
21 Average
  • 27
  • 7
0
votes
1 answer

What is the fld qword[EBP+8] in this quadratic equation code and also what does fadd ST0 do with just one argument?

; roots.asm segment ;gcc.text global -c rootsc._roots _roots: enter 0,0 ;create stack frame for procedure parameters xor EAX,EAX ;EAX = 0 fld qword[EBP+8] ; load floating point…
0
votes
0 answers

Madhava-Leibniz series in Intel x87

I teach a computer architecture class and am preparing examples of Intel i7 floating point processing for it. The example algorithm is the Madhava-Leibniz series, which is a particularly slow way of calculating pi divided by 4. (I am well aware of…
DisplayName
  • 26
  • 1
  • 5
0
votes
0 answers

TASM - How can I push a normal word-sized register into the floating point stack?

I'm trying to use the floating point stack for calculation, however, I'm having some trouble pushing values to the stack. I've tried casting with a double word floatHelper variable using mov [floatHelper], dword ptr [cx] fld [floatHelper] mov word…
Ghost
  • 163
  • 1
  • 7
0
votes
1 answer

asm ("fldl %0"...) in DOS, Intel syntax?

I'm working on a retro project trying to compile some test code in Borland Turbo C++/DosBox. I have this function: double sin(double x){ asm ("fldl %0;" "fsin;" "fstpl %0" : "+m"(x)); return x; } I figure it returns the sin…
Dacobi
  • 417
  • 4
  • 14
0
votes
1 answer

Convert this embedded assembly code as to work with gcc

I am trying to convert this piece of code as to work with the AT&T assembly that g++ uses: double sqrt13(double n) { __asm{ fld n fsqrt } } Based on this link: https://ibiblio.org/gferg/ldp/GCC-Inline-Assembly-HOWTO.html: I tried this: double…
user2752471
  • 444
  • 1
  • 6
  • 14
0
votes
0 answers

passing long double on x86-64 to a variadic function

Compiling with gcc on x86-64, I have a function with the signature void * g(void* p, unsigned char a, unsigned char b, ...) and a function call long double zero = 0; g(NULL, 0, 0, zero); But when g() reads the zero argument via va_arg(...,long…
Kolodez
  • 553
  • 2
  • 9
0
votes
1 answer

nasm rejects fst tword [mem] --- bug?

fst tword [mem] generates a compilation error under nasm (generates "error: invalid combination of opcode and operands"). fst qword [mem] is accepted by nasm. fstp tword [mem] and fstp qword [mem] are both accepted by nasm. Is this a bug in nasm?
Mayer Goldberg
  • 1,378
  • 11
  • 23
0
votes
2 answers

How does GCC compile the 80 bit wide 10 byte float __float80 on x86_64?

According to one of the slides in the video by What's A Creel video, "Modern x64 Assembly 4: Data Types" (link to the slide), Note: real10 is only used with the x87 FPU, it is largely ignored nowadays but offers amazing precision! He…
Evan Carroll
  • 78,363
  • 46
  • 261
  • 468
0
votes
2 answers

Assembly x86 FPU - Stack Confusion

I am trying to understand FPU, and I am pretty confused. The problem is that as I understand from here, FPU has its own stack. But for example in this code (NASM): global _main extern _printf section .data hellomessage db `Hello World!\n`, 10,…
user5900485
0
votes
1 answer

Calculating exp(x) in x86 assembly

I am trying to make a compiler for my own simple programming language. It should output Intel-syntax x86 assembly. However, I am struggling to make it produce the correct code for the decimal numbers. Specifically, I am trying to implement the "exp"…
FlatAssembler
  • 667
  • 7
  • 30
0
votes
1 answer

Fault in calculation with small numbers in fpu?

Hi, i am trying to do this formula in fpu. (y = v*t*sin(a) - 0.5*g*t^2) My code in c++ is: typedef void(*Ipa_algorithm2)(double t, double alfa, double *return_value); Ipa_algorithm2 count_y; count_y = (Ipa_algorithm2)GetProcAddress(hInstLibrary,…
Erik
  • 303
  • 1
  • 3
  • 12
0
votes
1 answer

Compare float sum

I'm working on a MASM32 project that performs arithmetic operations. We have to use the coprocessor (8087 instruction set) to use the floating point unit. So, supose my floating point limit is 100.0 then every number must be less than the limit. I'm…
Tomás Juárez
  • 1,517
  • 3
  • 21
  • 51