a5: Flags ausgelesen
This commit is contained in:
parent
7654da783f
commit
d14a041061
1
.gitignore
vendored
1
.gitignore
vendored
@ -6,6 +6,7 @@ CMakeFiles
|
||||
*.cmake
|
||||
CMakeCache.txt
|
||||
Makefile
|
||||
!/src/c/a5/Makefile
|
||||
Hardwarenahe_Programmierung.cbp
|
||||
*~
|
||||
*.[oa]
|
||||
|
@ -30,14 +30,10 @@ return:
|
||||
|
||||
pop edx;Flagregister in edx schreiben
|
||||
|
||||
;FIXME: Hier wird an die falsche Stelle oder so geschrieben
|
||||
|
||||
mov ebx, [ebp+20]
|
||||
|
||||
mov [ebx], edx
|
||||
|
||||
;mov [ebp+20], edx;Flagregister aus edx in flags ptr aus C kopieren
|
||||
;mov word[ebp+24], 32
|
||||
|
||||
pop edx
|
||||
pop ecx
|
||||
@ -47,6 +43,4 @@ return:
|
||||
pop ebp
|
||||
ret
|
||||
|
||||
section .data
|
||||
|
||||
temp dw 0
|
||||
section .data
|
@ -26,9 +26,12 @@ int main(int argc, char **argv) {
|
||||
int op2 = atoi(argv[3]);
|
||||
char what = *argv[2];
|
||||
|
||||
signed short sop1 = (short) op1;
|
||||
signed short sop2 = (short) op2;
|
||||
unsigned short uop1 = (unsigned short) op1;
|
||||
unsigned short uop2 = (unsigned short) op2;
|
||||
|
||||
unsigned int *flags = malloc(sizeof(unsigned int));
|
||||
//TODO: DEBUG Statement, remove later
|
||||
*flags = 42;
|
||||
|
||||
int result = addsub(op1, op2, what, flags);
|
||||
|
||||
@ -38,22 +41,30 @@ int main(int argc, char **argv) {
|
||||
printf("Flags:\n");
|
||||
printf("O D I T S Z A P C\n");
|
||||
|
||||
int flagArray[12];
|
||||
|
||||
/*
|
||||
* TODO: Interpretation wenn Fehler im ASM behoben
|
||||
* https://stackoverflow.com/a/9361069
|
||||
*/
|
||||
|
||||
printf("%u\n\n", *flags);
|
||||
printf("%p\n", flags);
|
||||
|
||||
for(int i = 0; i < 12; ++i) {
|
||||
flagArray[i] = *flags % 2;
|
||||
*flags = *flags / 2;
|
||||
}
|
||||
|
||||
for(int i = 12; i > 0; --i) {
|
||||
printf("%d ", flagArray[i-1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
printf("\n\n");
|
||||
|
||||
printf("Ergebnis und Operanden Signed:\n");
|
||||
printf("%d %c %d = %d", op1, what, op2, signedRes);
|
||||
printf("%d %c %d = %d", sop1, what, sop2, signedRes);
|
||||
|
||||
printf("\n\n");
|
||||
|
||||
printf("Ergebnis und Operanden Unsigned:\n");
|
||||
printf("%d %c %d = %u", op1, what, op2, unsignedRes);
|
||||
printf("%u %c %u = %u", uop1, what, uop2, unsignedRes);
|
||||
|
||||
printf("\n\n");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user