diff --git a/lib83/__assert_fail.c b/lib83/__assert_fail.c index 7aca21e..2cdf7b1 100644 --- a/lib83/__assert_fail.c +++ b/lib83/__assert_fail.c @@ -3,7 +3,7 @@ #include #include -void __assert_fail(const char *__assertion, const char *__file, unsigned int __line, const char *__function) { +void __assert_fail(const char * __assertion, const char * __file, unsigned int __line, const char * __function) { clrscr(); gotoxy(0, 0); puts("Assertion failed"); @@ -22,4 +22,3 @@ void __assert_fail(const char *__assertion, const char *__file, unsigned int __l getchar(); exit(); } - diff --git a/lib83/gotoxy.c b/lib83/gotoxy.c index 10cf1aa..463ef91 100644 --- a/lib83/gotoxy.c +++ b/lib83/gotoxy.c @@ -1,11 +1,10 @@ #include -__at (0x844B) unsigned char curRow; -__at (0x844C) unsigned char curCol; +__at(0x844B) unsigned char curRow; +__at(0x844C) unsigned char curCol; void gotoxy(int x, int y) { curRow = y; curCol = x; } - diff --git a/lib83/memcpy.c b/lib83/memcpy.c new file mode 100644 index 0000000..cc615f6 --- /dev/null +++ b/lib83/memcpy.c @@ -0,0 +1,9 @@ + +#include + +void * memcpy(void * dest, const void * src, size_t n) { + char * d = dest; + const char * s = src; + while (n--) *d++ = *s++; + return dest; +} diff --git a/lib83/memmove.c b/lib83/memmove.c new file mode 100644 index 0000000..1299fd9 --- /dev/null +++ b/lib83/memmove.c @@ -0,0 +1,24 @@ + +#include + +void * memmove(void * dst, void * src, size_t acount) { + void * ret = dst; + char * d; + char * s; + + if (((int)src < (int)dst) && ((((int)src) + acount) > (int)dst)) { + d = ((char *)dst) + acount - 1; + s = ((char *)src) + acount - 1; + while (acount--) { + *d-- = *s--; + } + } else { + d = dst; + s = src; + while (acount--) { + *d++ = *s++; + } + } + + return (ret); +} diff --git a/lib83/put_int.c b/lib83/put_int.c index b68f250..3881ef7 100644 --- a/lib83/put_int.c +++ b/lib83/put_int.c @@ -12,7 +12,5 @@ void put_int(int i) { buf[j++] = i % 10 + '0'; i /= 10; } while (i > 0); - while (j > 0) - putchar(buf[--j]); + while (j > 0) putchar(buf[--j]); } - diff --git a/lib83/puts.c b/lib83/puts.c index 4eee60f..17ae520 100644 --- a/lib83/puts.c +++ b/lib83/puts.c @@ -2,9 +2,8 @@ #include void puts(const char * s) { - while(*s) { + while (*s) { putchar(*s); s++; } } - diff --git a/lib83/string.h b/lib83/string.h index 962b5af..c14c339 100644 --- a/lib83/string.h +++ b/lib83/string.h @@ -2,7 +2,18 @@ #ifndef _STRING_H #define _STRING_H +#include +extern void *memcpy(void *dest, const void *src, size_t n); +extern void *memset(void *s, int 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 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); #endif