Fix bugs and have emulator emulate itself

This commit is contained in:
Justine Tunney 2020-08-31 05:17:31 -07:00
parent 5aabacb361
commit bd29223891
111 changed files with 1283 additions and 2073 deletions

View file

@ -46,7 +46,7 @@ tinymath_acosl:
fsqrt
fabs # needed in downward rounding mode
#endif
fxch %st(1)
fxch
fpatan
pop %rbp
ret

View file

@ -51,5 +51,4 @@ tinymath_asinl:
.alias tinymath_asinl,asinl
.rodata.cst4
.align 4
.Lone: .float 1.0

View file

@ -27,7 +27,7 @@ tinymath_cabsl:
fldt 32(%rbp)
fldt 16(%rbp)
fmul %st,%st
fxch %st(1)
fxch
fmul %st,%st
faddp %st,%st(1)
fsqrt

View file

@ -29,7 +29,7 @@ tinymath_carg:
fldl -16(%rbp)
movsd %xmm1,-16(%rbp)
fldl -16(%rbp)
fxch %st(1)
fxch
fpatan
fstpl -16(%rbp)
movsd -16(%rbp),%xmm0

View file

@ -34,7 +34,7 @@ tinymath_exp10l:
fld %st
frndint
fsubr %st,%st(1)
fxch %st(1)
fxch
f2xm1
fld1
faddp

View file

@ -32,7 +32,7 @@ tinymath_exp2l:
fld %st
frndint
fsubr %st,%st(1)
fxch %st(1)
fxch
f2xm1
fadds .Lone(%rip)
fscale

View file

@ -34,7 +34,7 @@ tinymath_expl:
fld %st
frndint
fsubr %st,%st(1)
fxch %st(1)
fxch
f2xm1
fld1
faddp

View file

@ -25,14 +25,14 @@
tinymath_floor:
.leafprologue
.profilable
movsd .LC6(%rip),%xmm1
movsd .LC5(%rip),%xmm2
movsd 4f(%rip),%xmm1
movsd 3f(%rip),%xmm2
andpd %xmm0,%xmm1
comisd %xmm1,%xmm2
jbe 1f
cvttsd2siq %xmm0,%rax
pxor %xmm1,%xmm1
movsd .LC4(%rip),%xmm2
movsd 2f(%rip),%xmm2
cvtsi2sdq %rax,%xmm1
movapd %xmm1,%xmm3
cmpnlesd %xmm0,%xmm3
@ -45,13 +45,6 @@ tinymath_floor:
.alias tinymath_floor,floor
.rodata.cst8
.LC4: .long 0
.long 1072693248
.LC5: .long 0
.long 1127219200
.rodata.cst16
.LC6: .long 4294967295
.long 2147483647
.long 0
.long 0
2: .double 1
3: .double 0x0010000000000000
4: .double nan

View file

@ -1,45 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/math.h"
#include "libc/macros.h"
.source __FILE__
tinymath_fpclassify:
.leafprologue
movd %xmm0,%rax
movd %xmm0,%rdx
shr $52,%rax
mov %eax,%ecx
and $0x7ff,%ecx
jne 2f
add %rdx,%rdx
cmp $1,%rdx
sbb %eax,%eax
add $3,%eax
jmp 1f
2: mov $FP_NORMAL,%eax
cmp $0x7ff,%ecx
jne 1f
xor %eax,%eax
sal $12,%rdx
sete %al
1: .leafepilogue
.endfn tinymath_fpclassify,globl
.alias tinymath_fpclassify,__fpclassify

View file

@ -1,46 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/math.h"
#include "libc/macros.h"
.source __FILE__
tinymath_fpclassifyf:
.leafprologue
movd %xmm0,%edx
movd %xmm0,%eax
shr $23,%eax
and $255,%eax
je 7f
cmp $255,%eax
je 8f
mov $FP_NORMAL,%eax
jmp 1f
7: add %edx,%edx
je 5f
mov $FP_SUBNORMAL,%eax
jmp 1f
5: mov $FP_ZERO,%eax
jmp 1f
8: sal $9,%edx
sete %al
movzbl %al,%eax
1: .leafepilogue
.endfn tinymath_fpclassifyf,globl
.alias tinymath_fpclassifyf,__fpclassifyf

View file

