Recent

This Page

User

Disassembling objects and executables

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.

Disassembling using the GUI

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, 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".

Including source information

It is possible to change the default options used by the disassemble so that the assembly instructions are interleaved with the source statements. To do this,

Go to Windows->Preferences

Select LPCXpresso or Red Suite, depending upon which toolchain you are using

Select Utilities.

Add -S to the 'disassemble command'.

However, be warned that for each level of optimization beyond -O0, then the link between assembler and C source becomes more and more tenuous as the compiler will remove code, reorder it and otherwise optimize it.

Automatically disassembling every build

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.

Automatically disassembling every source file

Sometimes you may want to create a disassembly of each object file every time that you carry out a build. To do this...

Go to Project Properties

Select C/C++ Build - Settings

Select MCU C Compiler - Miscellaneous

Add the following into the flag field:

-Wa,-ahlnds=${OutputFileBaseName}.asm

This will then generate the interleaved source/asm file during the build for each source file.

Note that -Wa is an option to the compiler which tells it to pass the following command to the assembler (the -ahlnds). For more details of these options, please see the appropriate compiler and assembler documention.

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.