3 ms·
The operand constraint should be "r" since bswap works only on registers. You can also simplify it a little using an input/output operand: asm ("bswap %0"
by mansr 15y ago
The operand constraint should be "r" since bswap works only on registers. You can also simplify it a little using an input/output operand:
asm ("bswap %0" : "+r"(x));
That said, since version 4.5, gcc recognises the typical byte-swapping pattern and uses the appropriate CPU instruction.