Compare commits

..

2 Commits

Author SHA1 Message Date
3981746d2a
strlen 2023-10-08 15:09:04 +02:00
4da76c0f3c
more stuff 2023-10-08 15:05:03 +02:00
6 changed files with 26 additions and 6 deletions

View File

@ -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 \ 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 \ getchar.rel put_int.rel ctype.rel memcpy.rel memset.rel memmove.rel memcmp.rel \
strcpy.rel strlen.rel \
main.rel main.rel
.PHONY: all clean try .PHONY: all clean try

View File

@ -2,8 +2,8 @@
#include <string.h> #include <string.h>
void * memcpy(void * dest, const void * src, size_t n) { void * memcpy(void * dest, const void * src, size_t n) {
char * d = dest; register char * d = dest;
const char * s = src; register const char * s = src;
while (n--) *d++ = *s++; while (n--) *d++ = *s++;
return dest; return dest;
} }

View File

@ -2,11 +2,11 @@
#include <string.h> #include <string.h>
void * memmove(void * dst, void * src, size_t acount) { void * memmove(void * dst, void * src, size_t acount) {
void * ret = dst; register void * ret = dst;
char * d; register char * d;
char * s; 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; d = ((char *)dst) + acount - 1;
s = ((char *)src) + acount - 1; s = ((char *)src) + acount - 1;
while (acount--) { while (acount--) {

9
lib83/strcpy.c Normal file
View File

@ -0,0 +1,9 @@
#include <string.h>
char * strcpy (char * d, const char * from) {
register char * to = d;
while (*to++ = *from++);
return d;
}

View File

@ -14,6 +14,7 @@ extern char *strncpy(char *dest, const char *src, size_t n);
extern size_t strlen(const char *s); extern size_t strlen(const char *s);
extern int8_t strcmp(const char *s1, const char *s2); extern int8_t strcmp(const char *s1, const char *s2);
extern int8_t strncmp(const char *s1, const char *s2, size_t n); extern int8_t strncmp(const char *s1, const char *s2, size_t n);
extern char * strcat(char *dest, const char *src);
#endif #endif

9
lib83/strlen.c Normal file
View File

@ -0,0 +1,9 @@
#include <string.h>
size_t strlen (const char * str) {
register size_t i = 0;
while(*str++) i++;
return i;
}