Generate assembly code with gcc/icc
- With GCC, add
-S
option
gcc -x c -c -O4 -Wall -g -lineinfo -masm=intel -S main.c
main.s
will be created in the current directory and includes the assembly code
To view assembly code along with source code, use -Wa,-adhlng
. source
gcc -Wa,-adhln -g -x c -c -O4 -lineinfo -masm=intel main.c
The assembly code along with original source code will be printed to the standard output.
You can use -masm=att
(default) if you prefer the att dialect.
- With ICC, use
-S
option. Similar to GCC
icc -x c -c -O3 -Wall -debug inline-debug-info -g -lineinfo -S main.c
main.s
will be created in the current directory and includes the assembly code.
- To generate source code along with the assembly code, use
-fsource-asm
icc -x c -c -O3 -Wall -debug inline-debug-info -g -lineinfo -S -fsource-asm main.c
Source code will be attached together with assembly code in main.s
.
- Generate from object files. source
objdump -d -S -l -M intel critical.o &> critical.asm