diff options
| -rw-r--r-- | userspace/Makefile | 8 | ||||
| -rw-r--r-- | userspace/add.c | 37 |
2 files changed, 43 insertions, 2 deletions
diff --git a/userspace/Makefile b/userspace/Makefile index 1663d1d..c6bfb3f 100644 --- a/userspace/Makefile +++ b/userspace/Makefile @@ -8,7 +8,7 @@ LDFLAGS=-L/home/miguel/temp/fool-os-stuff/newlib-build-clean/i686-elf/newlib/ \ -L/home/miguel/temp/fool-os-stuff/newlib-build-clean/i686-elf/libgloss/libnosys/ \ -lnosys -ext2.img: shell simple brainfuck +ext2.img: shell simple brainfuck add dd if=/dev/zero of=ext2.img bs=512 count=500 sudo mkfs.ext2 -O none ext2.img -F mkdir mnt @@ -20,6 +20,7 @@ ext2.img: shell simple brainfuck cp shell mnt cp simple mnt cp brainfuck mnt + cp add mnt sync sudo umount mnt rm mnt -rf @@ -33,8 +34,11 @@ shell: foolshell.o crt0.o simple: simple.o crt0.o ${CC} -T linker.ld ${LDFLAGS} $< -Wl,--oformat,binary -o simple +add: add.o crt0.o + ${CC} -T linker.ld ${LDFLAGS} $< -Wl,--oformat,binary -o add + clean: - -rm *.o *.out shell simple ext2.img brainfuck + -rm *.o *.out shell simple ext2.img brainfuck add umount: sudo umount mnt diff --git a/userspace/add.c b/userspace/add.c new file mode 100644 index 0000000..17ddb64 --- /dev/null +++ b/userspace/add.c @@ -0,0 +1,37 @@ +#include <stdio.h> +#include <string.h> +#include "syscalls.c" +#include "../fs/fs.h" + + +int main(int argc, char **argv) +{ + syscalls_init(); + + FILE *input; + input=fopen(1,"r"); + char *buf=malloc(256); + + int sum=0; + int i=0; + + while(1) + { + printf("enter numer %i: ",i+1); + fgets(buf,255,input); + if(buf[1]=='x')break; + i++; + sum+=atoi(buf); + + } + + printf("sum = %i \n",sum); + printf("avg = %i \n\n",sum/i); + + execve(15,0,0); +} + + + + + |
