summaryrefslogtreecommitdiff
path: root/zap/source/amd64/mem/strcp.S
diff options
context:
space:
mode:
Diffstat (limited to 'zap/source/amd64/mem/strcp.S')
-rw-r--r--zap/source/amd64/mem/strcp.S34
1 files changed, 19 insertions, 15 deletions
diff --git a/zap/source/amd64/mem/strcp.S b/zap/source/amd64/mem/strcp.S
index eb5c276..820ed96 100644
--- a/zap/source/amd64/mem/strcp.S
+++ b/zap/source/amd64/mem/strcp.S
@@ -5,35 +5,39 @@
.globl zap_strcp
zap_strcp:
- # rax: Address of the current input character.
- # rdi: Address of the first input character.
- # rsi: Address of the current output character.
- # rdx: Current character.
+# Address of the current input character:
+#define iaddr %rax
+# Address of the first input character:
+#define start %rdi
+# Address of the current output character:
+#define oaddr %rsi
+# Current character:
+#define chr %dl
- movq %rdi,%rax
+ movq start,iaddr
# Iterate over the strings:
.loop:
# Copy character:
- movb (%rax),%dl # Move it into a register...
- movb %dl,(%rsi) # ... and then back into memory.
+ movb (iaddr),chr # chr = *iaddr
+ movb chr,(oaddr) # *oaddr = chr
# Check if we have reached the null-terminator:
- testb %dl,%dl
- jz .done
+ testb chr,chr # if (chr == 0x0)
+ jz .done # goto done
# Continue to the next character:
- incq %rax
- incq %rsi
- jmp .loop
+ incq iaddr # ++iaddr
+ incq oaddr # ++oaddr
+ jmp .loop # goto loop
# Finish:
.done:
# Get the length of the (input) string:
- subq %rdi,%rax
- decq %rax # We do not count the null-terminator in the string length.
+ subq start,iaddr # iaddr -= start
+ decq iaddr # --iaddr // We do not count the null-terminator in the string length.
- ret
+ ret # return iaddr