Generating assembly code

Completed

Is there a way to automatically generate assembly source code every time I compile?

0
1 comment

Yes, and the syntax depends on the compiler you are using. If you're using `gcc` on Linux, try adding the following to your `CMakeLists.txt`:

set_target_properties(sandbox PROPERTIES COMPILE_FLAGS "-save-temps -fverbose-asm -O0 -Wa,-adhlmn=main.lst")

Replace `sandbox` with the name of your project. the `-O0` is a fully optimized compile; use `-O3` for unoptimized compile. It will leave *.s files in the `cmake-build-debug` directory.

Be warned that the .s file(s) generated are pretty cryptic (even for assembly).

 Oh, and the `main.lst` part will cause a combined C++/assembly listing to be written to `main.lst`

1

Please sign in to leave a comment.