Você está na página 1de 8

F0028

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.
2.
3.
4.

enter an assembly program into the PC;


execute it;
examine the results that the program produces; and
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
:

Laboratory Exercise 1: Debug Facility Part 1

* Property of STI
Page 1 of 8

F0028
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
AX
BX
CX
DX
SI
DI
SP
BP
CS
DS
SS
ES
F

Register
Accumulator register
Base register
Count register
Data register
Source index register
Destination index register
Stack pointer register
Base pointer register
Code segment register
Data segment register
Stack segment register
Extra segment register
Flag register

Notations Used for Displaying the Flag Status:


Flag
OF
DF
IF
SF
ZF
AF
PF
CF

Meaning

Set
OV
DN
EI
NG
ZR
AC
PE
CY

Overflow
Direction
Interrupt
Sign
Zero
Auxiliary Carry
Parity
Carry

Reset
NV
UP
DI
PL
NZ
NA
PO
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
:FF00
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 -

Laboratory Exercise 1: Debug Facility Part 1

()
()

()
()
* Property of STI
Page 2 of 8

F0028
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

Laboratory Exercise 1: Debug Facility Part 1

()

* Property of STI
Page 3 of 8

F0028
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.
2.
3.

Press the enter key: this action terminates the ENTER command without
modifying the contents of the memory location.
Press the space bar: this action causes the contents of the next consecutive
memory location to be displayed.
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.

Laboratory Exercise 1: Debug Facility Part 1

* Property of STI
Page 4 of 8

F0028
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 ()

Laboratory Exercise 1: Debug Facility Part 1

* Property of STI
Page 5 of 8

F0028
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
0CDE:0203
0CDE:0205
0CDE:0208
0CDE:020B
0CDE:020E
0CDE:0210
0CDE:0212
0CDE:0213
0CDE:0214
0CDE:0215
0CDE:0217
0CDE:0218

MOV
MOV
MOV
MOV
MOV
MOV
MOV
INC
INC
DEC
JNZ
NOP

AX, 1020
DS, AX
SI, 0100
DI, 0120
CX, 0010
AH, [SI]
[DI], AH
SI
DI
CX
020E

()
()
()
()
()
()
()
()
()
()
()
()
()

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:

Laboratory Exercise 1: Debug Facility Part 1

* Property of STI
Page 6 of 8

F0028
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 instructions 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 Exercise 1: Debug Facility Part 1

* Property of STI
Page 7 of 8

F0028
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
MOV
MOV
MOV
MOV
MOV
MOV
INC
INC
DEC
JNZ
NOP

AX, 0500
DS, AX
SI, 0100
DI, 0120
CX, 0020
AL, [SI]
[DI], AL
SI
DI
CX
050E

6. Execute the program.


7. Trace the program and observe the contents of the registers and the memory locations used.

Laboratory Exercise 1: Debug Facility Part 1

* Property of STI
Page 8 of 8

Você também pode gostar