Microprocessor-Based Systems Design (UCS617)
Lab Assignment-2 (8086)
Submitted to:
Dr Sumit Kumar
Submitted by:
Aarushi Kamboj 102103237
Anurag Pannu 102283020
Yati Dhanda 102103250
Samriddh Raman Bhatla 102103256
Muskan 102103265
BE Third Year, COE Group No: 3COE9_1
Computer Science and Engineering Department
TIET, Patiala
1
Index
SNo. TITLE Page
No.
1 Write an assembly language program to add two 16-bit numbers in 3
8086.
2 Write an assembly language program to add two 16-bit numbers in 4
8086.
3 Write an assembly language program to add two 16-bit 5
numbers in 8086.
4 Write an assembly language program to add two 16-bit 6
numbers in 8086.
5 Write an assembly language program to add two 16-bit 7
numbers in 8086.
6 Write an assembly language program to add two 16-bit 13
numbers in 8086.
7 Write an assembly language program to add two 16-bit 15
numbers in 8086.
8 Write an assembly language program to add two 16-bit 17
numbers in 8086.
9 Write an assembly language program to add two 16-bit 19
numbers in 8086.
10 Write an assembly language program to add two 16-bit 21
numbers in 8086.
2
Experiment 1
Q1) Write an assembly language program to add two 16-bit numbers in 8086.
Ans) MOV AX,15H
MOV BX,15H
ADD AX,BX
HLT
OUTPUT:
Fig 1
3
Experiment 2
Q2) Write an assembly language program to subtract two 16-bit numbers in 8086.
Ans) MOV AX,15H
MOV BX,10H
ADD AX,BX
HLT
OUTPUT:
Fig 2
4
Experiment 3
Q3) Write an assembly language program to multiply two 16-bit numbers in 8086
Ans) MOV AX,[1001H]
MOV BX,[1003H]
MUL BX
HLT
OUTPUT:
Fig 3
5
Experiment 4
Q4) Write an assembly language program to divide two 16-bit numbers in 8086.
Ans) MOV AX,[1001H]
MOV BX,[1003H]
DIV BX
HLT
OUTPUT:
Fig 4
6
Experiment 5
Q5) Write an assembly language program to demonstrate AAA, AAS, AAM, AAD, DAA
and DAS in 8086.
Ans) AAA Instruction
MOV AX,010FH
AAA
HLT
Fig 5.1
7
AAS Instruction:
MOV AX,020FH
AAS
HLT
Fig 5.2
8
AAM Instruction:
MOV AL,'3'
MOV BL,'9'
AND AL,0FH
AND BL,0FH
MUL BL
AAM
OR AX,3030H
Fig 5.3
9
AAD Instruction:
MOV AX,0207H
MOV BL,05H
AAD
DIV BL
Fig 5.4
10
DAA Instruction:
MOV AL,73H
ADD AL,45H
DAA
HLT
Fig 5.5
11
DAS Instruction:
MOV AL,81H
SUB AL,33H
DAS
HLT
Fig 5.6
12
Experiment 6
Q6) Write an assembly language program to find out the count of positive numbers and
negative numbers from a series of signed numbers in 8086.
Ans) MOV CL,0AH
MOV BL,00H
MOV DL,00H
LEA SI, [1000H]
L1: MOV AL, [SI]
SHL AL, 01
JNC L2
INC DL
JMP L3
L2: INC BL
L3: INC SI
DEC CL
JNZ L1
MOV [100AH], BL
MOV [100BH], DL
HLT
13
Output:
Fig 6
14
Experiment 7
Q7) Write an assembly language program to find out the largest number from a given
unordered array of 8-bit numbers, stored in the locations starting from a known address in
8086.
Ans) MOV CL, 0AH
LEA SI, [1000H]
MOV AL, [SI]
L1: INC SI
MOV BL, [SI]
CMP AL, BL
JC L2
JMPL3
L2: MOV AL, BL
L3: DEC CL
JNZ L1
MOV [100AH], AL
HLT
15
Output:
Fig 7
16
Experiment 8
Q8) Write an assembly language program to convert the largest number from a given
unordered array of 16-bit numbers, stored in the locations starting from a known address
in 8086.
Ans) MOV BX, 1000H
MOV CL, [BX]
INC BX
MOV AX, [BX[
DEC CL
Back: INC BX
INC BX
CMP AX, [BX]
JNC Next
MOV AX, [BX]
Next: DEC CL
JNZ Back
MOV [1020H],
AXHLT
17
Output:
Fig 8
18
Experiment 9
Q9) Write an assembly language program to print Fibonacci series in 8086.
Ans) MOV AL,00H
MOV SI,500H
MOV [SI],AL
ADD SI,01H
ADD AL,01H
MOV [SI],AL
MOV CX,[0000H]
SUB CX,0002H
L1:MOV AL,[SI-1]
ADD AL,[SI]
ADD SI,01H
MOV [SI],AL
LOOP L1
HLT
19
Output:
Fig 9.1
Fig 9.2
Fig 9.3
20
Experiment 10
Q10) Write an assembly language program to perform the division 15/6 using the ASCII codes.
Store the ASCII codes of the result in register DX.
Ans) MOV AX, ’15’
MOV BH, ’6’
SUB AX,3030h
SUB BH,30H
AAD
DIV BH
ADD AX,3030H
MOV [SI], AX
HLT
Output:
Fig 10
21