Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1. /****************************************************************************
  2. *
  3. *                            Open Watcom Project
  4. *
  5. *    Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
  6. *
  7. *  ========================================================================
  8. *
  9. *    This file contains Original Code and/or Modifications of Original
  10. *    Code as defined in and that are subject to the Sybase Open Watcom
  11. *    Public License version 1.0 (the 'License'). You may not use this file
  12. *    except in compliance with the License. BY USING THIS FILE YOU AGREE TO
  13. *    ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
  14. *    provided with the Original Code and Modifications, and is also
  15. *    available at www.sybase.com/developer/opensource.
  16. *
  17. *    The Original Code and all software distributed under the License are
  18. *    distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  19. *    EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
  20. *    ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
  21. *    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
  22. *    NON-INFRINGEMENT. Please see the License for the specific language
  23. *    governing rights and limitations under the License.
  24. *
  25. *  ========================================================================
  26. *
  27. * Description:  Implementation of strcpy().
  28. *
  29. ****************************************************************************/
  30.  
  31.  
  32. #include "variety.h"
  33. #include "widechar.h"
  34. #include <stdio.h>
  35. #include <string.h>
  36. #include "riscstr.h"
  37.  
  38. #undef  strcpy
  39.  
  40. extern CHAR_TYPE *__strcpy( CHAR_TYPE *dst, const CHAR_TYPE *src );
  41. #if defined(__386__)
  42.  #pragma aux __strcpy = \
  43.         "       push    eax"      \
  44.         "L1:    mov     cl,[edx]" \
  45.         "       mov     [eax],cl" \
  46.         "       cmp     cl,0"     \
  47.         "       je      L2"       \
  48.         "       mov     cl,1[edx]"\
  49.         "       add     edx,2"    \
  50.         "       mov     1[eax],cl"\
  51.         "       add     eax,2"    \
  52.         "       cmp     cl,0"     \
  53.         "       jne     L1"       \
  54.         "L2:    pop     eax"      \
  55.         parm [eax] [edx] value [eax] modify exact [eax edx ecx];
  56. #elif defined(M_I86)
  57.  #if defined(__SMALL_DATA__)
  58.   #pragma aux __strcpy = \
  59.         "       push    di"       \
  60.         "       test    si,1"     \
  61.         "       je      L1"       \
  62.         "       lodsb"            \
  63.         "       mov     [di],al"  \
  64.         "       inc     di"       \
  65.         "       cmp     al,0"     \
  66.         "       je      L3"       \
  67.         "L1:    mov     ax,[si]"  \
  68.         "       test    al,al"    \
  69.         "       je      L2"       \
  70.         "       mov     [di],ax"  \
  71.         "       add     di,2"     \
  72.         "       test    ah,ah"    \
  73.         "       je      L3"       \
  74.         "       mov     ax,2[si]" \
  75.         "       test    al,al"    \
  76.         "       je      L2"       \
  77.         "       mov     [di],ax"  \
  78.         "       add     si,4"     \
  79.         "       add     di,2"     \
  80.         "       test    ah,ah"    \
  81.         "       jne     L1"       \
  82.         "       je      L3"       \
  83.         "L2:    mov     [di],al"  \
  84.         "L3:    pop     ax"       \
  85.         parm [di] [si] value [ax] modify exact [si di];
  86.  #else  // compact, large, or huge
  87.   #pragma aux __strcpy = \
  88.         "       push    ds"       \
  89.         "       push    di"       \
  90.         "       mov     ds,dx"    \
  91.         "       test    si,1"     \
  92.         "       je      L1"       \
  93.         "       lodsb"            \
  94.         "       stosb"            \
  95.         "       cmp     al,0"     \
  96.         "       je      L3"       \
  97.         "L1:    mov     ax,[si]"  \
  98.         "       test    al,al"    \
  99.         "       je      L2"       \
  100.         "       stosw"            \
  101.         "       test    ah,ah"    \
  102.         "       je      L3"       \
  103.         "       mov     ax,2[si]" \
  104.         "       test    al,al"    \
  105.         "       je      L2"       \
  106.         "       stosw"            \
  107.         "       add     si,4"     \
  108.         "       test    ah,ah"    \
  109.         "       jne     L1"       \
  110.         "       je      L3"       \
  111.         "L2:    stosb"            \
  112.         "L3:    pop     ax"       \
  113.         "       mov     dx,es"    \
  114.         "       pop     ds"       \
  115.         parm [es di] [dx si] value [dx ax] modify exact [si di];
  116.  #endif
  117. #else
  118.  /* currently no pragma for non-x86 */
  119. #endif
  120.  
  121.  
  122. /* copy string t to string s */
  123.  
  124. #if defined(__RISCSTR__) && defined(__WIDECHAR__)
  125.  _WCRTLINK CHAR_TYPE *__simple_wcscpy( CHAR_TYPE *s, const CHAR_TYPE *t )
  126. #else
  127.  _WCRTLINK CHAR_TYPE *__F_NAME(strcpy,wcscpy)( CHAR_TYPE *s, const CHAR_TYPE *t )
  128. #endif
  129. {
  130. #if !defined(__WIDECHAR__) && defined(_M_IX86)
  131.     return( __strcpy( s, t ) );
  132. #else
  133.     CHAR_TYPE *dst;
  134.  
  135.     dst = s;
  136.     while( *dst++ = *t++ )
  137.         ;
  138.     return( s );
  139. #endif
  140. }
  141.