NOTICE: This website will be shut down in the near future. Product content has moved to Forum content and FAQs have been moved to We encourage you to create a user account on to use the new community forums and access NXP microcontroller content. We greatly appreciate your contributions and look forward to seeing you at our new web location.


Disassembling objects and executables

lpcxpresso-support's picture

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

Including source information

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,

  1. Go to Window->Preferences
  2. Select LPCXpresso
  3. Select Utilities.
  4. 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 tenuous as the compiler will remove, reorder and optimize the generated code.

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 object file

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

  1. Go to Project Properties
  2. Select C/C++ Build - Settings
  3. Select MCU C Compiler - Miscellaneous
  4. 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 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.

Disassembly during debugging

It is also possible to see the disassembly of your code whilst debugging. For more details see:

Your rating: None