diff options
Diffstat (limited to 'kernel/terminal.cpp')
-rw-r--r-- | kernel/terminal.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/kernel/terminal.cpp b/kernel/terminal.cpp index 59e1ee5..1074fe7 100644 --- a/kernel/terminal.cpp +++ b/kernel/terminal.cpp @@ -108,4 +108,14 @@ namespace mercury::kernel::terminal { } + static char hex_digits[] = "0123456789abcdef"; + + void put_int_hex(uint64_t n, int digits, bool with_dots) { + for (int digit = digits - 1; digit >= 0; --digit) { + put_char(hex_digits[(n >> (digit * 4)) & 0xf]); + if (with_dots && digit % 4 == 0 && digit != 0) + put_char('.'); + } + } + } |