@ -1,54 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/math.h"
#include "libc/macros.h"
.source __FILE__
tinymath_fpclassifyl:
push %rbp
mov %rsp,%rbp
mov 24(%rbp),%rax
mov 16(%rbp),%rdx
and $0x7fff,%ax
mov %rdx,%rcx
shr $63,%rcx
movzwl %ax,%esi
or %ecx,%esi
jne 2f
cmp $1,%rdx
sbb %eax,%eax
add $3,%eax
jmp 1f
2: cmp $0x7fff,%ax
jne 4f
xor %eax,%eax
test %rcx,%rcx
je 1f
xor %eax,%eax
add %rdx,%rdx
sete %al
jmp 1f
4: mov %ecx,%eax
neg %eax
and $FP_NORMAL,%eax
1: pop %rbp
ret
.endfn tinymath_fpclassifyl,globl
.alias tinymath_fpclassifyl,__fpclassifyl

View file

@ -28,7 +28,7 @@ tinymath_hypotl:
fldt 32(%rbp)
fldt 16(%rbp)
fmul %st,%st
fxch %st(1)
fxch
fmul %st,%st
faddp
pop %rbp

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
/ Returns log exponent part of double.
/ Returns log𝑥 exponent part of double.
/
/ @param 𝑥 is double passed in %xmm0
/ @return result in %eax

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
/ Returns log exponent part of float.
/ Returns logx exponent part of float.
/
/ @param 𝑥 is float passed in %xmm0
/ @return result in %eax

View file

@ -19,7 +19,7 @@
*/
#include "libc/macros.h"
/ Returns log exponent part of long double.
/ Returns logx exponent part of long double.
/
/ @param 𝑥 is long double passed on stack
/ @return result in %eax

View file

@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isgreaterf:
.leafprologue
.profilable
xor %eax,%eax
comiss %xmm1,%xmm0
seta %al
.leafepilogue
.endfn tinymath_isgreaterf,globl
.alias tinymath_isgreaterf,isgreaterf

View file

@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isgreaterequal:
.leafprologue
.profilable
xor %eax,%eax
comisd %xmm1,%xmm0
setnb %al
.leafepilogue
.endfn tinymath_isgreaterequal,globl
.alias tinymath_isgreaterequal,isgreaterequal

View file

@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isgreaterequalf:
.leafprologue
.profilable
xor %eax,%eax
comiss %xmm1,%xmm0
setnb %al
.leafepilogue
.endfn tinymath_isgreaterequalf,globl
.alias tinymath_isgreaterequalf,isgreaterequalf

View file

@ -1,36 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isgreaterequall:
push %rbp
mov %rsp,%rbp
.profilable
fldt 32(%rbp)
fldt 16(%rbp)
xor %eax,%eax
fcomip %st(1),%st
fstp %st
setnb %al
pop %rbp
ret
.endfn tinymath_isgreaterequall,globl
.alias tinymath_isgreaterequall,isgreaterequall

View file

@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isgreater:
.leafprologue
.profilable
xor %eax,%eax
comisd %xmm1,%xmm0
seta %al
.leafepilogue
.endfn tinymath_isgreater,globl
.alias tinymath_isgreater,isgreater

View file

@ -1,36 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isgreaterl:
push %rbp
mov %rsp,%rbp
.profilable
fldt 32(%rbp)
fldt 16(%rbp)
xor %eax,%eax
fcomip %st(1),%st
fstp %st
seta %al
pop %rbp
ret
.endfn tinymath_isgreaterl,globl
.alias tinymath_isgreaterl,isgreaterl

View file

@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isless:
.leafprologue
.profilable
xor %eax,%eax
comisd %xmm0,%xmm1
seta %al
.leafepilogue
.endfn tinymath_isless,globl
.alias tinymath_isless,isless

View file

@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_islessequal:
.leafprologue
.profilable
xor %eax,%eax
comisd %xmm0,%xmm1
setnb %al
.leafepilogue
.endfn tinymath_islessequal,globl
.alias tinymath_islessequal,islessequal

View file

@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_islessequalf:
.leafprologue
.profilable
xor %eax,%eax
comiss %xmm0,%xmm1
setnb %al
.leafepilogue
.endfn tinymath_islessequalf,globl
.alias tinymath_islessequalf,islessequalf

View file

@ -1,36 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_islessequall:
push %rbp
mov %rsp,%rbp
.profilable
fldt 16(%rbp)
xor %eax,%eax
fldt 32(%rbp)
fcomip %st(1),%st
fstp %st
setnb %al
pop %rbp
ret
.endfn tinymath_islessequall,globl
.alias tinymath_islessequall,islessequall

View file

