scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | Submodules | README | LICENSE

commit 1de26472868d15174ef01a9655555340234c4dbe
parent f2750859e3c3be0019fc10890baa96c41be40b68
Author: Naveen Narayanan <zerous@simple-cc.org>
Date:   Sat,  2 Oct 2021 03:24:29 +0200

libc: Fix bug in strchr.s for amd64

Reset ZF flag after subq instruction as the sub operation sets ZF flag
when the length of string s is 0. This busts the jump logic used
after scan string instruction.

Diffstat:
Msrc/libc/arch/amd64/strchr.s | 2++
1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/src/libc/arch/amd64/strchr.s b/src/libc/arch/amd64/strchr.s @@ -15,6 +15,8 @@ strchr: leaq -1(%rdi),%rcx subq %r8,%rcx + cmp %rdi,%rsi /* set ZF to 0 */ + movq %r8,%rdi movb %sil,%al repne