slmemset.c 890 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /* Copyright (c) 1992, 1995 John E. Davis
  2. * All rights reserved.
  3. *
  4. * You may distribute under the terms of either the GNU General Public
  5. * License or the Perl Artistic License.
  6. */
  7. /* These routines are fast memcpy, memset routines. When available, I
  8. use system rouines. For msdos, I use inline assembly. */
  9. /* The current versions only work in the forward direction only!! */
  10. #include "config.h"
  11. #include <stdio.h>
  12. #include "_slang.h"
  13. void SLmemset(char *p, char space, int n)
  14. {
  15. #if defined(msdos) && !defined(__WIN32__) && !defined(__GO32__)
  16. asm mov al, space
  17. asm mov dx, di
  18. asm mov cx, n
  19. asm les di, p
  20. asm cld
  21. asm rep stosb
  22. asm mov di, dx
  23. #else
  24. register char *pmax;
  25. pmax = p + (n - 4);
  26. n = n % 4;
  27. while (p <= pmax)
  28. {
  29. *p++ = space; *p++ = space; *p++ = space; *p++= space;
  30. }
  31. while (n--) *p++ = space;
  32. #endif
  33. }