Professional Documents
Culture Documents
EXPERIMENT 1
Basic Debug Facility
At the end of the exercise, the students must be able to:
1. Use tools in applying assembly language;
2. Understand basic assembly language codes and programs;
3. Be familiar with the different commands used in DOS debug;
4. Describe in detail the nature of assembly programs; and
5. Write a laboratory report based on the finding.
Basic Information
DEBUG is a program that is part of the MS-DOS that allows the user to:
1. Enter any assembly program into the PC;
2. Execute the program;
3. Examine the results that the program produces; and
4. If necessary, debug any errors in its operation.
The command name is debug.
The DEBUG prompt is a hyphen or an underscore; commands are written after this
prompt.
1. At the windows desktop press window key + R, then type cmd to open the DOS
command prompt window.
2. On the DOS prompt type cd.. until you are at the root directory of the drive.
3. Type debug on the DOS prompt line and the debug prompt should appear.
4. Type in ? for a listing of the DEBUG commands you can enter.
1 | Page
DEBUG Commands
The R Command
Format:
R <register name>
Example:
R AX
Displays the contents of the register AX. Its execution causes the current value in
AX to be displayed. If, for instance the accumulator contains 0000, this command
displays
AX 0000
:
If the value is to be changed, enter the new value after the colon (:) and press the
enter key (), if to be unchanged press the enter key ().
2 | Page
Examples:
1. Issue commands to the debugger on the PC that will cause the value in BX to
be modified to FF00H and then verify that this value exists in BX.
To modify the contents of BX:
R BX ()
BX 0000
: FF00 ()
To verify the contents of BX:
R BX ()
BX FF00
: ()
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
3 | Page
2. Use the register command to set the parity flag to even parity. Verify that the
flag has been changed.
To modify the parity
R F ()
NV UP EI PL NZ NA PO NC - PE ()
To verify the modification
R F ()
NV UP EI PL NZ NA PE NC - ()
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
The D Command
This command stands for DUMP, examines the contents of a memory location or
a block of consecutive memory locations.
FORMAT:
The value of the address entered is automatically referenced to the current value
D <address>
For all memory dumps, an ASCII version of the memory data is displayed to the
right of the hexadecimal data.
Repeated executions of the D command display, iteratively, the next 128 bytes of
memory locations.
To examine the data that are stored in the code segment, stack segment or extra
segment, use the appropriate segment register name in the command.
4 | Page
Example:
1. To examine two bytes of data that are at offset equal to 0200H and 0201H in the
current data segment, enter the command:
2. Issue a dump command that will display the 32 bytes of memory location that are
located at offsets 0300H through 031FH in the current data segment.
D 0300 031F ()
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
3. The commands needed to dump the values in the first 16 bytes of the current
code segment and extra segment are:
5 | Page
THE E COMMAND
The E (Enter) command modifies the data stored in specific memory locations.
Format:
The address part of the E command follows the same notational semantics as in
E <address><list>
the D command if no segment name is included with the offset, the DS register
is assumed.
The list that follows the address is the data values that are loaded in the specified
memory locations.
Issuing an E command with an address but no data displays the contents of the
addressed storage location However, the programmer may opt to do one of the
three actions:
1. Press the enter key. This action terminates the ENTER command without
modifying the contents of the memory location.
2. Press the space bar. This action causes the contents of the next
consecutive memory location to be displayed.
3. Enter a new value of data. This modifies the contents of the specified
memory location and allows the programmer to continue with the next
consecutive memory location (by pressing the space bar) or to terminate
the ENTER command (by pressing the return key).
The ENTER command can also be used to enter ASCII data this is done by
enclosing the data entered in quotation marks.
Example:
1. The command that loads five consecutive byte-wide memory locations
that start at address DS:0100 with the value FF is:
E DS: 0100 FF FF FF FF FF ()
OBSERVATION:
6 | Page
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
2. The command
The F Command
The F (FILL) command stores a block of consecutive memory locations with the
same data.
Format:
The starting address and the ending address specify the block of storage
locations in memory.
7 | Page
Example:
1. The command:
F 0100 011F 22 ()
Causes the 32-byte locations in the range DS:0100 through DS:011F to be
loaded with 22H.
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
F 0120 013F 33 ()
F 0140 015F 44 ()
Then they are verified with the DUMP command:
D 0120 015F ()
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
The A Command
8 | Page
Format:
The parameter starting address refers to the address at which the machine code
A <starting address>
A CS: 0100 ()
Assuming that the code segment (CS) register is initialized to 0CDEH, the
response to this command input is the display starting address in the form:
0CDE:0100_
The instruction to be assembled is typed in following this address and
when the ENTER () key is pressed; the instruction is assembled into
machine code. It is thus stored in the memory and the starting address of
the next instruction is displayed. At this point, either the next instruction is
enter or the ENTER () key is pressed to terminate the ASSEMBLE
command.
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
A CS:0200 ()
9 | Page
Assuming that the code segment (CS) register contains the value 0CDEH,
this gives the response:
0CDE:0200_
The instructions of the program are typed in as follows:
The G Command
10 | P a g e
The G (GO) command provides the option of executing the entire program or of
executing the program in several segments of instruction by using breakpoints.
Format:
begin.
A list of up to ten (10) breakpoint addresses can be supplied with the command.
Examples:
1. The command
G=CS:0200 0217 ()
Loads the IP register with 0200H, sets a breakpoint at address CS:0217,
and then begins program execution at address CS:0200. Instruction
execution proceeds until the address CS:0217 is accessed. When the
breakpoint address is reached, program execution is terminated, the
complete internal status of the 8086 is displayed, and control is returned
to DEBUG.
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
2. The command
G CS:0100 ()
11 | P a g e
Executes a program that starts at offset 0100H in the current CS. This
command causes the program to run to completion. If the CS and IP are
already initializzed with the correct values, the command:
G ()
Will execute the program to completion
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
The T Command
The T (TRACE) command steps through the program by executing one or more
instruction at a time.
Thus, this command allows the programmer with the ability to execute one
instruction at a time (this operation is know as single-stepping the program).
Format:
T=<address><number>
Example:
1. The command
T=CS:0100 ()
Causes the instruction starting at address CS:0100 to be executed. At the
completion of the instructions execution, the complete state of the internal
12 | P a g e
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
2. The command
T ()
Executes the instruction pointed by the current values of the CS and IP
(CS:IP) registers. This is the form of the TRACE command used to
execute the next instruction.
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
3. The command
13 | P a g e
T=CS:0100 3 ()
Traces through three instructions. Again, the internal state of the 8086 is
displayed after each instruction is executed.
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
LABORATORY WORK
1. Issue a dump command that will display the 64 bytes of memory locations that are
located at offsets 0500H through 053FH to the current data segment. Observe the
memory data displayed to the right of the hexadecimal data.
2. Execute the command below:
14 | P a g e
15 | P a g e