summaryrefslogtreecommitdiff
path: root/zap/source/amd64/mem/strfill.S
diff options
context:
space:
mode:
Diffstat (limited to 'zap/source/amd64/mem/strfill.S')
-rw-r--r--zap/source/amd64/mem/strfill.S25
1 files changed, 14 insertions, 11 deletions
diff --git a/zap/source/amd64/mem/strfill.S b/zap/source/amd64/mem/strfill.S
index 590b99f..f570a35 100644
--- a/zap/source/amd64/mem/strfill.S
+++ b/zap/source/amd64/mem/strfill.S
@@ -5,30 +5,33 @@
.globl zap_strfill
zap_strfill:
- # rdi: Address of the first character of the string.
- # rsi: Fill character.
- # rax: Address of the current character.
+# Address of the current character:
+#define addr %rax
+# Address of the first character of the string:
+#define start %rdi
+# Fill character:
+#define chr %sil
- movq %rdi,%rax
+ movq start,addr
# Iterate over string:
.loop:
# Check if we have reached the null-terminator:
- cmpb $0x0,(%rax)
- je .done # Exit loop if we have.
+ cmpb $0x0,(addr) # if (*addr == 0x0)
+ je .done # goto done
# Set the value of the current element:
- movb %sil,(%rax)
+ movb chr,(addr) # *addr = chr
# Continue to next character:
- incq %rax
- jmp .loop
+ incq addr # ++addr
+ jmp .loop # goto loop
# Finish:
.done:
# Get the length of the string:
- subq %rdi,%rax
+ subq start,addr # addr -= start
- ret
+ ret # return addr