Sid Muthal
Sid Muthal

Reputation: 63

How do I view Assembly my C code in MPLAB x

I have code written in C but I need to see the Assembly file so I can optimize the code and figure out how long certain functions will take. Does anyone know of a quick way to pull up the Assembly code?

Upvotes: 6

Views: 15306

Answers (5)

theerrormagnet
theerrormagnet

Reputation: 314

This works for MPLAB X IDE v5.40:

Go to Project Properties.
Select Simulator as tool.
Set a breakpoint somewhere in your code.
Debug Main Project.
Window -> Debugging -> Disassembly

Upvotes: 1

avl_sweden
avl_sweden

Reputation: 622

Look in the folder dist/default/production/ and you may find a '.lst'-file there, which contains an annotated assembly representation of your program.

At least that works on my machine, MPLAB v3.45 and XC8 compiler v1.38.

Upvotes: 1

SpaceDog
SpaceDog

Reputation: 3269

For anyone looking for this in the future, I stumbled on the same problem and a better solution.

In MPLAB X, right click the toolbar and select customize (also under View/Toolbars). Now in the menu of things you can drag to the toolbar find the 'Window' tree and under that 'Disassembly Listing File'. Drag that to somewhere on a toolbar (choose one you have set to always be there).

Now when you build something in debug mode you can click the button to open a (nicely formatted) assembly window. If you keep it open it will auto-refresh after each build.

Upvotes: 4

Rocky
Rocky

Reputation: 91

I also had the same problem as you. Here is what worked for me.

Debug the main program, when finished, choose

" Window >> Debugging >> Disassembly ".

Then you would see the corresponding assembly code.

Hope it could help you out.

Upvotes: 9

JoeManiaci
JoeManiaci

Reputation: 475

You basically just have to not compile it all the way through, there are flags available so that you can see your code in various states, including assembly.

Take a .c file and compile it with gcc -S test.c

EDIT: I didn't think MPLAB was important to your question until I googled it, but I guess it's safe to assume that you're running this code in the non-OS form?

EDIT: A few MPLAB answers http://www.microchip.com/forums/m537589.aspx

Upvotes: 2

Related Questions