mirror of
https://github.com/reactos/reactos.git
synced 2025-07-29 08:31:57 +00:00
[CRT] Implement portable + amd64 asm version of fabs/fabsf
Note: older versions of ML64 are broken and don't understand the register form of movq. See https://stackoverflow.com/questions/24789339/move-quadword-between-xmm-and-general-purpose-register-in-ml64
This commit is contained in:
parent
8a67170616
commit
b85afdfd25
7 changed files with 149 additions and 48 deletions
|
@ -1,9 +1,8 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* PURPOSE: Implementation of fabs
|
||||
* FILE: lib/sdk/crt/math/amd64/fabs.S
|
||||
* PROGRAMMER: Timo Kreuzer (timo.kreuzer@reactos.org)
|
||||
* PROJECT: ReactOS CRT library
|
||||
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||
* PURPOSE: x64 asm implementation of fabs
|
||||
* COPYRIGHT: Copyright 2021 Timo Kreuzer <timo.kreuzer@reactos.org>
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
@ -14,18 +13,42 @@
|
|||
.code64
|
||||
|
||||
#ifdef _USE_ML
|
||||
/* fabs is now allowed as label name, so create _fabs instead and alias fabs to it */
|
||||
/* fabs is not allowed as label name, so create _fabs instead and alias fabs to it */
|
||||
ALIAS <fabs> = <_fabs>
|
||||
PUBLIC _fabs
|
||||
_fabs:
|
||||
#else
|
||||
PUBLIC fabs
|
||||
fabs:
|
||||
#endif
|
||||
UNIMPLEMENTED fabs
|
||||
ret
|
||||
|
||||
#ifdef _USE_ML
|
||||
ALIAS <fabs> = <_fabs>
|
||||
/* Copy parameter into rcx */
|
||||
#if !defined(_MSC_VER) || (_MSC_VER >= 1916)
|
||||
movq rcx, xmm0
|
||||
#else
|
||||
/* Old ML64 version does not understand this form of movq and uses movd instead */
|
||||
movd rcx, xmm0
|
||||
#endif
|
||||
|
||||
/* Copy into rax */
|
||||
mov rax, rcx
|
||||
|
||||
/* Clear sign bit in rax */
|
||||
btr rax, 63
|
||||
|
||||
/* Check for NAN */
|
||||
mov r8, HEX(7FF0000000000000)
|
||||
cmp rax, r8
|
||||
|
||||
/* If it is NAN, copy original value back to rax */
|
||||
cmova rax, rcx
|
||||
|
||||
#if !defined(_MSC_VER) || (_MSC_VER >= 1916)
|
||||
movq xmm0, rax
|
||||
#else
|
||||
/* Old ML64 version does not understand this form of movq and uses movd instead */
|
||||
movd xmm0, rax
|
||||
#endif
|
||||
|
||||
ret
|
||||
|
||||
END
|
||||
|
|
49
sdk/lib/crt/math/amd64/fabsf.S
Normal file
49
sdk/lib/crt/math/amd64/fabsf.S
Normal file
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* PROJECT: ReactOS CRT library
|
||||
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||
* PURPOSE: x64 asm implementation of fabsf
|
||||
* COPYRIGHT: Copyright 2021 Timo Kreuzer <timo.kreuzer@reactos.org>
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <asm.inc>
|
||||
|
||||
/* CODE **********************************************************************/
|
||||
.code64
|
||||
|
||||
PUBLIC fabsf
|
||||
fabsf:
|
||||
/* Copy parameter into rcx */
|
||||
#if !defined(_MSC_VER) || (_MSC_VER >= 1916)
|
||||
movq rcx, xmm0
|
||||
#else
|
||||
/* Old ML64 version does not understand this form of movq and uses movd instead */
|
||||
movd rcx, xmm0
|
||||
#endif
|
||||
|
||||
/* Copy into eax */
|
||||
mov eax, ecx
|
||||
|
||||
/* Clear sign bit in eax */
|
||||
btr eax, 31
|
||||
|
||||
/* Set error bit in rcx */
|
||||
bts ecx, 22
|
||||
|
||||
/* Check for NAN */
|
||||
cmp eax, HEX(7F800000)
|
||||
|
||||
/* If eax is NAN, copy error result to rax */
|
||||
cmova eax, ecx
|
||||
|
||||
#if !defined(_MSC_VER) || (_MSC_VER >= 1916)
|
||||
movq xmm0, rax
|
||||
#else
|
||||
/* Old ML64 version does not understand this form of movq and uses movd instead */
|
||||
movd xmm0, rax
|
||||
#endif
|
||||
|
||||
ret
|
||||
|
||||
END
|
Loading…
Add table
Add a link
Reference in a new issue