blob: 403586bf7e9feccf253ede2d2e83a017c6a15e02 (
plain) (
tree)
|
|
/* needs to stay the first line */
asm(".code16gcc\njmp $0, $main");
/* space for additional code */
char WRITE_CHARACTER_TTY = 0x0E;
void put(char c) {
short command = WRITE_CHARACTER_TTY << 8 | c;
// volatile because there is no output, so the function might get optimized
// away
// clang-format off
asm volatile(
"int $0x10;"
::"a"(command)
);
// clang-format on
}
void print(char const *const str) {
for (int i = 0; str[i] != '\0'; ++i) {
put(str[i]);
}
}
char getc() {
char ret;
asm("mov $0x00, %%ah;"
"int $0x16;"
: "=a"(ret));
return ret;
}
void main(void) {
print("Hello!");
put(getc());
}
|