summaryrefslogtreecommitdiff
path: root/userspace
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-08-17 03:57:35 +0200
committerMiguel <m.i@gmx.at>2018-08-17 03:57:35 +0200
commit413f1f19184acd9024b9a97156c467b88ff72484 (patch)
treefcc8ba0a4ea8a1785d5818c7793e946da84e07e6 /userspace
parentc742be9c738c91703a7be787639cad167de3a6b1 (diff)
math, time, seed and randomness - simple test
Diffstat (limited to 'userspace')
-rw-r--r--userspace/Makefile8
-rw-r--r--userspace/add.c41
-rw-r--r--userspace/crt0.S3
-rw-r--r--userspace/task1.c1
-rw-r--r--userspace/test-math.c32
5 files changed, 36 insertions, 49 deletions
diff --git a/userspace/Makefile b/userspace/Makefile
index 62bc857..2812edd 100644
--- a/userspace/Makefile
+++ b/userspace/Makefile
@@ -1,4 +1,3 @@
-
CC=i686-foolos-gcc
CC=i686-elf-gcc
@@ -12,9 +11,10 @@ CFLAGS+=-g
#CFLAGS+=-fstack-protector-all
#LDFLAGS=-nostdlib
-LDFLAGS=-L/home/miguel/foolos/usr/i686-foolos/lib/ -lc -lm -lg -lnosys
+LDFLAGS=-L/home/miguel/foolos/usr/i686-foolos/lib/
+LDLIBS=-lc -lm -lg -lnosys
-PROGS=foolshell ls simple brainfuck add checker clear task1 task2 init cat snake
+PROGS=foolshell ls simple brainfuck test-math checker clear task1 task2 init cat snake
include ../Makefile.common
@@ -50,7 +50,7 @@ brainfuck: brainfuck.o
snake: snake.o
foolshell: foolshell.o
simple: simple.o
-add: add.o
+test-math: test-math.o
checker: checker.o
task1: task1.o
task2: task2.o
diff --git a/userspace/add.c b/userspace/add.c
deleted file mode 100644
index 94bb244..0000000
--- a/userspace/add.c
+++ /dev/null
@@ -1,41 +0,0 @@
-#include <stdio.h>
-#include <string.h>
-#include <stdint.h>
-#include <math.h>
-#include "../fs/fs.h"
-
-int main(int argc, char **argv)
-{
-
- float sum=0;
- float 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,stdin);
-
- if(buf[1]=='x')break;
-
- i++;
- sum+=atoi(buf);
- }
-
- if(i!=0)
- {
- puts("--------");
- printf("sum = %f \n",sum);
- printf("avg = %f \n",sum/i);
-// printf("sin(avg) = %f \n\n",sin(sum/i));
- }
-
- return 0;
-}
-
-
-
-
-
diff --git a/userspace/crt0.S b/userspace/crt0.S
index 4c08f89..23efec5 100644
--- a/userspace/crt0.S
+++ b/userspace/crt0.S
@@ -24,6 +24,3 @@ call _exit2
.wait:
hlt
jmp .wait
-
-.hellostr:
-.ascii "Hello Ass"
diff --git a/userspace/task1.c b/userspace/task1.c
index d9875f4..793b7f8 100644
--- a/userspace/task1.c
+++ b/userspace/task1.c
@@ -27,7 +27,6 @@ ULL fib(ULL i)
}
-
int main(unsigned int argc, char **argv)
{
ULL i=0;
diff --git a/userspace/test-math.c b/userspace/test-math.c
new file mode 100644
index 0000000..acaecad
--- /dev/null
+++ b/userspace/test-math.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <math.h>
+#include <time.h>
+
+int main(int argc, char **argv)
+{
+ time_t ltime;
+ time(&ltime);
+ printf("the time is %s", ctime(&ltime));
+
+ unsigned int seed=time(NULL);
+ printf("seed = %u\n",seed);
+
+ srand(seed);
+
+ for(int i=0;i<10;i++)
+ {
+ int r=rand()%100;
+ printf("sin(%i) = %f \n",r,sin(r));
+ }
+
+
+ return 0;
+}
+
+
+
+
+