@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_islessf:
.leafprologue
.profilable
xor %eax,%eax
comiss %xmm0,%xmm1
seta %al
.leafepilogue
.endfn tinymath_islessf,globl
.alias tinymath_islessf,islessf

View file

@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_islessgreater:
.leafprologue
.profilable
xor %eax,%eax
comisd %xmm1,%xmm0
setne %al
.leafepilogue
.endfn tinymath_islessgreater,globl
.alias tinymath_islessgreater,islessgreater

View file

@ -1,31 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_islessgreaterf:
.leafprologue
.profilable
xor %eax,%eax
comiss %xmm1,%xmm0
setne %al
.leafepilogue
.endfn tinymath_islessgreaterf,globl
.alias tinymath_islessgreaterf,islessgreaterf

View file

@ -1,36 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_islessgreaterl:
push %rbp
mov %rsp,%rbp
.profilable
fldt 16(%rbp)
xor %eax,%eax
fldt 32(%rbp)
fcomip %st(1),%st
fstp %st
setne %al
pop %rbp
ret
.endfn tinymath_islessgreaterl,globl
.alias tinymath_islessgreaterl,islessgreaterl

View file

@ -1,36 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_islessl:
push %rbp
mov %rsp,%rbp
.profilable
fldt 16(%rbp)
xor %eax,%eax
fldt 32(%rbp)
fcomip %st(1),%st
fstp %st
seta %al
pop %rbp
ret
.endfn tinymath_islessl,globl
.alias tinymath_islessl,islessl

View file

@ -1,29 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isunordered:
.leafprologue
.profilable
xor %eax,%eax
.leafepilogue
.endfn tinymath_isunordered,globl
.alias tinymath_isunordered,isunordered

View file

@ -1,29 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isunorderedf:
.leafprologue
.profilable
xor %eax,%eax
.leafepilogue
.endfn tinymath_isunorderedf,globl
.alias tinymath_isunorderedf,isunorderedf

View file

@ -1,29 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_isunorderedl:
.leafprologue
.profilable
xor %eax,%eax
.leafepilogue
.endfn tinymath_isunorderedl,globl
.alias tinymath_isunorderedl,isunorderedl

View file

@ -20,21 +20,26 @@
#include "libc/macros.h"
.source __FILE__
/ Returns 𝑥 × 2ʸ.
/
/ @param 𝑥 is double passed in %xmm0
/ @param 𝑦 is exponent via %edi
/ @return double in %xmm0
tinymath_ldexp:
push %rbp
mov %rsp,%rbp
.profilable
push %rax
movsd %xmm0,-8(%rbp)
fldl -8(%rbp)
mov %edi,-8(%rbp)
fildl -8(%rbp)
fxch %st(1)
push %rdi
fildl (%rsp)
movsd %xmm0,(%rsp)
fldl (%rsp)
fscale
fstp %st(1)
fstpl -8(%rbp)
movsd -8(%rbp),%xmm0
fstpl (%rsp)
movsd (%rsp),%xmm0
leave
ret
.endfn tinymath_ldexp,globl
.alias tinymath_ldexp,ldexp
.alias tinymath_ldexp,scalbn
.alias tinymath_ldexp,scalbln

View file

@ -20,21 +20,26 @@
#include "libc/macros.h"
.source __FILE__
/ Returns 𝑥 × 2ʸ.
/
/ @param 𝑥 is float passed in %xmm0
/ @param 𝑦 is exponent via %edi
/ @return float in %xmm0
tinymath_ldexpf:
push %rbp
mov %rsp,%rbp
.profilable
push %rax
movss %xmm0,-4(%rbp)
flds -4(%rbp)
movl %edi,-4(%rbp)
fildl -4(%rbp)
fxch %st(1)
push %rdi
fildl (%rsp)
movss %xmm0,(%rsp)
flds (%rsp)
fscale
fstp %st(1)
fstps -4(%rbp)
movss -4(%rbp),%xmm0
fstps (%rsp)
movss (%rsp),%xmm0
leave
ret
.endfn tinymath_ldexpf,globl
.alias tinymath_ldexpf,ldexpf
.alias tinymath_ldexpf,scalbnf
.alias tinymath_ldexpf,scalblnf

View file

