MP_01 Testat
This commit is contained in:
parent
7bfc780c81
commit
8f7457e64d
BIN
01_ENV/Testat/a.out
Executable file
BIN
01_ENV/Testat/a.out
Executable file
Binary file not shown.
4
01_ENV/Testat/build-c.sh
Executable file
4
01_ENV/Testat/build-c.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
bash clean.sh
|
||||
clang-6.0 -c func1.c main.c
|
||||
clang-6.0 -s func1.o main.o -lm
|
14
01_ENV/Testat/build.sh
Executable file
14
01_ENV/Testat/build.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
# generate main.s, main.o, b.out
|
||||
pcc -O0 -S main.c
|
||||
as -o main.o main.s
|
||||
#ld -o b.out main.o /lib/crt0.o /lib/crti.o -lc
|
||||
pcc -o b.out main.o
|
||||
|
||||
# generate a.out
|
||||
pcc -O0 -g main.c
|
||||
|
||||
# generate assembly intermixed with source code
|
||||
objdump -S a.out > objdump-S_a.out.txt
|
||||
|
4
01_ENV/Testat/clean.sh
Executable file
4
01_ENV/Testat/clean.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
rm *.o *.out
|
||||
|
5
01_ENV/Testat/func1.c
Normal file
5
01_ENV/Testat/func1.c
Normal file
@ -0,0 +1,5 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int func1(int x) {
|
||||
return (x-2)*(x-6)*(x-10)*(x-15);
|
||||
}
|
1
01_ENV/Testat/func1.h
Normal file
1
01_ENV/Testat/func1.h
Normal file
@ -0,0 +1 @@
|
||||
int func1(int x);
|
BIN
01_ENV/Testat/func1.o
Normal file
BIN
01_ENV/Testat/func1.o
Normal file
Binary file not shown.
29
01_ENV/Testat/main.c
Normal file
29
01_ENV/Testat/main.c
Normal file
@ -0,0 +1,29 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "func1.h"
|
||||
|
||||
int recursive(int start, int stop);
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int zero = 0;
|
||||
for(int i = 0; i <= 20; ++i) {
|
||||
int tmp = func1(i);
|
||||
printf("Stelle: %d Wert: %d\n", i, tmp);
|
||||
if(tmp == 0) ++zero;
|
||||
}
|
||||
|
||||
printf("Nullstellen: %d\n", zero);
|
||||
|
||||
recursive(0, 20);
|
||||
|
||||
}
|
||||
|
||||
|
||||
int recursive(int start, int stop) {
|
||||
if(start <= stop) {
|
||||
recursive(start + 1, stop);
|
||||
printf("Stelle: %d, Wert: %d\n", start, func1(start));
|
||||
}
|
||||
return 0;
|
||||
}
|
BIN
01_ENV/Testat/main.o
Normal file
BIN
01_ENV/Testat/main.o
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user