summaryrefslogtreecommitdiffstats
path: root/sw/z80/libc
diff options
context:
space:
mode:
authorleleraffa97@hotmail.it <leleraffa97@hotmail.it>2017-06-19 15:06:25 +0200
committerleleraffa97@hotmail.it <leleraffa97@hotmail.it>2017-06-19 15:06:25 +0200
commitacee9e74f6bd183b284af028b1f08aab666df9be (patch)
tree02d8df6267dd75dd92760ab9b8e924f4f4b8b400 /sw/z80/libc
parentMerge branch 'master' of github.com:NaoPross/z80uPC into atlas (diff)
downloadz80uPC-acee9e74f6bd183b284af028b1f08aab666df9be.tar.gz
z80uPC-acee9e74f6bd183b284af028b1f08aab666df9be.zip
libc memset, memcmpHEADmaster
boot improved program allocation
Diffstat (limited to 'sw/z80/libc')
-rw-r--r--sw/z80/libc/include/string.h4
-rw-r--r--sw/z80/libc/string.c26
2 files changed, 30 insertions, 0 deletions
diff --git a/sw/z80/libc/include/string.h b/sw/z80/libc/include/string.h
index f224c87..9c002e3 100644
--- a/sw/z80/libc/include/string.h
+++ b/sw/z80/libc/include/string.h
@@ -3,6 +3,10 @@
#include "types.h"
+void * memset(void *dest, const int8_t src, size_t n);
+
void *memcpy(void *dest, const void *src, size_t n);
+int8_t memcmp(const void *s1, const void *s2, size_t n);
+
#endif
diff --git a/sw/z80/libc/string.c b/sw/z80/libc/string.c
index fd6a7ff..9dd56cc 100644
--- a/sw/z80/libc/string.c
+++ b/sw/z80/libc/string.c
@@ -1,5 +1,15 @@
#include "string.h"
+void * memset(void *dest, const int8_t src, size_t n) {
+
+ void *dp = dest;
+
+ while (n--)
+ *dp++ = src;
+
+ return dest;
+}
+
void *memcpy(void *dest, void *src, size_t n)
{
char *dp = dest;
@@ -11,3 +21,19 @@ void *memcpy(void *dest, void *src, size_t n)
return dest;
}
+
+int8_t memcmp(const void *s1, const void *s2, size_t n) {
+
+ uint8_t u1, u2;
+
+ for ( ; n--; s1++, s2++) {
+
+ u1 = *s1;
+ u2 = *s2;
+
+ if (u1 != u2)
+ return u1 - u2;
+ }
+
+ return 0;
+} \ No newline at end of file