Debug Disassembly Window

Last modified by Microchip on 2023/11/14 15:23

Summary

When C programs are compiled, it is quite common for several lines of assembly code to be generated for an individual line of C code. Having multiple lines of assembly for each line of user, generated source code presents debugging challenges for the user. Entering breakpoints and single-step commands in the source code window does not provide a mechanism for examining the underlying assembly code. The Debug Disassembly Window gives the user access to debugging in assembly language for projects written in C. The Debug Disassembly Window allows the user to perform all the normal debug operations including single stepping and setting breakpoints on the individual assembly instructions generated from C code.

Opening the Debug Disassembly Window

In order for the debug disassembly window to open, the project must be in a debug session.
To open the Debug Disassembly Window, first, pause the debug session then select Window > Debugging > Disassembly.

Window > Debugging > Disassembly

The Debug Disassembly Window will open up in a new editor window tab. The Disassembly window will display the disassembly of the function pointed to by the Program Counter. The assembly language will be interspersed with the original C source code.

Opened disassembly window

Moving the Disassembly Window can allow both the disassembly and original source code to be viewed together. The image on the right displays two green lines for the single program counter value. Both green lines point to the same line of executable code.

source and disassembly opened

Selecting C or Assembly Code to Debug

You will select whether you want to debug in the Source Code Window or Debug Disassembly Window. “Left Click” in either the C file or the Debug Disassembly window to select the file to debug.

The window tabs will let you know which window is the active debug window. When a file has been selected the “tab” will appear in a light blue shade.

Debug in C or assembly

Stepping Through the Assembly Code

If the Debug Disassembly window is selected the “step into” function will only execute one line of assembly code. Each "step into" will move the green bar in the disassembly window one line of assembly code. Using assembly code may take several “step into”' presses before the green arrow in the C file window moves.

You can switch back and forth from the disassembly window to the source code window at any time by simply clicking in the window in which you wish to debug

Breakpoints in the Disassembly Window

When working with the C files the line breakpoint can be used. When working in the Debug Disassembly window, line breakpoints cannot be set. Address breakpoints must be used to stop the code on a line of code in the debug Disassembly window.
To set an Address Breakpoint in the debug disassembly window, left-click on the line number. When the breakpoint is set you will notice the address breakpoint icon in the line number margin.

Set an address breakpoint