Subversion Repositories Kolibri OS

Rev

Rev 1408 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*      _strncpy()                                      Author: Kees J. Bot */
  2. /*                                                              1 Jan 1994 */
  3.  
  4. /* char *_strncpy(char *s1, const char *s2, size_t ecx) */
  5. /*      Copy string s2 to s1. */
  6. /* */
  7. #include "asm.h"
  8.  
  9. ENTRY(_strncpy)
  10.         movl    12(%ebp), %edi  /* edi = string s2 */
  11.         xorb    %al, %al        /* Look for a zero byte */
  12.         movl    %ecx, %edx      /* Save maximum count */
  13.         cld
  14.  
  15.         repne scasb     /* Look for end of s2 */
  16.         subl    %ecx, %edx      /* Number of bytes in s2 including null */
  17.         xchgl   %edx, %ecx
  18.         movl    12(%ebp), %esi  /* esi = string s2 */
  19.         movl    8(%ebp), %edi   /* edi = string s1 */
  20.  
  21.         rep movsb       /* Copy bytes */
  22.         ret
  23.