Skip to content
Related Articles

Related Articles

Debugging a machine level program

View Discussion
Improve Article
Save Article
  • Last Updated : 28 Jun, 2018
View Discussion
Improve Article
Save Article

Debugging is the process of identifying and removing bug from software or program. It refers to identification of errors in the program logic, machine codes, and execution. It gives step by step information about the execution of code to identify the fault in the program.

Debugging of machine code: Translating the assembly language to machine code is similar to building a circuit from a schematic diagram. Debugging can help in determining:

  • Values of register.
  • Flow of program.
  • Entry and exit point of a function.
  • Entry into if or else statement.
  • Looping of code.
  • Calculation check.

Common sources of error:

  • Selecting a wrong code
  • Forgetting second or third byte of instruction
  • Specifying wrong jump locations
  • Not reversing the order of high and low bytes in a Jump instruction
  • Writing memory addresses in decimal instead of hexadecimal
  • Failure to clear accumulator when adding two numbers
  • Failure to clear carry registers
  • Failure to set flag before Jump instruction
  • Specifying wrong memory address on Jump instruction
  • Use of improper combination of rotate instructions

The debugging process is divided into two parts:

  1. Static Debugging: It is similar to visual inspection of circuit board, it is done by a paper and pencil to check the flowchart and machine codes. It is used to the understanding of code logic and structure of program.
  2. Dynamic Debugging: It involves observing the contents of register or output after execution of each instruction (in single step technique) or a group of instructions (in breakpoint technique).
    In a single board microprocessor, techniques and tools commonly used in dynamic debugging are:

    1. Single Step: This technique allows to execute one instruction at a time and observe the results of each instruction. Generally, this is build using hard-wired logic circuit. As we press the single step run key we will be able to observe the contents of register and memory location. This helps to spot:
      • incorrect addresses
      • incorrect jump location in loops
      • incorrect data or missing codes

      However, if there is large loop then single step debugging can be very tiring and time-consuming. So instead of running the loop n times, we can reduce the number of iteration to check the effectiveness of the loop. The single step technique is very useful for short programs.

    2. Breakpoint: The breakpoint facility is usually a software routine that allows users to execute a program in sections. The breakpoints can be set using RST instruction. When we push the Execute key, the program will be executed till the breakpoint. The registers can be examined for the expected result. With the breakpoint facility, isolate the segment of program with errors. Then that segment can be debugged using the single-step facility. It is usually used to check:
      • Timing loop
      • I/O section
      • Interrupts
    3. Register Examine: The register examine key allows you to examine the contents of the microprocessor register. This technique is used in conjunction with either single-step or breakpoint facility.
My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!