0% found this document useful (0 votes)
49 views20 pages

LaboratoryNo2 - Debug CELOCIA & PEREZ

The document discusses using the Debug program to perform basic assembly language programming. It provides an overview of the Debug commands and basic assembly language instructions like MOV, ADD, SUB, MUL, DIV, INC, and DEC. It also includes a sample program and instructions for creating and running a basic program in Debug.

Uploaded by

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

LaboratoryNo2 - Debug CELOCIA & PEREZ

The document discusses using the Debug program to perform basic assembly language programming. It provides an overview of the Debug commands and basic assembly language instructions like MOV, ADD, SUB, MUL, DIV, INC, and DEC. It also includes a sample program and instructions for creating and running a basic program in Debug.

Uploaded by

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

Name: CELOCIA & PEREZ Section: 301-G

Date Performed: JUNE 19, 2023 Date Submitted: JUNE 19, 2023
Instructor: ENGR. AMOR ELLARES Date: JUNE 19, 2023

LABORATORY ACTIVITY NO. 2


BASIC ASSEMBLY PROGRAMMING INSTRUCTION
USING DEBUG

1. Objective(s):

The activity aims to introduce the debug programming to the student

2. Intended Learning Outcomes (ILOs):


The students shall be able to:

1. Perform the arithmetic operations based on the given number system using Debug.
2. Demonstrate the knowledge in data manipulation using Debug.

3. Discussion
Debug is software that is used as tool for testing executable programs. A feature of
DEBUG is that it
displays all program code and data in hexadecimal format and any data you enter into
memory must also be in hex form. It is found in any PC with the MS_DOS which make it
available to any user who has access to a machine with these characteristics.

Debug provides a set of commands that lets you perform a number of useful operations.
It is possible to visualize the values of the internal registers of the CPU using the DEBUG
program.

DEBUG Commands

o A (assemble) symbolic instruction into machine code


o D (display) the contents of an area of memory
o E (enter) data into memory beginning at a specific location
o G (go) or run the executable program in memory
o N (name) a program
o P (proceed) or execute a set of related instructions
o Q (quit) the debug program
o R (run) or display the contents of one or more registers
o T (trace) the contents of one instruction
o U (unassembled) machine code into symbolic code
o W (write) a program onto disk

The following are some of the basic debug


commands: Q (Quit)
Finishes the debug session and exits back to dos environment.
Ex. –Q
R (Register)
Allows you to display all registers and their values.
Ex. –R
-R CX
A (Assemblle)
Allows you to create program in mnemonic or symbolic code
Ex. –A 0100gramming using Debug

G (Go)
Runs the program as a whole in memory and displays
the output Ex. –G

T (Trace)
Runs the program in single step mode. It also displays the new values of
the registers and the next instructions to be executed.
Ex. –T

Basic Assembly Language Instructions

The following commands are the operation used to program in assembly language.

● mov (move data)


it copies and transfer data between two registers, or between an immediate
data to a register.

Format: mov <destination>, <source>


mov <register>,
<register> mov <register>,
<data>

Example: hexadecimal Decimal


mov ax, 1234H mov bh, 30
mov bl, 12H mov cl, 15
mov ax, bx mov cl, bh
add (add data)

it is used to get the sum of two registers or a register and a data and store
the result to the left most register.

Format: add <destination>, <source>


add <register>, <register>
add <register>, <data>

Example: hexadecimal: Decimal:


mov ax,1234H mov bh, 30
add al, ah 🡪 al=al + ah mov bl, 45
mov bx, 0034H add bh, bl 🡪 bh = bh+ bl
add ax, bx 🡪 ax = ax +bx

● sub (subtract data)


it is used to get the different of two registers or a register and a data and
store the result to the left most register.
Format: sub <destination>, <source>
sub <register>, <register>
sub <register>, <data>
Example: hexadecimal Decimal
mov ax, 1234H mov bh, 30
sub al, ah 🡪 al = al –ah mov bl, 45
mov cx, 0012H sub bl, bh 🡪 bl = bl -
bh
sub ax, bx 🡪 ax = ax –bx

● mul (multiply data)


it is used to get the product of a given register AX and multiply data, and
stores the result to AX register. (If the product is greater than 16 bits, the
overflow is stored in DX register.)

Format: mul<source>
mul<register>

Example: hexadecimal Decimal


mov ax, 1234H mov al, 30
mov bl, 03H mov bl, 4
mul bl 🡪 ax = ax * bl mul bl 🡪 ax = ax * bl

● div (divide data)


it is used to get the quotient of a given register AX register and divide
data, and stores the result to AX register. (If the quotient produces a
remainder, the data is stored in DX register.)

Format: div <source>


div <register>

Example: hexadecimal Decimal


mov ax, 1234H mov al, 40
mov bl, 02H mov bl, 2
div bl 🡪 ax = ax / bl div bl 🡪 ax = ax / bl

● inc (increment by one)


it is used to increase the value of the register by

one(1). Format: inc <register>


Example: hexadecimal Decimal
mov dx, 0FF0H mov dl, 50
inc dx 🡪 dx = dx +1 inc dl 🡪 dl = dl +1

● dec (decrement by one )


it is used to decrease the value of the register by

one(1). Format: dec<register>

Example: hexadecimal Decimal


mov cx, 0FF0H mov cl,15dec cx 🡪 cx = cx -1

dec cl 🡪 c l = cl -1
4. Resources:

Desktop Computer
DOSbox application with Debug file

5. Procedure:
To begin working with DEBUG, type the following prompt in your computer.

