diff options
Diffstat (limited to 'zap/source/amd64/mem/streq.S')
-rw-r--r-- | zap/source/amd64/mem/streq.S | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/zap/source/amd64/mem/streq.S b/zap/source/amd64/mem/streq.S index 4270e7d..e054531 100644 --- a/zap/source/amd64/mem/streq.S +++ b/zap/source/amd64/mem/streq.S @@ -5,39 +5,43 @@ .globl zap_streq zap_streq: - # rdi: Address of the current left character. - # rsi: Address of the current right character. - # rax: Current left character. - # rdx: Current right character. +# Address of the current left character: +#define laddr %rdi +# Address of the current right character: +#define raddr %rsi +# Current left character: +#define lchr %al +# Current right character: +#define rchr %dl # Iterate over the strings: .loop: # Copy the characters into registers: - movb (%rdi),%al - movb (%rsi),%dl + movb (laddr),lchr # lchr = *laddr + movb (raddr),rchr # rchr = *raddr # Check if the characters are equal: - cmpb %al,%dl - jne .neq # If not, the strings also aren't equal. + cmpb lchr,rchr # if (lchr != rchr) + jne .neq # goto neq // If not, the strings also aren't equal. # Check if we have reached the null-terminator: - testb %al,%al - jz .eq # If so, all previous characters have compared equal, and the strings are equal. + testb lchr,lchr # if (lchr == 0x0) + jz .eq # goto eq // If so, all previous characters have compared equal, and the strings are equal. # Continue to the next characters: - incq %rdi - incq %rsi - jmp .loop + incq laddr # ++laddr + incq raddr # ++raddr + jmp .loop # goto loop # The strings have compared equal: .eq: movb $0xFF,%al - ret + ret # return FF - /* The strings have compared unequal: */ + # The strings have compared unequal: .neq: movb $0x0,%al - ret + ret # return 0 |