Compare commits
2 Commits
57fc34cb2d
...
3981746d2a
Author | SHA1 | Date | |
---|---|---|---|
3981746d2a | |||
4da76c0f3c |
1
Makefile
1
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 \
|
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
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
9
lib83/strcpy.c
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
char * strcpy (char * d, const char * from) {
|
||||||
|
register char * to = d;
|
||||||
|
while (*to++ = *from++);
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
|
@ -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
9
lib83/strlen.c
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
size_t strlen (const char * str) {
|
||||||
|
register size_t i = 0;
|
||||||
|
while(*str++) i++;
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user