Set default rounding mode to FE_NEAREST again. Thanks to Matthias Bentrup for providing some explanations.

This commit is contained in:
Thilo Schulz committed 2011-09-27 14:43:20 +00:00
1 parent ebec84c55d
commit 8a500d71da
6 files changed
+34 -59

No files matched your search

+12 -1
View File
@@ -22,6 +22,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "qasm-inline.h"
static const unsigned short fpucw = 0x0C7F;
/*
* GNU inline asm ftol conversion functions using SSE or FPU
*/
@@ -59,14 +61,18 @@ int qvmftolsse(void)
long qftolx87(float f)
{
long retval;
unsigned short oldcw;
__asm__ volatile
(
"fnstcw %2\n"
"fldcw %3\n"
"flds %1\n"
"fistpl %1\n"
"fldcw %2\n"
"mov %1, %0\n"
: "=r" (retval)
: "m" (f)
: "m" (f), "m" (oldcw), "m" (fpucw)
);
return retval;
@@ -75,13 +81,18 @@ long qftolx87(float f)
int qvmftolx87(void)
{
int retval;
unsigned short oldcw;
__asm__ volatile
(
"fnstcw %1\n"
"fldcw %2\n"
"flds (" EDI ", " EBX ", 4)\n"
"fistpl (" EDI ", " EBX ", 4)\n"
"fldcw %2\n"
"mov (" EDI ", " EBX ", 4), %0\n"
: "=r" (retval)
: "m" (oldcw), "m" (fpucw)
);
return retval;