Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

3rd Class: Microprocessors Lab

Introduction to Debugger: The Intel Corporation’s 8086


Microprocessor

Supervisor: Dr. Faris S. Alghareb

Staff:
1. Ahmed Jameel
2. Awan Nahel Mahmood

Systems and Control Engineering Department


College of Electronics Engineering
Ninevah University
2019-2020

FARIS S. ALGHAREB 1
Contents
1. Experiment (1): Introduction to Debugger
2. Experiment (2): Programming using Debugger
3. Experiment (3): Programming the 8086 MPU using
Assembling language
4. Experiment (4): to be determined (TBD)
5. Experiment (5): to be determined (TBD)

FARIS S. ALGHAREB 2
Microprocessors Lab
Introduction to Debugger

Systems and Control Engineering Department


College of Electronics Engineering
Ninevah University
2019-2020

FARIS S. ALGHAREB 3
Experiment 1: Introduction to Debugger

► DEBUG:-
Is a program execution/debug tool that operates in the IBM PCs operating system (DOS)
environment. It is used to examine or modify the contents of the Microprocessing Unit (MPU) internal
registers.

THE COMMAND SET OF DEBUG IS:

► REGISTER:-
The syntax of register command is (R). This is the debugger command that allows examining or
modifying the contents of internal registers of the MPU. The general form of this command is:

R [Register Name]

Example for displaying the value in register AX:-

- R AX (after executing this command), the current value in the register AX is displayed as
shown below:-

Other examples:

R ; Display the contents of all registers

R IP ; Display the contents of IP and prompt for a new value.

R CX ; Same (for CX register).

To load register AX with a new value of (00FFh), this can be done using the following command:

► QUIT:-
The syntax of this command is (Q). This command is the end of a debug program, quits Debug
and returns to DOS. The form of this command is:-
-Q
► DUMP:-
The syntax of this command is (D), this allows examining the contents of a memory location or a
bock of consecutive memory locations. The general form for DUMP command is:-

FARIS S. ALGHAREB 4
D [Address]

Example:

Executing this command causes the 16 consecutive bytes that starting at offset of (0100h) for the
current vale of register DS to be displayed.

► ENTER COMMAND:-

The E command places individual bytes in memory. A starting memory address/location, to where
the values will be stored, have to be supplied. The syntax of this command is (E). This command
allows to modify or enter information in memory. Command formats are:

E address ; Enter new byte value at address

E address list ; Replace the contents of one or more bytes starting the specified address, with the

values contained in the list

To begin entering hexadecimal or character data at DS:100, type:

E 100

Press the space key to enter to the next byte, and press the enter key to stop. To enter a string into
memory starting at location CS:100, type:

E CS:100 “This is a string.”

Example: Write down (type in) a command that will load five consecutive byte-width memory
locations that start at address DS: 100 with the value (FFh). This can be done using the following
command:- EDS

EDS: 100

This allows the value of the address to be displayed as follows:-

1342: 0100FF.

► FILL COMMAND:-

The syntax of this command id (F). This command is used to fill a block of consecutive memory
locations all with the same data. The general form of FILL command is:-

F [STARTING ADDRESS] [ENDING ADDRESS] [LIST]

Example: If 32-byte locations in the range of 1342:100 through 1342:11F are loaded with the value
(22h), the command is written as:

FARIS S. ALGHAREB 5
- F 100 11F22

Other examples:

F 100 500, ‘ ‘ ; Fill locations 100 through 500 with spaces

F CS:300 CS:1000,FF ; Fill locations CS:300 through 1000 with hex FFh.

F 100 L 20 ‘A’ ; Fill 20h bytes with the letter ‘A’, starting address 100.

► MOVE COMMAND: -

The syntax of this command is (M). The M command copies a block of data from one memory
location to another. The general form of the command is:-

M [STARTING ADDRESS] [ENDING ADDRESS] [DESTINITION ADDRESS]

All offsets are assumed to be from register DS unless specified otherwise.

Example:

32-byte block of data that resides in memory from DS:100 to DS:11F can be copied to the address
range of DS:0200 through DS:21F using the following command:-

M 100 11F 200

Other Examples:

M 100 105 110 ; move bytes in the range DS:100-105 to location DS:110.

M CS:100 105 CS:110 ; Same as above, except that all offsets are relative to the segment value in CS.

► COMPARE COMMAND: -

The syntax of this command is (C). This command compares the contents of two blocks of data to
determine whether they are the same or not. The general form of this command is:-

C [STARTING ADDRESS] [ENDING ADDRESS] [DESTINITION ADDRESS]

Example:

Compare a block of data that is located at address DS:100 to an equal size block of data starting at
address DS:160. The command is:-

C 100 160

After the execution of this command, the contents of address DS:100 are compared to those at
address DS:160, the contents of DS:101 are compared to those at address DS:161, and so on.

FARIS S. ALGHAREB 6
Whenever unequal elements are found, the address and contents of that byte in both blocks are
displayed.

► HEXADECIMAL ADDING AND SUBTRACTING:-


