Pract 1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Aim : To assemble a com program in DEBUG, save it to disk and to

execute it at the command prompt

Software : Microsoft DEBUG

Theory : DEBUG program is part of the DOS operating system. It allows us


to assemble a program, execute it, examine the results it produces,
and if necessary, debug any errors. We can also examine and
modify the contents of the microprocessors’ registers and return
back to DOS. It is almost a must for Assembler Language
programmers and an ideal tool for beginners to learn the operation
of the machine at the bit level.
A com program is an executable program limited to 65,280 bytes
[ (64 x 1024) - 256 ] or less. It is assembled from location 100h
onwards. The first 256 bytes are used for internal data and is needed
by DOS to return control back to the operating system when the the
program terminates. All the data, code, and the stack area are in the
same segment of memory.

Procedure : 1. Open command.com. At the DOS prompt, type edit filename.txt


to invoke the DOS editor.
2. Type any string and end it with a $ sign. Return to the beginning
of the text file and type some spaces that will reserve some bytes
to used later.
3. Close edit and return to DOS prompt.
4. At the prompt load DEBUG by typing
C> debug filename.txt (enter)
Debug will then load itself into memory along with the file that is
specified and put the first byte of the file at offset 100 of the work
area.
5. Type D (dump) to verify that the file is entered properly in
memory. The first few bytes will be 20, the ascii code for space
character.
6. Assemble the following code starting at offset 100.
Assemble the following code starting at offset 100.
_A 0100(enter)
XXXX:0100 MOV AH,09
MOV DX, starting address of string
INT 21
INT 20
7. Using the name command, enter the new name with a .COM extension.
_ n filename.com
8. Find the offset number for the end of the file ($) and set the CX
register for the number of bytes using R command
_r cx
9. Enter w to write the file to the disk
_w
10. Quit debug and enter the name of the com file just assembled. If the
program is assembled correctly, the string will be displayed on the
screen.
Conclusio : Thus we have assembled a com program and executed it. The
n registers and memory of the PC is examined. The A, N, W, D, R
commands of debug are studied.

Remarks :

You might also like