The gcc -S option will generate assembly code in AT&T syntax, is there a way to generate files in Intel syntax? Or is there a way to convert between the two?
The gcc -S option will generate assembly code in AT&T syntax, is there a way to generate files in Intel syntax? Or is there a way to convert between the two?
-masm=intelgcc -S -masm=intel -Og -fverbose-asm test.c
That works with GCC, and clang3.5 and later. GCC manual:
-masm=dialect
Output asm instructions using selected dialect. Supported choices are intel or att (the default one). Darwin does not support intel.
For Mac OSX, note that by default, the gcc command actually runs clang. Modern clang supports -masm=intel as a synonym for this, but this always works with clang:
clang++ -S -mllvm --x86-asm-syntax=intel test.cpp
Note that until clang 14, this does not change how clang processes inline asm() statements, unlike for GCC.
These are the options used by Matt Godbolt's Compiler Explorer site by default: https://godbolt.org/
See also How to remove "noise" from GCC/clang assembly output? for other options and tips for getting asm output that's interesting to look at.