home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / STRCPY.CAS < prev    next >
Encoding:
Text File  |  1990-06-07  |  1.9 KB  |  67 lines

  1. /*-----------------------------------------------------------------------*
  2.  * filename - strcpy.cas
  3.  *
  4.  * function(s)
  5.  *        strcpy - copy string src to string dest
  6.  *-----------------------------------------------------------------------*/
  7.  
  8. /*[]------------------------------------------------------------[]*/
  9. /*|                                                              |*/
  10. /*|     Turbo C Run Time Library - Version 3.0                   |*/
  11. /*|                                                              |*/
  12. /*|                                                              |*/
  13. /*|     Copyright (c) 1987,1988,1990 by Borland International    |*/
  14. /*|     All Rights Reserved.                                     |*/
  15. /*|                                                              |*/
  16. /*[]------------------------------------------------------------[]*/
  17.  
  18.  
  19. #pragma inline
  20. #include <asmrules.h>
  21. #include <string.h>
  22.  
  23. /*-----------------------------------------------------------------------*
  24.  
  25. Name        strcpy - copy string src to string dest
  26.  
  27. Usage        char *strcpy (char *dest, const char *src);
  28.  
  29. Prototype in    string.h
  30.  
  31. Description    Copy the ASCIIZ string *src to    the buffer *dest. It is the
  32.         callers responsibility    to ensure that    the dest buffer  is
  33.         large enough  to contain the  string, and to  guard against
  34.         supplying NULL arguments.
  35.  
  36. Return value    strcpy returns dest.
  37.  
  38. *------------------------------------------------------------------------*/
  39. #undef strcpy                  /* not an intrinsic */
  40. char *_CType strcpy(char *dest, const char *src)
  41. {
  42. #if !(LDATA)
  43.     _ES = _DS;
  44. #endif
  45. asm    cld
  46. asm    LES_    di, src
  47. asm    mov    si, di
  48. asm    xor    al, al
  49. asm    mov    cx, -1
  50. asm    repne    scasb
  51. asm    not    cx
  52.  
  53. #if  (LDATA)
  54. #if  !defined(__HUGE__)
  55. asm    push    DS
  56. #endif
  57.     _DS = _ES;
  58. #endif
  59. asm    LES_    di, dest
  60. asm    rep    movsb
  61. #if  defined(__LARGE__) || defined(__COMPACT__)
  62. asm    pop    DS
  63. #endif
  64.  
  65.     return(dest) ;
  66. }
  67.