memcmp
This commit is contained in:
parent
efa476138e
commit
57fc34cb2d
2
Makefile
2
Makefile
|
@ -3,7 +3,7 @@ CC=sdcc
|
|||
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 \
|
||||
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
|
||||
|
||||
.PHONY: all clean try
|
||||
|
|
13
lib83/memcmp.c
Normal file
13
lib83/memcmp.c
Normal 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;
|
||||
}
|
||||
|
|
@ -7,13 +7,13 @@
|
|||
extern void *memcpy(void *dest, const void *src, 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 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 *strncpy(char *dest, const char *src, size_t n);
|
||||
extern size_t strlen(const char *s);
|
||||
extern int strcmp(const char *s1, const char *s2);
|
||||
extern int strncmp(const char *s1, const char *s2, size_t n);
|
||||
extern int8_t strcmp(const char *s1, const char *s2);
|
||||
extern int8_t strncmp(const char *s1, const char *s2, size_t n);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user