summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--stage3/font.c19
-rw-r--r--stage3/font.h1
2 files changed, 20 insertions, 0 deletions
diff --git a/stage3/font.c b/stage3/font.c
index 43f2f02..291cdb1 100644
--- a/stage3/font.c
+++ b/stage3/font.c
@@ -102,3 +102,22 @@ void print(const char *line)
while (*line != '\0')
print_char(*line++);
}
+
+
+void print_num(u64 x, u8 base, u8 pad)
+{
+ char digit[65];
+ char *ptr = &digit[64];
+ *ptr = '\0';
+
+ do {
+ u8 digit = x % base;
+ *--ptr = digit + (digit < 10 ? '0' : ('A' - 10));
+ x /= base;
+ } while (x != 0);
+
+ while (ptr > digit + 64 - pad)
+ *--ptr = ' ';
+
+ print(ptr);
+}
diff --git a/stage3/font.h b/stage3/font.h
index 8ad2874..fcb36bf 100644
--- a/stage3/font.h
+++ b/stage3/font.h
@@ -6,5 +6,6 @@
void print(const char *line);
void set_font_size(u16 size);
void print_char(char c);
+void print_num(u64 x, u8 base, u8 pad);
#endif