Write print_int function in C
This commit is contained in:
23
c_keyboard.c
23
c_keyboard.c
@@ -4,6 +4,25 @@ extern int clear(int x86_specifier);
|
|||||||
|
|
||||||
void c_entry() {
|
void c_entry() {
|
||||||
write_to_coord(1,1, (0xf0 << 8) | 'm');
|
write_to_coord(1,1, (0xf0 << 8) | 'm');
|
||||||
write_to_coord(1,5, (0xf0 << 8) | 'j');
|
print_int(0x73f, 10);
|
||||||
write_to_coord(2,5, (0xf0 << 8) | 'j');
|
}
|
||||||
|
|
||||||
|
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'));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user