Professional Documents
Culture Documents
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 program’s final address (010AH), and the program’s initial address (0100H).
The first result the command shows us is the addition of the parameters and the second is the
subtraction.
-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.
-r cx
CX 0000
:000A
Lastly, the “w” command writes our program on the disk, indicating how many bytes it wrote.
-w
Writing 000A bytes
To load a saved file, two steps are necessary:
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:
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
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
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:
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
C 100 10F 160 ()
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.
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 microcomputer’s memory. The
command
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 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
displays the source code. The first section of the program is executed with the command
Another GO command is used to execute the program down through address CS:215
The commands
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.
MOV AX, 1020
MOV DS, AX
MOV SI, 100
MOV DI, 120
MOV CS, 10H
MOV AH, [SI]
MOV [DI], AH
INC SI
INC DI
DEC CX
JNZ $-9
NOP
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.