Super User's BSD Cross Reference: /OpenBSD/sys/lib/libkern/arch/i386/memchr.S

1 /* $OpenBSD: memchr.S,v 1.2 2014年11月29日 18:51:23 tedu Exp $ */
2
3 /*
4 * Written by J.T. Conklin <jtc@netbsd.org>.
5 * Public domain.
6 */
7
8#include <machine/asm.h>
9
10 ENTRY(memchr)
11 pushl %edi
12 movl 8(%esp),%edi /* string address */
13 movl 12(%esp),%eax /* set character to search for */
14 movl 16(%esp),%ecx /* set length of search */
15 testl %ecx,%ecx /* test for len == 0 */
16 jz L1
17 repne /* search! */
18 scasb
19 jne L1 /* scan failed, return null */
20 leal -1(%edi),%eax /* adjust result of scan */
21 popl %edi
22 ret
23 .align 2,0x90
24 L1: xorl %eax,%eax
25 popl %edi
26 ret
27 

AltStyle によって変換されたページ (->オリジナル) /