filled in a few more formatting routines; linking with libgcc.a to work with 64-bit unsigned integer division/modulus

git-svn-id: svn://anubis/hos/trunk@45 5b3e749e-e535-0410-8002-a9bb6afbdfca
This commit is contained in:
josh committed 2009-07-13 20:08:16 +00:00
1 parent 6a8c7431ff
commit 6a69fd06ec
2 files changed
+45 -2

No files matched your search

+43 -1
View File
@@ -2,6 +2,7 @@
#include "kio.h"
#include "string.h"
#include <limits.h>
#include <stdarg.h> /* va_*() */
static void fmt_d2a(char * buf, int val);
@@ -95,7 +96,7 @@ void kputs(char * s)
static void fmt_d2a(char * buf, int val)
{
if (val == 0x7FFFFFFF)
if (val == INT_MIN)
{
strcpy(buf, "-2147483648");
}
@@ -112,14 +113,55 @@ static void fmt_d2a(char * buf, int val)
static void fmt_u2a(char * buf, unsigned int val)
{
bool printing = false;
for (unsigned int div = 1000000000; div >= 1; div /= 10)
{
unsigned int n = val / div;
if (n)
{
printing = true;
}
if (printing)
{
*buf++ = '0' + (val % div);
}
val -= n * div;
}
}
static void fmt_ll2a(char * buf, long long val)
{
if (val == LONG_LONG_MIN)
{
strcpy(buf, "-9223372036854775808");
}
else
{
if (val < 0)
{
*buf++ = '-';
val = -val;
}
fmt_ull2a(buf, (unsigned long long) val);
}
}
static void fmt_ull2a(char * buf, unsigned long long val)
{
bool printing = false;
for (unsigned long long div = 10000000000000000000ull; div >= 1; div /= 10)
{
unsigned long long n = val / div;
if (n)
{
printing = true;
}
if (printing)
{
*buf++ = '0' + (val % div);
}
val -= n * div;
}
}
static void fmt_x2a(char * buf, unsigned int val)