How do I tell GCC asm that an input register is clobbered?

后端 未结 1 330
太阳男子
太阳男子 2020-12-18 07:34

I\'m trying to do a 64=32x32 multiply via the x86 mul instruction, but I only need the high dword of the result (the edx register). So naturally,

相关标签:
1条回答
  • 2020-12-18 08:09

    Just make a useless temp for the output to go into and the compiler will optimize it out. For example:

    __asm__("mull\t%2" : "=d"(div10), "=a"((int){0})
        : "a"(UINT32_C(0x1999999A)), "r"(number) : "cc");
    

    That's the easiest way I know to handle clobbered inputs.

    0 讨论(0)
提交回复
热议问题