0% found this document useful (0 votes)
76 views

Laboratory Exercise # 1: Debug Facility Part 1

This document provides instructions for using the DEBUG command in DOS to debug assembly language programs. It introduces the DEBUG command and describes the R, D, E, and F commands. The R command displays and modifies register values. The D command dumps memory contents. The E command enters data into memory locations. The F command fills a range of memory with a given value. The goal is for students to learn assembly programming and debugging tools.

Uploaded by

Ryan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

Laboratory Exercise # 1: Debug Facility Part 1

This document provides instructions for using the DEBUG command in DOS to debug assembly language programs. It introduces the DEBUG command and describes the R, D, E, and F commands. The R command displays and modifies register values. The D command dumps memory contents. The E command enters data into memory locations. The F command fills a range of memory with a given value. The goal is for students to learn assembly programming and debugging tools.

Uploaded by

Ryan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

LABORATORY EXERCISE # 1

Debug Facility Part 1

At the end of the exercise, the students must be able to:

1. Introduce the students to assembly language programming and the use of the tools that he/she will
need throughout the lab experiments;
2. Be familiar with the different commands used in DOS debug; and
3. Describe in detail the nature of assembly programs and write a laboratory report based on
findings.

BASIC INFORMATION

 DEBUG is a program that is a part of the MS-DOS that allows the user to:

1. enter an assembly program into the PC;


2. execute it;
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. Click on “Start” to get to DEBUG.


2. On the pull down menu, select “Programs”.
3. On the next menu, select “MS-DOS Prompt” or “Command Prompt”. You should get the DOS
prompt line “C:\WINDOWS>”.
4. Type “DEBUG” on the DOS prompt line and the Debug prompt “-“should appear.
5. Type in “?” for a listing of the DEBUG commands you can enter.

DEBUG Commands

THE R COMMAND

 This command stands for the REGISTER command.

 Format:
R <register name>

Example:

The command

-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 unchanged, press the ENTER () key. Otherwise, enter the
new value after the colon (:) and press the ENTER () key.

 Register Mnemonics for the R Command:

Symbol Register
AX Accumulator register
BX Base register
CX Count register
DX Data register
SI Source index register
DI Destination index register
SP Stack pointer register
BP Base pointer register
CS Code segment register
DS Data segment register
SS Stack segment register
ES Extra segment register
F Flag register

 Notations Used for Displaying the Flag Status:

Flag Meaning Set Reset


OF Overflow OV NV
DF Direction DN UP
IF Interrupt EI DI
SF Sign NG PL
ZF Zero ZR NZ
AF Auxiliary Carry AC NA
PF Parity PE PO
CF Carry CY NC

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 new value exists in BX.

To modify the contents of BX


-R BX ()
BX 0000
:FF00H ()
-

To verify the contents


-R BX ()
BX FF00
:_ ()
-

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 - ()
THE D COMMAND

 This command, which stands for DUMP, examines the contents of a memory location or a
block of consecutive memory locations.

 Format:
D <address>

 The value of the address entered is automatically referenced to the current value in the
data segment (DS) register.

 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 display a specific range of data, use the command:

D <start address> <end address>

 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.

Examples:

1. To examine two bytes of data that are at offsets equal to 0200H and 0201H in the
current data segment, enter the command:

-D DS:0200 0201 ()

2. Issue a dump command that will display the 32 bytes of memory locations that are
located at offsets 0300H through 031FH in the current data segment.

-D 0300 031F ()

3. The commands needed to dump the values in the first 16 bytes of the current
code segment and extra segment are:

-D CS:0000 000F ()


-D ES:0000 000F ()

4. Use the DUMP command to examine the 16 bytes of memory just below the top of
the stack.

The top of the stack is defined by the contents of the SS and SP registers
(SS:SP). If the SP was initialized to FFEE when debug was loaded, the 16 bytes
of interest reside at offset FFEE through FFFD from the current value in SS. This
part of the stack is examined with the command:

-D SS:FFEE FFFD ()


THE E COMMAND

 The E (ENTER) command modifies the data stored in specific memory locations.

 Format:
E <address> <list>

 The address part of the E command follows the same notational semantics as in 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 into 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 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 (single or double quotation marks can be used).

Examples:

1. The command that loads five consecutive byte-wide memory locations that start at
address DS:100 with the value FF is

-E DS:0100 FF FF FF FF FF ()

2. The command

-E DS:0200 “ASCII” ()

causes the ASCII data for the letters A, S, C, I, and I to be stored in memory
locations with addresses DS:0200, DS:0201, DS:0202, DS:0203, DS:0204,
respectively.

