| The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | /*	$OpenBSD: bzero.S,v 1.3 2005/08/07 11:30:38 espie Exp $ */ | 
|  | 2 | /* | 
|  | 3 | * Written by J.T. Conklin <jtc@netbsd.org>. | 
|  | 4 | * Public domain. | 
|  | 5 | */ | 
|  | 6 |  | 
|  | 7 | #include <machine/asm.h> | 
|  | 8 |  | 
|  | 9 | ENTRY(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 boundries, 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 |