How to set a variable in GCC with Intel syntax inline assembly?

后端 未结 3 1559
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 09:25

Why doesn\'t this code set temp to 1? How do I actually do that?

int temp;
__asm__(
    \".intel_syntax;\"
    \"mov %0, eax;\"
    \"mov eax, %         


        
3条回答
  •  时光取名叫无心
    2020-11-30 09:39

    You want temp to be an output, not an input, I think. Try:

      __asm__(
          ".intel_syntax;"
          "mov eax, %1;"
          "mov %0, eax;"
          ".att_syntax;"
          : "=r"(temp)
          : "r"(1) 
          : "eax");
    

提交回复
热议问题