/* * Inline assembly snippet * Polprog 2018 * 3 clause BSD */ #include int main(){ int h; std::cout << "Enter h: "; std::cin >> h; bool a; asm volatile (" \ cmp $10, %1\n \ mov $1, %0\n \ jg 1f\n \ mov $0, %0\n \ 1:\n \ ":"=r" (a) : "r" (h) : "cc"); //CMP could overwrite existing CC [== EFLAGS] value, hence cc in clobbers //volatile modifier on those variables unnecesary since we are modifying the register that // holds a and h at this moment if(a){ std::cout << "H > 10" << std::endl; } else { std::cout << "H <= 10" << std::endl; } }