Download as pdf or txt
Download as pdf or txt
You are on page 1of 32

EXPERIMENT: 2(b)

Subtraction Using 8086 Microprocessor

Aim: To subtract two 8-bit and two 16-bit numbers using the 8086 Microprocessor’s emulator.

Requirements: emu8086 Software.

Theory & Introduction:

8086 microprocessor supports the following subtraction Instructions:


SUB – Used to subtract the byte from byte/word from word.
SBB – Used to perform subtraction with borrow
DEC – Decrement destination
AAS – ASCII Adjust after subtraction.
DAS – Decimal Adjust After Subtraction

To subtract two numbers, the algorithm that is used is given below.

Algorithm:-

Load the data to register ‘a’ from the memory.

Load the data to register ‘b’ from the memory.

Subtract the contents of register ‘b’ with accumulator ‘a’.

Code:
; Subtraction of two 16-bit numbers

mov ax,
[1000h] mov
bx, [1002h]

sub ax, bx

jnc Goto1
not ax
add ax, 01h

Goto1:
mov [1009h], ax

; Subtraction of two 8-bit numbers

mov ah,
[1100h] mov
bh, [1102h]

sub ah, bh

jnc Goto2
not ah
add ah, 01h

Goto2:
mov [1109h], ah
hlt

Results:

FOR 16-BITS > Inputs: AE56 and 1320

Outputs: Difference = 9B36, Borrow = 0


FOR 8-BITS > Inputs: 5C and AE

Outputs: Difference = -52, Borrow = 1

Conclusion: The numbers have been successfully and correctly subtracted using the program in 8086
Emulator.
EXPERIMENT: 3(a)
Multiplication Using 8086 Microprocessor

Aim: To multiply two 8-bit and two 16-bit numbers using the 8086 Microprocessor’s emulator.

Requirements: emu8086 Software.

Theory & Introduction:

MUL :Unsigned Multiplication Byte or Word


This instruction multiplies an unsigned byte or word by the contents of AL.
Eg.
MUL BH ; (AX) (AL) x (BH)
MUL CX ; (DX)(AX) (AX) x (CX)
MUL WORD PTR [SI] ; (DX)(AX) (AX) x
([SI])
IMUL :Signed Multiplication
This instruction multiplies a signed byte in source operand by a signed byte
in AL or
a signed word in source operand by a signed word in AX.
Eg. IMUL BH
IMUL CX
IMUL [SI]

To multiply two numbers, the algorithm that is used is given below.

Algorithm:-

Load the data to register ‘a’ from the memory.

Load the data to register ‘b’ from the memory.

Multiply the contents of register ‘b’ with accumulator ‘a’.


Move the result into memory.
Code:

; Multiplication of 16-bit numbers

mov ax,
[1000h] mov
bx, [1002h]

mul bx
mov [1004h],
ax mov
[1011h], dx

; Multiplication of 8-bit numbers

mov al,
[1006h] mov
bl, [1008h]

mul bl
mov [1009h],
al mov
[1013h], ah
hlt
Results:

FOR 16-BITS > Inputs: 5321 and ABDF

Outputs: Product = 37CF74BF

Outputs: Product = 21C3


Conclusion: The numbers have been successfully and correctly multiplied using the program in 8086
Emulator.
EXPERIMENT: 3(a)
Division Using 8086 Microprocessor

Aim: To divide two 8-bit and two 16-bit numbers using the 8086 Microprocessor’s emulator.

Requirements: emu8086 Software.

Theory & Introduction:

DIV : Unsigned division

This instruction is used to divide an unsigned word by a byte or to divide an unsigned


double word by a word.
Eg.
DIV CL ; Word in AX / byte in CL
; Quotient in AL, remainder in AH
DIV CX ; Double word in DX and AX / word
; in CX, and Quotient in AX,
; remainder in DX

To divide two numbers, the algorithm that is used is


given below.

Algorithm:-

Load the data to register ‘a’ from the memory.


Code:

; Division of 16-bit numbers

mov ax,
[1000h] mov
bx, [1002h]

div bx
mov [1004h], ax

; Division of 8-bit numbers

mov al,
[1006h] mov
bl, [1008h]

div bl
mov [1009h],
al hlt
Results:

FOR 16-BITS > Inputs: ABDF and A152

Outputs: Quotient = 01

FOR 8-BITS > Inputs: 53 and 2F

Outputs: Quotient = 2401


Conclusion: The numbers have been successfully and correctly divided using the program in 8086
Emulator.
EXPERIMENT: 4
Logical Operations Using 8086 Microprocessor

Aim: To perform logical operations using the 8086 Microprocessor’s emulator.

Requirements: emu8086 Software.

Theory & Introduction:

8086 AND logical Instruction


The AND instruction is 8086 microcontroller is performs bit by bit logical AND operation of two
operands and places the result in the specified destination.
8086 OR Logical Instruction
OR operation performs bit by bit OR operation and then stores final result in first operand. Operation
between two operands and stores the result back into the destination operand. The destination operand
can be a register or a memory location whereas the source can be immediate, register, or a memory
location.
8086 XOR logical Instruction
This instruction Performs bit by bit logical XOR operation of two operands and places the result in the
specified destination. The XOR operation gives 1 when both inputs are different. When both inputs
are same then the output will be zero.
8086 NOT Instruction
It complements each bit of Source to produce one’s complement of the specified operand. The
operand can be a register or memory
location. NOT can use any addressing mode except segment register addressing. The NOT function is
considered logical, NEG
function is considered an arithmetic operation. None of flags are affected by NOT instruction.

To perform logical operations, the algorithm that is used is given below.

