]> git.gag.com Git - fw/sdcc/blob - device/lib/z80/string.c
Added timing and asm implementations of strcpy, strcmp, memcpy.
[fw/sdcc] / device / lib / z80 / string.c
1 /* Dumb strings stub.
2    Wanted a quick hack for now - will use the libc version later.
3 */
4 #if 0
5 char *strcpy(char *dest, const char *source)
6 {
7     char *ret = dest;
8     while (*dest++ = *source++);
9     return ret;
10 }
11 #endif
12
13 #if 0
14 void *memcpy(void *dest, const void *source, int count)
15 {
16     char *d = dest;
17     const char *s = source;
18     while (count--)
19         *d++ = *s++;
20
21     return dest;
22 }
23 #endif
24
25 int __strcmp(const char *s1, const char *s2)
26 {
27     int ret = 0;
28
29     while (!(ret = *s1 - *s2) && *s2)
30         ++s1, ++s2;
31
32     if (ret < 0)
33         return -1;
34     else if (ret > 0)
35         return 1;
36     return 0;
37 }
38