Created
July 10, 2014 18:46
-
-
Save jroelofs/126d2563f9c32f7e7353 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main() { | |
int Cpsr = 0x40000173; | |
int armflag_N = (Cpsr >> 31) & 1; | |
int armflag_Z = (Cpsr >> 30) & 1; | |
int armflag_C = (Cpsr >> 29) & 1; | |
int armflag_V = (Cpsr >> 28) & 1; | |
int armflag_Q = (Cpsr >> 27) & 1; | |
int armflag_J = (Cpsr >> 24) & 1; | |
int armflag_GE = (Cpsr >> 16) & 7; | |
int armflag_E = (Cpsr >> 9) & 1; | |
int armflag_A = (Cpsr >> 8) & 1; | |
int armflag_I = (Cpsr >> 7) & 1; | |
int armflag_F = (Cpsr >> 6) & 1; | |
int armflag_T = (Cpsr >> 5) & 1; | |
int armflag_M = (Cpsr >> 0) & 31; | |
printf(" +----+----+----+----+----+----+----+----+\n"); | |
printf("Legend: |NZCV|Q--J|----|GEGE|----|--EA|IFTM|MMMM|\n"); | |
printf(" +----+----+----+----+----+----+----+----+\n"); | |
printf(" | x%X| x%X| x%X| x%X| x%X| x%X| x%X| x%X|\n", | |
(Cpsr & 0xf0000000) >> 28, | |
(Cpsr & 0x0f000000) >> 24, | |
(Cpsr & 0x00f00000) >> 20, | |
(Cpsr & 0x000f0000) >> 16, | |
(Cpsr & 0x0000f000) >> 12, | |
(Cpsr & 0x00000f00) >> 8, | |
(Cpsr & 0x000000f0) >> 4, | |
(Cpsr & 0x0000000f) >> 0); | |
printf("Actual: |"); | |
printf(armflag_N ? "N" : " "); | |
printf(armflag_Z ? "Z" : " "); | |
printf(armflag_C ? "C" : " "); | |
printf(armflag_V ? "V" : " "); | |
printf("|"); | |
printf(armflag_Q ? "Q" : " "); | |
printf("--"); | |
printf(armflag_J ? "J" : " "); | |
printf("|"); | |
printf("----"); | |
printf("|"); | |
printf("%d", armflag_GE & 8); | |
printf("%d", armflag_GE & 4); | |
printf("%d", armflag_GE & 2); | |
printf("%d", armflag_GE & 1); | |
printf("|"); | |
printf("----"); | |
printf("|"); | |
printf("--"); | |
printf(armflag_E ? "E" : " "); | |
printf(armflag_A ? "A" : " "); | |
printf("|"); | |
printf(armflag_I ? "I" : " "); | |
printf(armflag_F ? "F" : " "); | |
printf(armflag_T ? "T" : " "); | |
printf("%d", (armflag_M & 16)?1:0); | |
printf("|"); | |
printf("%d", (armflag_M & 8)?1:0); | |
printf("%d", (armflag_M & 4)?1:0); | |
printf("%d", (armflag_M & 2)?1:0); | |
printf("%d", (armflag_M & 1)?1:0); | |
printf("|"); | |
printf("\n"); | |
printf(" +----+----+----+----+----+----+----+----+\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment