Using Windbg

Download windbg.zip from my Web page. Unzip it into the same folder as masm.

Assemble and link your program, following the directions in Using Masm to add directives to save the symbol table (example below assembles and links prog2.asm):

 

ml /c /coff /Fl /Zi prog2.asm                 //assembles (that switch is F-ell, not F-one)

link /debug /subsystem:console /entry:start /out:prog2.exe prog2.obj kernel32.lib

 

Start Debugger by typing Windbg at the DOS prompt.  From the menu bar, choose File | Open Executable. Select your .exe file, like assn9.exe. Another window may open; just bring the Windbg window to the front by clicking in it.

 

Press the Trace Into button { ↓}. A window saying “No information for Debugee” may appear. Click OK to make it disappear. The command window will appear with several lines, and the last will be “Stopped at program entry point.” Your source code appears in a window behind the Command Window. Minimize the Command window to see the source code.  A black DOS window may appear; move it aside.

 

From the source code window, open a window that shows the floating point stack by selecting View | Floating Point.   (You can open a window to show the 80x86 registers by choosing View | registers.) Make the window smaller and move it to the right side of the source code. Then open a window that shows memory (View | memory). If the name of the first variable is number,  type &number in the "Address Expression" box. That will cause the window to open with the view of memory starting at the variable number. Make the window smaller, leaving the top few lines visible, and move it below the source code. 

 

In the source code window, the yellow line indicates the next line to be executed. Each time you click the Trace Into button { ↓}, a line will be executed and the registers will show the result of that execution. When you have executed the last instruction in the program, you will not be able to click the icon again.

 

              Use PrintScreen to copy the window. Open a window in a program like Word, paste the image into the window, and print it.