2010-03-03 15:27:30 +01:00
|
|
|
/* fpu_rndint() - round integer Author: Erik van der Kouwe */
|
|
|
|
/* 17 Dec 2009 */
|
2010-08-17 18:44:07 +02:00
|
|
|
#include <machine/asm.h>
|
2010-03-03 15:27:30 +01:00
|
|
|
|
|
|
|
/* void fpu_rndint(double *value) */
|
2010-08-17 18:44:07 +02:00
|
|
|
ENTRY(fpu_rndint)
|
2010-03-03 15:27:30 +01:00
|
|
|
/* move the value onto the floating point stack */
|
|
|
|
mov 4(%esp), %eax
|
|
|
|
fldl (%eax)
|
|
|
|
|
|
|
|
/* round it (beware of precision exception!) */
|
|
|
|
frndint
|
|
|
|
|
|
|
|
/* store the result */
|
|
|
|
fstpl (%eax)
|
|
|
|
ret
|
|
|
|
|
|
|
|
/* void fpu_remainder(double *x, double y) */
|
2010-08-17 18:44:07 +02:00
|
|
|
ENTRY(fpu_remainder)
|
2010-03-03 15:27:30 +01:00
|
|
|
/* move the values onto the floating point stack */
|
|
|
|
fldl 8(%esp)
|
|
|
|
mov 4(%esp), %edx
|
|
|
|
fldl (%edx)
|
|
|
|
|
|
|
|
/* compute remainder, multiple iterations may be needed */
|
|
|
|
1:
|
|
|
|
fprem1
|
|
|
|
.byte 0xdf, 0xe0 /* fnstsw ax */
|
|
|
|
sahf
|
|
|
|
jp 1b
|
|
|
|
|
|
|
|
/* store the result and pop the divisor */
|
|
|
|
fstpl (%edx)
|
|
|
|
fstp %st
|
|
|
|
ret
|