0% found this document useful (0 votes)
33 views33 pages

Chapter-4 4.3

Uploaded by

anupatil7576
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views33 pages

Chapter-4 4.3

Uploaded by

anupatil7576
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 33

K. K.

Wagh Polytechnic,
Nashik
Program:- Information Technology Semester:- III
Subject:- Data Techniques & Microprocessor Course Code:- 313305

Unit – IV
Basic assembly Language
Programming using 8086

(16 Marks)

Presented by: Mr. R. J. Shinde, Information Technology Dept.


Course Outcome:
CO3 - Perform operations on registers using 8086 instructions.

Theory Learning Outcome:


TLO 4.3 Use data transfer and arithmetic instruction for given situation
employing specific addressing mode.

Topic:
4.3 Format of instruction, instruction set: data transfer, arithmetic, logical,
branch and loop, flag manipulation

Presented by: Mr. R. J. Shinde, Information Technology Dept.


Instruction Set of 8086:
•An instruction is a binary pattern designed inside a microprocessor to
perform a specific task or function.
•The entire group of instructions that a microprocessor supports is called
Instruction Set.
•8086 has more than 20,000 instructions.

Presented by: Mr. R. J. Shinde, Information Technology Dept.


Presented by: Mr. R. J. Shinde, Information Technology Dept.
Data Transfer Instructions:
•These instructions are used to transfer data from source to destination.

•The operand can be a constant, memory location, register or I/O port


address.

Sr No. Instructions Definition/Meaning


Transfer data from source to
1 MOV
destination.

Swap the contents of two registers or


2 XCHG
a register and a memory location.

3 PUSH Push data onto the stack.

4 POP Pop the data from the stack

Presented by: Mr. R. J. Shinde, Information Technology Dept.


MOV Destination, Source:
• Source operand can be register, memory location or immediate operand.

• Destination can be register or memory operand.

• Both Source and Destination cannot be memory location at the same


time.
e.g.:

Presented by: Mr. R. J. Shinde, Information Technology Dept.


XCHG Des, Src:
• This instruction exchanges Src with Des.

• It cannot exchange two memory locations directly.

e.g.:

PUSH Operand:
•It pushes the operand into top of stack.

e.g.:

Presented by: Mr. R. J. Shinde, Information Technology Dept.


POP Des:
•It pops the operand from top of stack to Des.

•Des can be a general purpose register, segment register (except CS) or


memory location.

e.g.:

Presented by: Mr. R. J. Shinde, Information Technology Dept.


Arithmetic Instructions:
Arithmetic Instructions are the instructions which perform basic arithmetic
operations such as addition, subtraction and a few more.

Sr No. Instructions Definition/Meaning


ADD, SUB, ADC, Sum, difference, sum with carry,
1
SBB difference with borrow.
2 INC, DEC: Increment, decrement.
MUL, IMUL, DIV, Multiplication and division
3
IDIV: (unsigned and signed).

Presented by: Mr. R. J. Shinde, Information Technology Dept.


Presented by: Mr. R. J. Shinde, Information Technology Dept.
SUB Des, Src:
• It subtracts source operand from destination operand.

• For subtraction, CF acts as borrow flag.

e.g.:

ADC Des, Src:


•This instruction adds the carry flag into the result.
• Destination= Source +Destination +CF
• It adds the two operands with CF.
e.g.:

Presented by: Mr. R. J. Shinde, Information Technology Dept.


SBB Des, Src:
• It subtracts the two operands and also the borrow from the result.
e.g.:

Presented by: Mr. R. J. Shinde, Information Technology Dept.


INC Src:
•It increments the byte or word by one.

•The operand can be a register or memory location.


e.g.:

DEC Src:
•It decrements the byte or word by one.
•The operand can be a register or memory location.
e.g.:

Presented by: Mr. R. J. Shinde, Information Technology Dept.


MUL Src:
•This is unsigned multiplication instruction.

e.g. :

IMUL Src:
•It is a signed multiplication instruction.

Presented by: Mr. R. J. Shinde, Information Technology Dept.


DIV Src:
•It is an unsigned division instruction.
• It divides word by byte or double word by word.

• During the division of word by byte, the word (dividend) must be in AX


register and the byte (divisor) may be in any 8 bit register or memory
location.
• After the division, 8 bit quotient will be available in AL and 8bit
remainder will be in AH register.
e.g.:

IDIV Src:
It is a signed division instruction.
Presented by: Mr. R. J. Shinde, Information Technology Dept.
DAA (Decimal Adjust after Addition)
• It only works on AL register.
• This instruction must be used after the ADD/ADC instruction.
• The ADD/ADC instruction adds the two BCD number in hexadecimal
format and DAA instruction convert this hexadecimal result into BCD
result.

Presented by: Mr. R. J. Shinde, Information Technology Dept.


The working of DAA instruction is given below:

1. If lower nibble in AL accumulator > 9 or AF=1 then


AL=AL+06

2. If higher nibble in AL accumulator > 9 or CF=1


AL=AL+60

3. If both above conditions are satisfied, then


AL=AL+66

Presented by: Mr. R. J. Shinde, Information Technology Dept.


