Using Turbo Debugger
As Dr. Lovell said in class, we will not be covering the Turbo Debugger in class. However, I recognize that many of you will want to use this tool, so I will give you a few quick instructions on how to use it. Please understand that you should not spend too much time learning how to use this tool. We will very quickly advance to programs where using a dubugger is impossible. You will be much better off learning how to read through code and debug it on paper. This will be made easier if you spend your time designing on paper. The best time to use the debugger is when you suspect that you are trashing your stack (I'll cover this in class) or when you are trying to figure out what some interrupt call is doing - sometimes they change registers and are NOT documented well!
Given that, where do we begin. Grab the hi_world.asm file I provided as an example and compile it using the al.bat file also provided. As you probably noticed, this batch file tells the assembler and linker to retain all of the debugging information. To launch the debugger type
When the debugger first starts up, you will be presented with a blue screen and will see a copy of your source code. This view is only available if you have compiled your code and retained all of the debugging information. The CPU view will be the default if you are missing any of the debugging info. In this code view, you can move up and down with the arrow keys. The current instruction is denoted by an arrow in the left-hand margin. This will move as you step or trace through the program. If you want to set a breakpoint like you would in C, simply move to that line and press
Step Over vs. Trace Through
To execute your program line by line, you have two choices. Stepping over (
If you pull down the
Of course, you don't have to have all of these view ports in one window. Turbo Debugger does have the option of opening any one or more of these windows separately. Don't waste a lot of time with this, just use the little bit you need and get back to designing your code more carefully.
Okay, so you now have a little background with the debugger. Allow me to interject a small personal comment. If you find a bug in your program, and reading through a printout of your code doesn't find it. I would strongly recommend taking out the portion of code that is not working, put it in a separate module, and force all of the registers to be what you expect them to be when you enter that block of code. When you get it working, you will hopefully have identified your bugs and fixed them. More times than not, you will do this exercise and then find that the code you thought was broken... works fine. The reason for a bug typically is a trashing of the stack or a slight typo (DS and DX look really similar after an hour of coding, trust me). The debugger will not catch or even help identify errors like this. Careful reading of your code will be the only way. Use your classmates to have them look over sections you are stuck with due to a bug, don't copy code, but feel free to help spot typos, etc.Last Modified: January 26, 1999 - Barry E. Mapen