#include #if __i386__ int detect(char c) { char result = 0; asm(" call 1f \n\t" "1: pop %%edi \n\t" " sub $9,%%edi \n\t" " mov $0x20,%%ecx \n\t" " repne scasb \n\t" " sete %0 \n\t" :"=a"(result): "0"(c)); return result; } #elif __x86_64__ int detect(char c) { char result = 0; asm("mov $0x20,%%ecx \n\t" "lea detect(%%rip),%%edi \n\t" "repne scasb \n\t" "sete %0 \n\t" :"=a"(result): "0"(c)); return result; } #else #error unexpected arch!!! #endif int main() { const int N = 4; const char INT0 = 0xce, INT1 = 0xf1, INT3 = 0xcc, INTn = 0xcd; // 0xcd + 0x03 const char a[] = {INT0, INT1, INT3, INTn}; for (int i = 0; i < N; ++i) if (detect(a[i])) printf("%hhx detected!!!\n", a[i]); else printf("%hhx not detected!!!\n", a[i]); }