06ac923e9c19eb0af9f557f12514d71387790a77
[musl] / src / string / i386 / memset.s
1 .global memset
2 .type memset,@function
3 memset:
4         mov 8(%esp),%al
5         push %edi
6         mov %al,%ah
7         mov %al,%dl
8         mov 16(%esp),%ecx
9         shl $16,%eax
10         mov 8(%esp),%edi
11         mov %dl,%al
12         mov %dl,%ah
13         cmp $16,%ecx
14         jb 1f
15
16         mov %eax,-4(%edi,%ecx)
17         shr $2,%ecx
18         rep
19         stosl
20         mov 8(%esp),%eax
21         pop %edi
22         ret
23
24 1:      test %ecx,%ecx
25         jz 1f
26
27         mov %al,(%edi)
28         mov %al,-1(%edi,%ecx)
29         cmp $2,%ecx
30         jbe 1f
31
32         mov %al,1(%edi)
33         mov %al,-2(%edi,%ecx)
34         cmp $4,%ecx
35         jbe 1f
36
37         mov %eax,(%edi)
38         mov %eax,-4(%edi,%ecx)
39         cmp $8,%ecx
40         jbe 1f
41
42         mov %eax,4(%edi)
43         mov %eax,-8(%edi,%ecx)
44
45 1:      mov 8(%esp),%eax
46         pop %edi
47         ret