@ -20,16 +20,23 @@
#include "libc/macros.h"
.source __FILE__
/ Returns 𝑥 × 2ʸ.
/
/ @param 𝑥 is long double passed on stack
/ @param 𝑦 is exponent via %edi
/ @return result in %st0
tinymath_ldexpl:
push %rbp
mov %rsp,%rbp
.profilable
sub $24,%rsp
fldt 32(%rsp)
movl %edi,12(%rsp)
fildl 12(%rsp)
fxch %st(1)
add $24,%rsp
push %rdi
fildl (%rsp)
fldt 16(%rbp)
fscale
fstp %st(1)
leave
ret
.endfn tinymath_ldexpl,globl
.alias tinymath_ldexpl,ldexpl
.alias tinymath_ldexpl,scalbnl
.alias tinymath_ldexpl,scalblnl

View file

@ -34,12 +34,12 @@ tinymath_log1p:
fld %st
fabs
fldt .LC16(%rip)
fxch %st(1)
fxch
fcomip %st(1),%st
fstp %st
jnb 1f
fldln2
fxch %st(1)
fxch
fyl2xp1
fstpl (%rsp)
vmovsd (%rsp),%xmm0
@ -48,7 +48,7 @@ tinymath_log1p:
1: fld1
faddp %st,%st(1)
fldln2
fxch %st(1)
fxch
fyl2x
fstpl (%rsp)
vmovsd (%rsp),%xmm0

View file

@ -34,12 +34,12 @@ tinymath_log1pf:
fld %st
fabs
fldt .LC16(%rip)
fxch %st(1)
fxch
fcomip %st(1),%st
fstp %st
jnb 2f
fldln2
fxch %st(1)
fxch
fyl2xp1
1: fstps -4(%rbp)
vmovss -4(%rbp),%xmm0
@ -48,7 +48,7 @@ tinymath_log1pf:
2: fld1
faddp %st,%st(1)
fldln2
fxch %st(1)
fxch
fyl2x
jmp 1b
.endfn tinymath_log1pf,globl

View file

@ -32,19 +32,19 @@ tinymath_log1pl:
fld %st
fabs
fldt .LC16(%rip)
fxch %st(1)
fxch
fcomip %st(1),%st
fstp %st
jnb 1f
fldln2
fxch %st(1)
fxch
fyl2xp1
0: pop %rbp
ret
1: fld1
faddp %st,%st(1)
fldln2
fxch %st(1)
fxch
fyl2x
jmp 0b
.endfn tinymath_log1pl,globl

View file

@ -39,7 +39,7 @@ tinymath_powl:
f2xm1
faddp
fscale
fxch %st(1)
fxch
fstp %st
pop %rbp
ret

View file

@ -20,21 +20,14 @@
#include "libc/macros.h"
.source __FILE__
/ Returns 𝑥 × 2ʸ.
/
/ @param 𝑥 is double passed in %xmm0
/ @param 𝑦 is double passed in %xmm1, which is truncated
/ @return result in %xmm0
/ @see ldexp()
tinymath_scalb:
push %rbp
mov %rsp,%rbp
.profilable
push %rax
movsd %xmm0,(%rsp)
fldl (%rsp)
movsd %xmm1,(%rsp)
fldl (%rsp)
fxch %st(1)
fscale
fstp %st(1)
fstpl (%rsp)
movsd (%rsp),%xmm0
leave
ret
cvttsd2si %xmm1,%edi
jmp tinymath_ldexp
.endfn tinymath_scalb,globl
.alias tinymath_scalb,scalb

View file

@ -20,21 +20,14 @@
#include "libc/macros.h"
.source __FILE__
/ Returns 𝑥 × 2ʸ.
/
/ @param 𝑥 is float passed in %xmm0
/ @param 𝑦 is float passed in %xmm1, which is truncated
/ @return result in %xmm0
/ @see ldexpf()
tinymath_scalbf:
push %rbp
mov %rsp,%rbp
.profilable
push %rax
movss %xmm0,-4(%rbp)
flds -4(%rbp)
movss %xmm1,-4(%rbp)
flds -4(%rbp)
fxch %st(1)
fscale
fstp %st(1)
fstps -4(%rbp)
movss -4(%rbp),%xmm0
leave
ret
cvttss2si %xmm1,%edi
jmp tinymath_ldexpf
.endfn tinymath_scalbf,globl
.alias tinymath_scalbf,scalbf

View file

@ -20,6 +20,12 @@
#include "libc/macros.h"
.source __FILE__
/ Returns 𝑥 × 2ʸ.
/
/ @param 𝑥 is long double passed on stack
/ @param 𝑦 is long double passed on stack
/ @return result in %st0
/ @see ldexpl()
tinymath_scalbl:
push %rbp
mov %rsp,%rbp

View file

@ -1,40 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_scalbln:
push %rbp
mov %rsp,%rbp
.profilable
push %rax
movsd %xmm0,-8(%rbp)
fldl -8(%rbp)
movq %rdi,-8(%rbp)
fildl -8(%rbp)
fxch %st(1)
fscale
fstp %st(1)
fstpl -8(%rbp)
movsd -8(%rbp),%xmm0
leave
ret
.endfn tinymath_scalbln,globl
.alias tinymath_scalbln,scalbln

View file

@ -1,40 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
tinymath_scalblnf:
push %rbp
mov %rsp,%rbp
.profilable
push %rax
movss %xmm0,(%rsp)
flds (%rsp)
movq %rdi,(%rsp)
fildl (%rsp)
fxch %st(1)
fscale
fstp %st(1)
fstps (%rsp)
movss (%rsp),%xmm0
leave
ret
.endfn tinymath_scalblnf,globl
.alias tinymath_scalblnf,scalblnf

View file

@ -1,44 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
/ Returns 𝑥 × 2ʸ.
/
/ @param 𝑥 is double passed in %xmm0
/ @param 𝑦 is exponent via %edi
tinymath_scalbn:
push %rbp
mov %rsp,%rbp
.profilable
push %rax
movsd %xmm0,-8(%rbp)
fldl -8(%rbp)
movl %edi,-8(%rbp)
fildl -8(%rbp)
fxch %st(1)
fscale
fstp %st(1)
fstpl -8(%rbp)
movsd -8(%rbp),%xmm0
leave
ret
.endfn tinymath_scalbn,globl
.alias tinymath_scalbn,scalbn

View file

@ -1,44 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
/ Returns 𝑥 × 2ʸ.
/
/ @param 𝑥 is float passed in %xmm0
/ @param 𝑦 is exponent via %edi
tinymath_scalbnf:
push %rbp
mov %rsp,%rbp
.profilable
push %rax
movss %xmm0,-4(%rbp)
flds -4(%rbp)
movl %edi,-4(%rbp)
fildl -4(%rbp)
fxch %st(1)
fscale
fstp %st(1)
fstps -4(%rbp)
movss -4(%rbp),%xmm0
leave
ret
.endfn tinymath_scalbnf,globl
.alias tinymath_scalbnf,scalbnf

View file

@ -1,40 +0,0 @@
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi
Copyright 2020 Justine Alexandra Roberts Tunney
This program is free software; you can redistribute it and/or modify │
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License. │
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of │
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software │
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA
*/
#include "libc/macros.h"
.source __FILE__
/ Returns 𝑥 × 2ʸ.
/
/ @param 𝑥 is long double passed on stack
/ @param 𝑦 is exponent via %edi
tinymath_scalbnl:
push %rbp
mov %rsp,%rbp
.profilable
fldt 16(%rsp)
push %rdi
fildl (%rsp)
fxch
fscale
fstp %st(1)
leave
ret
.endfn tinymath_scalbnl,globl
.alias tinymath_scalbnl,scalbnl

View file

@ -34,7 +34,7 @@ tinymath_sincos:
movsd %xmm0,-8(%rbp)
fldl -8(%rbp)
fsincos
fxch %st(1)
fxch
fstpl (%rdi)
fstpl (%rsi)
leave

View file

@ -34,7 +34,7 @@ tinymath_sincosf:
movss %xmm0,4(%rsp)
flds 4(%rsp)
fsincos
fxch %st(1)
fxch
fstps (%rdi)
fstps (%rsi)
leave

View file

@ -20,6 +20,10 @@
#include "libc/macros.h"
.source __FILE__
/ Returns square root of 𝑥.
/
/ @param 𝑥 is an double passed in %xmm0
/ @return result in %xmm0
tinymath_sqrt:
.leafprologue
.profilable

View file

@ -20,6 +20,10 @@
#include "libc/macros.h"
.source __FILE__
/ Returns square root of 𝑥.
/
/ @param 𝑥 is an float passed in %xmm0
/ @return result in %xmm0
tinymath_sqrtf:
.leafprologue
.profilable

View file

@ -43,11 +43,5 @@ tinymath_trunc:
.alias tinymath_trunc,trunc
.rodata.cst8
2: .long 0
.long 1127219200
.rodata.cst16
3: .long 4294967295
.long 2147483647
.long 0
.long 0
2: .double 0x0010000000000000
3: .double nan