diff --git a/CMakeLists.txt b/CMakeLists.txt index ce38bb3..c764f3d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,4 +8,6 @@ SET(CMAKE_BUILD_TYPE Debug) set (EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/bin) set (LIBRARY_OUTPUT_PATH ${EXECUTABLE_OUTPUT_PATH}) -add_subdirectory(src/c) \ No newline at end of file +add_subdirectory(src/c/a3) + +add_executable(a5 src/c/a5/flagtest.c) \ No newline at end of file diff --git a/src/c/CMakeLists.txt b/src/c/a3/CMakeLists.txt similarity index 100% rename from src/c/CMakeLists.txt rename to src/c/a3/CMakeLists.txt diff --git a/src/c/a3.c b/src/c/a3/a3.c similarity index 100% rename from src/c/a3.c rename to src/c/a3/a3.c diff --git a/src/c/a3.h b/src/c/a3/a3.h similarity index 100% rename from src/c/a3.h rename to src/c/a3/a3.h diff --git a/src/c/a5/Makefile b/src/c/a5/Makefile new file mode 100644 index 0000000..74ca55f --- /dev/null +++ b/src/c/a5/Makefile @@ -0,0 +1,20 @@ +# C-Quellcode kompilieren und mit ASM-Modul linken +flagtest: addsub.o flagtest.o + gcc -m32 -o flagtest flagtest.o addsub.o # linken + +flagtest.o: flagtest.c + gcc -m32 -c -o flagtest.o flagtest.c # compilieren + +# ASM-Modul assemblieren +addsub.o: addsub.asm + nasm -f elf -o addsub.o addsub.asm + +# Projekt aufraemen +clean: + @echo 'Ausgabedateien loeschen' + rm -f flagtest *.o *~ + + + + + diff --git a/src/c/a5/addsub.asm b/src/c/a5/addsub.asm new file mode 100644 index 0000000..6ae41f8 --- /dev/null +++ b/src/c/a5/addsub.asm @@ -0,0 +1,14 @@ + +section .text + +global _addsub + +_addsub: + push ebp + mov ebp, esp + + mov eax, 0 + + mov esp, ebp + pop ebp + ret \ No newline at end of file diff --git a/src/c/a5/flagtest.c b/src/c/a5/flagtest.c new file mode 100644 index 0000000..1657ff9 --- /dev/null +++ b/src/c/a5/flagtest.c @@ -0,0 +1,24 @@ +#include +#include + +extern int addsub(int op1, int op2, char what, unsigned int *flags); + + +int main(int argc, char **argv) { + if(argc != 4) { + printf("Wrong number of arguments\n"); + return -1; + } + + int op1 = atoi(argv[1]); + int op2 = atoi(argv[3]); + char what = *argv[2]; + + unsigned int * flags = NULL; + + int result = addsub(op1, op2, what, flags); + + printf("%d\n", result); + + return 0; +} \ No newline at end of file