Professional Documents
Culture Documents
Lab 2 Debug Facilty Part 2 PDF
Lab 2 Debug Facilty Part 2 PDF
LABORATORY EXERCISE # 2
Debug Facility Part 2
BASIC INFORMATION
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.
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
-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
To obtain the correct result of the following steps, it is necessary that the above program
be already created.
-n A:\test.com
-l
-u 0100 0108
0C3D:0100 B80200 MOV AX,0002
0C3D:0103 BB0400 MOV BX,0004
0C3D:0106 01D8 ADD AX,BX
0C3D:0108 0402 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:
Before this command is issued, a formatted diskette must be inserted into the appropriate
drive.
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:
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:
Examples:
1. The command to copy a 32-byte block of data from DS:100 through DS:11F is
written as
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 ()
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:
Each time unequal elements are found, the address and the contents of that byte in both
blocks are displayed.
Examples:
THE S COMMAND
Format:
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.
S 100 17F 33 ()
THE U COMMAND
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:
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 ()
U CS:200 201 ()
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.
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 ()
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 ()
G=CS:20E 215 ()
The commands
D DS:100 10F ()
D DS:120 12F ()
check the state of the corresponding blocks of memory. Execute the program
through CS:217 with the command
G=CS:215 217 ()
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.
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.
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
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.