Subversion Repositories Kolibri OS

Rev

Go to most recent revision | 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.  
  8. .intel_syntax
  9.  
  10. .text
  11. .globl __strncpy
  12. .align  16
  13.  
  14. __strncpy:
  15.         mov     edi, [ebp+12]   # edi = string s2
  16.         xorb    al, al          # Look for a zero byte
  17.         mov     edx, ecx        # Save maximum count
  18.         cld
  19.         repne
  20.         scasb                   # Look for end of s2
  21.         sub     edx, ecx        # Number of bytes in s2 including null
  22.         xchg    ecx, edx
  23.         mov     esi, [ebp+12]   # esi = string s2
  24.         mov     edi, [ebp+8]     # edi = string s1
  25.         rep
  26.         movsb                   # Copy bytes
  27.         ret
  28.