summaryrefslogtreecommitdiff
path: root/zap/source/amd64/mem/memfill.S
diff options
context:
space:
mode:
Diffstat (limited to 'zap/source/amd64/mem/memfill.S')
-rw-r--r--zap/source/amd64/mem/memfill.S24
1 files changed, 14 insertions, 10 deletions
diff --git a/zap/source/amd64/mem/memfill.S b/zap/source/amd64/mem/memfill.S
index e563b55..c38eec8 100644
--- a/zap/source/amd64/mem/memfill.S
+++ b/zap/source/amd64/mem/memfill.S
@@ -5,26 +5,30 @@
.globl zap_memfill
zap_memfill:
- # rdi: Address of the current element.
- # rsi: Address of the element after the last element.
- # rdx: Byte value.
+# Address of the current element:
+#define addr %rdi
+# Address of the element after the last element:
+#define afterbuf %rsi
+# Byte value:
+#define val %dl
- addq %rdi,%rsi
+ addq addr,afterbuf # afterbuf += addr // afterbuf contains the number of bytes
# Iterate over buffer:
.loop:
# Check if we have reached the final element:
- cmpq %rdi,%rsi
- je .done # Exit loop if we have.
+ cmpq addr,afterbuf # if (addr == afterbuf)
+ je .done # goto done
# Set the value of the current element:
- movb %dl,(%rdi)
+ movb val,(addr) # *addr = val
# Continue to next element:
- incq %rdi
- jmp .loop
+ incq addr # ++addr
+ jmp .loop # goto loop
# Finish:
.done:
- ret
+
+ ret # return