Vous êtes sur la page 1sur 7

F0028

LABORATORY EXERCISE # 2
Debug Facility Part 2

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


1. Be familiar with the different commands used in DOS debug;
2. Describe in detail the nature of assembly programs and write a laboratory report based on
findings; and
3. Store and load assembly programs.

BASIC INFORMATION
STORING AND LOADING PROGRAMS

It would not seem practical to type an entire program each time it is needed. Thus, to
avoid this, it is possible to store a program on the disk, with the enormous advantage that
by being already assembled it will not be necessary to run Debug again to execute it.

The steps to save a program that it is already stored on memory are:


0C1B:0100
0C1B:0103
0C1B:0106
0C1B:0108
0C1B:010A

MOV AX, 0002


MOV BX, 0004
ADD AX, BX
ADD AL, 02

To obtain the length of a program the h command is used, since it will show us the
addition and subtraction of two numbers in hexadecimal. To obtain the length of ours, we
give it as parameters the value of our programs final address (010AH), and the programs
initial address (0100H).
The first result the command shows us is the addition of the parameters and the second is
the subtraction.
-h 010A 0100
020A 000A
The n command allows us to name the program.
-n A:\test.com
The rcx command allows us to change the content of the CX register to the value we
obtained from the size of the file with h, in this case 000AH, since the result of the
subtraction of the final address from the initial address.
-rcx
CX 0000
:000A
Lastly, the w command writes our program on the disk, indicating how many bytes it
wrote.
-w
Writing 000A bytes

Laboratory Exercise 2: Debug Facility Part 2

* Property of STI
Page 1 of 7

F0028

To load a saved file, two steps are necessary:


1. Give the name of the file to be loaded.
2. Load it using the 1 (load) command.
To obtain the correct result of the following steps, it is necessary that the above program
be already created.
Inside Debug we write the following:
-n A:\test.com
-l
-u 0100 0108
0C3D:0100 B80200
0C3D:0103 BB0400
0C3D:0106 01D8
0C3D:0108 0402

MOV AX,0002
MOV BX,0004
ADD AX,BX
ADD AL, 02

The last u command is used to verify that the program was loaded on memory. What it
does is that it disassembles the code and shows it disassembled. The parameters
indicate to Debug from where and to where to disassemble.
Debug always loads the programs on memory on the address 0100H, otherwise indicated.

THE W COMMAND

The W (WRITE) command saves specified data stored in the memory on a diskette.

Format:
W<starting address> <drive> <starting sector> <number of sectors>

Before this command is issued, a formatted diskette must be inserted into the appropriate
drive.

This command automatically references the CS register instead of the DS register.


Examples:
1.

The command
W CS:200 1 10

()

saves the machine code of an ADD instruction loaded at address CS:200. This
data is saved on the diskette inserted in disk drive 1 (Drive B), using an arbitrary
starting sector (10) on the diskette, and an arbitrary length of 1 sector.

THE L COMMAND

The L (LOAD) command reloads the memory with the specified data from a diskette.

Format:
L <starting address> <drive> <starting sector> <number of sectors>

Laboratory Exercise 2: Debug Facility Part 2

* Property of STI
Page 2 of 7

F0028
Example:
1.

The command
L 300 1 10 1

()

loads the instruction saved on the appropriate locations on the disk onto the
memory location with address CS:300. The reloading of the instruction can be
verified using the UNASSEMBLE command
U CS:300 301

()

THE M COMMAND

The M (MOVE) command copies a block of data from one part of the memory to another
part.

Format:
M <starting address> <ending address> <destination address>
Examples:
1.

The command to copy a 32-byte block of data from DS:100 through DS:11F is
written as
M 100 11F 200

2.

()

Fill each storage location in the block of memory from address DS:100 through
DS:11F with the value 11. Then copy this block of data to a destination block
starting at address DS:160. Verify that the block move was correctly done.
The command
F 100 11F 11

()

fills the source block with 11.

THE C COMMAND

The C (COMPARE) command compares the contents of two blocks of data to determine if
they are or are not the same.

Format:
C <starting address> <ending address> <destination address>

If both blocks contain the same information, no data are displayed.

Each time unequal elements are found, the address and the contents of that byte in both
blocks are displayed.
Examples:
1.

To compare a block of data located from address DS:100 through DS:10F to an


equal sized block of data starting at address DS:160, issue the command

Laboratory Exercise 2: Debug Facility Part 2

