LibC: Fix memchr and memcmp assembly implementations

These functions did not work with size 0 :D
This commit is contained in:
2025-01-23 21:55:26 +02:00
parent ee078fc638
commit 15021b442c
2 changed files with 10 additions and 6 deletions

View File

@@ -2,15 +2,17 @@
memchr:
movb %sil, %al
movq %rdx, %rcx
movq $1, %rdx
cmpq $1, %rcx # clear ZF if count is zero
repne scasb
xorq %rax, %rax
testq %rcx, %rcx
cmovnzq %rdi, %rax
cmoveq %rdi, %rdx
leaq -1(%rdx), %rax
ret
.global memcmp
memcmp:
movq %rdx, %rcx
testq %rcx, %rcx # set ZF if count is zero
repe cmpsb
jne .memcmp_not_equal
xorq %rax, %rax