0% found this document useful (0 votes)
198 views10 pages

Activity No 1 DEBUG

The document discusses using the DEBUG program to write, assemble, execute, and debug assembly language programs. It describes DEBUG commands for manipulating memory contents, loading and saving files, and controlling program execution. Sample problems demonstrate using DEBUG to enter and display data, assemble and run a short program that outputs text, and save/execute the program as a .COM file.

Uploaded by

reese stan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
198 views10 pages

Activity No 1 DEBUG

The document discusses using the DEBUG program to write, assemble, execute, and debug assembly language programs. It describes DEBUG commands for manipulating memory contents, loading and saving files, and controlling program execution. Sample problems demonstrate using DEBUG to enter and display data, assemble and run a short program that outputs text, and save/execute the program as a .COM file.

Uploaded by

reese stan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Activity No.

1
Debug
Course Code: CPE 005 Program:
Course Title: Computer Systems Organization with Assembly Language Date Performed:
Section: Date Submitted:
Name: Instructor:
1. Objective:
This activity aims to demonstrate how Debug can be used as an assembler and disassembler.

2. Intended Learning Outcomes (ILOs):


After completion of this activity the students should be able to:
2.1 Write a short assembly language sequence using Debug
2.2 Execute an assembler instruction in Debug
2.3 Examine the contents memory
3. Discussion :

The DEBUG program

To create a program in assembly options are to use an assembler or a debugger. The debugger that
comes with both Windows and DOS is debug.exe or DEBUG program.

DEBUG allows users to:


 control and monitor execution of programs
 Interactively display, examine memory contents, and view registers and variables as they change.
 alter and selectively load COM, EXE and other file types
 access specific sectors, I/O ports and memory addresses

The Debug Commands

Debug commands are issued at command prompt, denoted by a hyphen (-), either as a single
letter, in uppercase or lowercase, or with a combination of parameter. Table 1.1 shows the summary of the
Debug commands. The “?” is used to show the long name of each command.

Description
Command
Program Creation and Debugging
A Assemble a program using instruction mnemonics
G Execute the program currently in memory
R Display the contents of register
P Proceed past an instruction, procedure or loop
T Trace a single instruction
U Disassemble memory into assembler mnemonics
Memory Manipulation
C Compare one memory range with another
D Dump (display) the contents of memory
E Enter bytes into memory
F Fill a memory range with a single value
M Move bytes from one memory range to another
S Search a memory range for specific values
Miscellaneous
H Perform Hexadecimal addition and subtraction
Q Quit Debug and return to DOS
Input-Output
I Input a byte from a port
L Load data from disk
O Send a byte to a port
N Create a filename for use by the L and W commands
W Write data from memory to disk
Table 1.1 Summary of the Debug Commands

Once a Debug command has been issued, the <Enter> key must be pressed so that the command
becomes effective.

4. Resources:
Computer with 32-bit Operating System
Debug.exe
5. Procedure:
Sample Problem A.
1. Open Debug.exe. Type the following at the DOS command prompt of your computer:
C:/>Debug <Enter>
2. Issue the command E when prompted by hyphen ( - ), to place bytes in the memory,
- E CS:100 “Welcome to Assembly Programming!”
3. Use the D command to view contents at CS:0100
-D 100
Describe how your data are stored in the memory of the computer. In what number system are
they stored?
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
Record all results in Table 1.2.
4. Display the contents of a range, type
-D 110 11F
Describe what happened to the display.
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
5. Type Q to quit from Debug.
-Q
Sample Problem B.
1. Open Debug.exe.
2. Assemble the following program at address CS:0100. Type,
-A 100
138C:0100 mov ah,02
138C:0102 mov dl,49
138C:0104 int 21
138C:0106 mov dl,20
138C:0108 int 21
138C:010A mov dl,03
138C:010C int 21
138C:010E mov dl,20
138C:0110 int 21
138C:0112 mov dl,54
138C:0114 int 21
138C:0116 mov dl,49
138C:0118 int 21
138C:011A mov dl,50
138C:011C int 21
138C:011E int 20
138C:0120 [Enter]
-
3. Execute the program, type Gat the debug prompt.
-G
4. Analyze the output and record all results in Table 1.3
5. Unassemble the program at address 100 to 11e, type
- U 100 11E
6. Observe the output and record all results in Table 1.4.
7. Edit the values of address 107 and 10f, type
-E CS:107
20.0A
-E CS:10F
20.0A
8. Unassemblethe program at address 100
-U 100
Observe what happened to the output and record all results in Table 1.5.
What changes have you observed in the values of the memory?
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
9. Execute the program. Type,
-G
10. Save the program as Prog1.com, type
-N c:\CompOrg\Prog1.com <Enter>
Note: You should have had created CompOrg directory in C: drive.
11. Use H command to get the sum and difference of the addresses 0120 and 0100. Type,
–H 0120 0100
0220 0020
12. Change the value of the CX register to 0020. Type,
-R CX <Enter>
CX 0000
:0020
13. Type W to write the file Prog1.com,
-W <Enter>
The computer should display “Writing 00020” bytes.
14. Exit from Debug.

