cfenollosa_os-tutorial/19-interrupts-irqs/kernel/util.c
Carlos Fenollosa c2a05935f8 lesson 19, IRQs
2015-03-17 20:18:06 +01:00

31 lines
580 B
C

#include "util.h"
void memory_copy(char *source, char *dest, int nbytes) {
int i;
for (i = 0; i < nbytes; i++) {
*(dest + i) = *(source + i);
}
}
void memory_set(u8 *dest, u8 val, u32 len) {
u8 *temp = (u8 *)dest;
for ( ; len != 0; len--) *temp++ = val;
}
/**
* K&R implementation
*/
void int_to_ascii(int n, char str[]) {
int i, sign;
if ((sign = n) < 0) n = -n;
i = 0;
do {
str[i++] = n % 10 + '0';
} while ((n /= 10) > 0);
if (sign < 0) str[i++] = '-';
str[i] = '\0';
/* TODO: implement "reverse" */
}