C:\> debug

On the next line a dash will appear, this is the indicator of DEBUG at this
moment the instructions of DEBUG can be introduced using the following
command:

-r [enter key]

All the contents of the internal registers of the CPU are displayed; an alternative
of viewing them is to use the “r” command using as a parameter, the name of the
register whose value wants to be seen.

For example:
-rbx
BX 0000
This instruction will only display the content of the BX register and the DEBUG indicator
change from “-“ to “:”. When the prompt is like this, it is possible to change the value of
the register which was seen by typing the new value and [enter], or the old value can be
left by pressing [enter] without typing any other value.

Creating Basic Assemble Program in DebugTo assemble a program on


the DEBUG, the “a” (assemble) command is used; when this command is used,
the address where you want the assembling to begin can be given as a
parameter, if the parameter is omitted the assembling will be initiated at the
locality specified by CS:IP, usually 0100H which is the locality where programs
with .COM extension must be initiated.
Example: Values of registers to be entered in DEBUG program are
as follows: mov ax, 0002
mov bx,
0004 add
ax, bx nop

Appear on the screen are the assembly instructions machine:

Type the command “t” (trace) to execute each instruction of the program.

You see
that the value 0002H move to AX register. Type the command “t” (trace) again
and you see the second instruction is executed.
Type the command “t” (trace) to see the instruction add is executed

To exit DEBUG use the “q” (quit) command.


1. When you add the value of AX to BX, what will be value of AX?

AX's hexadecimal value after being added to BX is 0006.


2. After adding the BX to AX, what is the value of BX?

BX's hexadecimal value stays at 0004 when BX and AX are combined.

3. What is the purpose of NOP in your program in DEBUG? Try not to include the
NOP in your code, what happened?

NOP, which stands for "No Operation" in assembly language, is an


instruction that does nothing and merely acts as a placeholder or a delay in the
program. NOP can serve a number of functions in DEBUG, including aligning
code, adding delays, and serving as a stand-in for upcoming instructions. Since
the NOP instruction comes after the addition instruction in this particular
situation, removing it from the code would not immediately affect how the
program runs.
Assemble Program using Debug

Creating program on DEBUG, proceed debug type “-a 100” each input line starts with a
segment-offset address, and if you want to see the output type “- g”.

1. mov ax,
1234H mov
bh, 30 mov
bl, 12H mov
ax, bx mov
cl, 15

AX = 3012 BX= 0000 CX= 0000 DX= 0000


CS = 0072A BP= 0000 SS= 072F DI= 0000
2.mov ax,
1234H mov
bl, 02H div
bl

AX = 1234 BX= 0000 CX= 0000 DX= 0000

DS = 072F BP= 0000 DI= 0000 DI= 0000


3. mov ax,
1234H mov
bl, 03H mul
bl

AX = 009C BX= 0003 CX= 0000 DX= 0000


SS = 072F DI= 0000 DS= 072F IP= 0107

4. mov
ax,1234H
add al, ah
mov bx,
0034H
AX = 1246 BX= 0000 CX= 0000 DX= 0000
SS = 072F IP= 0108 ES= 072F SI= 0000

QUESTIONS:

1. What will happen if “- a 100” segment offset change to “ –a 200”?


You are providing a different starting address for inputting the code if we change the
segment offset in DEBUG from -a 100 to -a 200. Where the code is loaded into memory is
determined by the segment offset. Therefore, changing the segment offset will change the
starting address of the code segment.

2. What is the purpose of setting the segment offset?


To specify the starting address of the code segment, the segment offset must
be set. Memory is segmented in the 16-bit x86 architecture (like the 8086),
which means that the physical memory is divided into segments, each of which
has a starting address.

3. What is the purpose of NOP in your program in DEBUG? Try to not include
the NOP in your code, what happened?
NOP, which stands for "No Operation" in assembly language, is an
instruction that does nothing and merely acts as a placeholder or a delay in
the program. NOP can serve a number of functions in DEBUG, including
aligning code, adding delays, and serving as a stand-in for upcoming
instructions. Since the NOP instruction comes after the addition instruction
in this particular situation, removing it from the code would not immediately
affect how the program runs.
6. Supplemental Activities:
A. Using DEBUG, determine the contents of AX, BX, CX, and DX after executing
every sequence of assembly language instruction. Write your answer on the
space provided.

Table 1:

Register AX BX CX DX
Code
MOV AX,
0420H 0420 0000 0000 0000

MOV BX,
1220H 0420 1220 0000 0000

MOV CX,
0002H 0420 1220 0002 0000

MUL CX
0840 1220 0002 0000

SUB AX, BX
F620 1220 0002 0000

ADD AL, BL
F620 1220 0002 0000

ADD CL, AH
F620 1220 00F8 0000

Table 2:

Mov AX, 0235


0235 0000 0000 0000
MOV DX,
0004 0235 0000 0000 0004

DIV DL
018D 0000 0000 0004

Mov Bx, 1230


018D 1230 0000 0004

SUB BX, AX
018D 10A3 0000 0004

INC AL
018E 10A3 0000 0004

DEC DL
018E 10A3 0000 0003

7. Conclusion:

What conclusion can you make based on the activity?


With the registers we used in this activity, we learned how to operate them in the
DOSbox program for the debugging process. We also learned how to move
registers and apply logical functions with the registers we used in this exercise.

8. Assessment (Rubric for Laboratory Performance):


Evaluated by: Date:

Printed Name and Signature of Faculty Member

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy