diff --git a/OVMFbin/OVMF_VARS-pure-efi.fd b/OVMFbin/OVMF_VARS-pure-efi.fd index 344dbbe..25ae794 100644 Binary files a/OVMFbin/OVMF_VARS-pure-efi.fd and b/OVMFbin/OVMF_VARS-pure-efi.fd differ diff --git a/kernel/bin/CustomOS.img b/kernel/bin/CustomOS.img index 25971e4..5d6e59b 100644 Binary files a/kernel/bin/CustomOS.img and b/kernel/bin/CustomOS.img differ diff --git a/kernel/bin/kernel.elf b/kernel/bin/kernel.elf index a0de7ed..195adf7 100755 Binary files a/kernel/bin/kernel.elf and b/kernel/bin/kernel.elf differ diff --git a/kernel/lib/cstr.o b/kernel/lib/cstr.o index 2e79926..0047c58 100644 Binary files a/kernel/lib/cstr.o and b/kernel/lib/cstr.o differ diff --git a/kernel/lib/kernel.o b/kernel/lib/kernel.o index c2b5c75..d089ee4 100644 Binary files a/kernel/lib/kernel.o and b/kernel/lib/kernel.o differ diff --git a/kernel/src/cstr.cpp b/kernel/src/cstr.cpp index 7916ca4..09c21fd 100644 --- a/kernel/src/cstr.cpp +++ b/kernel/src/cstr.cpp @@ -25,6 +25,79 @@ const char* to_string(uint64_t value) { return uintTo_StringOutput; } +char hexTo_StringOutput[128]; +const char* to_hstring(uint64_t value) { + uint64_t* valPtr = &value; + uint8_t* ptr; + uint8_t temp; + uint8_t size = 8*2 - 1; + + for (uint8_t i = 0; i < size; i++) { + ptr = ((uint8_t*)valPtr + i); + temp = ((*ptr & 0xF0) >> 4); + hexTo_StringOutput[size - (i * 2 + 1)] = temp + (temp > 9 ? 'A' : '0'); + temp = ((*ptr & 0x0F)); + hexTo_StringOutput[size - (i * 2)] = temp + (temp > 9 ? 'A' : '0'); + } + + hexTo_StringOutput[size + 1] = 0; + return hexTo_StringOutput; +} +char hexTo_StringOutput32[128]; +const char* to_hstring(uint32_t value) { + uint32_t* valPtr = &value; + uint8_t* ptr; + uint8_t temp; + uint8_t size = 4*2 - 1; + + for (uint8_t i = 0; i < size; i++) { + ptr = ((uint8_t*)valPtr + i); + temp = ((*ptr & 0xF0) >> 4); + hexTo_StringOutput32[size - (i * 2 + 1)] = temp + (temp > 9 ? 55 : '0'); + temp = ((*ptr & 0x0F)); + hexTo_StringOutput32[size - (i * 2)] = temp + (temp > 9 ? 55 : '0'); + } + + hexTo_StringOutput32[size + 1] = 0; + return hexTo_StringOutput32; +} +char hexTo_StringOutput16[128]; +const char* to_hstring(uint16_t value) { + uint16_t* valPtr = &value; + uint8_t* ptr; + uint8_t temp; + uint8_t size = 2*2 - 1; + + for (uint8_t i = 0; i < size; i++) { + ptr = ((uint8_t*)valPtr + i); + temp = ((*ptr & 0xF0) >> 4); + hexTo_StringOutput16[size - (i * 2 + 1)] = temp + (temp > 9 ? 55 : '0'); + temp = ((*ptr & 0x0F)); + hexTo_StringOutput16[size - (i * 2)] = temp + (temp > 9 ? 55 : '0'); + } + + hexTo_StringOutput16[size + 1] = 0; + return hexTo_StringOutput16; +} +char hexTo_StringOutput8[128]; +const char* to_hstring(uint8_t value) { + uint8_t* valPtr = &value; + uint8_t* ptr; + uint8_t temp; + uint8_t size = 1*2 - 1; + + for (uint8_t i = 0; i < size; i++) { + ptr = ((uint8_t*)valPtr + i); + temp = ((*ptr & 0xF0) >> 4); + hexTo_StringOutput8[size - (i * 2 + 1)] = temp + (temp > 9 ? 55 : '0'); + temp = ((*ptr & 0x0F)); + hexTo_StringOutput8[size - (i * 2)] = temp + (temp > 9 ? 55 : '0'); + } + + hexTo_StringOutput8[size + 1] = 0; + return hexTo_StringOutput8; +} + char intTo_StringOutput[128]; const char* to_string(int64_t value) { uint8_t isNegative = 0; @@ -60,6 +133,10 @@ const char* to_string(int64_t value) { char doubleTo_StringOutput[128]; const char* to_string(double value, uint8_t decimalPlaces) { + if (decimalPlaces > 20) { + decimalPlaces = 20; + } + char* intPtr = (char*)to_string((int64_t)value); char* doublePtr = doubleTo_StringOutput; @@ -87,4 +164,7 @@ const char* to_string(double value, uint8_t decimalPlaces) { *doublePtr = 0; return doubleTo_StringOutput; +} +const char* to_string(double value) { + return to_string(value, 2); } \ No newline at end of file diff --git a/kernel/src/cstr.h b/kernel/src/cstr.h index eca6b26..342bc2b 100644 --- a/kernel/src/cstr.h +++ b/kernel/src/cstr.h @@ -3,4 +3,9 @@ const char* to_string(uint64_t value); const char* to_string(int64_t value); -const char* to_string(double value, uint8_t decimalPlaces); \ No newline at end of file +const char* to_hstring(uint64_t value); +const char* to_hstring(uint32_t value); +const char* to_hstring(uint16_t value); +const char* to_hstring(uint8_t value); +const char* to_string(double value, uint8_t decimalPlaces); +const char* to_string(double value); \ No newline at end of file diff --git a/kernel/src/kernel.cpp b/kernel/src/kernel.cpp index beb83ce..0d47bab 100644 --- a/kernel/src/kernel.cpp +++ b/kernel/src/kernel.cpp @@ -16,7 +16,15 @@ extern "C" void _start(Framebuffer* framebuffer, PSF1_FONT* psf1_Font) { newRenderer.cursorPosition = {0, 18}; newRenderer.Print(0xFFFFFF, to_string((int64_t)-1234976)); newRenderer.cursorPosition = {0, 36}; - newRenderer.Print(0xFFFFFF, to_string(3.141, 2)); + newRenderer.Print(0xFFFFFF, to_string(-3.141)); + newRenderer.cursorPosition = {0, 54}; + newRenderer.Print(0xFFFFFF, to_hstring((uint64_t)0xF0)); + newRenderer.cursorPosition = {0, 72}; + newRenderer.Print(0xFFFFFF, to_hstring((uint32_t)0xF0)); + newRenderer.cursorPosition = {0, 90}; + newRenderer.Print(0xFFFFFF, to_hstring((uint16_t)0xF0)); + newRenderer.cursorPosition = {0, 108}; + newRenderer.Print(0xFFFFFF, to_hstring((uint8_t)0xF0)); return; } \ No newline at end of file