It is sometime useful to be able to view the assembly instructions generated by the compilation tools. There are a number of ways of doing this.
First of all open out the project within the Project Explorer, so that you can see the files and directories within it. Assuming a default project structure, and that a build has alread occured, two of these directories will be Debug and Release - matching the project's build configurations. Navigate into the directory matching the build configuration you are currently using.
Now if you want to disassemble the complete executable, look for the file with the .axf file extension (Arm eXecutable File), and right click over it. In the context sensitive menu that is then displayed, highlight "Binary Utilities->Disassemble". The GUI will then invoke the GNU objdump utility to generate a disassembly file, which will be launched into the editor view.
If you want to disassemble a particular source file, rather than the whole executable, open the "src" subdirectory of the Debug (or Release) directory of your project, and right click over the appropriate .o file, and then highlight "Binary Utilities->Disassemble".
It is possible to change the default options used by the disassembler so that the assembly instructions are interleaved with the source statements. To do this,
However, be warned that for each level of optimization beyond -O0, then the link between assembler and C source becomes more tenuous as the compiler will remove, reorder and optimize the generated code.
It is also possible to automatically create a disassembly of your application every time you carry out a (successful) build (with source information included if required). Details of how to do this can be found in the FAQ Post-processing your linked application.
Sometimes you may want to create a disassembly of each generated object file each time that you carry out a build. To do this...
This will then generate the interleaved source/asm file during the build for each source file.
Note that the "," (comma) character is required. The -Wa is an option to the compiler which tells it to pass the following command to the assembler (the -ahlnds).
Alternatively, you can add the -save-temps to the miscellaneous compiler options. This will cause the compiler to leave the temporary .i (preprocessed source) and .s (assembler listing) files that it creates during a build in your build directory.
It is also possible to see the disassembly of your code whilst debugging. For more details see:
Is there any documentation on how to read the generated .asm file, or what the -ahlnds means? (I couldn't find this command mentioned in the GCC documentation).
See https://mcuoneclipse.com/2018/07/08/creating-disassembly-listings-with-gnu-tools-and-eclipse/, it explains the -a option and has a link to the GNU gcc documentation.