reflect a change in the main help file...
[midnight-commander.git] / slang / slmemcpy.c
blob9829c2e30a67d43fede52acd6148627a1194c642
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"
19 char *SLmemcpy(char *s1, char *s2, int n)
21 #if defined(msdos) && !defined(__WIN32__) && !defined(__GO32__)
22 asm mov ax, ds
23 asm mov bx, si
24 asm mov dx, di
25 asm mov cx, n
26 asm les di, s1
27 asm lds si, s2
28 asm cld
29 asm rep movsb
30 asm mov ds, ax
31 asm mov si, bx
32 asm mov di, dx
33 return(s1);
35 #else
36 register char *smax, *s = s1;
37 int n2;
39 n2 = n % 4;
40 smax = s + (n - 4);
41 while (s <= smax)
43 *s = *s2; *(s + 1) = *(s2 + 1); *(s + 2) = *(s2 + 2); *(s + 3) = *(s2 + 3);
44 s += 4;
45 s2 += 4;
47 while (n2--) *s++ = *s2++;
48 return(s1);
49 #endif