xref: /reactos/sdk/lib/ucrt/string/i386/strset.s (revision 72951421)
1#include <asm.inc>
2#if 0
3        page    ,132
4        title   strset - set all characters of string to character
5;***
6;strset.asm - sets all charcaters of string to given character
7;
8;       Copyright (c) Microsoft Corporation. All rights reserved.
9;
10;Purpose:
11;       defines _strset() - sets all of the characters in a string (except
12;       the '\0') equal to a given character.
13;
14;*******************************************************************************
15
16        .xlist
17        include cruntime.inc
18        .list
19
20page
21;***
22;char *_strset(string, val) - sets all of string to val
23;
24;Purpose:
25;       Sets all of characters in string (except the terminating '/0'
26;       character) equal to val.
27;
28;       Algorithm:
29;       char *
30;       _strset (string, val)
31;             char *string;
32;             char val;
33;             {
34;             char *start = string;
35;
36;             while (*string)
37;                     *string++ = val;
38;             return(start);
39;             }
40;
41;Entry:
42;       char *string - string to modify
43;       char val - value to fill string with
44;
45;Exit:
46;       returns string -- now filled with val's
47;
48;Uses:
49;
50;Exceptions:
51;
52;*******************************************************************************
53#endif
54
55        .code
56
57        public  __strset
58.PROC __strset
59// Prolog. Original sources used ML's extended PROC feature to autogenerate this.
60        push ebp
61        mov ebp, esp
62        push edi // uses edi
63#define string ebp + 8 // string:ptr byte
64#define val ebp + 12 // val:byte
65
66
67        mov     edi,[string]    // di = string
68        mov     edx,edi         // dx=string addr; save return value
69
70        xor     eax,eax         // ax = 0
71        or      ecx,-1          // cx = -1
72repne   scasb                   // scan string & count bytes
73        add     ecx,2           // cx=-strlen
74        neg     ecx             // cx=strlen
75        mov     al,[val]        // al = byte value to store
76        mov     edi,edx         // di=string addr
77rep     stosb
78
79        mov     eax,edx         // return value: string addr
80
81// Epilog. Original sources used ML's extended PROC feature to autogenerate this.
82        pop     edi
83        pop     ebp
84
85        ret                     // _cdecl return
86
87.ENDP // __strset
88        end
89