|
|
1.1 root 1: //////////
2: / libc/string/i386/memset.s
3: / i386 C string library.
4: / ANSI 4.11.6.1.
5: //////////
6:
7: //////////
8: / void *
9: / memset(void *String, int Char, size_t Count)
10: /
11: / Set Count bytes of String to Char.
12: / Uses repeated dword copy for efficiency.
13: //////////
14:
15: String .equ 8
16: Char .equ String+4
17: Count .equ Char+4
18:
19: .data
20: fourx: .long 0x01010101
21:
22: .text
23: .globl memset
24:
25: memset:
26: push %edi
27:
28: movl %ecx, Count(%esp) / Count to ECX
29: movl %edi, String(%esp) / String address to EDI
30: movzxb %eax, Char(%esp) / Char to EAX
31: mull %eax, fourx / Char:Char:Char:Char in EAX
32: movl %edx, %ecx / Save Count in EDX
33: shrl %ecx, $2 / Count/4
34: cld
35: rep
36: stosl / Copy Count/4 Char dwords to String
37: jnc ?byte / CF contains Count bit 1 from shrl above
38: stosw / Copy a word
39:
40: ?byte:
41: shrl %edx, $1
42: jnc ?done
43: stosb / Copy Char to String
44:
45: ?done:
46: movl %eax, String(%esp) / Return the destination in EAX
47:
48: pop %edi
49: ret
50:
51: / end of libc/string/i386/memset.s
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.