Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.1 KiB

  1. page ,132
  2. title strset - set all characters of string to character
  3. ;***
  4. ;strset.asm - sets all charcaters of string to given character
  5. ;
  6. ; Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  7. ;
  8. ;Purpose:
  9. ; defines _strset() - sets all of the characters in a string (except
  10. ; the '\0') equal to a given character.
  11. ;
  12. ;Revision History:
  13. ; 11-18-83 RN initial version
  14. ; 05-18-88 SJM Add model-independent (large model) ifdef
  15. ; 08-04-88 SJM convert to cruntime/ add 32-bit support
  16. ; 08-23-88 JCR 386 cleanup
  17. ; 10-26-88 JCR General cleanup for 386-only code
  18. ; 03-26-90 GJF Changed to _stdcall. Also, fixed the copyright.
  19. ; 01-18-91 GJF ANSI naming.
  20. ; 05-10-91 GJF Back to _cdecl, sigh...
  21. ; 06-12-01 PML inc->add 1, dec->sub 1 for Pentium 4 perf (vs7#267015)
  22. ;
  23. ;*******************************************************************************
  24. .xlist
  25. include cruntime.inc
  26. .list
  27. page
  28. ;***
  29. ;char *_strset(string, val) - sets all of string to val
  30. ;
  31. ;Purpose:
  32. ; Sets all of characters in string (except the terminating '/0'
  33. ; character) equal to val.
  34. ;
  35. ; Algorithm:
  36. ; char *
  37. ; _strset (string, val)
  38. ; char *string;
  39. ; char val;
  40. ; {
  41. ; char *start = string;
  42. ;
  43. ; while (*string)
  44. ; *string++ = val;
  45. ; return(start);
  46. ; }
  47. ;
  48. ;Entry:
  49. ; char *string - string to modify
  50. ; char val - value to fill string with
  51. ;
  52. ;Exit:
  53. ; returns string -- now filled with val's
  54. ;
  55. ;Uses:
  56. ;
  57. ;Exceptions:
  58. ;
  59. ;*******************************************************************************
  60. CODESEG
  61. public _strset
  62. _strset proc \
  63. uses edi, \
  64. string:ptr byte, \
  65. val:byte
  66. mov edi,[string] ; di = string
  67. mov edx,edi ; dx=string addr; save return value
  68. xor eax,eax ; ax = 0
  69. or ecx,-1 ; cx = -1
  70. repne scasb ; scan string & count bytes
  71. add ecx,2 ; cx=-strlen
  72. neg ecx ; cx=strlen
  73. mov al,[val] ; al = byte value to store
  74. mov edi,edx ; di=string addr
  75. rep stosb
  76. mov eax,edx ; return value: string addr
  77. ifdef _STDCALL_
  78. ret DPSIZE + ISIZE ; _stdcall return
  79. else
  80. ret ; _cdecl return
  81. endif
  82. _strset endp
  83. end