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

1 /* $OpenBSD: bzero.S,v 1.6 2022年08月22日 09:33:40 jsg 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(bzero)
11 pushl %edi
12 movl 8(%esp),%edi
13 movl 12(%esp),%edx
14
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 

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