diff options
| author | Eugen Wissner <belka@caraus.de> | 2017-10-02 14:55:30 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2017-10-02 14:55:30 +0200 |
| commit | e4cd57a61543833c00b3e6a7254962b385db5ef2 (patch) | |
| tree | b09424a4182169072987ade67fa4661794d8b451 /arch | |
| parent | 74b085b88d4e44a6d5b175c6ef954acee8e1619d (diff) | |
| download | tanya-e4cd57a61543833c00b3e6a7254962b385db5ef2.tar.gz | |
math.nbtheory: Implement natural logarithm
Diffstat (limited to 'arch')
| -rw-r--r-- | arch/build.ninja | 3 | ||||
| -rw-r--r-- | arch/x64/linux/math/log.S | 48 |
2 files changed, 50 insertions, 1 deletions
diff --git a/arch/build.ninja b/arch/build.ninja index fce2838..824efa4 100644 --- a/arch/build.ninja +++ b/arch/build.ninja @@ -5,9 +5,10 @@ rule archive command = ar rcs $out $in build abs.o: gas x64/linux/math/abs.S +build log.o: gas x64/linux/math/log.S build cmp.o: gas x64/linux/memory/cmp.S build fill.o: gas x64/linux/memory/fill.S build copy.o: gas x64/linux/memory/copy.S build syscall.o: gas x64/linux/syscall.S -build tanya.a: archive syscall.o copy.o fill.o cmp.o abs.o +build tanya.a: archive syscall.o copy.o fill.o cmp.o log.o abs.o diff --git a/arch/x64/linux/math/log.S b/arch/x64/linux/math/log.S new file mode 100644 index 0000000..7f23703 --- /dev/null +++ b/arch/x64/linux/math/log.S @@ -0,0 +1,48 @@ + .text + + +// logl. + .globl _D5tanya4math8nbtheory2lnFNaNbNiNfeZe + .type _D5tanya4math8nbtheory2lnFNaNbNiNfeZe, @function + +_D5tanya4math8nbtheory2lnFNaNbNiNfeZe: + fldln2 // Put lb(e) onto the FPU stack + fldt 8(%rsp) // Put the argument onto the FPU stack + fyl2x // %st1 * lb(%st0) + ret + + +// log. + .globl _D5tanya4math8nbtheory2lnFNaNbNiNfdZd + .type _D5tanya4math8nbtheory2lnFNaNbNiNfdZd, @function + +_D5tanya4math8nbtheory2lnFNaNbNiNfdZd: + movsd %xmm0, -8(%rsp) // Put the argument onto the stack + + fldln2 // Put lb(e) onto the FPU stack + fldl -8(%rsp) // Put a double onto the FPU stack + fyl2x // %st1 * lb(%st0) + + // The result is on the FPU stack, but returned in %xmm0 + fstpl -8(%rsp) + movsd -8(%rsp), %xmm0 + + ret + + +// logf. + .globl _D5tanya4math8nbtheory2lnFNaNbNiNffZf + .type _D5tanya4math8nbtheory2lnFNaNbNiNffZf, @function + +_D5tanya4math8nbtheory2lnFNaNbNiNffZf: + movss %xmm0, -4(%rsp) // Put the argument onto the stack + + fldln2 // Put lb(e) onto the FPU stack + flds -4(%rsp) // Put a float onto the FPU stack + fyl2x // %st1 * lb(%st0) + + // The result is on the FPU stack, but returned in %xmm0 + fstps -4(%rsp) + movss -4(%rsp), %xmm0 + + ret |
