mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Fix bugs and have emulator emulate itself
This commit is contained in:
parent
5aabacb361
commit
bd29223891
111 changed files with 1283 additions and 2073 deletions
|
@ -1,7 +1,6 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_BITS_SAFEMACROS_H_
|
||||
#define COSMOPOLITAN_LIBC_BITS_SAFEMACROS_H_
|
||||
#ifndef __STRICT_ANSI__
|
||||
#include "libc/limits.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/dns/consts.h"
|
||||
#include "libc/dns/dns.h"
|
||||
|
@ -92,8 +93,8 @@ int resolvedns(const struct ResolvConf *resolvconf, int af, const char *name,
|
|||
}
|
||||
if (p + 2 + 2 + 4 + 2 < pe) {
|
||||
uint16_t rtype, rclass, rdlength;
|
||||
rtype = read16be(p), p += 2;
|
||||
rclass = read16be(p), p += 2;
|
||||
rtype = READ16BE(p), p += 2;
|
||||
rclass = READ16BE(p), p += 2;
|
||||
/* ttl */ p += 4;
|
||||
rdlength = read16be(p), p += 2;
|
||||
if (p + rdlength <= pe && rdlength == 4 &&
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_FMT_PFLINK_H_
|
||||
#define COSMOPOLITAN_LIBC_FMT_PFLINK_H_
|
||||
#include "libc/dce.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
#ifndef __STRICT_ANSI__
|
||||
#include "libc/dce.h"
|
||||
|
||||
/**
|
||||
* @fileoverview builtin+preprocessor+linker tricks for printf/scanf.
|
||||
|
|
|
@ -18,16 +18,16 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/shufpd.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
* Shuffles double vector.
|
||||
* @param 𝑚 needs to be a literal, constexpr, or embedding
|
||||
* @mayalias
|
||||
*/
|
||||
void(shufpd)(double b[2], const double a[2], uint8_t m) {
|
||||
void(shufpd)(double c[2], const double b[2], const double a[2], uint8_t m) {
|
||||
double t[2];
|
||||
t[0] = a[(m & 0b0000001) >> 0];
|
||||
t[1] = a[(m & 0b0000010) >> 1];
|
||||
b[0] = t[0];
|
||||
b[1] = t[1];
|
||||
t[1] = b[(m & 0b0000010) >> 1];
|
||||
memcpy(c, t, 16);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
void shufpd(double[2], const double[2], uint8_t);
|
||||
void shufpd(double[2], const double[2], const double[2], uint8_t);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -18,20 +18,18 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/intrin/shufps.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
/**
|
||||
* Shuffles float vector.
|
||||
* @param 𝑚 needs to be a literal, constexpr, or embedding
|
||||
* @mayalias
|
||||
*/
|
||||
void(shufps)(float b[4], const float a[4], uint8_t m) {
|
||||
void(shufps)(float c[4], const float b[4], const float a[4], uint8_t m) {
|
||||
float t[4];
|
||||
t[0] = a[(m & 0b00000011) >> 0];
|
||||
t[1] = a[(m & 0b00001100) >> 2];
|
||||
t[0] = b[(m & 0b00000011) >> 0];
|
||||
t[1] = b[(m & 0b00001100) >> 2];
|
||||
t[2] = a[(m & 0b00110000) >> 4];
|
||||
t[3] = a[(m & 0b11000000) >> 6];
|
||||
b[0] = t[0];
|
||||
b[1] = t[1];
|
||||
b[2] = t[2];
|
||||
b[3] = t[3];
|
||||
memcpy(c, t, 16);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
void shufps(float[4], const float[4], uint8_t);
|
||||
void shufps(float[4], const float[4], const float[4], uint8_t);
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_LOG_LOG_H_
|
||||
#define COSMOPOLITAN_LIBC_LOG_LOG_H_
|
||||
#include "libc/dce.h"
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § liblog ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
|
26
libc/math.h
26
libc/math.h
|
@ -80,11 +80,20 @@ typedef float float_t;
|
|||
typedef double double_t;
|
||||
#endif
|
||||
|
||||
#define isinf(x) __builtin_isinf(x)
|
||||
#define isnan(x) __builtin_isnan(x)
|
||||
#define isfinite(x) __builtin_isfinite(x)
|
||||
#define isnormal(x) __builtin_isnormal(x)
|
||||
#define signbit(x) __builtin_signbit(x)
|
||||
#define isinf(x) __builtin_isinf(x)
|
||||
#define isnan(x) __builtin_isnan(x)
|
||||
#define isfinite(x) __builtin_isfinite(x)
|
||||
#define isnormal(x) __builtin_isnormal(x)
|
||||
#define signbit(x) __builtin_signbit(x)
|
||||
#define isgreater(x, y) __builtin_isgreater(x, y)
|
||||
#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
|
||||
#define isless(x, y) __builtin_isless(x, y)
|
||||
#define islessequal(x, y) __builtin_islessequal(x, y)
|
||||
#define islessgreater(x, y) __builtin_islessgreater(x, y)
|
||||
#define isunordered(x, y) __builtin_isunordered(x, y)
|
||||
|
||||
#define fpclassify(x) \
|
||||
__builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
|
||||
|
||||
double acos(double);
|
||||
double acosh(double);
|
||||
|
@ -276,13 +285,6 @@ void sincos(double, double *, double *);
|
|||
void sincosf(float, float *, float *);
|
||||
void sincosl(long double, long double *, long double *);
|
||||
|
||||
int __fpclassify(double);
|
||||
int __fpclassifyf(float);
|
||||
int __fpclassifyl(long double);
|
||||
#define fpclassify(X) \
|
||||
(sizeof(X) == 8 ? __fpclassify(X) \
|
||||
: sizeof(X) == 4 ? __fpclassifyf(X) : __fpclassifyl(X))
|
||||
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
│ cosmopolitan § mathematics » x87 ─╬─│┼
|
||||
╚────────────────────────────────────────────────────────────────────────────│*/
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* generate code that calls MS ABI functions directly, without needing
|
||||
* to jump through the assembly thunks.
|
||||
*/
|
||||
#if __GNUC__ * 100 + __GNUC_MINOR_ >= 408 || \
|
||||
#if __GNUC__ * 100 + __GNUC_MINOR__ >= 408 || \
|
||||
(__has_attribute(__ms_abi__) || defined(__llvm__))
|
||||
#define __msabi __attribute__((__ms_abi__))
|
||||
#endif
|
||||
|
|
|
@ -45,15 +45,15 @@ COSMOPOLITAN_C_START_
|
|||
#endif
|
||||
|
||||
#define kNtSioSocketCloseNotify 0x9800000Du
|
||||
#define kNtSioUdpConnreset 0x9800000Cu
|
||||
#define kNtSioUdpNetreset 0x9800000F
|
||||
#define kNtSioUdpConnreset 0x9800000Cu
|
||||
#define kNtSioUdpNetreset 0x9800000F
|
||||
|
||||
#define kNtTfDisconnect 0x01
|
||||
#define kNtTfReuseSocket 0x02
|
||||
#define kNtTfWriteBehind 0x04
|
||||
#define kNtTfDisconnect 0x01
|
||||
#define kNtTfReuseSocket 0x02
|
||||
#define kNtTfWriteBehind 0x04
|
||||
#define kNtTfUseDefaultWorker 0x00
|
||||
#define kNtTfUseSystemThread 0x10
|
||||
#define kNtTfUseKernelApc 0x20
|
||||
#define kNtTfUseSystemThread 0x10
|
||||
#define kNtTfUseKernelApc 0x20
|
||||
|
||||
struct sockaddr;
|
||||
struct sockaddr_in;
|
||||
|
@ -295,8 +295,8 @@ struct NtWsaCompletion {
|
|||
* functions are declared within their respective wrappers.
|
||||
*/
|
||||
|
||||
nodiscard int32_t WSAStartup(uint16_t wVersionRequested,
|
||||
struct NtWsaData *lpWSAData) paramsnonnull();
|
||||
int32_t WSAStartup(uint16_t wVersionRequested, struct NtWsaData *lpWSAData)
|
||||
paramsnonnull() nodiscard;
|
||||
|
||||
int WSACleanup(void);
|
||||
int WSAGetLastError(void);
|
||||
|
@ -312,9 +312,9 @@ int __listen$nt(uint64_t, int);
|
|||
int __setsockopt$nt(uint64_t, int, int, const void *, int);
|
||||
int __shutdown$nt(uint64_t, int);
|
||||
|
||||
nodiscard uint64_t WSASocket(int af, int type, int protocol,
|
||||
const struct NtWsaProtocolInfo *opt_lpProtocolInfo,
|
||||
const uint32_t opt_group, uint32_t dwFlags);
|
||||
uint64_t WSASocket(int af, int type, int protocol,
|
||||
const struct NtWsaProtocolInfo *opt_lpProtocolInfo,
|
||||
const uint32_t opt_group, uint32_t dwFlags) nodiscard;
|
||||
|
||||
int WSAConnect(uint64_t s, const struct sockaddr *name, const int namelen,
|
||||
const struct iovec$nt *opt_lpCallerData,
|
||||
|
@ -340,11 +340,11 @@ bool32 WSAConnectByList(uint64_t s,
|
|||
const struct timeval$nt *opt_timeout,
|
||||
struct NtOverlapped *__Reserved) paramsnonnull((2));
|
||||
|
||||
nodiscard int64_t WSAAccept(uint64_t s, struct sockaddr *out_addr,
|
||||
int32_t *opt_inout_addrlen,
|
||||
const NtConditionProc opt_lpfnCondition,
|
||||
const uint32_t *opt_dwCallbackData)
|
||||
paramsnonnull((2));
|
||||
int64_t WSAAccept(uint64_t s, struct sockaddr *out_addr,
|
||||
int32_t *opt_inout_addrlen,
|
||||
const NtConditionProc opt_lpfnCondition,
|
||||
const uint32_t *opt_dwCallbackData)
|
||||
paramsnonnull((2)) nodiscard;
|
||||
|
||||
int WSASend(uint64_t s, const struct iovec$nt *lpBuffers,
|
||||
uint32_t dwBufferCount, uint32_t *opt_out_lpNumberOfBytesSent,
|
||||
|
@ -406,7 +406,7 @@ int WSANSPIoctl(int64_t hLookup, uint32_t dwControlCode,
|
|||
const struct NtWsaCompletion *opt_lpCompletion)
|
||||
paramsnonnull((3, 5, 7));
|
||||
|
||||
nodiscard int64_t WSACreateEvent(void);
|
||||
int64_t WSACreateEvent(void) nodiscard;
|
||||
bool32 WSACloseEvent(const int64_t hEvent);
|
||||
bool32 WSAResetEvent(const int64_t hEvent);
|
||||
bool32 WSASetEvent(const int64_t hEvent);
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/dce.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/str/str.h"
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
│ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA │
|
||||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/bits.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/calls/struct/sigset.h"
|
||||
|
@ -71,7 +72,7 @@ privileged void __hook(void ifunc(void), struct SymbolTable *symbols) {
|
|||
pe = (unsigned char *)(symbols->addr_base +
|
||||
symbols->symbols[i + 1].addr_rva);
|
||||
p < pe - 8; ++p) {
|
||||
code = read64le(p);
|
||||
code = READ64LE(p);
|
||||
|
||||
/*
|
||||
* Test for -mrecord-mcount (w/ -fpie or -fpic)
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
│ 02110-1301 USA │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/assert.h"
|
||||
#include "libc/dce.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/runtime/memtrack.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
#define kMappingsSize 0x100000000000 /* 16TB */
|
||||
#define kMappingsSize 0x0000100000000000 /* 16TB */
|
||||
#define kMappingsStart (IsGenuineCosmo() ? 0x300000000000 : 0x200000000000)
|
||||
#define kFixedMappingsStart 0x0000100000000000
|
||||
#define kFixedMappingsSize kMappingsSize
|
||||
|
|
|
@ -129,7 +129,7 @@ void *mmap(void *addr, size_t size, int prot, int flags, int fd, int64_t off) {
|
|||
if (!CANONICAL(addr)) return VIP(einval());
|
||||
if (!(!!(flags & MAP_ANONYMOUS) ^ (fd != -1))) return VIP(einval());
|
||||
if (!(!!(flags & MAP_PRIVATE) ^ !!(flags & MAP_SHARED))) return VIP(einval());
|
||||
if (fd != -1) size = ROUNDUP(size, FRAMESIZE);
|
||||
if (fd == -1) size = ROUNDUP(size, FRAMESIZE);
|
||||
if (flags & MAP_FIXED) {
|
||||
if (UntrackMemoryIntervals(addr, size) == -1) {
|
||||
return MAP_FAILED;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_RUNTIME_RUNTIME_H_
|
||||
#define COSMOPOLITAN_LIBC_RUNTIME_RUNTIME_H_
|
||||
#include "libc/dce.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_STR_STR_H_
|
||||
#define COSMOPOLITAN_LIBC_STR_STR_H_
|
||||
#include "libc/bits/bits.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
/*───────────────────────────────────────────────────────────────────────────│─╗
|
||||
|
|
|
@ -46,7 +46,7 @@ tinymath_acosl:
|
|||
fsqrt
|
||||
fabs # needed in downward rounding mode
|
||||
#endif
|
||||
fxch %st(1)
|
||||
fxch
|
||||
fpatan
|
||||
pop %rbp
|
||||
ret
|
||||
|
|
|
@ -51,5 +51,4 @@ tinymath_asinl:
|
|||
.alias tinymath_asinl,asinl
|
||||
|
||||
.rodata.cst4
|
||||
.align 4
|
||||
.Lone: .float 1.0
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -34,7 +34,7 @@ tinymath_exp10l:
|
|||
fld %st
|
||||
frndint
|
||||
fsubr %st,%st(1)
|
||||
fxch %st(1)
|
||||
fxch
|
||||
f2xm1
|
||||
fld1
|
||||
faddp
|
||||
|
|
|
@ -32,7 +32,7 @@ tinymath_exp2l:
|
|||
fld %st
|
||||
frndint
|
||||
fsubr %st,%st(1)
|
||||
fxch %st(1)
|
||||
fxch
|
||||
f2xm1
|
||||
fadds .Lone(%rip)
|
||||
fscale
|
||||
|
|
|
@ -34,7 +34,7 @@ tinymath_expl:
|
|||
fld %st
|
||||
frndint
|
||||
fsubr %st,%st(1)
|
||||
fxch %st(1)
|
||||
fxch
|
||||
f2xm1
|
||||
fld1
|
||||
faddp
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Returns log₂ₓ exponent part of float.
|
||||
/ Returns log₂x exponent part of float.
|
||||
/
|
||||
/ @param 𝑥 is float passed in %xmm0
|
||||
/ @return result in %eax
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.h"
|
||||
|
||||
/ Returns log₂ₓ exponent part of long double.
|
||||
/ Returns log₂x exponent part of long double.
|
||||
/
|
||||
/ @param 𝑥 is long double passed on stack
|
||||
/ @return result in %eax
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -39,7 +39,7 @@ tinymath_powl:
|
|||
f2xm1
|
||||
faddp
|
||||
fscale
|
||||
fxch %st(1)
|
||||
fxch
|
||||
fstp %st
|
||||
pop %rbp
|
||||
ret
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
|
@ -34,7 +34,7 @@ tinymath_sincos:
|
|||
movsd %xmm0,-8(%rbp)
|
||||
fldl -8(%rbp)
|
||||
fsincos
|
||||
fxch %st(1)
|
||||
fxch
|
||||
fstpl (%rdi)
|
||||
fstpl (%rsi)
|
||||
leave
|
||||
|
|
|
@ -34,7 +34,7 @@ tinymath_sincosf:
|
|||
movss %xmm0,4(%rsp)
|
||||
flds 4(%rsp)
|
||||
fsincos
|
||||
fxch %st(1)
|
||||
fxch
|
||||
fstps (%rdi)
|
||||
fstps (%rsi)
|
||||
leave
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue