a5: erster Anfang
This commit is contained in:
parent
949a74f52c
commit
69a5b559cd
@ -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)
|
||||
add_subdirectory(src/c/a3)
|
||||
|
||||
add_executable(a5 src/c/a5/flagtest.c)
|
20
src/c/a5/Makefile
Normal file
20
src/c/a5/Makefile
Normal file
@ -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 *~
|
||||
|
||||
|
||||
|
||||
|
||||
|
14
src/c/a5/addsub.asm
Normal file
14
src/c/a5/addsub.asm
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
section .text
|
||||
|
||||
global _addsub
|
||||
|
||||
_addsub:
|
||||
push ebp
|
||||
mov ebp, esp
|
||||
|
||||
mov eax, 0
|
||||
|
||||
mov esp, ebp
|
||||
pop ebp
|
||||
ret
|
24
src/c/a5/flagtest.c
Normal file
24
src/c/a5/flagtest.c
Normal file
@ -0,0 +1,24 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user