// printf(" cf=%04x\npf=%04x\naf=%04x\nzf=%04x\nsf=%04x\ntf=%04x\nif=%04x\ndf=%04x\nof=%04x\n", _CF, _PF, _AF, _ZF, _SF, _TF, _IF, _DF, _OF);\r
printf("cflag: "BYTE_TO_BINARY_PATTERN""BYTE_TO_BINARY_PATTERN"\n", BYTE_TO_BINARY(_cflag>>8), BYTE_TO_BINARY(_cflag));\r
// printf("cflag: %s\n",(_cflag));\r
+ printf("dx: "NIBBLE_TO_BINARY_PATTERN""NIBBLE_TO_BINARY_PATTERN"\n", NIBBLE_TO_BINARY(_dx>>4), NIBBLE_TO_BINARY(_dx));\r
#endif\r
printf("dx: "BYTE_TO_BINARY_PATTERN""BYTE_TO_BINARY_PATTERN"\n", BYTE_TO_BINARY(_dx>>8), BYTE_TO_BINARY(_dx));\r
printf(" ---------------------------------------\n");\r
(byte & 0x02 ? '1' : '0'), \\r
(byte & 0x01 ? '1' : '0')\r
\r
+#define NIBBLE_TO_BINARY_PATTERN "%c%c%c%c"\r
+#define NIBBLE_TO_BINARY(byte) \\r
+ (byte & 0x08 ? '1' : '0'), \\r
+ (byte & 0x04 ? '1' : '0'), \\r
+ (byte & 0x02 ? '1' : '0'), \\r
+ (byte & 0x01 ? '1' : '0')\r
+\r
#define PRINT_OPAQUE_STRUCT(p) print_mem((p), sizeof(*(p)))\r
\r
#endif/*__16_HEAD_H__*/\r
}\r
}\r
#endif\r
-\r
-//from https://stackoverflow.com/questions/18327439/printing-binary-representation-of-a-char-in-c\r
-const char *word_to_binary(int x)\r
-{\r
- static char b[17];\r
- int z;\r
-\r
- b[0] = '\0';\r
- for (z = 256; z > 0; z >>= 1)\r
- {\r
-/// printf(" z=%u b=%u x=%u\n", z, b, x);\r
- strcat(b, ((x & z) == z) ? "1" : "0");\r
- }\r
- return b;\r
-}\r
-\r
-const char *byte_to_binary(int x)\r
-{\r
- static char b[9];\r
- int z;\r
-\r
- b[0] = '\0';\r
- for (z = 128; z > 0; z >>= 1)\r
- {\r
- strcat(b, ((x & z) == z) ? "1" : "0");\r
- }\r
- return b;\r
-}\r
-\r
-const char *nibble_to_binary(int x)\r
-{\r
- static char b[9];\r
- int z;\r
-\r
- b[0] = '\0';\r
- for (z = 8; z > 0; z >>= 1)\r
- {\r
- strcat(b, ((x & z) == z) ? "1" : "0");\r
- }\r
- return b;\r
-}\r
-\r
-const char *boolean_to_binary(int x)\r
-{\r
- static char b[3];\r
- int z;\r
-\r
- b[0] = '\0';\r
- for (z = 1; z > 0; z >>= 1)\r
- {\r
- strcat(b, ((x & z) == z) ? "1" : "0");\r
- }\r
- return b;\r
-}\r
-\r
-void wordtest()\r
-{\r
- word pee;\r
- printf("wordtest\n");\r
- /* word to binary string */\r
- for(pee=0;pee<280;pee++)\r
- printf(" %u %s\n", pee, word_to_binary(pee));\r
- printf(" sizeof(word)=%s\n", word_to_binary(sizeof(word)));\r
- printf("end of word test\n");\r
-}\r
-\r
-void bytetest()\r
-{\r
- byte pee;\r
- printf("bytetest\n");\r
- /* byte to binary string */\r
- for(pee=0;pee<18;pee++)\r
- printf(" %u %s\n", pee, byte_to_binary(pee));\r
- printf(" sizeof(byte)=%s\n", byte_to_binary(sizeof(byte)));\r
- printf("end of byte test\n");\r
-}\r
-\r
-void nibbletest()\r
-{\r
- nibble pee;\r
- printf("nibbletest\n");\r
- /* nibble to binary string */\r
- for(pee=0;pee<18;pee++)\r
- printf(" %u %s\n", pee, nibble_to_binary(pee));\r
- printf(" sizeof(nibble)=%s\n", nibble_to_binary(sizeof(nibble)));\r
- printf("end of nibble test\n");\r
-}\r
-\r
-void booleantest()\r
-{\r
- boolean pee;\r
- printf("booleantest\n");\r
- /* boolean to binary string */\r
- for(pee=0;pee<4;pee++)\r
- printf(" %u %s\n", pee, boolean_to_binary(pee));\r
- printf(" sizeof(boolean)=%s\n", boolean_to_binary(sizeof(boolean)));\r
- printf("end of boolean test\n");\r
-}\r
void ClearMemory (global_game_variables_t *gvar);\r
void Quit (global_game_variables_t *gvar, char *error);\r
void turboXT(byte bakapee);\r
-const char *word_to_binary(int x);\r
-const char *byte_to_binary(int x);\r
-const char *nibble_to_binary(int x);\r
-const char *boolean_to_binary(int x);\r
-void wordtest();\r
-void bytetest();\r
-void nibbletest();\r
-void booleantest();\r
\r
#endif /*__16_TAIL__ */\r