From e429ac610279a7e30450f2372e907e2d0f73f735 Mon Sep 17 00:00:00 2001 From: "E. Almqvist" Date: Fri, 27 Aug 2021 23:42:30 +0200 Subject: [PATCH] Borked int_to_str --- Makefile | 4 ++-- kernel/kernel.c | 5 +++++ lib/strf.c | 12 +++++++++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 5b13a7e..4c23ad8 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ -C_SOURCES = $(wildcard kernel/*.c drivers/*.c) -HEADERS = $(wildcard kernel/*.h drivers/*.h) +C_SOURCES = $(wildcard kernel/*.c drivers/*.c lib/*.c) +HEADERS = $(wildcard kernel/*.h drivers/*.h lib/*.h) OBJ = $(C_SOURCES:.c=.o) all: os-image diff --git a/kernel/kernel.c b/kernel/kernel.c index 2d24fd9..7fbcba1 100644 --- a/kernel/kernel.c +++ b/kernel/kernel.c @@ -1,9 +1,14 @@ #include "../drivers/vga.h" +#include "../lib/strf.h" void main() { vga_init(); // Initialize the screen first // i.e. clear the screen et cetera. + int test = 1234; + char* teststr = int_to_str(test); + println(teststr, 0xf0); + set_cursor_pos(28, 2); print("eOS Version 0.1 2021", 0xf0); } diff --git a/lib/strf.c b/lib/strf.c index c273e1b..5259262 100644 --- a/lib/strf.c +++ b/lib/strf.c @@ -1,9 +1,15 @@ -#include "lib/strf.h" +#include "strf.h" #define int_offset 48 // 0:48 - 9:57 char* int_to_str(int i) { - char* strbuf; - double num = (double)i; + char* strbuf = "XXXXXX"; + + while( i > 0 ) { + *(strbuf + 1) = (i % 10) + int_offset; + i /= 10; + } + + return strbuf; }