xref: /reactos/sdk/lib/crt/math/amd64/fabsf.S (revision 09dde2cf)
1/*
2 * PROJECT:     ReactOS CRT library
3 * LICENSE:     MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE:     x64 asm implementation of fabsf
5 * COPYRIGHT:   Copyright 2021 Timo Kreuzer <timo.kreuzer@reactos.org>
6 */
7
8/* INCLUDES ******************************************************************/
9
10#include <asm.inc>
11
12/* CODE **********************************************************************/
13.code64
14
15PUBLIC fabsf
16fabsf:
17    /* Copy parameter into rcx */
18#if !defined(_MSC_VER) || (_MSC_VER >= 1916)
19    movq rcx, xmm0
20#else
21    /* Old ML64 version does not understand this form of movq and uses movd instead */
22    movd rcx, xmm0
23#endif
24
25    /* Copy into eax */
26    mov eax, ecx
27
28    /* Clear sign bit in eax */
29    btr eax, 31
30
31    /* Set error bit in rcx */
32    bts ecx, 22
33
34    /* Check for NAN */
35    cmp eax, HEX(7F800000)
36
37    /* If eax is NAN, copy error result to rax */
38    cmova eax, ecx
39
40#if !defined(_MSC_VER) || (_MSC_VER >= 1916)
41    movq xmm0, rax
42#else
43    /* Old ML64 version does not understand this form of movq and uses movd instead */
44    movd xmm0, rax
45#endif
46
47    ret
48
49END
50