summaryrefslogtreecommitdiff
path: root/arch/x64/linux/memory/copy.S
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2017-09-26 08:26:12 +0200
committerEugen Wissner <belka@caraus.de>2017-09-26 08:26:12 +0200
commitfaebf3e4d5f6fcdfe1ad9f30c75fb478a7259fd1 (patch)
treead53ce90a2314d4676331bce326c7b5aeb9a2f59 /arch/x64/linux/memory/copy.S
parent20e7df386bfd9449bf7fb0926918e176bb37140c (diff)
downloadtanya-faebf3e4d5f6fcdfe1ad9f30c75fb478a7259fd1.tar.gz
Fix #304
Replace inline assembly with GAS.
Diffstat (limited to 'arch/x64/linux/memory/copy.S')
-rw-r--r--arch/x64/linux/memory/copy.S67
1 files changed, 67 insertions, 0 deletions
diff --git a/arch/x64/linux/memory/copy.S b/arch/x64/linux/memory/copy.S
new file mode 100644
index 0000000..bf74e0f
--- /dev/null
+++ b/arch/x64/linux/memory/copy.S
@@ -0,0 +1,67 @@
+ .text
+
+/*
+ * copyMemory.
+ *
+ * rdi - source length
+ * rsi - source data.
+ * rdx - target length.
+ * rcx - target data.
+ */
+ .globl _D5tanya6memory2op10copyMemoryFNaNbNixAvAvZv
+ .type _D5tanya6memory2op10copyMemoryFNaNbNixAvAvZv, @function
+
+_D5tanya6memory2op10copyMemoryFNaNbNixAvAvZv:
+ mov %rdi, %rdx
+ mov %rcx, %rdi
+
+ cmp $0x08, %rdx
+ jc aligned_1
+ test $0x07, %edi
+ jz aligned_8
+
+ naligned:
+ movsb
+ dec %rdx
+ test $0x07, %edi
+ jnz naligned
+
+ aligned_8:
+ mov %rdx, %rcx
+ shr $0x03, %rcx
+ rep movsq
+ and $0x07, %edx
+ jz end
+
+ aligned_1:
+ // Write the remaining bytes
+ mov %rdx, %rcx
+ rep movsb
+
+ end:
+ ret
+
+/*
+ * moveMemory.
+ *
+ * rdi - source length
+ * rsi - source data.
+ * rdx - target length.
+ * rcx - target data.
+ */
+ .globl _D5tanya6memory2op10moveMemoryFNaNbNixAvAvZv
+ .type _D5tanya6memory2op10moveMemoryFNaNbNixAvAvZv, @function
+
+_D5tanya6memory2op10moveMemoryFNaNbNixAvAvZv:
+ mov %rdi, %rdx
+
+ lea -1(%rdx, %rsi), %rsi
+ lea -1(%rdx, %rcx), %rdi
+ mov %rdx, %rcx
+
+ std // Set the direction flag
+
+ rep movsb
+
+ cld // Clear the direction flag
+ ret