De-fuzzyed some msgs...
[midnight-commander.git] / slang / slmemcpy.c
blob5edf25b3520b29936f13634a78282fbbc5a1643f
1 /* Copyright (c) 1992, 1995 John E. Davis
2 * All rights reserved.
3 *
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Perl Artistic License.
6 */
9 /* These routines are fast memcpy, memset routines. When available, I
10 use system rouines. For msdos, I use inline assembly. */
12 /* The current versions only work in the forward direction only!! */
14 #include "config.h"
16 #include <stdio.h>
17 #include "slang.h"
18 #include "_slang.h"
20 char *SLmemcpy(char *s1, char *s2, int n)
22 #if defined(msdos) && !defined(__WIN32__) && !defined(__GO32__)
23 asm mov ax, ds
24 asm mov bx, si
25 asm mov dx, di
26 asm mov cx, n
27 asm les di, s1
28 asm lds si, s2
29 asm cld
30 asm rep movsb
31 asm mov ds, ax
32 asm mov si, bx
33 asm mov di, dx
34 return(s1);
36 #else
37 register char *smax, *s = s1;
38 int n2;
40 n2 = n % 4;
41 smax = s + (n - 4);
42 while (s <= smax)
44 *s = *s2; *(s + 1) = *(s2 + 1); *(s + 2) = *(s2 + 2); *(s + 3) = *(s2 + 3);
45 s += 4;
46 s2 += 4;
48 while (n2--) *s++ = *s2++;
49 return(s1);
50 #endif