1
Department of Computer ENGINEERING - Networks
College of computer & information system
Jazan University, Jazan
KINGDOM OF SAUDI ARABIA
LABORATORY MANUAL
Microprocessor & assembly language
(CNET 315)
Prepared BY: Naasir Kamaal khan, COURSE COORDINATOR
REVISED: SEPTEMBER 2013
2
This document is an academic resource focused on the function and design of the
various components necessary to process information digitally. This document has
been prepared to suffice as a laboratory manual for CNET 315 Microprocessor and
Assembly Language course for Computer Science & Computer Network students.
The manual consists of a set of experiments designed to allow students to build,
and verify DEBUG and TASM systems. This set of experiments cover relevant
topics prescribed in the syllabus and are designed to fortify the theoretical concepts
taught in the classroom with practical experience in the lab. By the end of the
course, students are expected to have a good understanding of Assembly Language
and implementation on DEBUG & TASM software. .
3
List of Programs
No. Name of Program
1 Introduction of DEBUG and its commands.
2 Demonstration of Display, Fill, Enter, and Register Flag commands.
3 Write down your name in DEBUG & Display it.
4 Display Flag Register of 8086 in DEBUG & change status of each Flag.
5 Write a Program in DEBUG to Add two 16 bit numbers.
6 Write a Program in DEBUG to Subtract two 16 bit numbers.
7 Write a Program in DEBUG to Multiply two 16 bit numbers.
8 Write a Program in DEBUG to Divide two 16 bit numbers.
9 Write a Program in DEBUG to transfer a Data block from Data Segment to Data Segment.
10 Write a Program in DEBUG to transfer a Data block from Data Segment to Extra Segment using
STRING instruction.
11 Write a Program in DEBUG to reverse string of 32 bits.
12 Write a Program in DEBUG to find out number of even numbers and odd numbers in a series.
13 Write a Program in DEBUG to arrange a series of bytes in ascending order.
14 Write a Program in DEBUG to convert CASES of given string.
15 Write a Program in DEBUG to check if entered string is Palindrome or not.
16 Write a Program in DEBUG to demonstrate working of keyboard as typewriter.
17 Write a Program in TASM to Add two 16 bit numbers.
18 Write a Program in TASM to Subtract two 16 bit numbers.
19 Write a Program in TASM to Multiply two 16 bit numbers.
20 Write a Program in TASM to Divide two 16 bit numbers.
21 Write a Program in TASM to calculate Area of Circle. (8087)
22 Write a Program in TASM to calculate Hypotenuse of a triangle using Pythagoras theorem.
(8087)
23 Write a Program in TASM to calculate Roots of quadratic equation. (8087)
24 Write a Program in TASM to calculate Resonant frequency. (8087)
Hint: F = 1/ (2* *sqrt(L*C))
4
Experiment # 1
This experiment will introduce you to DEBUG, allowing you to become familiar with the
process of assembling, debugging and executing an assembly language program with a PC.
DEBUG is a program available with every version of WINDOWS and DOS. Here you will learn
how to use DEBUG to assemble, disassemble, execute and debug assembly language programs
with a PC. You will also be instructed on how to examine and modify the memory and CPU
registers of your PC.
DEBUG
This tutorial is made to present an overview of the DEBUG.COM program for the IBM PC.
This utility can be extremely useful, when used correctly. It is almost a must for Assembler
language programmers, and can also provide an insight into the operation of the machine at
the bit level. It has several nice features, including the ability to display and change any of the
registers in the IBMPC, start and stop program execution at any time, change the program, and
look at diskettes, sector by sector. DEBUG works at the machine code level, but it does also
have the ability to disassemble machine code, and (at dos 2.0), assemble instructions directly into
machine code.
STARTING DEBUG
There are two ways to start DEBUG with a file. Both ways produce the same results, and either
can be used.
In the Command Line: C>debug
Separate from the command line: C>debug
-
With either method, you will get the DEBUG prompt of a hyphen (-). DEBUG has loaded your
program and is ready to run. The description of each instruction will assume this as a starting
point, unless otherwise mentioned. If at any time you get different results, check your procedure
carefully. If you do have problems, you can enter the command Q (Quit) any time you have
the DEBUG prompt (-). This should return you to the DOS prompt.
5
The Debug prompt, a hyphen (-).
Debug commands
Command Description
? Displays a list of the Debug commands.
A Assembles 8086/8087/8088 mnemonics.
C Compares two portions of memory.
D Displays the contents of a portion of memory.
E Enters data into memory starting at a specified address.
F Fills a range of memory with specified values.
G Runs the executable file that is in memory.
H Performs hexadecimal arithmetic.
I Displays one byte value from a specified port.
L Loads the contents of a file or disk sectors into memory.
M Copies the contents of a block of memory.
N Specifies a file for an l or w command, or specifies the parameters for the file you
are testing.
O Sends one byte value to an output port.
P Executes a loop, a repeated string instruction, a software interrupt, or a subroutine.
Q Stops the Debug session.
R Displays or alters the contents of one or more registers.
S Searches a portion of memory for a specified pattern of one or more byte values.
T Executes one instruction and then displays the contents of all registers, the status of
all flags, and the decoded form of the instruction that Debug will execute next.
U Disassembles bytes and displays the corresponding source statements.
W Writes the file being tested to a disk.
Xa Allocates expanded memory.
Xd Deallocates expanded memory.
xm Maps expanded memory pages.
6
xs Displays the status of expanded memory.
Demonstration of R command & changing value of each register.
-R AX
AX 0000
: 1234
-.
Demonstration of Fill command.
-f 0B20:0100 07FF 45
-d 0B20:0100 07FF
Demonstration of Enter command.
-e BCF:0220 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4f
-d BCF2-0220
Experiment 3: Write down your name in DEBUG and display it.
C:>debug
-E 2000:0100 ‘ Naasir Kamaal Khan’
-D 2000:0100 010A
2000:0100 4E 41 41 53 4 9 52 20 4B-4S 41 4E Naasir Kamaal Khan
7
Experiment 4: Demonstration of Flag Command
C:\>debug
-r f
NV UP EI PL NZ NA PO NC -ov
-r f
OV UP EI PL NZ NA PO NC -dn
-r f
OV DN EI PL NZ NA PO NC -di
-r f
OV DN DI PL NZ NA PO NC -ng
-r f
OV DN DI NG NZ NA PO NC -zr
-r f
OV DN DI NG ZR NA PO NC -ac
-r f
OV DN DI NG ZR AC PO NC -pe
-r f
OV DN DI NG ZR AC PE NC -cy
-r f
OV DN DI NG ZR AC PE CY -
-
8
Experiment 5:- Write a program in DEBUG to Add two 16 bit numbers.
C:\>debug
-a 0100
0AF8:0100 mov ax,1234
0AF8:0103 mov bx,4321
0AF8:0106 add ax,bx
0AF8:0108 int 3
0AF8:0109
-g =0100
AX=5555 BX=4321 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0AF8 ES=0AF8 SS=0AF8 CS=0AF8 IP=0108 NV UP EI PL NZ NA PE NC
0AF8:0108 CC INT 3
Experiment 6:- Write a program in DEBUG to Subtract two 16 bit numbers.
C:\>debug
-a 0100
0AF8:0100 mov ax,1234
0AF8:0103 mov bx,4321
0AF8:0106 sub ax,bx
0AF8:0108 int 3
0AF8:0109
-g =0100
Experiment 7:- Write a program in DEBUG to Multiply two 16 bit numbers.
C:\>debug
-a 0100
0AF8:0100 mov ax,2222
0AF8:0103 mov bx,0002
0AF8:0106 mul bx
0AF8:0108 int 3
0AF8:0109
-g =0100
AX=4444 BX=0002 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0AF8 ES=0AF8 SS=0AF8 CS=0AF8 IP=0108 NV UP EI PL NZ NA PE NC
0AF8:0108 CC INT 3
9
Experiment 8:- Write a program in DEBUG to Divide two 16 bit numbers.
C:\>debug
-a 0100
0AF8:0100 mov ax,2468
0AF8:0103 mov bx,0002
0AF8:0106 div bx
0AF8:0108 int 3
0AF8:0109
-g =0100
AX=1234 BX=0002 CX=0000 DX=0000 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0AF8 ES=0AF8 SS=0AF8 CS=0AF8 IP=0108 NV UP EI PL NZ NA PO NC
0AF8:0108 CC INT 3
-
Experiment 9:- Write a program in DEBUG to transfer a Data block from
data segment to data segment
C:\>debug
-a 5000:0100
5000:0100 MOV AX,2000
5000:0103 MOV DS,AX
5000:0105 MOV SI,0200
5000:0108 MOV DI,0300
5000:010B MOV CX,00FF
5000:010E MOV AX,[SI]
5000:0110 MOV [DI],AX
5000:0112 INC SI
5000:0113 INC DI
5000:0114 DEC CX
5000:0115 JNZ 010e
5000:0117 INT 3
5000:0118
-e 2000:0200 11 22 33 44 55 66 77 88 99 88 77 66 55 44 33 22 11
-g =5000:0100
AX=0000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=02FF DI=03FF
DS=2000 ES=0B32 SS=0B32 CS=5000 IP=0117 NV UP EI PL ZR NA PE NC
5000:0117 CC INT 3
-d 2000:0300 030f
2000:0300 11 22 33 44 55 66 77 88-99 88 77 66 55 44 33 22 ."3DUfw...wfUD3"
-
10
Experiment 10:- Write a program in DEBUG to transfer a Data block from
data segment to Extra segment using STRING function.
C:\>debug
-a 5000:0100
5000:0100 MOV AX,2000
5000:0103 MOV DS,AX
5000:0105 MOV AX,3000
5000:0108 MOV ES,AX
5000:010A MOV SI,0000
5000:010D MOV DI,0000
5000:0110 MOV CX,00FF
5000:0113 CLD
5000:0114 REP MOVSB
5000:0116 INT 3
5000:0117
-e ds:0000 11 22 33 44 55 66 77 88 99
-g =5000:0100
AX=3000 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=00FF DI=00FF
DS=2000 ES=3000 SS=0B32 CS=5000 IP=0116 NV UP EI PL NZ NA PO NC
5000:0116 CC INT 3
-d es:0000 0009
3000:0000 11 22 33 44 55 66 77 88-99 00 ."3DUfw...
-
11
Experiment 11:- Write a program in DEBUG to reverse string of 32 bits.
C:\>debug
-a 2000:0100
2000:0100 MOV DX,5678
2000:0103 MOV AX,1234
2000:0106 XCHG DX,AX
2000:0107 XCHG DH,DL
2000:0109 XCHG AH,AL
2000:010B MOV CL,04
2000:010D ROL AH,CL
2000:010F ROL AL,CL
2000:0111 ROL DH,CL
2000:0113 ROL DL,CL
2000:0115 INT 3
2000:0116
-g =2000:0100
AX=8765 BX=0000 CX=0004 DX=4321 SP=FFEE BP=0000 SI=0000 DI=0000
DS=0B32 ES=0B32 SS=0B32 CS=2000 IP=0115 OV UP EI PL NZ NA PO CY
2000:0115 CC INT 3
-
12
Experiment 12:- Write a program in DEBUG to arrange a series of bytes in
ascending order.
-A 0100
0AF5:0100 MOV DL,03
0AF5:0102 MOV CL,DL
0AF5:0104 MOV SI,1000
0AF5:0107 MOV AL,[SI]
0AF5:0109 CMP AL,[SI+1]
0AF5:010C JL 0113
0AF5:010E XCHG [SI+1],AL
0AF5:0111 XCHG [SI],AL
0AF5:0113 INC SI
0AF5:0114 LOOP 0107
0AF5:0116 DEC DL
0AF5:0118 JNZ 0102
0AF5:011A INT 3
0AF5:011B
-E DS:1000 53 25 19 02
-G =0100
AX=0019 BX=0000 CX=0000 DX=0000 SP=FFEE BP=0000 SI=1001 DI=0000
DS=0AF5 ES=0AF5 SS=0AF5 CS=0AF5 IP=011A NV UP EI PL ZR NA PE NC
0AF5:011A CC INT 3
-D DS:1000 1003
0AF5:1000 02 19 25 53
13
Experiment 13:- Write a program in DEBUG to find out number of Even and
Odd numbers in a series.
-A 0100
0AF5:0100 XOR BX,BX
0AF5:0102 XOR DX,DX
0AF5:0104 MOV CL,0F
0AF5:0106 MOV SI,1000
0AF5:0109 MOV AL,[SI]
0AF5:010B RCR AL,1
0AF5:010D JC 0112
0AF5:010F INC BX
0AF5:0110 JMP 0113
0AF5:0112 INC DX
0AF5:0113 INC SI
0AF5:0114 DEC CL
0AF5:0116 JNZ 0109
0AF5:0118 INT 3
0AF5:0119
-E DS:1000 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
-G =0100
AX=4412 BX=0007 CX=0000 DX=0008 SP=FFEE BP=0000 SI=100F DI=0000
DS=0AF5 ES=0AF5 SS=0AF5 CS=0AF5 IP=0118 NV UP EI PL ZR NA PE CY
14
Experiment 14:- Write a program in DEBUG to convert CASES of given
string.
C:\>DEBUG
-A 135A:1000
135A:1000 MOV AX,2000
135A:1003 MOV DS,AX
135A:1005 MOV SI,1000
135A:1008 MOV AX,[SI]
135A:100A CMP AL,24
135A:100C JZ 1021
135A:100E CMP AL,61
135A:1010 JC 101A
135A:1012 SUB AX,20
135A:1015 MOV [SI],AL
135A:1017 INC SI
135A:1018 JMP 1008
135A:101A ADD AL,20
135A:101C MOV [SI],AL
135A:101E INC SI
135A:101F JMP 1008
135A:1021 MOV AH,09
135A:1023 INT 21
135A:1025 INT 20
135A:1027
-A 2000:1000
2000:1000 DB ‘COMPUTER$’
2000:1008 INT 3
2000:1009
-G =1000
computer
15
Experiment No. 15 - Write a Program in DEBUG to check if entered string is Palindrome
or not.
-A 0100
0AF8:0100 mov cx,0000
0AF8:0103 mov ax,0b00
0AF8:0106 mov ds,ax
0AF8:0108 mov ax,0c00
0AF8:010B mov es,ax
0AF8:010D mov si,0010
0AF8:0110 mov di,0030
0AF8:0113 mov al,[si]
0AF8:0115 cmp al,24
0AF8:0117 jz 0120
0AF8:0119 cld
0AF8:011A movsb
0AF8:011B inc cx
0AF8:011C dec di
0AF8:011D dec di
0AF8:011E jmp 0113
0AF8:0120 inc di
0AF8:0121 mov si,0010
0AF8:0124 cld
0AF8:0125 repz
0AF8:0126 cmpsb
0AF8:0127 jnz 0132
0AF8:0129 mov dx,0400
0AF8:012C mov ah,09
0AF8:012E int 21
0AF8:0130 int 20
0AF8:0132 mov dx,0500
0AF8:0135 mov ah,09
0AF8:0137 int 21
0AF8:0139 int 20
0AF8:013B
16
-A 0B00:0010
0B00:0010 db 'malyalam$'
0B00:0019 int 21
0B00:001B
-a 0b00:0400
0B00:0400 db 'palindrome$'
0B00:040B int 21
0B00:040D
-a 0b00:0500
0B00:0500 db 'not palindrome$'
0B00:050F int 3
0B00:0510
-g =0100
not palindrome
Program terminated normally
17
Experiment No. 16 - Write a Program in DEBUG to demonstrate working of keyboard as
typewriter.
C:\>DEBUG
-A 1365:0100
1365:0100 MOV AX,2000
1365:0103 MOV DS,AX
1365:0105 MOV DX,0000
1365:0108 MOV AH,09
1365:010A INT 21
1365:010C MOV AH,01
1365:010E INT 21
1365:0110 CMP AL,00
1365:0112 JE 0116
1365:0114 JMP 010E
1365:0116 INT 20
1365:0118 INT 3
1365:0119
-A 2000:0000
2000:0000 DB 'Please enter any character and press function key to terminate:$'
2000:0040 INT 21
2000:0042 INT 3
2000:0043
-G =1365:0100
Please enter any character and press function key to terminate:Your course name
is microprocessor and assembly language
C:\>
19
Experiment No. 17 - Write a Program in TASM to Add two 16 bit numbers.
DATA SEGMENT
NUM1 DW 4321H
NUM2 DW 1234H
RESULT DW ?
CARRY DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV AX,NUM1
ADD AX,NUM2
JNC JUMP
MOV CARRY,01H
JUMP: MOV RESULT,AX
INT 03H
CODE ENDS
END START
Output window
20
Experiment No. 18 - Write a Program in TASM to subtract two 16 bit numbers.
DATA SEGMENT
NUM1 DW 4321H
NUM2 DW 1234H
RESULT DW ?
BORROW DB 00H
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:MOV AX,DATA
MOV DS,AX
MOV AX,NUM1
SUB AX,NUM2
JNC JUMP
MOV BORROW,01H
JUMP:MOV RESULT,AX
INT 03H
CODE ENDS
END START
Output window
21
Experiment No. 19 - Write a Program in TASM to multiply two 16 bit numbers.
DATA SEGMENT
NUM1 DW 4321H
NUM2 DW 1234H
RESULT DD ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV DX,0000H
MOV AX,NUM1
MUL NUM2
MOV WORD PTR RESULT,AX
MOV WORD PTR RESULT+2,DX
INT 03H
CODE ENDS
END START
Output window
22
Experiment No. 20 - Write a Program in TASM to divide two 16 bit numbers.
DATA SEGMENT
NUM1 DW 4321H
NUM2 DW 1234H
REM DW ?
QUO DW ?
RESULT DD ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
MOV DX,0000H
MOV AX,NUM1
DIV NUM2
MOV QUO,AX
MOV REM,DX
INT 03H
CODE ENDS
END START
Output window
23
Experiment No. 21 - Write a Program in TASM to calculate Area of Circle. (8087)
DATA SEGMENT
RADIUS DD 5.0
PIE DD 3.14
AREA DD ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
FINIT
FLD RADIUS
FMUL RADIUS
FMUL PIE
FST AREA
INT 03
CODE ENDS
END START
Output Window
24
Experiment No. 22 - Write a Program in TASM to calculate Hypotenuse of a triangle using
Pythagoras theorem. (8087)
DATA SEGMENT
SIDE1 DD 5.0
SIDE2 DD 12.0
HYPO DD ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
FINIT
FLD SIDE1
FMUL SIDE1
FLD SIDE2
FMUL SIDE2
FADD
FSQRT
FST HYPO
INT 03
CODE ENDS
END START
25
Experiment No. 23 - Write a Program in TASM to calculate Roots of quadratic equation.
(8087)
DATA SEGMENT
A DD 1.0
B DD 5.0
C DD 6.0
K DD 2.0
X DD ?
X1 DD ?
X2 DD ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
FINIT
FLD A
FLD C
FMUL ST(0),ST(1)
FADD ST(0),ST(0)
FADD ST(0),ST(0)
FLD B
FMUL ST(0),ST(0)
FSUB ST(0),ST(1)
FSQRT
FST X
FLD K
FLD B
FSUBR ST(0),ST(2)
FDIV ST(0),ST(1)
FST X1
FLD B
FCHS
FSUB ST(0),ST(3)
FDIV ST(0),ST(2)
FST X2
INT 03
CODE ENDS
END START
27
Experiment No. 24 - Write a Program in TASM to calculate resonant frequency. (8087)
DATA SEGMENT
RES DD 7.0
CAP DD 7.0
C1 DD 1.0
C2 DD 2.0
FREQ DD ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
FINIT
FLD RES
FMUL CAP
FLDPI
FMUL
FMUL C2
FSQRT
FDIVR C1
FST FREQ
INT 03
CODE ENDS
END START
Top Related