How to use the Turbo Assembler tools to assemble, link, and debug

(Assume that your program is called "proj.asm")

1. Open an MSDOS window.

2. Set the PATH so that the TASM programs are available

The TASM programs are on the C drive; set the path so that DOS can find them. This only needs to be done once each time you open an MSDOS prompt.

set PATH=%PATH%;C:\TASM\BIN

3. Use a Text Editor to Edit the .ASM File

Create your file using one of the following programs:

notepad proj.asm

wordpad proj.asm

edit proj.asm

Make sure it has an .ASM ending. Also, be sure you are doing your work on the A: drive, not in the C:\WINDOWS directory.

4. Compile the source code to create an object module.

tasm/z/zi proj.asm

The /z switch causes TASM to display the lines that generate compilation errors. The /zi switch enables information needed by the debugger to be included in the .OBJ file.

Note that you should use "real mode" assembler, TASM.EXE. Do not use the "protected mode" assembler TASM32.EXE for the assignments that will be given in class.

5. Run the Linker to generate an .EXE file from the .OBJ file

tlink/v proj

6. Run the Program

Your final program (if there were no errors in the previous step) will have an .EXE ending. To just run it, type:

proj

If you want to use the debugger to examine the instructions, registers, etc., type:

td proj

This brings up the regular full-screen version of the Turbo debugger.

Using the Turbo Debugger

(Appendix D in Irvine contains additional information about the Turbo Debugger). The Turbo debugger is a comprehensive menu-driven debugging package. Here are the debugging functions that are most important for you to know how to use as CS 2011 students:

1. Tracing the Program's Execution

When the Turbo debugger first starts, a Module Window which contains the source of your program is displayed. Executable lines of code are marked with a bullet in the left column of the window. You can set breakpoints or step to any of these lines of code. An arrow in the first column of the window indicates the location of the instruction pointer. This always points to the next statement to be executed. To execute just that instruction use one of the two methods listed under the Run menu item:

o Trace into (can use F7 key): executes one instruction; traces "into" procedures.

o Step over (can use F8 key): executes one instruction; skips (does not trace into) procedures.

Hitting either of these executes the instruction, and moves the arrow to the next instruction. As each instruction executes, the effects might be visible in the Registers Window and Watches Window.

2. Setting and Removing Breakpoints

To set a breakpoint, position the cursor on the desired line of source code and press F2. The line containing the breakpoint will turn red. Pressing F2 again removes the breakpoint. To execute all instructions from the current instruction pointer up to the next encountered breakpoint, choose Run (can use F9 key) from the Run menu item.

3. Examining Registers

Another window, the Registers Window, can be opened to examine the current value of the CPU registers and flags. The View menu can be used to open this Registers Window. The registers and flags might change as each instruction is executed.

4. Examining Memory

To examine memory, you will need to open an Inspector window. An Inspector window shows the contents of a data structure (or simple variable) in the program you are debugging. It also allows you to modify the contents of the data structure or variable.

To open an Inspector window, place the cursor on what you want to inspect and press CTRL-I. After you've examined the data item, press the ESC key to remove the Inspector window.

5. Viewing the Program's Output

Output written to the screen by a program is not immediately visible, since the main purpose of using a debugger is to examine the internal operation of the program. To observe what the user would see, press ALT-F5. The entire screen will change to a user-view showing the program's input and output (and possibly that of previous programs as well). Press any key to return to the debugger screen.