summaryrefslogtreecommitdiff
path: root/zap/source/amd64/mem/strlen.S
diff options
context:
space:
mode:
Diffstat (limited to 'zap/source/amd64/mem/strlen.S')
-rw-r--r--zap/source/amd64/mem/strlen.S25
1 files changed, 14 insertions, 11 deletions
diff --git a/zap/source/amd64/mem/strlen.S b/zap/source/amd64/mem/strlen.S
index e8739e2..a3f68b1 100644
--- a/zap/source/amd64/mem/strlen.S
+++ b/zap/source/amd64/mem/strlen.S
@@ -5,30 +5,33 @@
.globl zap_strlen
zap_strlen:
- # rax: Address of the current character.
- # rdi: Address of the first character.
- # rdx: Current character.
+# Address of the current character:
+#define addr %rax
+# Address of the first character:
+#define start %rdi
+# Current character:
+#define chr %dl
- movq %rdi,%rax
+ movq start,addr
# Iterate over the string:
.loop:
# Move the character into a register:
- movb (%rax),%dl
+ movb (addr),chr # chr = *addr
# Check if we have reached the null-terminator:
- testb %dl,%dl
- jz .done # If so, we are done.
+ testb chr,chr # if (chr == 0x0)
+ jz .done # goto done
# Continue to the next character:
- incq %rax
- jmp .loop
+ incq addr # ++addr
+ jmp .loop # goto loop
# Done:
.done:
# Get the length:
- subq %rdi,%rax
+ subq start,addr # addr -= start
- ret
+ ret # return addr