e.g.
If AL=99H, BL=99H
ADD AL, BL ; 1001 1001 AL=99H
+ 1001 1001 BL=99H
--------------------------
0011 0010 AL=32H , CF=1, AF=1
i.e . third condition is true (AF=CF=1), then add 66H into the AL register.
0011 0010 AL=32H
+ 0110 0110 BL=66H
-----------------------
1001 1000 AL=198 in BCD form.
Presented by: Mr. R. J. Shinde, Information Technology Dept.
DAS (Decimal Adjust after Subtraction)
•It only works on AL register.
•This instruction must be used after the SUB/SBB instruction.
•The SUB/SBB instruction subtracts the two BCD number in
hexadecimal format and DAS instruction convert this hexadecimal
result into BCD result.

Presented by: Mr. R. J. Shinde, Information Technology Dept.


The working of DAS instruction is given below:

1. If lower nibble in AL accumulator > 9 or AF=1 then


AL=AL-06

2. If higher nibble in AL accumulator > 9 or CF=1


AL=AL-60

3. If both above conditions are satisfied, then


AL=AL-66

Presented by: Mr. R. J. Shinde, Information Technology Dept.


Presented by: Mr. R. J. Shinde, Information Technology Dept.
NEG Src:
• It creates 2’s complement of a given number.
• That means, it changes the sign of a number.

e.g.:

Presented by: Mr. R. J. Shinde, Information Technology Dept.


Bit Manipulation(Logical) Instructions:
Logical instructions in the 8086 microprocessor are instructions that
perform logical operations on data stored in registers or memory
locations.

Sr No. Instructions Definition/Meaning


1 AND, OR, NOT Bitwise logical operations.
Shift left, shift right (logical and
2 SHL, SHR
arithmetic).

3 ROL, ROR Left rotate, right rotate (with carry).

Presented by: Mr. R. J. Shinde, Information Technology Dept.


AND Des, Src:
• It performs AND operation of Des and Src.
• Src can be immediate number, register or memory location.
• Des can be register or memory location.
• Both operands cannot be memory locations at the same time.
• Destination =destination AND source
e.g.:

Presented by: Mr. R. J. Shinde, Information Technology Dept.


OR Des, Src:
•It performs OR operation of Des and Src.
•Src can be immediate number, register or memory location.
•Des can be register or memory location.
•Both operands cannot be memory locations at the same time.

e.g.:

Presented by: Mr. R. J. Shinde, Information Technology Dept.


NOT Src:
• It complements each bit of Src to produce 1’s complement of the specified
operand.
• The operand can be a register or memory location.

e.g.:

Presented by: Mr. R. J. Shinde, Information Technology Dept.


SHL Des, Count:
•It shift each bit in the specified destination count times toward left.
•It puts zero(s) in LSBs. LSB 0
•MSB is shifted into carry flag. CF MSB
•If the number of bits desired to be shifted is 1, then the immediate number
1 can be written in Count.
•However, if the number of bits to be shifted is more than 1, then the count
is put in CL register.
e.g.:

***Shift register BL Left 4 times.***


Presented by: Mr. R. J. Shinde, Information Technology Dept.
SHR Des, Count:
•It shift bits of byte or word right, by count.
•It puts zero(s) in MSBs.
•LSB is shifted into carry flag.
•If the number of bits desired to be shifted is 1, then the immediate number
1 can be written in Count.
•However, if the number of bits to be shifted is more than 1, then the count
is put in CL register.
e.g.:

*** Shift register BL Right 3 times. ***

Presented by: Mr. R. J. Shinde, Information Technology Dept.


ROL Des, Count:
•It rotates bits of byte or word left, by count .
•MSB is transferred to LSB and also to CF.
•If the number of bits desired to be shifted is 1, then the immediate number
1 can be written in Count.
•However, if the number of bits to be shifted is more than 1, then the count
is put in CL register.

e.g.:

*** Rotate register BL Left 4 times. ***

Presented by: Mr. R. J. Shinde, Information Technology Dept.


ROR Des, Count:
•It rotates bits of byte or word right, by count.
•LSB is transferred to MSB and also to CF.
•If the number of bits desired to be shifted is 1, then the immediate number
1 can be written in Count.
•However, if the number of bits to be shifted is more than 1, then the count
is put in CL register.

e.g.:

Presented by: Mr. R. J. Shinde, Information Technology Dept.


Flag Manipulation Instructions:
This type of instructions are used to change the status of flags in the
flag register such as CF, DF and IF.

STC: It sets the carry flag to 1. i.e. CF=1


CLC: It clears the carry flag to 0. i.e. CF=0
CMC: It complements the carry flag. i.e. CF= ~ CF
STD: It sets the direction flag to 1. i.e. DF=1
CLD: It clears the direction flag to 0. i.e. DF=0
CLI :-It clears the interrupt flag to 0. i.e. IF=0
STI :- It sets the interrupt flag to 1. i.e. IF=1

Presented by: Mr. R. J. Shinde, Information Technology Dept.


Branch and Loop Instructions:

Instruction Definition/Meaning
Branching Instruction that transfers the flow of
Branching Instructions execution onto certain conditions or unconditional
transfers to the part of the program.

Instruction that can be used to repeatedly execute a


Looping Instructions
block of code either conditionally or unconditionally.

Presented by: Mr. R. J. Shinde, Information Technology Dept.


THANK YOU !!

Presented by: Mr. R. J. Shinde, Information Technology Dept.

You might also like