COA ExperimentNo.1
COA ExperimentNo.1
COA ExperimentNo.1
Section:
Date Performed:
Date Submitted:
Instructor:
LABORATORY ACTIVITY NO. 1
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 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 Commands
Debug provides a set of commands that lets you perform a number of useful operations:
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
It is possible to visualize the values of the internal registers of the CPU using the DEBUG program.
4. Resources:
1 Desktop Computer
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 Debug
To 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: Registers to be entered in DEBUG program are as follow:
mov ax, 0002
mov bx, 0004
add ax, bx
nop
Appear on the screen the assembly instructions machine:
You see that the value 0002H move to AX register. Type the command t (trace) again and you see
the second instruction is executed.
Format:
Example:
hexadecimal
Decimal
mov bh, 30
mov cl, 15
mov ax, bx
mov cl, bh
Example:
hexadecimal:
mov ax,1234H
add al, ah al=al + ah
mov bx, 0034H
Decimal:
mov bh, 30
mov bl, 45
add bh, bl bh = bh+ bl
Example:
hexadecimal
Decimal
mov bh, 30
mov bl, 45
sub bl, bh bl = bl - bh
mul <source>
mul <register>
Example:
hexadecimal
Decimal
mov al, 30
mov bl, 4
mul bl
ax = ax * bl
mul bl
ax = ax * bl
Format:
div <source>
div <register>
Example:
hexadecimal
Decimal
mov al, 40
mov bl, 2
div bl
ax = ax / bl
Format:
inc <register>
Example:
hexadecimal
Decimal
mov dl, 50
dx = dx +1
inc dl dl = dl +1
Format:
dec<register>
Example:
hexadecimal
Decimal
mov cl,15
dec cx
div bl
inc dx
ax = ax / bl
cx = cx -1
dec cl c l = cl -1
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.
output: A
output : SaM
mov ah, 02
mov cx, 000A
mov dl, 30
int 21h
inc dl
loop
nop
int20h
output: 0123456789
1. What will happen if a change the - a 100 segment offset into a 200?
______________________________________________________________________________
______________________________________________________________________________
2. What is the purpose of setting the segment offset?
______________________________________________________________________________
______________________________________________________________________________
3. What is the purpose of NOP in your program in DEBUG? Try to not include the NOP in your
code what will happen?
______________________________________________________________________________
______________________________________________________________________________
6. Data and Results:
A. Using DEBUG program, determine the contents of AX, BX, CX, and DX after executing every
sequence of assembly language instruction. Write your answer on the space provides.
Table 1:
Register Code
MOV AX, 0420H
MOV BX, 1220H
MOV CX, 0002H
MUL CX
SUB AX, BX
ADD AL, BL
ADD CL, AH
Table 2:
Mov AX, 0235
MOV DX, 0004
DIV DL
Mov Bx, 1230
SUB BX, AX
AX
BX
CX
DX
B. Using ASCII reference table, translate the following string as sequences of hex code. Write your answer on the space
provided below each item.
o
ComPuteR Soc!etY
7. Conclusion:
Based from the results of the experiment, what general rule can you apply for?
DEBUG PROGRAMMING
______________________________________________________________________________________________
______________________________________________________________________________________________
______________________________________________________________________________________________
______________________________________________________________________________________________
______________________________________________________________________________________
ASSEMBLY PROGRAMMING
______________________________________________________________________________________________
______________________________________________________________________________________________
______________________________________________________________________________________________
______________________________________________________________________________________________
______________________________________________________________________________________