From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- .../ARM202U/EXAMPLES/CLSTAND/MEMMOVE.C | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CLSTAND/MEMMOVE.C (limited to 'Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CLSTAND/MEMMOVE.C') diff --git a/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CLSTAND/MEMMOVE.C b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CLSTAND/MEMMOVE.C new file mode 100644 index 0000000..8039f11 --- /dev/null +++ b/Bachelor/Mikroprozessorsysteme2/ARM202U/EXAMPLES/CLSTAND/MEMMOVE.C @@ -0,0 +1,23 @@ +#include "memmove.h" + +void *__rt_memmove(void *a, const void *b, size_t n) +/* copy memory taking care of overlap */ +/* Relies on sizeof(int)=sizeof(void *) and byte addressing. + Also that memory does not wrap round for direction test. */ +{ + /* do it fast if word aligned ... */ + if ((((int)a | (int)b | (int)n) & 3) == 0) + { int *wa,*wb; + n >>= 2; + if (a < (void *)b) + for (wa = (int *)a, wb = (int *)b; n-- > 0;) *wa++ = *wb++; + else for (wa = n+(int *)a, wb = n+(int *)b; n-- > 0;) *--wa = *--wb; + } + else + { char *ca,*cb; + if (a < (void *)b) + for (ca = (char *)a, cb = (char *)b; n-- > 0;) *ca++ = *cb++; + else for (ca = n+(char *)a, cb = n+(char *)b; n-- > 0;) *--ca = *--cb; + } + return a; +} -- cgit v1.2.3