OBJ_CRT0NS = $(SRC_CRT0NS:.s=.rel)
SRC_ASM = enter.s
OBJ_ASM = $(SRC_ASM:.s=.rel)
-SRC_C = __argv.c abort.c asctime.c assert.c atexit.c
+SRC_C = __argv.c abort.c asctime.c assert.c atexit.c atoi_small.c
SRC_C += bcmp.c bcopy.c bsearch.c bzero.c calloc.c cfree.c clock.c closedir.c
SRC_C += clock_gettime.c clock_getres.c clock_settime.c
SRC_C += creat.c crypt.c ctime.c difftime.c err.c errno.c error.c
--- /dev/null
+/*
+ * An implementation of atoi avoiding longs and 8bit unfriendly
+ * math
+ */
+#include <stdlib.h>
+#include <ctype.h>
+
+/**************************** atoi.c ****************************/
+int atoi(const char *str)
+{
+ int r = 0;
+ uint8_t minus = 0;
+
+ while(isspace(*str))
+ str++;
+ if (*str == '-') {
+ minus = 1;
+ str++;
+ }
+ while(*str) {
+ uint8_t c = *str++;
+ c -= '0';
+ if (c > 9)
+ break;
+ r = ((r << 2) + r) << 1;
+ r += c;
+ }
+ return minus ? - r : r;
+}
sdar d tmp.lib putchar.rel heap.rel fstubs.rel errno.rel
sdar d tmp.lib rand.rel _calloc.rel _malloc.rel _realloc.rel _free.rel
sdar d tmp.lib printf_large.rel puts.rel gets.rel assert.rel time.rel
-sdar d tmp.lib tolower.rel toupper.rel _ltoa.rel _itoa.rel abs.rel
+sdar d tmp.lib tolower.rel toupper.rel _ltoa.rel _itoa.rel abs.rel atoi.rel
mv tmp.lib sdccz80.lib