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

Storing the x87 FPU Control Word

I'm making a function which returns the FPU Control Word register (16bit). According to documentation, I have to use fstcw and a memory place. My place in memory is: fpuctl: .word 0 And my function is: .global getFPUControlState .type…
Fenrir
  • 151
  • 2
  • 14
2
votes
1 answer

fstcw assembly operand type mismatch

I'm trying to round an input double using a specified rounding mode in in-line assembly in C. To do so, I need to grab the FPU control word using fstcw and then change the bits in the word. Unfortunately I'm encountering an error on the very first…
tschuy
  • 89
  • 8
2
votes
1 answer

NASM coprocessor - not getting the expected output

I am writing a simple program where I am supposed to get the first two command line arguments, which are integers and then do some operations with them. But here I have a problem. When I want to print out the results of these operations I only get…
whatever
  • 21
  • 1
2
votes
1 answer

C++ and inline assembly code have same output in one program, but different in another

I'm working on an assignment where I have to convert a snippet of C code to inline assembly. The code is part of a program that renders a Julia fractal. I've tested the outputs of both code snippets and they match exactly, yet my program still…
ozma
  • 349
  • 1
  • 3
  • 10
2
votes
1 answer

Which bits in the x87 tag word does FFREE ST(i) modify?

This example was written in NASM: section .bss var28: resb 28 section .text _main: ; Initialize finit fldpi ; Read Tag Word fstenv [var28] mov ax, [var28 + 8] ; move…
Bite Bytes
  • 1,455
  • 8
  • 24
2
votes
1 answer

FXTRACT instruction example

I wrote this code in NASM: section .data fvar: dd 123.456 fsig: dq 0.0 fexp: dq 0.0 section .text fld dword[fVar] fxtract ; put significand in ST(0), and exponent in ST(1) fstp qword[fsig] ; fsig = 1.929 fstp…
Bite Bytes
  • 1,455
  • 8
  • 24
2
votes
2 answers

How to add two numbers, integer and a float in NASM?

I have this code that is suppose to add two numbers, a float(3.25) and a integer(2). EDITED: extern _printf, _scanf global _main section .bss num1: resb 4 section .data format_num: db "%f", 10, 0 section .text _main: mov dword [num1],…
Omar Murcia
  • 547
  • 2
  • 11
  • 26
2
votes
1 answer

What CPU state has an effect on intel FPU and SSE performance?

In trying to track down a performance issue, I ended up looking for information on what can have an effect on the performance of x87 and SSE instructions. I found that information incredibly difficult to track down as it tends to be hidden deep…
Olivier
  • 1,144
  • 1
  • 8
  • 15
2
votes
2 answers

What instructions should I be using for floating point operations?

I'm somewhat familiar with the x87 instructions for manipulating floating point numbers in x86 assembly. However, I read somewhere that these were seldom used anymore. (And weren't allowed in 64-bit Windows drivers)[1] If that's the case, what…
Nathan Osman
  • 71,149
  • 71
  • 256
  • 361
2
votes
1 answer

SSE: Mass integer conversion+multiply slower with SSE than FPU?

I'm working on an application that very often needs to convert 6 to 8 signed 32 bit integers to 32 bit real numbers. I replaced the delphi code with custom assembler code and to my great surprise the FPU conversion is always as fast and on some…
Marladu
  • 545
  • 5
  • 11
2
votes
1 answer

Can implementations supporting binary128 type easily offer consistent binary80 semantics?

If a language wished to offer consistent floating-point semantics on both x87 hardware and on hardware that supports the binary128 type, would existing binary128 implementations be able to operate efficiently with rules that required all…
supercat
  • 77,689
  • 9
  • 166
  • 211
2
votes
0 answers

Inline assembly in GNU C++ compiler

The following inline assemble code is not working on my system. What is the problem with that code? If I use asm instead of __asm__ then it works properly. #include int main() { float arg1, arg2, div ; printf( "Enter two…
Singh123
  • 216
  • 3
  • 10
2
votes
0 answers

Different results when using different cl.exe compiler options

I'm on Windows 7 64bit, using VS2013 Express for Desktop. Compile as default (using SSE) D:\Work>cl printf-test.c Microsoft (R) C/C++ Optimizing Compiler Version 18.00.21005.1 for x86 D:\Work>printf-test.exe FPU control word 0x0000037f 0. FPU…
Sonny
  • 182
  • 1
  • 1
  • 9
2
votes
1 answer

FILD and FSTP instructions

Was doing a crackme, trying to write a keygen and I was confused about some of the FPU instructions. fild qword ptr ss:[esp] ; loads 4275451536.0000000000 into ST0. ESP has FED63690 lea esp, dword ptr ss:[esp+8] fstp qword ptr ss:[ebp-410]…
randomname
  • 265
  • 1
  • 9
  • 20
2
votes
1 answer

SSE FPU parallel

I was wondering if it would be possible to use SSE in parallel with x87. So consider the following pseudo code, 1: sse_insn 2: x87_insn Would the pipeline execute 1 and 2 in parallel assuming they can be executed in parallel?