This commit is contained in:
Kamila Szewczyk 2023-10-08 14:58:45 +02:00
parent efa476138e
commit 57fc34cb2d
Signed by: Palaiologos
GPG Key ID: E34D7BADA3DACC14
3 changed files with 17 additions and 4 deletions

View File

@ -3,7 +3,7 @@ CC=sdcc
CFLAGS=-Ilib83 -c -mz80 --std-sdcc2x --no-std-crt0 --reserve-regs-iy --opt-code-size CFLAGS=-Ilib83 -c -mz80 --std-sdcc2x --no-std-crt0 --reserve-regs-iy --opt-code-size
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 \ getchar.rel put_int.rel ctype.rel memcpy.rel memset.rel memmove.rel memcmp.rel \
main.rel main.rel
.PHONY: all clean try .PHONY: all clean try

13
lib83/memcmp.c Normal file
View File

@ -0,0 +1,13 @@
#include <string.h>
int8_t memcmp(void * buf1, void * buf2, size_t count) {
if (!count) return 0;
while (--count && *(unsigned char*)buf1 == *(unsigned char*)buf2) {
buf1 = 1 + (unsigned char *)buf1; buf2 = 1 + (unsigned char *)buf2;
}
return *(char*)buf1 - *(char*)buf2;
}

View File

@ -7,13 +7,13 @@
extern void *memcpy(void *dest, const void *src, size_t n); extern void *memcpy(void *dest, const void *src, size_t n);
extern void *memset(void *s, unsigned char c, size_t n); extern void *memset(void *s, unsigned char c, size_t n);
extern void *memmove(void *dest, const void *src, size_t n); extern void *memmove(void *dest, const void *src, size_t n);
extern int memcmp(const void *s1, const void *s2, size_t n); extern int8_t memcmp(const void *s1, const void *s2, size_t n);
extern char *strcpy(char *dest, const char *src); extern char *strcpy(char *dest, const char *src);
extern char *strncpy(char *dest, const char *src, size_t n); 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 int strcmp(const char *s1, const char *s2); extern int8_t strcmp(const char *s1, const char *s2);
extern int strncmp(const char *s1, const char *s2, size_t n); extern int8_t strncmp(const char *s1, const char *s2, size_t n);
#endif #endif