summaryrefslogtreecommitdiff
path: root/string.s
diff options
context:
space:
mode:
authorMikhail Osipov <mike.osipov@gmail.com>2019-10-12 00:23:50 +0300
committerMikhail Osipov <mike.osipov@gmail.com>2019-10-12 00:23:50 +0300
commit2d78510b9af6f70ec34d77f0e047c698bdf061a9 (patch)
treef56f2c9d7c29952748d62aa99d6e8fdc76402ada /string.s
parent1248eae0617555a4f13f7bbee9f120ad3d46c5f3 (diff)
draftng
Diffstat (limited to 'string.s')
-rw-r--r--string.s21
1 files changed, 21 insertions, 0 deletions
diff --git a/string.s b/string.s
new file mode 100644
index 0000000..b6bc317
--- /dev/null
+++ b/string.s
@@ -0,0 +1,21 @@
+.include "lib.s"
+
+.globl strlen
+strlen:
+ prologue
+
+ backup %rdi, %rcx
+
+ movq 16(%rbp), %rdi
+ xorq %rax, %rax
+ movq $-1, %rcx
+
+ repne scasb
+
+ movq $-2, %rax
+ subq %rcx, %rax
+
+ restore %rdi, %rcx
+
+ leave
+ ret