a5: kleinere Änderungen
This commit is contained in:
parent
841c5961e0
commit
98d1ae60ae
|
@ -2,3 +2,4 @@
|
|||
.idea
|
||||
bin
|
||||
cmake-build-debug
|
||||
CMakeFiles
|
||||
|
|
|
@ -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
|
|
@ -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");
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#!/usr/bin/env bash
|
||||
make
|
||||
./flagtest 32769 + 2
|
||||
./flagtest 32769 - 2
|
Loading…
Reference in New Issue