Вы находитесь на странице: 1из 7

Lab Manual on Microprocessors and Interfacing 4-1

SHRI VAISHNAV VIDYAPEETH VISHVAVIDYALAYA, INDORE


Shri Vaishnav Institute of Technology & Science
Discipline: Electronics & Communication Engineering No. of Pages: 07
Name: Roll Number: Batch:
Subject Code: BTEC-504 Subject Name: Microprocessors & Interfacing
Details of Submissions & Performance
Performing on First Submission Second submission
Regular turn Extra turn

Remarks and Grade by tutor:

Cross the Grade Exc VG G Fr M F Signature

Experiment No. 4

4.1. AIM
Design an assembly language program to perform arithmetic operations using 8086
microprocessor.

4.2. OBJECTIVES
4.2.1. To understand the basic concepts of ALP development.
4.2.2. Development of algorithm for a given problem statement.
4.2.3. To develop flow chart using flowchart symbols.
4.2.4. Getting familiar with 8086 assembler.
4.2.5. To understand interfacing of 8086 with PC and procedure to load and execute the
program using assembler.

4.3. PRE-REQUISITES
4.3.1. Architecture of 8086 Microprocessor.
4.3.2. 8086 Internal Block Diagram.
4.3.3. Flag Register format of 8086.
4.3.4. Understanding of the arithmetic instruction.

Department of Electronics Engineering


Lab Manual on Microprocessors and Interfacing 4-2

4.4. APPARATUS REQUIRED


4.4.1. Microprocessor Kit 8086, PC, Power Supply.
4.4.2. 8086 Assembler, one PC, EMU-86
EMU -Simulator

4.5. THEORY
4.5.1. Register Organization of 8086
All Registers of 8086 are 16-bit
bit register .The GPR can be used as either 88-bit
bit or 16-bit. GPR
are used for holding data, variables and intermediate results temporarily. Other special
purpose registers are used as segment registers, pointers, index registers
register or as offset storage
registers for particular addressing modes.

General Purpose Registers (GPR)


X Specify the complete 16-bit
16 register
AX 16-bit accumulator.
BX Offset storage for forming physical address in case of certain addressing modes.
CX Default counter in case of string and loop instructions
DX Hold IO address during certain IO operations

Department of Electronics Engineering


Lab Manual on Microprocessors and Interfacing 4-3

4.5.2. Pointer and Index Registers


1. These registers are used to store the offset addresses of memory locations relative to the
segment registers.
2. The values in these registers can be read, loaded, or modified through Software.
Pointer registers
a) Base pointer (BP)
b) Stack pointer (SP)
Index registers
a) Source Index (SI)
b) Destination Index (DI)
3. Source Index is used to store an offset address for a source operand.
4. Destination Index is used for storage of an offset address for destination operand.
5. These registers can’t be accessed as two separate bytes like other general purpose
registers.
6. These registers are mainly used in string operations but can also be used as source or
destination registers in Arithmetic and Logical Operations.
7. Index registers are used as GPR as well as for offset storage in case of Indexed, based
indexed and relative based indexed addressing modes.

4.5.3. Flag register

Conditional Flags
1. CF Carry Flag Set if MSB has a carry.
2. PF Parity Flag Set if result has odd parity.
3. AF Auxiliary Carry Flag Used in BCD operations.
4. ZF Zero Flag. Set if result of arithmetic or logical operation is zero
5. SF Sign Flag Set if MSB of sign number is one.
6. OF Overflow. Flag Set when signed result id out range

Department of Electronics Engineering


Lab Manual on Microprocessors and Interfacing 4-4

Control Flags

1. Determines the direction in which the string operations


DF Direction Flag
will occur.
2. IF Interrupt Flag Allows or prohibit the interruption of program.
3. Trap Flag If this flag is set, microprocessor goes into the single
TF
step execution mode.

4.6. ARITHMETIC INSTRUCTION SET


These instructions usually perform the arithmetic operations like addition, subtraction,
multiplication, division along with the respective ASCII and decimal adjust instructions. The
increment and decrement operations also belong to this type of instructions. The arithmetic
instructions affect all the condition code flags. The operands are either the registers or
memory locations or immediate data depending on the addressing mode.

4.6.1. ADD: Add


This instruction adds an immediate data or contents of memory location specified in the
instruction or a register (source) to the contents of another register (destination) or memory
location. The result is in the destination operand.
Example:
ADD AX, 0100H //Immediate
ADD AX, DX //Register
ADD AX,[SI] //Register Indirect
ADD [5000H], 0100H //Immediate
4.6.2. ADC: Add with Carry
This instruction also adds the carry flag bit (which may be set as a result of previous
calculation) to the result.
Example:
ADC AX, BX //Register
ADC AX, [SI] //Register Indirect
4.6.3. INC: Increment
This instruction increments the content of the specified register or memory location by 1.
Example:
INC AX //Register
INC [BX] //Register Indirect

Department of Electronics Engineering


Lab Manual on Microprocessors and Interfacing 4-5

4.6.4. SUB: Subtract