The syntax of this command is (H). This provides the ability to add and subtract Hexadecimal
numbers. Both operations are performed with single command. The general form of this command
is:-
H [NUM1] [NUM2]

Example:
The current value in code segment (CS) register is (0ABC)h and that in the instruction pointer (IP)
is (0FFF)h. The sum and difference of these two numbers can be calculated using the following
command:
H 0ABC 0FFF

The execution of this command is:

BBBF9BC1

The sum of two hexadecimal numbers is (BBBF)h, whereas their difference is (9BC1)h.

The sum (BBBF)h is the value of physical address CS:IP

► UNASSEMBLE COMMAND:-
The syntax of this command is (U). This is important for debugging program on the PC. Unassemble
indicates the process of converting machine code instruction to their equivalent assembly language
source statements. The unassemble command lets us specify a range in memory and execution of
the command causes the source statements for the memory data in this range to be displayed on
the screen. The general form of this command:

U [STARTING ADDRESS] [ENDING ADDRESS]


Example:

This result displays the starting address (i.e., 1342) for the instruction followed by both the machine
code (i.e., 010088C3) and assembly form of the instruction (MOV BL,AL). This gives:

1342:0100 88C3 MOV BL,AL

► SEARCH COMMAND:-
The syntax of this command is (S). This command can be used to scan through a block of data in
memory to determine whether or not it contains certain data. The general form of this command as
given:

S [STARTING ADDRESS] [ENDING ADDRESS] [LIST]

FARIS S. ALGHAREB 7
Example:

S 100 17F33

This example shows all addresses in the range 100 through 17F contains this value.

► INPUT AND OUTPUT OF DATA:-


The syntax of these commands (I) for input data and (O) for output data. The I command inputs a
byte from a specified input/output port and display the value in hexadecimal. The general form for
input command:

I address/port , where the port represents the port number ranging between 0 and FFFF

Example: we input a byte from port 3F8 (one of the COM1 ports), and Debug returns a value of
00:

- I 3F8
00

After executing this command, the data is read from the port and displayed.

The general form of output command is:

O [ADDRESS] [BYTE]

Example:

O 61 4F

This command causes the value 4F to be written into the byte-wide output port.

► ASSEMBLE COMMAND:-
The syntax of this command is (A). The debug program has a command that lets us automatically
assemble the instruction of a program, one after the other, and store them in the memory. The
general form of Assemble command is given:

A [STARTING ADDRESS]

The starting address is the address at which the machine code of the first instruction of the program
is to be stored.

Example:
To assemble the instruction ADD [BX+SI+1234H],AX and store its machine code in memory starting
at address CS:100. The start command entry:-
ACS:100

The response to this command input is to display of the starting address in the form:-
CS: 100

FARIS S. ALGHAREB 8
The instruction is typed in following this address, when the enter key (^I) is depressed the instruction
is assembled into machine code. It is stored in memory and the starting address of the next
instruction is displayed:
1342:0100 ADD [BX+SI+1234H], AX 1342:0104

► EXECUTING INSTRUCTIONS AND PROGRAMS WITH THE TRACE AND GO COMMANDS:-


The Debug program allows us to execute the program with one GO (G) command or to execute the
program in several segments of instructions by using breakpoints in the GO command. Moreover,
by using the Trace (T) command, the program can be stepped through the executing one or more
instruction at a time.

TRACE provides the programmer with the ability to execute one instruction at a time. This mode of
operation is also known as signal stepping the program, it is very useful during early phases of
program debugging. This is because the contents of registers or memory can be viewed both before
and after the execution of each instruction to determine whether or not the correct operation was
performed. The general form of the command as shown:

T = [starting address] [number]

The starting address is specified at which execution is to begin. It is followed by a number that tells
how many instructions are to be executed. If an instruction count is not specified in the command,
then only a single instruction is executed.

Example:

T = CS:100

GO command is typically used to run programs that are already working, or to execute programs in
the latter stages of debugging. GO command can be used to execute this group of instructions and
then stop execution at a point in the program where additional debugging is to begin. The general
form of the GO command:-

G = [starting address] [Break point address]

The first address is the starting address of the segment of the program that is to be executed, that
is the address of the instruction at which execution is to begin. The second address the break point
address is the address of the end of the program segment.

Example:

G = 200 217

The execution at address CS: 200 until address CS: 217 are accessed. At break point, the program
execution is terminated, and the complete internal status of the MPU is displayed.

FARIS S. ALGHAREB 9
MS-DOS Debug Commands
assemble A [address]
compare C range address
dump D [range]
enter E address [list]
fill F range list
go G [=address] [addresses]
hex H value1 value2
input I port
load L [address] [drive] [firstsector] [number]
move M range address
name N [pathname] [arglist]
output O port byte
proceed P [=address] [number]
quit Q
register R [register]
search S range list
trace T [=address] [number]
unassemble U [range]
write W [address] [drive] [firstsector] [number]

FARIS S. ALGHAREB 10

You might also like