a5: kleinere Änderungen

This commit is contained in:
Johannes Theiner 2018-12-31 19:48:32 +01:00
parent 841c5961e0
commit 98d1ae60ae
4 changed files with 26 additions and 7 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
.idea
bin
cmake-build-debug
CMakeFiles

View File

@ -9,6 +9,7 @@ addsub:
push ebx
push ecx
push edx
mov eax, 0
@ -29,13 +30,23 @@ return:
pop edx;Flagregister in edx schreiben
;TODO: Hier wird an die falsche Stelle oder so geschrieben
mov [ebp+20], edx;Flagregister aus edx in flags ptr aus C kopieren
;FIXME: Hier wird an die falsche Stelle oder so geschrieben
mov ebx, [ebp+24]
mov [ebx], edx
;mov [ebp+24], edx;Flagregister aus edx in flags ptr aus C kopieren
;mov word[ebp+24], 32
pop edx
pop ecx
pop ebx
mov esp, ebp
pop ebp
ret
ret
section .data
temp dw 0

View File

@ -6,12 +6,11 @@
* @param op1 ebp+8
* @param op2 ebp+12
* @param what ebp+16
* @param flags ebp+16
* @param flags ebp+24
* @return
*/
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");
@ -27,7 +26,9 @@ int main(int argc, char **argv) {
int op2 = atoi(argv[3]);
char what = *argv[2];
unsigned int *flags = malloc(32);
unsigned int *flags = malloc(sizeof(unsigned int));
//TODO: DEBUG Statement, remove later
*flags = 42;
int result = addsub(op1, op2, what, flags);
@ -36,12 +37,14 @@ int main(int argc, char **argv) {
printf("Flags:\n");
printf("O D I T S Z A P C\n");
/*
* TODO: Interpretation wenn Fehler im ASM behoben
* https://stackoverflow.com/a/9361069
*/
printf("%d\n\n", *flags);
printf("%u\n\n", *flags);
printf("%p\n", flags);
printf("Ergebnis und Operanden Signed:\n");

4
src/c/a5/run.sh Executable file
View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
make
./flagtest 32769 + 2
./flagtest 32769 - 2