]>
Commit | Line | Data |
---|---|---|
9b8c947b JW |
1 | #include "console.h" |
2 | ||
3 | void memcpy(unsigned char *a2, unsigned char *a1, int bytes) | |
4 | { | |
5 | while (bytes--) | |
6 | *(a2++) = *(a1++); | |
7 | } | |
8 | ||
9 | void memmove(unsigned char *dest, unsigned char *src, int bytes) | |
10 | { | |
11 | if ((dest > src) && (dest <= (src + bytes))) | |
12 | { | |
13 | /* do it backwards! */ | |
14 | dest += bytes; | |
15 | src += bytes; | |
16 | while (bytes--) | |
17 | *(--dest) = *(--src); | |
18 | } else | |
19 | while (bytes--) | |
20 | *(dest++) = *(src++); | |
21 | } | |
22 | ||
d56898ee | 23 | int memcmp (unsigned char *a2, unsigned char *a1, int bytes) { |
24 | while (bytes--) | |
25 | { | |
26 | if (*(a2++) != *(a1++)) | |
27 | return 1; | |
28 | } | |
29 | return 0; | |
30 | } | |
31 | ||
32 | int strcmp (unsigned char *a2, unsigned char *a1) { | |
33 | while (1) { | |
34 | if (*a2 != *a1) return 1; | |
35 | if (*a2 == 0) return 0; | |
36 | a1++; | |
37 | a2++; | |
38 | } | |
39 | } | |
40 | ||
9b8c947b JW |
41 | int strlen(char *c) |
42 | { | |
43 | int l = 0; | |
44 | while (*(c++)) | |
45 | l++; | |
46 | return l; | |
47 | } | |
48 | ||
31be35cd JW |
49 | void strcpy(unsigned char *a2, unsigned char *a1) |
50 | { | |
51 | do { | |
52 | *(a2++) = *a1; | |
53 | } while (*(a1++)); | |
54 | } | |
55 | ||
9b8c947b JW |
56 | void puts(char *c) |
57 | { | |
58 | putbytes(c, strlen(c)); | |
59 | } | |
60 | ||
61 | static char hexarr[] = "0123456789ABCDEF"; | |
31be35cd | 62 | void tohex(unsigned char *s, unsigned long l) |
9b8c947b JW |
63 | { |
64 | int i; | |
65 | for (i = 0; i < 8; i++) | |
66 | { | |
31be35cd | 67 | s[i] = hexarr[l >> 28]; |
9b8c947b JW |
68 | l <<= 4; |
69 | } | |
70 | } | |
31be35cd JW |
71 | |
72 | void puthex(unsigned long l) | |
73 | { | |
74 | unsigned char d[9]; | |
75 | d[8] = 0; | |
76 | tohex(d, l); | |
77 | puts(d); | |
78 | } | |
79 | ||
80 |