diff --git a/drivers/vga.c b/drivers/vga.c index 5687714..333ef52 100644 --- a/drivers/vga.c +++ b/drivers/vga.c @@ -4,7 +4,7 @@ #include "../kernel/io.h" #include "../kernel/memory.h" #include "../lib/str.h" -#include "../lib/strf.h" +#include "../lib/conv.h" static uint cursor_row = 0; static uint cursor_col = 0; @@ -75,10 +75,12 @@ void println(char* str, int attribute_byte) { } void printint(int i, int attribute_byte) { + /* char* strbuf; strbuf = int_to_str(i, strbuf); println(strbuf, attribute_byte); + */ } void printalign(char* str, int attribute_byte, enum align alignment) { diff --git a/kernel/kernel.c b/kernel/kernel.c index 192ec27..446c01d 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -3,7 +3,7 @@ #include "paging.h" #include "../drivers/vga.h" #include "../lib/str.h" -#include "../lib/strf.h" +#include "../lib/conv.h" void init() { vga_init(); // Initialize the screen first diff --git a/lib/conv.c b/lib/conv.c index 5ed3295..8c9284c 100644 --- a/lib/conv.c +++ b/lib/conv.c @@ -1,2 +1,12 @@ #include "conv.h" +void int_to_str(int i, char* buf) { + bool use_sign = false; + + if( i < 0 ) { + i = (ulong)(i * (-1)) + use_sign = true; + } + + uint len = ulong_len(i); +} diff --git a/lib/conv.h b/lib/conv.h index 0c037b9..3e4e383 100644 --- a/lib/conv.h +++ b/lib/conv.h @@ -1 +1,3 @@ +#include "types.h" + void int_to_str(int i, char* buf); diff --git a/lib/util.c b/lib/util.c new file mode 100644 index 0000000..f534869 --- /dev/null +++ b/lib/util.c @@ -0,0 +1,10 @@ +#include "util.h" + +uint ulong_len(ulong i) { + int len = 0; + while (i != 0) { + i = i / 10; + ++len; + } + return len; +} diff --git a/lib/util.h b/lib/util.h new file mode 100644 index 0000000..6c4e531 --- /dev/null +++ b/lib/util.h @@ -0,0 +1,3 @@ +#include "types.h" + +uint ulong_len(ulong n);