diff --git a/iso/boot/kernel.elf b/iso/boot/kernel.elf index fcbd624..8423cb0 100755 Binary files a/iso/boot/kernel.elf and b/iso/boot/kernel.elf differ diff --git a/os.iso b/os.iso index 29c6535..9101acb 100644 Binary files a/os.iso and b/os.iso differ diff --git a/src/kernel/shell.c b/src/kernel/shell.c index a0bd268..763500f 100644 --- a/src/kernel/shell.c +++ b/src/kernel/shell.c @@ -12,7 +12,7 @@ void shell_install() char input_buffer[BUFFER_SIZE]; colorputs("blankos> ", 9); get_input(input_buffer, BUFFER_SIZE); - printf("\n"); + puts("\n"); // Childish shell if (strcmp(input_buffer, "") == 0) @@ -21,7 +21,7 @@ void shell_install() } else if (strcmp(input_buffer, "help") == 0) { - printf("This is the Blank Operating System\ndesigned for fun by xamidev\n\nCommand help:\n\n\thelp - shows this message\n\tpanic - makes the kernel panic\n\twords - generates random words\n"); + printf("This is the Blank Operating System\ndesigned for fun by xamidev\n\nCommand help:\n\n\thelp - shows this message\n\tpanic - makes the kernel panic\n\twords - generates random words\n\tprimes - computes prime numbers\n"); } else if (strcmp(input_buffer, "panic") == 0) { @@ -31,6 +31,10 @@ void shell_install() { program_words(); } + else if (strcmp(input_buffer, "primes") == 0) + { + program_primes(); + } else { printf("Unknown command %s\n", input_buffer); } diff --git a/src/programs/primes.c b/src/programs/primes.c new file mode 100644 index 0000000..b06ae7e --- /dev/null +++ b/src/programs/primes.c @@ -0,0 +1,23 @@ +#include "../libc/stdint.h" +#include "../libc/stdio.h" + +#define PRIMES_MAX 1000000 + +bool isPrime(int n) +{ + if (n == 1 || n == 0) return false; + for (int i=2; i<= n/2; i++) if (n%i == 0) return false; + return true; +} + +void program_primes() +{ + for (long long x=0; x