diff options
Diffstat (limited to 'src/asm/ftola.c')
-rw-r--r-- | src/asm/ftola.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/asm/ftola.c b/src/asm/ftola.c index ad197836..a2a4eaa0 100644 --- a/src/asm/ftola.c +++ b/src/asm/ftola.c @@ -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; |