Sample Problem C.
1. Check the created Prog1.com file. Open the DOS command prompt. Click START-type CMD-press
ENTER.
2. Change directory to CompOrg.
c:\cd CompOrg><Enter>
3. Execute Prog1.com.
c:\CompOrg>Prog1.com <Enter>
4. Record your output in Table 1.6.

Sample Problem D.
1. Open Debug.exe
2. Type ?
-?
Describe what happened after you typed “?” at the prompt.
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________

Which of the commands does not have a parameter?


______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________
______________________________________________________________________________

Use Table 1.7 to write the long names of the commands and given the examples,give the function
of each of the commands used in this activity.
6. DATA ANALYSIS:

Table 1.2-Sample Problem A.3

138C:0100 ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ Welcome to Assem
138C:0110 ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ ___ bly Programming!
138C:0120 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
138C:0130 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
138C:0140 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
138C:0150 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
138C:0160 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................
138C:0170 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 ................

--

Table 1.3- Output of Sample Problem B.3

Table 1.4-Result of Sample Problem B.4

Address Contents (Hex) Mnemonics


: 0100 MOV AH,02
: 0102 MOV DL,49
:0104 INT 21
:0106 MOV DL,20
:0108 INT 21
:010A MOV DL,03
:010C INT 21
:010E MOV DL,20
:0110 INT 21
:0112 MOV DL,54
:0114 INT 21
:0116 MOV DL,49
:0118 INT 21
:011A MOV DL,50
:011C INT 21
:011E INT 20
Table 1.5-Result of Sample Problem B.6

Table 1.6- Output of Procedure C.4


Address Contents (Hex) Mnemonics
: 0100 B4 02 MOV AH,02
: 0102 MOV DL,49
:0104 INT 21
:0106
:0108 INT 21
:010A MOV DL,03
:010C INT 21
:010E
:0110 INT 21
:0112 MOV DL,54
:0114 INT 21
:0116 MOV DL,49
:0118 INT 21
:011A MOV DL,50
:011C INT 21
:011E INT 20
Table 1.7- Debug Commands

Command Syntax Function Example


A [Starting Address] A 100

D [Start Addr] [End Addr] D 100


D 110 11F

E [Address] [Data] E CS:107


E CS:100 “Welcome to
Assembly Programming!”

G [Starting Addr] [Breakpoint Addr] G


G=CS:100 11F

H value1 value2 H 0120 0100

N [C:] [filename] [.ext] N c:\CompOrg\Prog1.com

Q Q

Register R [Register name] Examine or modify the R


contents of internal CPU R CX
register.
U [Starting Addr] U 100
U 100 11E

W W
7. PROBLEMS:

1. Create a DEBUG program that will display your name, program, and course, on the computer
screen. Save you program as Prog2.com.
Sample Output:
Juan dela Cruz
BS CpE
CPE005

8. CONCLUSIONS

9. Assessment (Rubric for Laboratory Performance):

You might also like