Write print_int function in C

This commit is contained in:
greg
2015-09-18 03:43:14 -07:00
parent b6851ab0b5
commit 82b80dc56c

View File

@@ -4,6 +4,25 @@ extern int clear(int x86_specifier);
void c_entry() {
write_to_coord(1,1, (0xf0 << 8) | 'm');
write_to_coord(1,5, (0xf0 << 8) | 'j');
write_to_coord(2,5, (0xf0 << 8) | 'j');
print_int(0x73f, 10);
}
void print_int(int input, int coord) {
#define k(x) (0xf0 << 8) | x
while (input > 0) {
int output = '0';
char s = input & 0xf;
if (s <= 9) {
output += s;
} else {
output = 'a' + (s - 10);
}
write_to_coord(15, coord, k(output));
input = input >> 4;
coord--;
}
write_to_coord(15, coord--, k('x'));
write_to_coord(15, coord, k('0'));
}