Keil Logo

How to view assembly code for specific function?

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Ryan Rutledge
Posted
9-Mar-2016 19:53 GMT
Toolset
ARM
New! How to view assembly code for specific function?

Hello, I'm trying to decide between implementations of a given function, based on the number of clock cycles each is supposed to take. I'm using the Lite version of µVision 5, with the debugger set to simulate. I can go into debug mode and open the disassembly view, but none of the source code is listed in the Hybrid display mode, it's all just assembly code. Further, I have no idea how to go to a section of assembly that represents either of my functions.

There isn't any context menu option in the source code window that would seem to take me to its section of assembly code, and I can't place a breakpoint in my source code window so that at least I could run to that and see where the program counter stops in the disassembly window. My coworker is under the impression that I should be able to click in my source code and have the disassembly view jump to the relevant section.

Bottom line, how do I find the assembly code of two functions so that I can compare their implementations? At this point it seems like my only choice is to toggle a bit in the functions and measure timing with an oscilloscope. :(

Ryan R.

Read-Only
Author
Sumatra Bigtotsie
Posted
9-Mar-2016 20:59 GMT
Toolset
ARM
New! RE: How to view assembly code for specific function?

You can use the keil utility fromelf [in the \Keil\ARM\ARMCC\bin\ directory) to view the code produced by the compiler.

I'm sure you are aware that whatever you do here, whatever you view and whatever you determine may change if you make a minor change to the code or change a project setting.

The only sure fire way of having fixed code is to resort to assembler. Even then the execution time is dependent on a large number of factors.

Read-Only
Author
Ryan Rutledge
Posted
9-Mar-2016 21:02 GMT
Toolset
ARM
New! RE: How to view assembly code for specific function?

I don't just want to see all the assembly code at once, I already have that in the disassembly window. What I really need is to be able to jump to the compiled code for a particular function.

Read-Only
Author
Westonsupermare Pier
Posted
9-Mar-2016 21:44 GMT
Toolset
ARM
New! RE: How to view assembly code for specific function?

So open the fromelf disassembly in a text editor and use the basic search functions?

For extra points you could push the listing through a post-processing step and annotate with cycle counts.

At the very least you should be able the right-click "Show Disassembly at address" in the disassembler pane and type in the name of the function rather than an address.

Read-Only
Author
Sumatra Bigtotsie
Posted
10-Mar-2016 07:14 GMT
Toolset
ARM
New! RE: How to view assembly code for specific function?

So open the fromelf disassembly in a text editor and use the basic search functions?

It seems imagination is no longer a prerequisite of becoming a developer <facepalm>.

Read-Only
Author
Sankalp Agarwal
Posted
10-Mar-2016 14:31 GMT
Toolset
ARM
New! RE: How to view assembly code for specific function?

You don't have to use fromelf etc. utility to see the source code corresponding to the assembly code.

Download the latest version of MDKv5.18 (in case you are working with Cortex-M) -> compile code -> in "Options for target" -> "Debug" -> select "Use Simulator" and "Load Application at startup"

Open the debug session and click on any line of assembly code in disassembly window you should see the corresponding source code in source code window and vice versa.

Read-Only
Author
Sumatra Bigtotsie
Posted
10-Mar-2016 15:34 GMT
Toolset
ARM
New! RE: How to view assembly code for specific function?

You don't have to use fromelf etc. utility to see the source code corresponding to the assembly code.

True. But having a file which you can view or edit makes it a whole lot easier to annotate the code.

Read-Only
Author
Per Westermark
Posted
10-Mar-2016 16:15 GMT
Toolset
ARM
New! RE: How to view assembly code for specific function?

Having a file also makes it easier to try to use diff or similar to compare. But this works best when having the pre-linked data without absolute addresses.

Read-Only
Author
Ryan Rutledge
Posted
10-Mar-2016 23:08 GMT
Toolset
ARM
New! RE: How to view assembly code for specific function?

It seems imagination is no longer a prerequisite of becoming a developer <facepalm>.
Well, that's an awfully rude thing to say given how well you know me.
My mistake was thinking that the disassembly output from fromelf was going to be the same as that of the disassembler in the IDE (not having any function labels), which it is not. Using fromelf --text -c, I do see assembly labels that contain the function names so I can see the code broken into functions.

I thank you for your original - albeit terse - suggestion to "use [fromelf] to view the code produced by the compiler", as that was indeed the right direction to go. I do not thank you for your snide crack about my lack of imagination since we all have occasionally missed something that is obvious to others. Perhaps if you had mentioned "--text", "disassemble code", or "object file" in the context of fromelf, I would have been more well-informed as a first-day user of Keil tools.

Sankalp,
You don't have to use fromelf etc. utility to see the source code corresponding to the assembly code.

Download the latest version of MDKv5.18 (in case you are working with Cortex-M) -> compile code -> in "Options for target" -> "Debug" -> select "Use Simulator" and "Load Application at startup"

Open the debug session and click on any line of assembly code in disassembly window you should see the corresponding source code in source code window and vice versa.

I tried to explain in my original post that exactly what you've suggested is not working for me, and I cannot identify why. I have the disassembly window in "mixed mode" but do not see any source code as seen in examples in Keil documentation. Clicking in either the disassembly window or a source code window does not cause any view change in either, contrary to what my coworker looking over my should said should be happening as you describe.

Read-Only
Author
Sumatra Bigtotsie
Posted
11-Mar-2016 07:12 GMT
Toolset
ARM
New! RE: How to view assembly code for specific function?

Well, that's an awfully rude thing to say given how well you know me.

Given your apparent dismissive response to my suggestion, I don't think it's particularly unfair.

Look at it from my side. I'm not here as a replacement manual. Be grateful that I didn't just simply reply RTFM (and include one of those really derogatory links to 'smart questions').

Anyway, I'm glad you've now found the information you were originally after and hope you can progress positively.

Read-Only
Author
Sankalp Agarwal
Posted
11-Mar-2016 10:32 GMT
Toolset
ARM
New! RE: How to view assembly code for specific function?

In that case, contact keil support at support.intl@keil.com along with a test project

Read-Only
Author
Larry Lai
Posted
13-Feb-2018 09:00 GMT
Toolset
ARM
New! Here is a 8051 Disassembler of win10 version

https://sites.google.com/site/larry2917b/home/search-the-8051-Disassembler-for-WINDOWS-10

It generates two assembly code from the HEX file. It will auto-detect where is DB statement.
Run these two files on IDE. Then try to combine these two files to a better one.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.