Super User's BSD Cross Reference: /OpenBSD/lib/libc/arch/i386/string/bzero.S

1 /* $OpenBSD: bzero.S,v 1.7 2022年12月04日 08:22:13 tb Exp $ */
2 /*
3 * Written by J.T. Conklin <jtc@netbsd.org>.
4 * Public domain.
5 */
6
7#include "DEFS.h"
8
9 ENTRY_NB(bzero)
10 pushl %edi
11 movl 8(%esp),%edi
12 movl 12(%esp),%edx
13
14 cld /* set fill direction forward */
15 xorl %eax,%eax /* set fill data to 0 */
16
17 /*
18 * if the string is too short, it's really not worth the overhead
19 * of aligning to word boundaries, etc. So we jump to a plain
20 * unaligned set.
21 */
22 cmpl $16,%edx
23 jb L1
24
25 movl %edi,%ecx /* compute misalignment */
26 negl %ecx
27 andl $3,%ecx
28 subl %ecx,%edx
29 rep /* zero until word aligned */
30 stosb
31
32 movl %edx,%ecx /* zero by words */
33 shrl $2,%ecx
34 andl $3,%edx
35 rep
36 stosl
37
38 L1: movl %edx,%ecx /* zero remainder by bytes */
39 rep
40 stosb
41
42 popl %edi
43 ret
44 END_WEAK(bzero)
45 

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