hazel/user/shell.c

53 lines
916 B
C

#include "../lib/strcmp.h"
void puts(const char *str) {
asm volatile (
"movl $1, %%eax\n\t"
"movl $1, %%edi\n\t"
"movl %0, %%esi\n\t"
"int $0x80"
:
: "r"(str)
: "%eax", "%edi", "%esi"
);
}
void read(int fd, void *buf, int size) {
asm volatile (
"movl $0, %%eax\n\t"
"int $0x80"
:
: "D"(fd), "d"(size), "S"(buf)
: "eax"
);
}
void reboot() {
asm volatile (
"movl $2, %%eax\n\t"
"int $0x80"
:
:
: "eax"
);
}
extern char *buf;
void _start() {
char buf1[256] = {0};
puts("Welcome to the Hazel user shell!\n");
while (1) {
puts("> ");
read(0, buf1, 256);
if (!strcmp(buf1, "SKIBIDI")) {
puts("dop dop yes yes!\n");
} else if (!strcmp(buf1, "REBOOT")) {
reboot();
}
else {
puts("unknown command!\n");
}
}
}