xref: /freebsd/lib/libc/amd64/gen/fabs.S (revision 1d386b48a555f61cb7325543adbbb5c3f3407a66)
147ae38b5SPeter Wemm/*-
247ae38b5SPeter Wemm * Copyright (c) 2004 Peter Wemm
347ae38b5SPeter Wemm * All rights reserved.
447ae38b5SPeter Wemm *
547ae38b5SPeter Wemm * Redistribution and use in source and binary forms, with or without
647ae38b5SPeter Wemm * modification, are permitted provided that the following conditions
747ae38b5SPeter Wemm * are met:
847ae38b5SPeter Wemm * 1. Redistributions of source code must retain the above copyright
947ae38b5SPeter Wemm *    notice, this list of conditions and the following disclaimer.
1047ae38b5SPeter Wemm * 2. Redistributions in binary form must reproduce the above copyright
1147ae38b5SPeter Wemm *    notice, this list of conditions and the following disclaimer in the
1247ae38b5SPeter Wemm *    documentation and/or other materials provided with the distribution.
1347ae38b5SPeter Wemm *
1447ae38b5SPeter Wemm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1547ae38b5SPeter Wemm * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1647ae38b5SPeter Wemm * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1747ae38b5SPeter Wemm * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1847ae38b5SPeter Wemm * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1947ae38b5SPeter Wemm * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2047ae38b5SPeter Wemm * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2147ae38b5SPeter Wemm * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2247ae38b5SPeter Wemm * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2347ae38b5SPeter Wemm * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2447ae38b5SPeter Wemm * SUCH DAMAGE.
2547ae38b5SPeter Wemm */
2647ae38b5SPeter Wemm
2732fdc423SDavid E. O'Brien#include <machine/asm.h>
2832fdc423SDavid E. O'Brien/*
2947ae38b5SPeter Wemm * Return floating point absolute value of a double.
3032fdc423SDavid E. O'Brien */
3132fdc423SDavid E. O'Brien
3247ae38b5SPeter Wemm	.text
3332fdc423SDavid E. O'BrienENTRY(fabs)
3447ae38b5SPeter Wemm	movsd	%xmm0, %xmm1
3547ae38b5SPeter Wemm	movsd	signbit(%rip), %xmm0
3647ae38b5SPeter Wemm	andnpd  %xmm1, %xmm0
3732fdc423SDavid E. O'Brien	ret
385d053f46SPeter WemmEND(fabs)
3947ae38b5SPeter Wemm
40*d218c6f6SKonstantin Belousov	.section .rodata
41f5480338SKonstantin Belousov	.p2align 3
4247ae38b5SPeter Wemmsignbit:
4347ae38b5SPeter Wemm	.quad	0x8000000000000000
4493ab7586SKonstantin Belousov
4593ab7586SKonstantin Belousov	.section .note.GNU-stack,"",%progbits
46