* Property of STI
Page 3 of 7

F0028
C 100 10F 160

()

THE S COMMAND

The S (SEARCH) command scans through a block of data in memory to determine


whether or not it contains a certain data

Format:
S <starting address> <ending address> <list>

The address is displayed for each memory location where a match is found.
Example:
1.

Perform a search of the block of data from address DS:100 through DS:17F to
determine which memory locations contain 33H.

2.

The search command that must be issued is


S 100 17F 33

()

THE U COMMAND

The U (UNASSEMBLE) command converts machine code instructions to their equivalent


assembly language source statements.

The execution of this command causes the starting memory location and the source
statements (in both machine code and assembler forms of the instruction) for the memory
data to be displayed on the screen.

Format:
U <starting address> <ending address>
Example:
1.

Use a series of commands to load, verify loading, and unassemble the machine
code 0304H (the object code of the ADD AX,[SI] instruction). Load the instruction
at address CS:200.
The command
E CS:200 03 04

()

loads the machine code into the code segment of the microcomputers memory.
The command
D CS:200 201

()

verifies that it was loaded correctly. Finally, the command


U CS:200 201

()

unassembles the instruction.

Laboratory Exercise 2: Debug Facility Part 2

* Property of STI
Page 4 of 7

F0028
2.

Assume that a block move program has been stored at file specification 1 10 1
of a data diskette. Load this program into the memory starting at address CS:200.
Then initialize the microprocessor by loading the DS register with 1020H. Fill the
block of memory from DS:100 through DS:10F with FFH and the block of memory
from DS:120 through DS:12F with 00. Verify that the blocks of memory were
initialized correctly. Load DS with 0CDEH and display the state of the 8086
registers. Display the assembly language version of the program from CS:200
through CS:217. Use a GO command to execute the program through address
CS:20E. Now execute down through address CS:215. Next execute the program
down to address CS:217.
The command needed to load the program is
L CS:200 1 10 1 ()
The following commands initialize the DS register and the specified locations in
the memory.
R DS ()
DS 0CDE
:1020 ()
F DS:100 10F FF ()
F DS:120 12F 00 ()
The blocks of data in memory are displayed by
D DS:100 10F ()
D DS:120 12F ()
The data segment (DS) register is loaded with 0CDEH using the command
R DS ()
DS 1020
:0CDE ()
and the state of the 8086 registers is displayed with the command
R ()
The command
U CS:200 217 ()
displays the source code. The first section of the program is executed with the
command
G=CS:200 20E ()
Another GO command is used to execute the program down through address
CS:215
G=CS:20E 215 ()
The commands
D DS:100 10F ()
D DS:120 12F ()

Laboratory Exercise 2: Debug Facility Part 2

* Property of STI
Page 5 of 7

F0028
check the state of the corresponding blocks of memory. Execute the program
through CS:217 with the command
G=CS:215 217 ()
and examine the block of data with the commands
D DS:100 10F ()
D DS:120 12F ()

LABORATORY WORK
1. 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
2.
3.
4.
5.

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

Execute the program above.


Save the program on the disk.
Load and then unassemble the saved file.
Show the sequence of keyboard entries needed to enter the following machine code program into the
memory of the PC.
B8 20 10 8E D8 BE 00 01 BF 20 01 B9 10 00 8A 24 88 25
46 47 49 75 F7 90
The program is to be loaded into the memory starting at address CS:100. Verify that the hexadecimal
machine code was entered correctly and then unassemble the machine code to ensure that it
represents the following source program.
MOV
MOV
MOV
MOV
MOV
MOV
MOV
INC
INC
DEC
JNZ
NOP

AX, 1020
DS, AX
SI, 100
DI, 120
CS, 10H
AH, [SI]
[DI], AH
SI
DI
CX
$-9

Save the program in sector 100 of a formatted diskette.


6. Load the instruction stored at file specification 0 100 1 at offset 100 of the current code segment.
Unassemble the instruction. Then initialize AX to 1111H, SI to 1234H, and the contents of the memory

Laboratory Exercise 2: Debug Facility Part 2

* Property of STI
Page 6 of 7

F0028
address 1234H to 2222H. Next, display the internal state of the 8086 and the contents of address
1234H to verify their initialization. Finally, execute the instruction with the TRACE command.

Laboratory Exercise 2: Debug Facility Part 2

* Property of STI
Page 7 of 7

Vous aimerez peut-être aussi