diff --git a/Makefile b/Makefile index 0de944f..d8119fc 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ CFLAGS=-Ilib83 -c -mz80 --std-sdcc2x --no-std-crt0 --reserve-regs-iy --opt-code- OBJS=_crt0.rel clrscr.rel putchar.rel puts.rel exit.rel gotoxy.rel __assert_fail.rel \ getchar.rel put_int.rel ctype.rel memcpy.rel memset.rel memmove.rel memcmp.rel \ + strcpy.rel \ main.rel .PHONY: all clean try diff --git a/lib83/memcpy.c b/lib83/memcpy.c index cc615f6..d6fbbfa 100644 --- a/lib83/memcpy.c +++ b/lib83/memcpy.c @@ -2,8 +2,8 @@ #include void * memcpy(void * dest, const void * src, size_t n) { - char * d = dest; - const char * s = src; + register char * d = dest; + register const char * s = src; while (n--) *d++ = *s++; return dest; } diff --git a/lib83/memmove.c b/lib83/memmove.c index 1299fd9..dfa867b 100644 --- a/lib83/memmove.c +++ b/lib83/memmove.c @@ -2,11 +2,11 @@ #include void * memmove(void * dst, void * src, size_t acount) { - void * ret = dst; - char * d; - char * s; + register void * ret = dst; + register char * d; + register char * s; - if (((int)src < (int)dst) && ((((int)src) + acount) > (int)dst)) { + if (src < dst && (char *)src + acount > dst) { d = ((char *)dst) + acount - 1; s = ((char *)src) + acount - 1; while (acount--) { diff --git a/lib83/strcpy.c b/lib83/strcpy.c new file mode 100644 index 0000000..0f1a8f9 --- /dev/null +++ b/lib83/strcpy.c @@ -0,0 +1,9 @@ + +#include + +char * strcpy (char * d, const char * from) { + register char * to = d; + while (*to++ = *from++); + return d; +} + diff --git a/lib83/string.h b/lib83/string.h index a039288..c33d86b 100644 --- a/lib83/string.h +++ b/lib83/string.h @@ -14,6 +14,7 @@ extern char *strncpy(char *dest, const char *src, size_t n); extern size_t strlen(const char *s); extern int8_t strcmp(const char *s1, const char *s2); extern int8_t strncmp(const char *s1, const char *s2, size_t n); +extern char * strcat(char *dest, const char *src); #endif