On 07.09.2016 17:21, lhmouse wrote:
(I don't write AT&T assembly so I am unable to make a patch.
Nevertheless I hope someone who writes AT&T assembly could fix it.)
I don't have time to write a patch but I can donate some code that AFAIK does what you need for the
sin functions.
>gcc -m32 sinl32.s sin.c
>a
sinl = -5.421010862427522170037264e-020
my_sinl = -0.000000000000000000000000e+000
sin = 1.224606353822377258211418e-016
my_sin = 1.225148454908620010428422e-016
sinf = -8.7422776573475858e-008
my_sinf = -8.7422780003674585e-008
>gcc -m64 sinl64.s sin.c
>a
sinl = -5.421010862427522170037264e-020
my_sinl = -0.000000000000000000000000e+000
sin = 1.224606353822377258211418e-016
my_sin = 1.225148454908620010428422e-016
sinf = -8.7422776573475858e-008
my_sinf = -8.7422776573475858e-008
Regards
Thomas
#define __USE_MINGW_ANSI_STDIO 1
#include <stdio.h>
#include <math.h>
#if defined(__x86_64__)
extern long double my_sinl64(long double x);
extern double my_sin64(double x);
extern float my_sinf64(float x);
#else
extern long double __cdecl my_sinl32(long double x);
extern double __cdecl my_sin32(double x);
extern float __cdecl my_sinf32(float x);
#endif
void
main()
{
const long double thetal = atanl(1.0l) * 4.0l;
printf(" sinl = %.24Le\n", sinl(thetal));
#if defined(__x86_64__)
printf(" my_sinl = %.24Le\n", my_sinl64(thetal));
#else
printf(" my_sinl = %.24Le\n", my_sinl32(thetal));
#endif
printf(" sin = %.24le\n", sin((double)thetal));
#if defined(__x86_64__)
printf(" my_sin = %.24le\n", my_sin64((double)thetal));
#else
printf(" my_sin = %.24le\n", my_sin32((double)thetal));
#endif
printf(" sinf = %.16e\n", sinf((float)thetal));
#if defined(__x86_64__)
printf(" my_sinf = %.16e\n", my_sinf64((float)thetal));
#else
printf(" my_sinf = %.16e\n", my_sinf32((float)thetal));
#endif
}
.macro M_FSIN
2: fprem1
fnstsw %ax
sahf
jp 2b
fstp %st(1)
fsin
testw $0x200, %ax
jz 1f
fchs
1:
.endm
.text
.align 4
.globl _my_sinl32
_my_sinl32:
fldpi
fldt 4(%esp)
M_FSIN
ret
.align 4
.globl _my_sin32
_my_sin32:
fldpi
fldl 4(%esp)
M_FSIN
ret
.align 4
.globl _my_sinf32
_my_sinf32:
fldpi
flds 4(%esp)
M_FSIN
ret
.macro M_FSIN
2: fprem1
fnstsw %ax
sahf
jp 2b
fstp %st(1)
fsin
testw $0x200, %ax
jz 1f
fchs
1:
.endm
.text
.globl my_sinl64
my_sinl64:
fldpi
fldt (%rdx)
M_FSIN
movq %rcx, %rax
fstpt (%rcx)
ret
.globl my_sin64
my_sin64:
fldpi
movsd %xmm0, 8(%rsp)
fldl 8(%rsp)
M_FSIN
fstpl 8(%rsp)
movsd 8(%rsp), %xmm0
ret
.globl my_sinf64
my_sinf64:
fldpi
movss %xmm0, 8(%rsp)
flds 8(%rsp)
M_FSIN
fstps 8(%rsp)
movss 8(%rsp), %xmm0
ret
------------------------------------------------------------------------------
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public