...
This commit is contained in:
@@ -1,7 +1,52 @@
|
||||
#include "print.h"
|
||||
|
||||
void init(void)
|
||||
/**
|
||||
* C++ version 0.4 char* style "itoa":
|
||||
* Written by Lukás Chmela
|
||||
* Released under GPLv3.
|
||||
*/
|
||||
char* itoa(int value, char* result, int base)
|
||||
{
|
||||
print_init();
|
||||
println("Starting nub-os");
|
||||
// check that the base if valid
|
||||
if (base < 2 || base > 36)
|
||||
{
|
||||
*result = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
char *ptr = result, *ptr1 = result, tmp_char;
|
||||
int tmp_value;
|
||||
|
||||
do
|
||||
{
|
||||
tmp_value = value;
|
||||
value /= base;
|
||||
*ptr++ =
|
||||
"zyxwvutsrqponmlkjihgfedcba9876543210123456789abcdefghijklmnopqrstuvwxyz"[35 + (tmp_value - value * base)];
|
||||
} while (value);
|
||||
|
||||
// Apply negative sign
|
||||
if (tmp_value < 0)
|
||||
*ptr++ = '-';
|
||||
*ptr-- = '\0';
|
||||
|
||||
// Reverse the string
|
||||
while (ptr1 < ptr)
|
||||
{
|
||||
tmp_char = *ptr;
|
||||
*ptr-- = *ptr1;
|
||||
*ptr1++ = tmp_char;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void kernel_init(void)
|
||||
{
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
// char buf[10];
|
||||
// itoa(i, buf, 10);
|
||||
// kernel_print(buf);
|
||||
kernel_print("Starting nub-osStarting");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user