aboutsummaryrefslogtreecommitdiffstats
path: root/src/u_strncmp.S
diff options
context:
space:
mode:
Diffstat (limited to 'src/u_strncmp.S')
-rw-r--r--src/u_strncmp.S33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/u_strncmp.S b/src/u_strncmp.S
index 9c90cd0..aafa721 100644
--- a/src/u_strncmp.S
+++ b/src/u_strncmp.S
@@ -49,8 +49,33 @@
.globl u_strncmp
u_strncmp:
-# xor %rcx, %rcx
-# dec %rdx
-#.u.loop
-# cmpb (%rsi)
+ xor %rcx, %rcx
+ dec %rdx
+.u.loop:
+ xor %r8, %r8
+ xor %r9, %r9
+ movb (%rdi, %rcx), %r8b
+ movb (%rsi, %rcx), %r9b
+ cmpb %r8b, %r9b
+ jne .u.retdiff
+ cmp %rdx, %rcx
+ jge .u.retdiff
+ cmpb $0x0, (%rdi, %rcx)
+ jne .u.inc
+ cmpb $0x0, (%rsi, %rcx)
+ je .u.retzer
+.u.inc:
+ inc %rcx
+ jmp .u.loop
+.u.retdiff:
+ xor %r8, %r8
+ xor %r9, %r9
+ movb (%rdi, %rcx), %r8b
+ movb (%rsi, %rcx), %r9b
+ sub %r9, %r8
+ xor %rax, %rax
+ movl %r8d, %eax
+ ret
+.u.retzer:
+ xor %rax, %rax
ret