Algorithm:-
Load the data to register ‘a’ from the memory.

Halt the program.

Code:

; Logical
Operations mov
AL, [1000h] mov
BL, [1002h] and
AL, BL
mov [1004h], AL

mov AL,
[1000h] or
AL, BL
mov [1006h], AL

mov AL, [1000h]

xor AL, BL
mov [1008h], AL
not BL
mov [1010h],
BL hlt

Results:

Inputs: AE and 59

Outputs: AND > 08

OR > FF

XOR > F7

NOT > A6
Conclusion: The numbers have been successfully and correctly operated logically using the program
in 8086 Emulator.
EXPERIMENT: 5
Operations on A Series Using 8086
Microprocessor
Aim: To perform following operations on a series of numbers using the 8086 Microprocessor’s
emulator:

Find the sum of numbers on odd positions.

Find the sum of numbers on even positions.

Find the average of complete series.

Requirements: emu8086 Software.

Theory & Introduction:

The algorithm that is used is given below.

Algorithm:-

Clear register ‘A’.

Move 0A data into ‘CL’ register for counting.

Use SI to read and perform operations on the data.


(Continued on next page)

(Continued)

Move the results into memory.

Halt the program.

Code:

mov ax,
00h mov cl,
0Ah mov SI,
1111h

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 JNZ
L2 JZ
L3

L3:
mov [1121h],
ah mov
[1122h], al
add al, ah
mov bl, 0Ah
mov ah, 00h
div bl
mov [1123h],
al hlt

Results:

Inputs: 05, 64, 11, 56, DF, 65, 78, 10, 2E, B8

Outputs: Sum of Odd placed numbers > 5A

Sum of Odd placed numbers > 28

Average of the Series > 0D


Conclusion: The series operations have been successfully and correctly carried out using the
program in 8086 Emulator.
MICROPROCESSORS & INTERFACING
PRACTICAL FILE
(EP-206)

Name: Subroto Bhowmik


Roll No.: 2K21/EP/96

Submitted To:-
DR. Anukul Pandey
INDEX

Sr. No. Experiment Name Page Date Remarks


No.
EXPERIMENT: 1
Introduction to 8086 Microprocessor
Aim: To get familiarized with the 8086 Microprocessor’s emulator, its commands and its interface.

Requirements: emu8086 Software.

Theory:

8085 microprocessor was designed by Intel in 1976. 8086 microprocessor is an enhanced version of
8085 microprocessor having 16 data lines and 20 address lines that provide 1 Mb of memory space.

8086 processor was the first 16-bit processor having 16-bit ALU, 16-bit registers, internal data bus
and also 16-bit external data bus resulting in fast processing. It is available in 3 versions based on the
frequency of operation: 5 MHz, 8MHz and 10 MHz. It also supports pipelined architecture.

Instruction Set of 8086 microprocessor:

MOV- Loads the byte or word from the provided source to the provided destination.

IN− Reads a byte or word from the provided port to the accumulator.

OUT- Sends out a byte or word from the accumulator to the provided port.

ADD- This command adds the provided numbers either byte-to-byte or word-to-word and stores
result in the accumulator.

ADC- It is used to add with a carry.

INC- It is used to increment the provided byte/word by one.

SUB- This command subtracts the provided numbers either byte-from-byte or word-from-word.
SBB-It is used to perform subtraction with borrow.

DEC- It is used to decrement the provided byte/word by one.

MUL- This command is used to multiply two numbers.

DIV- This command is used to divide two numbers.

NOT- This is used to invert each bit of a byte or word.

AND- ‘AND’ command is used for adding each bit in a byte/word with the corresponding bit in
another byte/word.

OR- This command is used to multiply each bit in a byte/word with the corresponding bit in another
byte/word.

XOR- It performs Exclusive-OR operation over each bit in a byte/word with the corresponding bit in
another byte/word.

JNC- “Jump if not carry” is used to jump to the specified address if there is no carry.

HLT- It halts the CPU until next interrupt.

In 8086, the memory registers are named as Register- a, b, c etc.

These are 16-bit registers and to use only 8-bit of them, we use ‘al’, ‘bl’, etc. To use complete 16-bits
of the register, we use ‘ax’, ‘bx’, etc. instead of ‘al’ and ‘bl’.

Comments in 8086 Emulator are added using semicolon. To specify memory addresses effectively,
write the memory location in square brackets and append an ‘h’ to it.
EXPERIMENT: 2
Addition Using 8086 Microprocessor

Aim: To add two 8-bit and two 16-bit numbers using the 8086 Microprocessor’s emulator.

Requirements: emu8086 Software.

Theory & Introduction:

8086 microprocessor supports the following types of addition


instructions. ADD – Used to add the provided byte to byte/word to
word.
ADC – Used to add with carry.

INC – Used to increment the provided byte/word by 1.

To add two numbers, the algorithm that is used is given below.

Algorithm:-

Halt the program.


Code:

; Addition of two 16-bit numbers

mov ax,
[1000h] mov
bx, [1002h]
mov cl, 00h

add ax, bx
mov [1005h],

ax jnc Sensei

inc cl

Sensei:
mov [1009h], cl
; Addition of two 8-bit
numbers mov al, [1100h]
mov bl,
[1102h] mov
cl, 00h

add al, bl
mov
[1105h], al
jnc Senpai
inc cl
Senpai:
mov [1109h],

cl hlt

Results:

FOR 16-BITS > Inputs: 0FFF and DE12

Outputs: Sum = EE11, Carry = 0


FOR 8-BITS > Inputs: F1 and D7

Outputs: Sum = C8, Carry = 1

You might also like