THE F COMMAND

 The F (FILL) command stores a block of consecutive memory locations with the same
data.

 Format:

F <starting address> <ending address> list

 The starting address and the ending address specify the block of storage locations in
memory.
Examples:

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.

2. Initialize all storage locations in the block of memory from DS:0120 through
DS:013F with the value 33H and the block of storage locations from DS:0140
through DS:015F with the value 44H. Verify that the contents of these ranges of
memory are correctly modified.

The initialization operations can be done with the FILL commands that follow:

F 0120 013F 33 ()


F 0140 015F 44 ()

They are then verified with the DUMP command:

D 0120 015F ()

THE A COMMAND

 The A (ASSEMBLE) command assembles the instructions of a program, one after the
other, and stores them in the specified memory location.

 Format

A <starting address>

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

Examples:

1. To assemble the instruction ADD [BX + SI + 1234], AX and store its machine
code in the memory starting at address CS:0100, the command entry is:

A CS:0100 ()

Assuming that the code segment (CS) register is initialized to 0CDEH, the
response to this command input is the display of the 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 entered or the ENTER () is
pressed to terminate the ASSEMBLE command.

2. Assume that the program listed below is to be stored in the memory starting at
address CS:0200. The assembler is invoked with the command:

A CS:0200 ()
Assuming that the code segment (CS) register contains the value OCDEH, this
gives the response:

0CDE:0200_

The instructions of the program are typed in as follows:

0CDE:0200 MOV AX, 1020 ()


0CDE:0203 MOV DS, AX ()
0CDE:0205 MOV SI, 0100 ()
0CDE:0208 MOV DI, 0120 ()
0CDE:020B MOV CX, 0010 ()
0CDE:020E MOV AH, [SI] ()
0CDE:0210 MOV [DI], AH ()
0CDE:0212 INC SI ()
0CDE:0213 INC DI ()
0CDE:0214 DEC CX ()
0CDE:0215 JNZ 020E ()
0CDE:0217 NOP ()
0CDE:0218 ()

THE G COMMAND

 The G (GO) command provides the option of executing the entire program or of executing
the program in several segments of instructions by using breakpoints.

 Format:

G=<starting address> <breakpoint address>

 The starting address is the address of the instruction at which execution is to begin.

 The breakpoint address is the address of the end of the program segment (that is, the
address of the instruction at which execution is to stop).

 The breakpoint address specified must correspond to the first byte of an instruction.

 A list of up to ten 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.

2. The command

G=CS:0100 ()

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 initialized
with the correct values, the command:
G ()

will execute the program to completion.

THE T COMMAND

 The T (TRACE) command steps through the program by executing one or more
instructions at a time.

 Thus, this command allows the programmer with the ability to execute one instruction at a
time (this operation is known as single-stepping the program).

 The single-step operation displays the contents of the registers or specified memory
locations before and after the execution of each instruction.

 Format:

T =<address> <number>

Address refers to the starting address at which execution is to begin.


Number refers to the number of instructions to be executed.

 If an instruction count is not specified, one instruction is executed at a time.

Examples:

1. The command

T=CS:0100 ()

causes the instruction starting at address CS:0100 to be executed. At the


completion of the instruction‟s execution, the complete state of the internal
registers is automatically displayed. At this point, other debug commands may be
issued.

2. The command

T ()

executes the instruction pointed to 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.

3. The command

T=CS:0100 3 ()

traces through three instructions. Again, the internal state of the 8086 is displayed
after each instruction is executed.
LABORATORY WORK

1. Issue a dump command that will display the 64 bytes of memory locations that are located at offsets
0500H through 053FH in the current data segment. Observe the memory data displayed to the right of
the hexadecimal data.
2. Execute the command below:

-E DS:0500 “Information and Communications Technology (ICT)‟

3. Repeat Step 1 and observe the memory data displayed to the right.
4. Initialize all storage locations in the block of memory from DS:0500 through DS:051F with the value
22H and the block of storage locations from DS:0520 through DS:053F with the value 44H. Verify that
the contents of these ranges of memory are correctly modified.
5. Assume that the program listed below is to be stored in the memory starting at address CS:0500.
Assemble the program below.

MOV AX, 0500 MOV


DS, AX
MOV SI, 0100
MOV DI, 0120
MOV CX, 0020 MOV
AL, [SI]
MOV [DI], AL
INC SI
INC DI
DEC CX
JNZ 050E NOP

6. Execute the program.


7. Trace the program and observe the contents of the registers and the memory locations used.
8. Make a screenshot of your final output.

You might also like