Skip to main content Skip to local navigation

Disassembling in MPLABX & MCUXpresso

[to be updated]

When you write programs in languages like C or C++ the programs get converted by the compiler tools into commands that the computer can read and understand.  Just before the compiler tools do that they convert your work into a sequence of commands into a language called Assembler.

Back in the day we taught entire courses in Assembler because compilers were considered expensive and not terribly efficient.  These days, they're generally free and do a really good job, so why would we need to know about Assembler?  Well, there are three reasons that I can think of that apply to students in 2020:

  1. You are learning about how computers work in a university or college course.
    • either write the Assembler from scratch (hard at first) or write the C solution and check out the Assembler listings that result (easier at first).
  2. You need to verify that the compiler is doing what you asked it to do, for the sake of optimization, safety or security.
    • You can write "in line" assembler routines in your C solution as necessary
  3. You're dealing with a chip that's so new or rare that the compiler tools aren't available or good enough (that's really rare)

In MPLAB X (5.35+)

Make sure that you1. Open the Project Properties.
2. Select the "Loading" node under "Conf: [your current configuration]".
3. Check "Load Symbols when Programming or building for production".

 

right click on the header and drag the disassembler icon onto the header.

In MCUXpresso (11.1+)

And in MCUXpresso for LPC802 and other parts, you can access the disassembly view while debugging.  But if you don't have a target board you can still see it as explained by Erich Styger.

Assembler code by disassembling the object file.

Assembler code can be accessed by disassembling the object file.

After you've clicked your way to the disassembled file you can see it.

After you've clicked your way to the disassembled file you can see it.

Alternatively, you can have it auto-generated via the compiler settings.

Alternatively, you can have it auto-generated via the compiler settings by adding (as described by Erich Styger) the flags: -Wa,-adhlns="$@.lst"

 

But if you use the automated compiler generated list file the result is pretty ugly.

Ugly disassembly.

Ugly disassembly.