github.com/afumu/libc@v0.0.6/musl/src/string/i386/memset.s (about)

     1  .global memset
     2  .type memset,@function
     3  memset:
     4  	mov 12(%esp),%ecx
     5  	cmp $62,%ecx
     6  	ja 2f
     7  
     8  	mov 8(%esp),%dl
     9  	mov 4(%esp),%eax
    10  	test %ecx,%ecx
    11  	jz 1f
    12  
    13  	mov %dl,%dh
    14  
    15  	mov %dl,(%eax)
    16  	mov %dl,-1(%eax,%ecx)
    17  	cmp $2,%ecx
    18  	jbe 1f
    19  
    20  	mov %dx,1(%eax)
    21  	mov %dx,(-1-2)(%eax,%ecx)
    22  	cmp $6,%ecx
    23  	jbe 1f
    24  
    25  	shl $16,%edx
    26  	mov 8(%esp),%dl
    27  	mov 8(%esp),%dh
    28  
    29  	mov %edx,(1+2)(%eax)
    30  	mov %edx,(-1-2-4)(%eax,%ecx)
    31  	cmp $14,%ecx
    32  	jbe 1f
    33  
    34  	mov %edx,(1+2+4)(%eax)
    35  	mov %edx,(1+2+4+4)(%eax)
    36  	mov %edx,(-1-2-4-8)(%eax,%ecx)
    37  	mov %edx,(-1-2-4-4)(%eax,%ecx)
    38  	cmp $30,%ecx
    39  	jbe 1f
    40  
    41  	mov %edx,(1+2+4+8)(%eax)
    42  	mov %edx,(1+2+4+8+4)(%eax)
    43  	mov %edx,(1+2+4+8+8)(%eax)
    44  	mov %edx,(1+2+4+8+12)(%eax)
    45  	mov %edx,(-1-2-4-8-16)(%eax,%ecx)
    46  	mov %edx,(-1-2-4-8-12)(%eax,%ecx)
    47  	mov %edx,(-1-2-4-8-8)(%eax,%ecx)
    48  	mov %edx,(-1-2-4-8-4)(%eax,%ecx)
    49  
    50  1:	ret 	
    51  
    52  2:	movzbl 8(%esp),%eax
    53  	mov %edi,12(%esp)
    54  	imul $0x1010101,%eax
    55  	mov 4(%esp),%edi
    56  	test $15,%edi
    57  	mov %eax,-4(%edi,%ecx)
    58  	jnz 2f
    59  
    60  1:	shr $2, %ecx
    61  	rep
    62  	stosl
    63  	mov 4(%esp),%eax
    64  	mov 12(%esp),%edi
    65  	ret
    66  	
    67  2:	xor %edx,%edx
    68  	sub %edi,%edx
    69  	and $15,%edx
    70  	mov %eax,(%edi)
    71  	mov %eax,4(%edi)
    72  	mov %eax,8(%edi)
    73  	mov %eax,12(%edi)
    74  	sub %edx,%ecx
    75  	add %edx,%edi
    76  	jmp 1b