polmon: refactor jump & stdlib
This commit is contained in:
31
stdlib.c
Normal file
31
stdlib.c
Normal file
@@ -0,0 +1,31 @@
|
||||
int getchar() {
|
||||
register char c asm ("al");
|
||||
asm volatile (
|
||||
"movb $0x00, %%ah\n\t"
|
||||
"int $0x16"
|
||||
: "=r" (c)
|
||||
:: "ah", "cc"
|
||||
);
|
||||
return c;
|
||||
}
|
||||
|
||||
int putchar(int c) {
|
||||
asm volatile (
|
||||
"push %%bp \n\t"
|
||||
"mov %0, %%ax \n\t"
|
||||
"movb $0x0e, %%ah \n\t"
|
||||
"movb $0, %%bh \n\t"
|
||||
"int $0x10 \n\t"
|
||||
"pop %%bp \n\t"
|
||||
:: "r" (c)
|
||||
: "ax", "bh", "cc"
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int puts(const char* s) {
|
||||
while (*s) {
|
||||
putchar(*s++);
|
||||
}
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user