polmon: refactor jump & stdlib

This commit is contained in:
2025-09-29 17:52:21 +02:00
parent 8a06693456
commit de41328677
3 changed files with 102 additions and 68 deletions

31
stdlib.c Normal file
View 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;
}