2010-07-21 16:03:44 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
2011-09-28 21:32:37 +00:00
|
|
|
* PURPOSE: Implementation of floorf
|
2010-07-21 16:03:44 +00:00
|
|
|
* FILE: lib/sdk/crt/math/amd64/floorf.S
|
|
|
|
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2010-11-27 22:12:15 +00:00
|
|
|
#include <asm.inc>
|
2010-07-21 16:03:44 +00:00
|
|
|
|
2011-02-10 10:30:43 +00:00
|
|
|
/* CODE **********************************************************************/
|
2010-07-21 16:03:44 +00:00
|
|
|
.code64
|
|
|
|
|
|
|
|
PUBLIC floorf
|
2011-08-19 18:10:17 +00:00
|
|
|
FUNC floorf
|
2010-11-27 22:12:15 +00:00
|
|
|
sub rsp, 16
|
2011-08-19 18:10:17 +00:00
|
|
|
.ENDPROLOG
|
2010-11-27 22:12:15 +00:00
|
|
|
|
2011-09-28 21:32:37 +00:00
|
|
|
/* Truncate xmm0 to integer (single precision) */
|
|
|
|
cvttss2si rcx, xmm0
|
2010-07-21 16:03:44 +00:00
|
|
|
|
2011-09-28 21:32:37 +00:00
|
|
|
/* Duplicate the bits into rax */
|
|
|
|
movd eax, xmm0
|
2010-07-21 16:03:44 +00:00
|
|
|
|
2011-09-28 21:32:37 +00:00
|
|
|
/* Shift all bits to the right, keeping the sign bit */
|
|
|
|
shr rax, 31
|
2010-07-21 16:03:44 +00:00
|
|
|
|
2011-09-28 21:32:37 +00:00
|
|
|
/* Substract the sign bit from the truncated value, so that
|
|
|
|
we get the correct result for negative values. */
|
|
|
|
sub rcx, rax
|
|
|
|
|
|
|
|
/* Convert the result back to xmm0 (single precision) */
|
|
|
|
cvtsi2ss xmm0, rcx
|
2010-07-21 16:03:44 +00:00
|
|
|
|
2010-11-27 22:12:15 +00:00
|
|
|
add rsp, 16
|
2010-07-21 16:03:44 +00:00
|
|
|
ret
|
2011-10-14 08:33:22 +00:00
|
|
|
ENDFUNC
|
2010-11-27 22:12:15 +00:00
|
|
|
|
|
|
|
END
|