48 lines
No EOL
885 B
C
48 lines
No EOL
885 B
C
// kernel for the bad dos.
|
|
char get_char();
|
|
void print_char(char c);
|
|
|
|
void print(const char* str) {
|
|
while (*str) {
|
|
__asm__ __volatile__(
|
|
"mov ah, 0x0E"
|
|
"mov al, %[char];"
|
|
"int 0x10;"
|
|
:
|
|
: [char] "r" (*str)
|
|
);
|
|
}
|
|
}
|
|
|
|
void kernel_main() {
|
|
print("Welcome to BadDOS!\r\n");
|
|
print("type something or die:\r\n");
|
|
|
|
while (1) {
|
|
print("/dev/flp/> ");
|
|
char c = get_char();
|
|
print_char(c);
|
|
if (c == '\r') print("\r\n");
|
|
}
|
|
}
|
|
|
|
char get_char() {
|
|
char c;
|
|
__asm__ __volatile__(
|
|
"mov ah, 0x00;"
|
|
"int 0x16;"
|
|
"mov %[char], al;"
|
|
: [char] "=r" (c)
|
|
);
|
|
return c;
|
|
}
|
|
|
|
void print_char(char c) {
|
|
__asm__ __volatile__(
|
|
"mov ah, 0x0E;"
|
|
"mov al, %[char];"
|
|
"int 0x10;"
|
|
:
|
|
: [char] "r" (c)
|
|
);
|
|
} |