You are on page 1of 15

NCP 312 (Computer Organization With

Assembly Language Laboratory)

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

NCP 312 (Computer Organization With


Assembly Language Laboratory)

DEBUG Commands
The R Command

This command stands for the REGISTER 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 ().

Table 1: Register Mnemonics for the R Command

2 | Page

NCP 312 (Computer Organization With


Assembly Language Laboratory)

Table 2: Notations used for displaying the Flag Statuses

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

NCP 312 (Computer Organization With


Assembly Language Laboratory)

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>

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.

4 | Page

NCP 312 (Computer Organization With


Assembly Language Laboratory)

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:

D DS: 0200 0201 ()


OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________

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:

D CS: 0000 000F ()


D ES: 0000 000F ()
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________

5 | Page

NCP 312 (Computer Organization With


Assembly Language Laboratory)

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

NCP 312 (Computer Organization With


Assembly Language Laboratory)

___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________

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.
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________

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

F <starting address> <ending address>

locations in memory.
7 | Page

NCP 312 (Computer Organization With


Assembly Language Laboratory)

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:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________

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 location
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
follows:

F 0120 013F 33 ()
F 0140 015F 44 ()
Then they are verified with the DUMP command:

D 0120 015F ()
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________

The A Command

The A (ASSEMBLE) command assebles the instruction of a program, one after


the other, and stores them in the specified memory location.

8 | Page

NCP 312 (Computer Organization With


Assembly Language Laboratory)

Format:

The parameter starting address refers to the address at which the machine code

A <starting address>

of the 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 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:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________

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

9 | Page

NCP 312 (Computer Organization With


Assembly Language Laboratory)

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:

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 ()
OBSERVATION:
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________
___________________________________________________________________________

The G Command

10 | P a g e

NCP 312 (Computer Organization With


Assembly Language Laboratory)

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:

The starting address is the address of the instruction at which execution is to

G=<starting address><breakpoint address>

begin.

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


instruction

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

NCP 312 (Computer Organization With


Assembly Language Laboratory)

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

The single-step operation displays the contents of the registers or specified


memory location before and after the execution of each instruciton.

Format:

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

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

NCP 312 (Computer Organization With


Assembly Language Laboratory)

registers is automatically displayed. At this point, other debug commands


may be issued.

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

NCP 312 (Computer Organization With


Assembly Language Laboratory)

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:

E DS:0500 NCP 311 Computer Organization With Assembly Language


3. Repeat #1 and observe the memory data displayed to the right.
4. Initialized 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.

14 | P a g e

NCP 312 (Computer Organization With


Assembly Language Laboratory)

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.

15 | P a g e

You might also like