Source code of Windows XP (NT5)
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.0 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. ;
  22. ;*******************************************************************************
  23. .xlist
  24. include cruntime.inc
  25. .list
  26. page
  27. ;***
  28. ;char *_strset(string, val) - sets all of string to val
  29. ;
  30. ;Purpose:
  31. ; Sets all of characters in string (except the terminating '/0'
  32. ; character) equal to val.
  33. ;
  34. ; Algorithm:
  35. ; char *
  36. ; _strset (string, val)
  37. ; char *string;
  38. ; char val;
  39. ; {
  40. ; char *start = string;
  41. ;
  42. ; while (*string)
  43. ; *string++ = val;
  44. ; return(start);
  45. ; }
  46. ;
  47. ;Entry:
  48. ; char *string - string to modify
  49. ; char val - value to fill string with
  50. ;
  51. ;Exit:
  52. ; returns string -- now filled with val's
  53. ;
  54. ;Uses:
  55. ;
  56. ;Exceptions:
  57. ;
  58. ;*******************************************************************************
  59. CODESEG
  60. public _strset
  61. _strset proc \
  62. uses edi, \
  63. string:ptr byte, \
  64. val:byte
  65. mov edi,[string] ; di = string
  66. mov edx,edi ; dx=string addr; save return value
  67. xor eax,eax ; ax = 0
  68. or ecx,-1 ; cx = -1
  69. repne scasb ; scan string & count bytes
  70. inc ecx
  71. inc ecx ; 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