diff options
Diffstat (limited to 'userspace')
| -rw-r--r-- | userspace/Makefile | 1 | ||||
| -rw-r--r-- | userspace/add.c | 14 | ||||
| -rw-r--r-- | userspace/checker.c | 1 | ||||
| -rw-r--r-- | userspace/foolshell.c | 19 | ||||
| -rw-r--r-- | userspace/simple.c | 2 |
5 files changed, 25 insertions, 12 deletions
diff --git a/userspace/Makefile b/userspace/Makefile index 7efc161..5d94a41 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -5,6 +5,7 @@ CFLAGS= CFLAGS+=-I.. CFLAGS+=-w CFLAGS+=-std=gnu11 +CFLAGS+=-O3 PROGS=foolshell ls simple brainfuck add checker clear diff --git a/userspace/add.c b/userspace/add.c index 2a13adf..3a624be 100644 --- a/userspace/add.c +++ b/userspace/add.c @@ -6,18 +6,16 @@ int main(int argc, char **argv) { - FILE *input; - input=fopen("input2.txt","r"); //stdin - int sum=0; int i=0; char *buf=malloc(256); + puts("\n*** fools calculator ***"); while(1) { printf("enter numer (or 'exit' to finish) %i: ",i+1); - fgets(buf,255,input); + fgets(buf,255,stdin); if(buf[1]=='x')break; @@ -25,8 +23,12 @@ int main(int argc, char **argv) sum+=atoi(buf); } - printf("sum = %i \n",sum); - printf("avg = %i \n\n",sum/i); + if(i!=0) + { + puts("--------"); + printf("sum = %i \n",sum); + printf("avg = %i \n\n",sum/i); + } return 0; } diff --git a/userspace/checker.c b/userspace/checker.c index e5352f6..ac0bcc9 100644 --- a/userspace/checker.c +++ b/userspace/checker.c @@ -9,6 +9,7 @@ int ch; /* Each character read. */ int checksum = 0; /* The checksum mod 2^16. */ int count=0; +printf("this will calc a simple checksum of the enered text\nPress Left Control + D to signify end of file \n",checksum,count); while ((ch = getc(fp)) != EOF) { checksum = (checksum >> 1) + ((checksum & 1) << 15); checksum +=(int) ch; diff --git a/userspace/foolshell.c b/userspace/foolshell.c index faa46be..e010c18 100644 --- a/userspace/foolshell.c +++ b/userspace/foolshell.c @@ -16,11 +16,12 @@ void hello() " / __/ / /_/ / /_/ / / / /_/ /___/ / \n" " /_/ \\____/\\____/_/ \\____//____/ \n" " \n" - "Welcome to FoolShell v0.3 (Compiled on " __DATE__ " at " __TIME__ "\n" + "Welcome to FoolShell v0.4 (Compiled on " __DATE__ " at " __TIME__ "\n" "------------------------------------------------------------------\n\n" "Please type 'help' anytime, to show shell \"built-ins\" or execute \n" "user programms that are in you $PATH directory by simply typing \n" - "their filenames.\n" + "their filenames. You can get additional information for many commands\n" + "by invking them with the --help or -h flag (e.g. ls --help) \n" ); printf("Your $PATH is currently set to: %s\n\n",getenv("PATH")); @@ -210,13 +211,23 @@ int process(char *buf) } else { - execve(token[0],token,0); char buf[256]; - sprintf(buf,"/bin/%s",token[0]); + sprintf(buf,"%s/%s",getenv("PATH"),token[0]); + asm("mov $0x05bff,%esp"); // set stack pointer execve(buf,token,environ); + asm("mov $0x07000,%esp"); // set stack pointer + puts("foolshell: command not found"); + + asm("mov $0x05bff,%esp"); // set stack pointer + static char *argv[]={"shell","--silent",NULL}; + execve("/bin/foolshell",argv,environ); // start shell + + + } + return 0; } diff --git a/userspace/simple.c b/userspace/simple.c index e84b072..0a04791 100644 --- a/userspace/simple.c +++ b/userspace/simple.c @@ -4,10 +4,8 @@ extern char **environ; int main(int argc, char **argv) { - printf("argv: 0x%08X\n",argv); - printf("env: 0x%08X\n",environ); int i=0; |
