
extern int write_to_coord(int x, int y, int x86_specifier);
extern int clear(int x86_specifier);
extern int rust_get_int();
void print_int(int, int);

void c_entry() {
    write_to_coord(1,1, (0xf0 << 8) | 'm');
    int from_rust = rust_get_int();
    print_int(from_rust, 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'));
}