This instruction subtracts an immediate data or contents of memory location specified in the
instruction or a register (source) from the contents of another register (destination) or
memory location. The result is in the destination operand.
Example:
SUB AX, 0100H //Immediate
SUB AX, DX //Register
SUB AX,[SI] //Register Indirect
SUB [5000H], 0100H //Immediate
4.6.5. SBB: Subtract with borrow
This instruction also subtracts the carry flag bit (which may be set as a result of previous
calculation) from the result.
Example:
SBB AX, BX //Register
SBB AX, [SI] //Register Indirect
4.6.6. CMP: Compare
This instruction compares the source operand which may be a register or an immediate data
or a memory location, with a destination operand which may be a register or a memory
location. For comparison it subtracts the source from the destination but doesn’t store the
result anywhere. If both the operands are equal, zero flag is set. If source is greater than
destination, carry flag is set.
Example:
CMP AX, 0100H //Immediate
CMP AX, DX //Register
4.6.7. DAA: Decimal Adjust Accumulator
This instruction is used to convert the result of the addition of two packed BCD numbers to a
valid BCD number. This result has to be only in AL. If the lower nibble is greater than 9,
after addition or if AF is set, it will add 06 to the lower nibble in AL. After adding 06 if the
upper nibble of AL is greater than 9 or if Carry flag is set, DAA instruction adds 60H to AL.
4.6.8. MUL: Multiplication
Unsigned Multiplication Byte or Word: This instruction multiplies an unsigned byte or word
by the content of AL. The unsigned byte or word may be in any one of general purpose
registers or memory location. The most significant word or result is stored in DX, while the
least significant in AX. Immediate operand is not allowed in thisinstruction.

Department of Electronics Engineering


Lab Manual on Microprocessors and Interfacing 4-6

Example:
MUL BH // (AX) ← (AL) × (BH)
4.6.9. DIV: Unsigned Division
This instruction divides an unsigned word or double word by a 16 bit or 8 bit operand. The
dividend must be in AX for 16-bit operation and divisor may be specified using any one of
the addressing modes except immediate. The result will be in AL (quotient) while AH will
contain the remainder. In case of double word dividend (32 bit), the higher word should be in
DX and lower word should be in AX. This instruction doesn’t affect any flag.

4.7. SAMPLE PROGRAMS


4.7.1. Write assembly language program for addition operation of two 8-bit hexadecimal
numbers on 8086 µP.
Solution:
MOV AL, 10H //Transfer of 10H into 8-bit register AL
MOV BL, 20H //Transfer of 20H into 8-bit register BL
ADD AL, BL //Addition of two 8-bit numbers
MOV DL, AL //Copy the contents of AL into DL register.
INT 5 //Termination
4.7.2. Write assembly language program for subtraction operation of two 8-bit hexadecimal
numbers on 8086 µP.
Solution:
MOV AL, 20H //Transfer of 10H into 8-bit register AL
MOV BL, 10H //Transfer of 20H into 8-bit register BL
SUB AL, BL //Subtraction of two 8-bit numbers
MOV DL, AL //Copy of AL in DL
INT 5 //Termination

4.8. PROBLEM STATEMENT


4.8.1. Write assembly language program for addition operation of two 16-bit hexadecimal
numbers on 8086 microprocessor.
4.8.2. Write assembly language program for subtraction operation of two 16-bit
hexadecimal numbers on 8086 microprocessor.
4.8.3. Write assembly language program for multiplication operation of two 16-bit
hexadecimal numbers on 8086 microprocessor.

Department of Electronics Engineering


Lab Manual on Microprocessors and Interfacing 4-7

4.8.4. Write assembly language program for division operation of two 16-bit hexadecimal
numbers on 8086 microprocessor.
4.8.5. Write assembly language program for squaring a 16-bit hexadecimal number on 8086
microprocessor.

4.9. TABULATION OF RESULTS


S.No Problems Status of Completion
1. Problem Statement 4.8.1
2. Problem Statement 4.8.2
3. Problem Statement 4.8.3
4. Problem Statement 4.8.4
5. Problem Statement 4.8.5

4.10. QUESTIONS TO BE ANSWERED:


4.10.1. If result of the multiplication operation exceeds from 16-bit how it will be stored?
4.10.2. If result of the division operation has 2 parts quotient and remainder where they will
be stored?
4.10.3. If result of the square operation exceeds from 16-bit how it will be stored?

4.11. STUDENTS SHOULD SUBMIT IN THEIR OWN HANDWRITING


4.11.1. Assembly Language Program for the problems given in the Problem statement along
with their results.
4.11.2. Answers to the questionnaire.

REFERENCES
[1]. A.K. Ray and K.M. Bhurchandi – Advanced Microprocessors and Peripherals, TMH
[2]. Douglas V.Hall - Microprocessor and Interfacing, TMH
[3]. Kennith J Ayala – 8086 Microprocessor, Pearson Education
[4]. Naresh Grover - Microprocessors: Comprehensive study, Dhanpat Rai Publictions

Department of Electronics Engineering

Вам также может понравиться