summaryrefslogtreecommitdiffstats
path: root/system/hex.c
diff options
context:
space:
mode:
Diffstat (limited to 'system/hex.c')
-rw-r--r--system/hex.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/system/hex.c b/system/hex.c
new file mode 100644
index 0000000..4374063
--- /dev/null
+++ b/system/hex.c
@@ -0,0 +1,31 @@
+/* hex.c - hexdecimal print functions */
+
+#include <system.h>
+
+
+extern unsigned char console_std_attr;
+
+static char hex_values[16] = "0123456789ABCDEF";
+
+void print_hex_byte(unsigned char hex) {
+ print_char(hex_values[(hex >> 4) & 0x0F]);
+ print_char(hex_values[hex & 0x0F]);
+}
+
+void print_hex_word(unsigned short hex) {
+ print_char(hex_values[(hex >> 12) & 0x0F]);
+ print_char(hex_values[(hex >> 8) & 0x0F]);
+ print_char(hex_values[(hex >> 4) & 0x0F]);
+ print_char(hex_values[hex & 0x0F]);
+}
+
+void print_hex_long(unsigned long hex) {
+ print_char(hex_values[(hex >> 28) & 0x0F]);
+ print_char(hex_values[(hex >> 24) & 0x0F]);
+ print_char(hex_values[(hex >> 20) & 0x0F]);
+ print_char(hex_values[(hex >> 16) & 0x0F]);
+ print_char(hex_values[(hex >> 12) & 0x0F]);
+ print_char(hex_values[(hex >> 8) & 0x0F]);
+ print_char(hex_values[(hex >> 4) & 0x0F]);
+ print_char(hex_values[hex & 0x0F]);
+}