Professional Documents
Culture Documents
3 Class: Microprocessors Lab Introduction To Debugger: The Intel Corporation's 8086 Microprocessor
3 Class: Microprocessors Lab Introduction To Debugger: The Intel Corporation's 8086 Microprocessor
Staff:
1. Ahmed Jameel
2. Awan Nahel Mahmood
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
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.
► 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]
- R AX (after executing this command), the current value in the register AX is displayed as
shown below:-
Other examples:
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 list ; Replace the contents of one or more bytes starting the specified address, with the
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:
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
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:-
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 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:-
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:-
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:-
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.
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
BBBF9BC1
The sum of two hexadecimal numbers is (BBBF)h, whereas their difference is (9BC1)h.
► 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:
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:
► 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:
FARIS S. ALGHAREB 7
Example:
S 100 17F33
This example shows all addresses in the range 100 through 17F contains this value.
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.
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
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:
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:-
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