home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / STRCPY.CAS < prev    next >
Encoding:
Text File  |  1992-06-10  |  1.7 KB  |  70 lines

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