Microprocessor and Interfacing
Microprocessor and Interfacing
1 Shreyansh Thakur
2k21/EP/92
Index
2 Shreyansh Thakur
2k21/EP/92
6. Write a program in Assembly
language to:-
● To find the minimum value in an
array
● To sort an array in ascending order
3 Shreyansh Thakur
2k21/EP/92
Experiment-1
Aim- Introduction about the Intel 8086 Microprocessor and its various
components
Theory-
The pin diagram of the 8086 microprocessor looks something like this,
Intel 8086 microprocessor has a 16-bit ALU, 16-bit registers, internal data
bus, and 16-bit external data bus resulting in faster processing.
The registers in the 8086 microprocessor are divided into 4 main categories,
i.e,
1. General Purpose registers
2. Index registers
3. Status & Control registers
4. Segment registers
4 Shreyansh Thakur
2k21/EP/92
The general purpose of the data registers is described as follows,
There are three Control flags in 8086, namely, TF(Trap flag), IF(Interrupt
Flag), DF(Direction Flag)
There are four segment registers, namely, CS, DS, ES, and SS—standing for
code segment register, data segment register, extra segment register, and
stack segment register respectively. When a particular memory is being read
or written into, the corresponding memory address is determined by the
content of one of these four segment registers in conjunction with their
offset addresses. The contents of these registers can be changed so that the
program may jump from one active code segment to another one. The use
of these segment registers will be more apparent in memory segmentation
schemes.
References-
● chrome-extension://efaidnbmnnnibpcajpcglclefindmkaj/https://www.bbau.ac.in/dept/UIET/Co
mputer%20Engineering%20II%20Year.pdf
● chrome-extension://efaidnbmnnnibpcajpcglclefindmkaj/https://www.shahucollegelatur.org.in/D
epartment/Studymaterial/sci/compsci/intelarchitecture.pdf
5 Shreyansh Thakur
2k21/EP/92
Experiment-2
Aim- Write a program in Assembly language to:-
1. Add two 8-bit Numbers with and without a carry
2. Add two 16-bit Numbers with and without a carry
3. Subtract two 8-bit Numbers with and without a borrow
4. Subtract two 16-bit Numbers with and without a borrow
Tools used:- emu8086 assembler and microprocessor emulator
Introduction:-
The 8086 Microprocessor is an enhanced version of the 8085
Microprocessor that Intel designed in 1976. It is a 16-bit Microprocessor
having 20 address lines and 16 data lines that provide up to 1MB of storage.
It consists of a powerful instruction set, which provides operations like
multiplication and division easily. We use the 8086 emulator to add and
subtract 8-bit and 16-bit numbers respectively.
Code:-
1. Addition:-
8-Bit:
mov al,[1000h]
mov bl,[1001h]
mov cl,00h
add al,bl
mov [1007h],al
jnc carry1
inc cl
carry1:
6 Shreyansh Thakur
2k21/EP/92
mov [1009h],cl
hlt
With carry:-
Input- (88)+(99)
Output-(21) + Cf=1
Without carry:
7 Shreyansh Thakur
2k21/EP/92
Input- (22)+(11)
Output- (33) + Cf=0
16-Bit:
mov ax,[1000h]
mov bx,[1002h]
mov cl,00h
add ax,bx
mov [1012h],ax
jnc carry2
inc cl
8 Shreyansh Thakur
2k21/EP/92
carry2:
mov [1009h],cl
hlt
With carry:
Input- (F389)+(9EC5)
Output- (924E) + Cf=1
Without carry:
9 Shreyansh Thakur
2k21/EP/92
Input- (3311)+(4422)
Output- (7733) + Cf=0
2. Subtraction:-
We subtract using the 2’s complement subtraction method
16-Bit:
mov ax,[1000h]
mov bx,[1002h]
mov cl,00h
sub ax,bx
10 Shreyansh Thakur
2k21/EP/92
jnc shr
inc cl
not ax
add ax,0001h
shr:
mov [1008h],ax
mov [1012h],cl
hlt
Without borrow:-
11 Shreyansh Thakur
2k21/EP/92
Input-(89F5)-(2381)
Output- (6674)
With borrow:-
Input- (33F5)-(99F7)
Output- (6602) & IF=1
Conclusion-
We can see that when we perform addition and/or subtraction operations,
the carry/borrow is indicated by the carry/borrow flag and the result gets
stored in the desired memory locations.
12 Shreyansh Thakur
2k21/EP/92
Experiment-3
Aim- Write a program in Assembly language to:-
1. Multiply two 16-bit numbers
2. Divide a 32-Bit number by a 16-bit number
Tools used:- emu8086 assembler and microprocessor emulator
Introduction:-
The 8086 Microprocessor is an enhanced version of the 8085
Microprocessor that Intel designed in 1976. It is a 16-bit Microprocessor
having 20 address lines and 16 data lines that provide up to 1MB of storage.
It consists of a powerful instruction set, which provides operations like
multiplication and division easily. We use the 8086 emulator to multiply and
divide 8-bit and 16-bit numbers respectively. Data is stored in the General
purpose registers and commands Mul and Div are used
Code:-
Multiplication:-
mov ax, [1600h]
mov bx, [1602h]
mul bx
mov [1606h],ax
mov [1608h],dx
Hlt
Conclusion- Multiplication of two 8-bit or 16-bit numbers gives the
desired result at the allocated memory location using the 8-86
emulator.
13 Shreyansh Thakur
2k21/EP/92
Input- (9FF2)*(995E)
Output- (5CD2)
14 Shreyansh Thakur
2k21/EP/92
Input- (99FF)*(88FF)
Output- (5268)
15 Shreyansh Thakur
2k21/EP/92
Experiment-4
Aim- Write a program in Assembly language to perform logic operations
AND, OR, XOR, NOT on 16-bit numbers
Tools used:- emu8086 assembler and microprocessor emulator
Introduction:-
The 8086 Microprocessor is an enhanced version of the 8085
Microprocessor that Intel designed in 1976. It is a 16-bit Microprocessor
having 20 address lines and 16 data lines that provide up to 1MB of storage.
It consists of a robust instruction set, which offers operations like
multiplication and division easily. We use the 8086 emulators to multiply and
divide 8-bit and 16-bit numbers respectively. Logical Operations are a vital
part of the 8086 instruction set and are used in a plethora of operations and
programs. They utilize the General Purpose registers as well as the carry flag
among other components of the 8086 infrastructure.
Code:-
mov ax,[1000h]
mov bx,[1002h]
and ax,bx
mov [1004h],ax
mov cx,[1000h]
or cx,bx
mov [1006h],cx
mov dx,[1000h]
xor dx,bx
mov [1008h],dx
mov cx,[1002h]
16 Shreyansh Thakur
2k21/EP/92
not dx
not ax
hlt
17 Shreyansh Thakur
2k21/EP/92
Experiment-5
Aim- Write an Assembly language program to:-
● Perform summation of even numbers in a series
● Perform summation of odd numbers in a series
● Find the average of all the numbers in the series
L2:
mov bh, [SI]
AND bh, 01h
JZ L1
add ah, [SI]
inc SI
Dec cl
JNZ L2
JZ L3
L1:
add al, [SI]
inc SI
Dec cl
18 Shreyansh Thakur
2k21/EP/92
JNZ L2
JZ L3
L3:
mov [1140h], ah
mov [1142h], al
add al, ah
mov bl, 0Ah
mov ah, 00h
div bl
mov [1148h], al
hlt
20 Shreyansh Thakur
2k21/EP/92
Experiment-6
Aim- Write an Assembly language program to:-
● To find the minimum value in an array
● To sort an array in ascending order
21 Shreyansh Thakur
2k21/EP/92
hlt
Input- 54,78,02,15,89,31,68
Output- 02
To arrange the particular array in ascending order
23 Shreyansh Thakur
2k21/EP/92
Experiment-7
Aim- Write an Assembly language program to:-
1. Find the square root of a given number
2. Convert the given binary code to equivalent grey number
Tools used- emu8086 assembler and microprocessor emulator
Code-
1. Code to find out the square root of a given number
mov ax,[1000h]
mov cx, 0000h
mov bx, 0FFFh
A:
Add bx,02
inc cx
sub ax,bx
JNZ A
mov [1030h],cx
hlt
Input- 81
Output-09
24 Shreyansh Thakur
2k21/EP/92
2. Code to convert given binary number into grey code
Conclusion- We Conclude that we can use the 8086 microprocessor and its
instruction set to find the square root of any given number assuming the
given number to be a perfect square. The instruction set of 8086
microprocessor also allows us to perform binary to grey code conversion.
25 Shreyansh Thakur
2k21/EP/92
Experiment-8
Aim- Write an Assembly language program to convert a given Decimal
Number into the equivalent Hexadecimal number
Tools used- emu8086 assembler and microprocessor emulator
Code-
mov SI,1000H
mov DI,1010H
mov BL,[SI]
and BL,0FH
mov AL,[SI]
and AL,00F0H
mov CL,04H
ror AL,CL
mov DL,0AH
mul DL
add AL,BL
mov DL,AL
mov [DI],AL
hlt
26 Shreyansh Thakur
2k21/EP/92
Input-56
Output-38
Carry Flag-0
Conclusion- We conclude that we can efficiently perform the
conversion of a decimal number to its hexadecimal equivalent using
the tools offered to us by the 8086 microprocessor’s instruction-set.
27 Shreyansh Thakur
2k21/EP/92