Download presentation
Presentation is loading. Please wait.
Published bySherman Mathews Modified over 8 years ago
1
The LC-3 – Chapter 6 COMP 2620 Dr. James Money COMP 2620 1
2
Debugging When you drive to someplace new and you make a wrong turn, what do you do? There are two driving debugging techniques – Drive aimlessly hoping to find your way back – Return to some known position and use a map to compare where you are and where you should be
3
Debugging Debugging is similar to this in many ways The simplest way to keep track of where you are is to trace a program That is you keep track of the sequence of instructions that have been executed and the results it has produced
4
Debugging Another useful technique to divide your program into modules, similar to functions in a C program You can compare the results before and after each module to see if your code is executed properly and debug if needed
5
Debugging We will now look at the LC-3 simulator Using this program you can debug interactively as the program is running You can use the keyboard, monitor, and menus to control the simulator
6
Debugging We need to be able to: – Deposit values into memory and registers – Execute instruction sequences in a program – Stop execution when desired – Examine what is in memory and registers at any point in the program The LC-3 simulator allows all of these
7
Debugging There are three classes of errors: – Syntax Errors – Logic Errors – Data Errors
8
Debugging Syntax Errors – You made a typing error that resulted in an illegal operation. – Not usually an issue with machine language, because almost any bit pattern corresponds to some legal instruction. – In high-level languages, these are often caught during the translation from language to machine code.
9
Debugging Logic Errors – Your program is legal, but wrong, so the results don’t match the problem statement. – Trace the program to see what’s really happening and determine how to get the proper behavior.
10
Debugging Data Errors – Input data is different than what you expected. – Test the program with a wide variety of inputs.
11
Debugging There are three ways to debug a program: – Single stepping – Breakpoints – Watchpoints
12
Debugging Single-Stepping – Execute one instruction at a time. – Tedious, but useful to help you verify each step of your program.
13
Debugging Breakpoints – Tell the simulator to stop executing when it reaches a specific instruction. – Check overall results at specific points in the program. – Lets you quickly execute sequences to get a high-level overview of the execution behavior. – Quickly execute sequences that your believe are correct.
14
Debugging Watchpoints – Tell the simulator to stop when a register or memory location changes or when it equals a specific value. – Useful when you don’t know where or when a value is changed.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.