sos

[unmaintained] experimenting with low level OS development
Log | Files | Refs | README | LICENSE

commit e8911ef5706128cf81b437c6b0df145c96c727c6
parent f4d64c45e2956dc72c7f3a46219665e8d9078866
Author: Stefan <misc@stefan-koch.name>
Date:   Mon, 30 Nov 2015 22:28:26 +0100

added function to print number in hex

Diffstat:
Minclude/arch/x86/io.c | 16++++++++++++++++
Minclude/arch/x86/io.h | 2++
2 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/include/arch/x86/io.c b/include/arch/x86/io.c @@ -74,3 +74,19 @@ void kprinti(int value) { kprintc((char)(digit + 48)); } } + +void kprintx(int value) { + kprint("0x"); + + int divisor = power(16, 7); + for (int i = 0; i < 8; i++) { + short digit = value / divisor; + value %= divisor; + divisor /= 16; + + if (digit < 10) + kprintc((char)(digit + 48)); + else + kprintc((char)(digit + 55)); + } +} diff --git a/include/arch/x86/io.h b/include/arch/x86/io.h @@ -27,4 +27,6 @@ void kprintc(char c); void kprinti(int value); +void kprintx(int value); + #endif