Add memtest support.
[syslinux-debian/hramrach.git] / com32 / lib / memmove.c
bloba398cd8dc986b45d41059169175a051d6efdf5d7
1 /*
2 * memmove.c
3 */
5 #include <string.h>
7 void *memmove(void *dst, const void *src, size_t n)
9 const char *p = src;
10 char *q = dst;
11 #if defined(__i386__) || defined(__x86_64__)
12 if (q < p) {
13 asm volatile("cld; rep; movsb"
14 : "+c" (n), "+S"(p), "+D"(q));
15 } else {
16 p += (n - 1);
17 q += (n - 1);
18 asm volatile("std; rep; movsb; cld"
19 : "+c" (n), "+S"(p), "+D"(q));
21 #else
22 if (q < p) {
23 while (n--) {
24 *q++ = *p++;
26 } else {
27 p += n;
28 q += n;
29 while (n--) {
30 *--q = *--p;
33 #endif
35 return dst;