summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2017-09-13 06:43:49 +0200
committerEugen Wissner <belka@caraus.de>2017-09-13 06:43:49 +0200
commit3e9ca359da0c2fd1987399e59f282374f069872e (patch)
treeac3e60eca2452189225279150cbee7f403fa44e1 /arch
parent3705cf387ec9a87f0330766ccc933ff53f0bf530 (diff)
downloadtanya-3e9ca359da0c2fd1987399e59f282374f069872e.tar.gz
math: Add floating point support to abs
Diffstat (limited to 'arch')
-rw-r--r--arch/build.ninja3
-rw-r--r--arch/x64/linux/math/abs.S35
2 files changed, 37 insertions, 1 deletions
diff --git a/arch/build.ninja b/arch/build.ninja
index 42ee8f6..eff2eb9 100644
--- a/arch/build.ninja
+++ b/arch/build.ninja
@@ -4,6 +4,7 @@ rule gas
rule archive
command = ar rcs $out $in
+build abs.o: gas x64/linux/math/abs.S
build syscall.o: gas x64/linux/syscall.S
-build tanya.a: archive syscall.o
+build tanya.a: archive syscall.o abs.o
diff --git a/arch/x64/linux/math/abs.S b/arch/x64/linux/math/abs.S
new file mode 100644
index 0000000..edf8ac9
--- /dev/null
+++ b/arch/x64/linux/math/abs.S
@@ -0,0 +1,35 @@
+ .text
+
+
+// fabsf.
+ .globl _D5tanya4math8nbtheory10__T3absTfZ3absFNaNbNiNffZf
+ .type _D5tanya4math8nbtheory10__T3absTfZ3absFNaNbNiNffZf, @function
+
+_D5tanya4math8nbtheory10__T3absTfZ3absFNaNbNiNffZf:
+ mov $0x7fffffff, %eax
+ movq %rax, %xmm1
+ andpd %xmm1, %xmm0
+ ret
+
+
+// fabs.
+ .globl _D5tanya4math8nbtheory10__T3absTdZ3absFNaNbNiNfdZd
+ .type _D5tanya4math8nbtheory10__T3absTdZ3absFNaNbNiNfdZd, @function
+
+_D5tanya4math8nbtheory10__T3absTdZ3absFNaNbNiNfdZd:
+ mov $0x7fffffffffffffff, %rax
+ movq %rax, %xmm1
+ andpd %xmm1, %xmm0
+ ret
+
+
+// fabsl.
+ .globl _D5tanya4math8nbtheory10__T3absTeZ3absFNaNbNiNfeZe
+ .type _D5tanya4math8nbtheory10__T3absTeZ3absFNaNbNiNfeZe, @function
+
+// Load the parameter from the stack onto FP stack, execute 'fabs' instruction
+// The result is returned in ST0.
+_D5tanya4math8nbtheory10__T3absTeZ3absFNaNbNiNfeZe:
+ fldt 0x8(%rsp)
+ fabs
+ ret