summaryrefslogtreecommitdiffstats
path: root/system/hex.c
blob: 43740636dff12bc53b82fe228817a7062a16677c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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]);
}