You are on page 1of 73

Vidarbha Youth Welfare Society’s

Prof. Ram Meghe Institute of Technology & Research,


Badnera-Amravati (M.S) 444701.

Practical Record
Semester IV

Subject: - (4KS08) Microprocessor and Assembly Language


Programming Lab

Department of Computer Science and Engineering


Vidarbha Youth Welfare Society’s
Prof. Ram Meghe Institute of Technology & Research Badnera,
Amravati (M.S) 444701.

CERTIFICATE

This is to certify that Mr. Mahesh Santosh Darvankar Enrolment

No. __________________________ Roll No. _79__ Section__B__ of B.E.


Second year Semester IV department of Computer Science & Engineering has
satisfactorily completed the practical work of the subject Microprocessor and
Assembly Language Programming Lab prescribed by Sant Gadge Baba
Amravati University, Amravati during the academic term 2020-21.

Signature of the faculty Head of Department

Date:
1. Vision and Mission of the Institute and Programme

 Vision& Mission statement of the Institute

VISION
To become a pace-setting centre of excellence believing in three
universal values namely Synergy, Trust and Passion, with zeal to serve the Nation in
the global scenario.

MISSION
To dedicate ourselves to the highest standard of technical education
& research in core & emerging engineering disciplines
and strive for the overall personality development of students
so as to nurture not only quintessential technocrats
but also responsible citizens.

 Vision& Mission statement of the Department of Computer Science &


Engineering

VISION
To ensure that the world saves time and other depletable resources and free it from
complexity by providing efficient computing services.

MISSION
To dedicate ourselves to the highest standard by providing knowledge, skills and
wisdom to the incumbent by imparting value based education to enable them to solve
complex system by simple algorithms and to make them innovative, research oriented
to serve the global society, while imbibing highest ethical values.
2. Program educational objective (PEO’s), program outcomes (PO’s) and
Program Specific Outcomes (PSO’s)
 Program educational objective (PEO’s)
PE01. Preparation: To prepare students for successful careers in software industry that meet the
needs of Indian and multinational companies or to excel in Higher studies.
PEO2. Core competence: To develop the ability among students to synthesize data and technical
concepts for software design and development.
PEO3. Breadth: To inculcate in students professional and ethical attitude, effective
communication skills, teamwork skills, multidisciplinary approach and an ability to relate
engineering issues to broader social context.
PEO4. Professionalism: To provide students with a sound foundation in the mathematical,
scientific and computer engineering fundamentals required to solve engineering problems and
also pursue higher studies.
PEO5. Learning Environment: To promote student with an academic environment aware of
excellence, leadership, written ethical codes and guidelines and the life-long learning needed for a
successful professional career.

 Program Outcomes (PO’s)


Engineering Graduate will be able to:
PO1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering
fundamentals, and an engineering specialization to the solution of complex engineering problems.
PO2. Problem analysis: Identify, formulate, review research literature, and analyse complex
engineering problems reaching substantiated conclusions using first principles of mathematics,
natural sciences, and engineering sciences.
PO3. Design/development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
considerations.
PO4. Conduct investigations of complex problems: Use research-based knowledge and
research methods including design of experiments, analysis and interpretation of data, and
synthesis of the information to provide valid conclusions.
PO5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modeling to complex engineering
activities with an understanding of the limitations.
PO6. The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent responsibilities relevant
to the professional engineering practice.
PO7. Environment and sustainability: Understand the impact of the professional engineering
solutions in societal and environmental contexts, and demonstrate the knowledge of, and need for
sustainable development.
PO8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and
norms of the engineering practice.
PO9. Individual and team work: Function effectively as an individual, and as a member or
leader in diverse teams, and in multidisciplinary settings.
PO10. Communication: Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being able to comprehend and write
effective reports and design documentation, make effective presentations, and give and receive
clear instructions.
PO11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s own work, as a member and
leader in a team, to manage projects and in multidisciplinary environments.
PO12. Life-long learning: Recognize the need for, and have the preparation and ability to engage
in independent and life-long learning in the broadest context of technological change.

 Program Specific Outcomes (PSO’s)


PS01: Foundation of Computer System Development: Ability to use knowledge of computer
systems and design principles in building the hardware and software components, products in the
domain of embedded system, artificial intelligence, databases, networking, web technology and
mobile computing.
PS02: Problem Solving Ability: Ability to apply knowledge in various problem domains and
implement innovative and suitable solutions to cater to needs of industry, business and
egovernance by imbibing highest ethical and economical values.

3. Syllabus, Course outcomes and Mapping of CO’s with PO’s

Course Number and Title : (4KS04) Assembly Language Programming


Faculty : Prof. P. B. Lohiya (pblohiya@mitra.ac.in)
Prof. A. B. Pahurkar (abpahurkar@mitra.ac.in)
Prof. G. B. Saboo (gbsaboo@mitra.ac.in)
Course Type : Theory + Laboratory
Compulsory / Elective : Compulsory
Teaching Method : Lecture: 03 Hrs / week.
Laboratory: 02 Hrs / week (04 Batches)
Subject Credits : 03 Credits for Theory + 01 Credit for Laboratory
Course Assessment : Theory: 02 Class Tests + 01 Improvement Test,
Semester end examination by SGBAU.
Laboratory: Lab Performance + Viva-Voce Semester
examination by SGBAU
Grading Policy : Theory: 20% Assignments, class test and viva-voce, 80%
Semester end examinations.
Laboratory: 50 % Internal + 50 % External.
25 Internal Marks + 25 External Marks (Viva-Voce
Semester exam by SGBAU)

Syllabus (Unit wise Course Contents)


Unit I: 8086 Architecture 8086 architecture and pin configuration, Software model of 8086
microprocessor. Memory addresses space and data organization. Data types. Segment
registers, memory segmentation. IP & Data registers, Pointer, Index registers. Memory
addresses generation.
Unit II: 8086 Instruction Set 8086 Instruction set overview, addressing modes. 8086
instruction formats. 8086 programming: Integer instructions and computations: Data transfer
instructions, Arithmetic instructions and their use in 8086 programming.
Unit III: 8086 Instruction Set 8086 programming: logical instructions. Shift and rotate
instructions and their use in 8086 programming. 8086 flag register and Flag control
instructions, compare instruction, control flow and jump instructions, Loops & loop handling
instructions. 8086 programming using these instructions.
Unit IV: Subroutines & Macros The 8086 stack segment and stack related instructions.
8086 I/O Address space. Subroutines and related instructions, Parameter passing, Concept of
Macros, Status saving on stack. Concept of recursion at assembly program level. 8086
Programming using subroutines, recursion and macros.
Unit V: 8086 Interrupt 8086 Interrupts types, priority and instructions. Interrupt vector
table, External hardware-interrupt interface signals & interrupts sequence. Software
interrupts. Non-maskable interrupts. 8086 microprocessor interrupt programming.
Unit VI: Internet of Things (IoT) Internet of things: An overview, IoT conceptual
framework, IoT Architectural View, Technology behind IoT, Sources of IoT, M2M
communication, Examples of IoT.

Text Book:

1. A. K. Ray & K. M. Bhurchandi: Advanced Microprocessors & Peripherals, Third Edition (TMH).
2. Raj Kamal: Internet of Things, Architecture and Design Principals, McGraw Hill Education (India)
Private Limited

Reference Books:

1. W. A. Triebel& Avatar Singh: The 8088/8086 Microprocessors (4e) (PHI /Pearson Education)
2. Liu & Gibson: The 8088/8086 Microprocessor Architecture Programming and Interface (6/e) (PHI)

Prerequisites: Computer Organisation, Computer Programming

 Course Learning Objectives:


1. To explore 8086 microprocessor and its architecture.
2. To introduce Assembly Language Programming and interfacing technique of 8086
microprocessor.
3. To illustrate the basic concept of subroutine, interrupt and exception handling in 8086
microprocessor.

 Course Outcomes (CO’s)


At the end of the course, Students will be able to:
Sr. No. Course Outcome
Describe 8086 microprocessor and its architecture; also understand instruction
4KS04.1
processing during the fetch-decode-execute cycle.
Design and Test assembly language programs using 8086 microprocessor
4KS04.2
instruction set.
Demonstrate the implementation of standard programming constructs, including
4KS04.3
control structures and functions, in assembly language.
Analyze the internal workings of the microprocessor on a procedure call and
4KS04.4
macros defined by user in an assembly language program.
Understand and realize the Interfacing of memory & various I/O devices with
4KS04.5
8086 microprocessor.
4KS04.6 Interpret the interfacing of microprocessor with interrupt controller IC.
Design and develop programs in Assembly Language Programming given in the
4KS08.1 forms of aims and objectives using existing tools and Conclude co-relation of
theory concept with practices.

 Mapping of Course Outcomes with Program Outcomes


Course PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12

4KS04.1 2 2 3 2 2 - - - - - 2 2
4KS04.2 3 2 2 2 2 - - - - - 2 2
4KS04.3 1 2 3 1 2 - - - - - 2 3
4KS04.4 3 2 1 2 2 - - - - - 2 1
4KS04.5 2 2 3 2 1 - - - - - 2 1
4KS04.6 2 2 3 2 2 - - - - - 2 3
4KS08.1 3 2 3 2 2 - - - - - 2 3

Correlation levels: 1. Low 2. Medium 3.High

 Mapping of Course Outcomes with Program Specific Outcomes


Course PSO 1 PSO 2

4KS04.1 2 2
4KS04.2 3 3
4KS04.3 2 2
4KS04.4 2 3
4KS04.5 3 3
4KS04.6 3 1
4KS08.1 3 1

Correlation levels: 1. Low 2. Medium 3.High

4. Practical Evaluation Guidelines: (ACPV Guidelines)


Guidelines for Awarding Internal Marks for Practical:
At the end of the semester, internal assessment marks for practical shall be the
average of marks scored in all the experiments.

a. Attendance (05 Marks): These 05 marks will be given for the regularity of a student. If
the student is present on the scheduled day, he / she will be awarded 05 marks.
b. Competency (05 Marks): Here the basic aim is to check competency of the student. The
skill to interprets the aim of the practical and provide solution for the same. Here
expectation from the student is to improvise the existing solution, and the given
modification. The marks will be given according to the level of improvement made in the
practical.

c. Performance (05 Marks): Here the basic aim is to check whether the student has
developed the skill to write down the code on his own, and compile / debug. If a student
correctly executes the practical on the scheduled day within the allocated time; he / she
will be awarded full marks. Otherwise, marks will be given according to the level of
completion / execution of practical.

d. Viva-Voce (05 Marks): These 05 marks will be totally based on the performance in
vivavoce. There shall be viva-voce on the completion of each practical in the same
practical session. The student shall get the record checked before next practical.
5. List of Practical’s

Sr. Page
Name of Practical Date Remarks
No. No.
• Study of TASM Assembler with basic commands and
directories.
1
• Write program to read or write data from memory to
understand addressing modes of 8086.
• Implement Arithmetic Group of Instructions of 8086 on
a series of data using Assembly Language.
2
• Perform addition and subtraction on 10 consecutive
numbers.
• Use Mul instruction to find a factorial of a given
3 number.
• Find mean of N numbers using Div instruction.
Apply Shift and Rotate Instructions on given numbers to
4 identify the logical arrangement of bits.
Find 31AX-7BX+BX/16.
Verify that whether given Eight bits numbers are
5 Positive or Negative using Logical Group of
Instructions.
WAP to transfer N bytes of block starting from address
1000H in the memory to another block of memory
location at an offset address 2000H. Assume both the
6 blocks are available in same data segment that’s starting
point, is define by the data segment value C000H. Write
above program by making use of branch and loop
instructions.
• Define procedure SQUARE to find square of
numbers present in the array. Take the Ten numbers
from the user in an array and call SQUARE
procedure to find square of these numbers.
7
• Write macros CUBE to find cube of numbers present
in the array. Take the Ten numbers from the user in
an array and call CUBE macro to find cube of these
numbers.
Find out the Length of string given by user. Write a
8 procedure to take string from the user and then write a
procedure to find the length of the string.
PALINDROME is the procedure that finds out whether
the string is palindrome or not. Take the string from the
9
user and check the entered string is palindrome or not
using PALINDROME procedure.
Practical No. 1 Title:- TASM Assembler Installation
Aim: Study of TASM Assembler with basic commands and directories.
Write program to read or write data from memory to understand addressing modes of 8086.

Objective:
Students will learn about TASM Assembler and able to set platform required for TASM.

S/W REQUIRED: TASM, DOSBOX


Study of TASM Assembler
Introduction:
The aim of this experiment is to introduce the student to assembly language programming and
the use of the tools that he will need throughout the lab experiments. This first experiment let
the student use the Dos Debugger and the Microsoft Turbo Assembler (TASM). Editing,
Assembling, Linking, Execute up can be done using TASM software Objectives:
1. Introduction to Microsoft Turbo Assembler (TASM)
2. General structure of an assembly language program
Overview:
In general, programming of microprocessor usually takes several iterations before the right
sequence of machine code instruction is written. The process, however is facilitated using a
special program called an “Assembler”. The Assembler allows the user to write alphanumeric
instructions. The Assembler, in turn, generates the desired machine instructions from the
assembly language instructions.
Assembly language programming consists of following steps:
Assembling the program:
The assembler is used to convert the assembly language instructions to machine code. It is
used immediately after writing the Assembly language program. The assembler starts by
checking the syntax or validity of the structure of each instruction in the source file .if any
errors are found, the assemblers displays a report on these errors along with brief explanation
of their nature. However If the program does contain any errors, the assembler produces an
object file that has the same name as the original file but with the “obj” extension Linking
the program:
The Linker is used convert the object file to an executable file. The executable file is the final
set of machine code instructions that can directly be executed by the microprocessor. It is the
different than the object file in the sense that it is self-contained and re-locatable. An object
file may represent one segment of a long program. This segment can not operate by itself, and
must be integrated with other object files representing the rest of the program, in order to
produce the final self-contained executable file
Executing the program
The executable contains the machine language code .it can be loaded in the RAM and
executed by the microprocessor simply by typing, from the DOS prompt ,the name of the file
followed by the carriage Return Key (Enter Key). If the program produces an output on the
screen or sequence of control signals to control a piece of hard ware, the effect should be
noticed almost immediately. However, if the program manipulates data in memory, nothing
would seem to have happened as a result of executing the program.
TASM is one of the softwares used for programming the microprocessor 8086. It is very
popular for domestic and commercial use. TASM stands for Turbo Assembler. We are going

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 1


to use the TASM version 5 for performing experiments of Assembly Language Programming
practical. The TASM software package comes with four .exe files mentioned below:
1. Edit
2. TASM
3. TLINK
4. TD
EDITOR An editor is a program, which allows you to create a file containing the assembly
language statements for your program. As you type in your program, the editor stores the
ASCII codes for the letters and numbers in successive RAM locations. When you have typed
in all of your programs, you then save the file on a hard disk. This file is called source file.
The next step is to process the source file with an assembler.
In the TASM assembler, you should give your source file name the extension, .ASM.
ASSEMBLER An assembler program is used to translate the assembly language mnemonics
for instructions to the corresponding binary codes. When you run the assembler, it reads the
source file of your program from the asm file created using edit command.
Syntax of assembler is TASM FILENAME.ASM. The output of assembler is object file. Its
extension is .OBJ. The object file contains the binary codes for the instructions and
information about the addresses of the instructions.
LINKER A linker is a program used to link several object files into one large object file and
convert to an exe file.
DEBUGGER The debugger allows you to look at the contents of registers and memory
locations after your program runs. It allows you to change the contents of register and
memory locations after your program runs. It allows you to change the contents of register
and memory locations and return the program. Syntax of debugger is : TD filename.
Following are directives which should be present in TASM program. 1) .Model:
Possible MODELS are:
TINY: Code and Data must fit in same 64k segment.
SMALL: Code & Data have separate segment, but must be each less than 64k. For most of
our experiments this model is going to be used.
MEDIUM: Code may be larger than 64k, but Data has to be less than 64k
COMPACT: Code is less than 64k, but Data may be greater than 64k LARGE: Both Code &
Data can be greater than 64k.
2) .Data:
The .data is used to separate variable declarations. Each group of variable declarations should
be preceded by a .data directive.
3) .code:
The .code is used to separate assembly language instructions. Each group of assembly
language instructions should be preceded by a .code directive. Conclusion: Basics commands
of TASM such as tasm, edit, tlink, td etc. and basic directives such as .model, .data, .code
were studies successfully.

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 2


Program:
.model small .data
num1 db 80h; first number store in variable
num2 db 08h; second number strore in variable
res db 0 ; result varialble

.code

mov ax,@data; initialization of data segment


mov ds,ax ;
mov al,num1: load num1 in AL
add al,num2; add num2 with num1 in AL
mov res,al; store result in memory location
ends
end
0utput:

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 3


Calculation:

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 4


Practical No. 2 Title:- TASM Assembler with Addition and Subtraction Group of Instructions
Aim: Implement Arithmetic Group of Instructions of 8086 on a series of data using Assembly
Language.
Perform addition and subtraction on ten consecutive numbers.

Objective:
Students will learn about arithmetic instruction set and they will solve problem using suitable
instructions.

S/W REQUIRED: TASM, DOSBOX


Theory:- Working of ADD and ADC:- ADD – ADD Destination, Source ADC – ADC
Destination, Source These instructions add a number from some source to a number in some
destination and put the result in the specified destination. The ADC also adds the status of the
carry flag to the result. The source may be an immediate number, a register, or a memory
location. The destination may be a register or a memory location. The source and the
destination in an instruction cannot both be memory locations. The source and the destination
must be of the same type (bytes or words). If you want to add a byte to a word, you must
copy the byte to a word location and fill the upper byte of the word with 0’s before adding.
Flags affected: AF, CF, OF, SF, ZF.
ADD AL, 74H Add immediate number 74H to content of AL. Result in AL
ADC CL, BL Add content of BL plus carry status to content of CL
ADD DX, BX Add content of BX to content of DX
ADD DX, [SI] Add word from memory at offset [SI] to content of DX
INC Instruction

The INC instruction is used for incrementing an operand by one. It works on a single operand
that can be either in a register or in memory.
Working of AAA:-
AAA (ASCII ADJUST FOR ADDITION) Numerical data coming into a computer from a
terminal is usually in ASCII code. In this code, the numbers 0 to 9 are represented by the
ASCII codes 30H to 39H. The 8086 allows you to add the ASCII codes for two decimal
digits without masking off the “3” in the upper nibble of each. After the addition, the AAA
instruction is used to make sure the result is the correct unpacked BCD.
Let AL = 0011 0101 (ASCII 5), and BL = 0011 1001 (ASCII 9)
ADD AL, BL AL = 0110 1110 (6EH, which is incorrect BCD)
AAA AL = 0000 0100 (unpacked BCD 4) CF
= 1 indicates answer is 14 decimal.
The AAA instruction works only on the AL register. The AAA instruction updates AF and
CF; but OF, PF, SF and ZF are left undefined.

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 5


Working of SUB and SBB:- SUB
– SUB Destination, Source SBB
– SBB Destination, Source
These instructions subtract the number in some source from the number in some destination
and put the result in the destination. The SBB instruction also subtracts the content of carry
flag from the destination. The source may be an immediate number, a register or memory
location. The destination can also be a register or a memory location. However, the source
and the destination cannot both be memory location. The source and the destination must
both be of the same type (bytes or words). If you want to subtract a byte from a word, you
must first move the byte to a word location such as a 16-bit register and fill the upper byte of
the word with 0’s. Flags affected: AF, CF, OF, PF, SF, ZF.
– BX; Result in CX
3427H from AX

DEC: Decrement
The decrement instruction subtracts 1 from the contents of the specified register or memory
location.
Ex.
DEC AX
DEC [5000h]
AAS: ASCII adjust AL after subtraction
AAS converts the result of the subtraction of two valid unpacked BCD digits to a single valid
BCD number and takes the AL register as an implicit operand. The two operands of the
subtraction must have its lower 4 bit contain number in the range from 0 to 9 .The AAS
instruction then adjust AL so that it contain a correct BCD digit. This instruction corrects the
result in AL register after subtracting two unpacked ASCII operands. The result is in
unpacked decimal format. The procedure is similar to AAA instruction except for the
subtraction of 06 from AL. Sample Viva Questions:- 1) What is TASM?
2) What is the difference between ADD & ADC?
3) What is the instruction syntax of AAA, SBB?
4) What is INC?
5) What is the difference between 8086 & 8085?
6) Compare TASM with Debug?
7) Who is the developer of TASM?
8) What is logical address?
9) What is physical address?
10) What is meant by memory address generation scheme?
(Space for program, Output, Conclusion & Viva Answers)

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 6


Practical No: 02
Part A:
1) Addition group of instraction [ ADD,ADC,INC,DAA]
Program :
.model
small .code
start:
mov al,0a2h
mov bl,34h
add al,bl
mov bl,0c2h
mov cl,0b8h
adc bl,cl inc
bl mov
al,49h mov
bl,63h add
al,bl daa;
mov ah,4ch
int 21h end
start

output:

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 7


Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 8
Calculation:

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 9


Practical No 02
Part A:
2)substraction group of instraction[SUB,SBB,DEC,DAS]

Program:
model
small .co
de start:

mov
al,0b2h
mov
bl,80h
sub al,bl

mov
bl,52h
mov
cl,0b0h
sbb bl,cl
dec bl

mov
al,55h
mov
bl,49h
sub al,bl
das;

mov
ah,4ch

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 10


int 21h
end start

output:

Calculation:

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 11


Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 12
Practical 2
Part B:
1)addition of 5 consicative number

program :
.model small
.data
array db
80h,05h,0b6h,0d4h,32h
result db 0; .code start:
mov
ax,@data;
mov ds,ax;
mov SI,offset
array mov al,
[si] add al,
[si+1] adc al,
[si+2] adc al,
[si+3] adc al,
[si+4] mov
result ,al
mov ah,4ch

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 13


int 21h end
start

output:

Calculation:

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 14


Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 15
Practical No 02:
Part B:
2) Substraction of 5 consecative number:
Program:
.model small
.data
array db 30h,10h,0b0h, 22h,32h;
result db
0; .code start:

mov ax,@data; mov


ds,ax; mov SI,offset
array mov al,[si] sbb al,
[si+1] sbb al,[si+2] sbb
al,[si+3] sbb al,[si+4]

mov result ,al mov


ah,4ch
int 21h

end start

Output:

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 16


Calculation:

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 17


Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 18
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 19
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 20
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 21
Practical No. 3
Title:- Multiplication and Division Instructions Aim:
Use Mul instruction to find a factorial of a given number.
Find mean of N numbers using Div instruction.

Objective:
Students will learn about multiplication and division instruction and they will solve problem
of two eight bits hexadecimal numbers using “mul” and “div” instruction.
S/W REQUIRED: TASM, DOSBOX
A) Multiply two Eight bits hexadecimal numbers using “mul” instruction.
Working of MUL:-
MUL – MUL Source This instruction multiplies an unsigned byte in some source with an
unsigned byte in AL register or an unsigned word in some source with an unsigned word in
AX register. The source can be a register or a memory location. When a byte is multiplied by
the content of AL, the result (product) is put in AX. When a word is multiplied by the content
of AX, the result is put in DX and AX registers. If the most significant byte of a 16-bit result
or the most significant word of a 32-bit result is 0, CF and OF will both be 0’s. AF, PF, SF
and ZF are undefined after a MUL instruction. If you want to multiply a byte with a word,
you must first move the byte to a word location such as an extended register and fill the upper
byte of the word with all 0’s. You cannot use the CBW instruction for this, because the CBW
instruction fills the upper byte with copies of the most significant bit of the lower byte.
MUL BH Multiply AL with BH; result in AX
MUL CX Multiply AX with CX; result high word in DX, low word in AX
Working of DIV:- DIV
– DIV Source
This instruction is used to divide an unsigned byte by a byte or to divide an unsigned word by
a word. When a bye is divided by a byte, the byte must be in the AL register. The divisor can
be in a register or a memory location. After the division, AL will contain the 8-bit quotient,
and AH will contain the 8-bit remainder. When a word is divided by a word, word must be in
AX. After the division, AX will contain the 16-bit quotient and DX will contain the 16-bit
remainder. If an attempt is made to divide by 0 or if the quotient is too large to fit in the
destination (greater than FFH / FFFFH), the 8086 will generate a type 0 interrupt. All flags
are undefined after a DIV instruction.
DIV BL Divide word in AL by byte in BL; Quotient in AL, remainder in AH
DIV CX Divide down word in AX by word in CX;Quotient in AX, and remainder in DX.
Sample Viva Questions:- 1) What is multiplication?
2) What is division?
3) What is the need of MUL instruction?
4) Which mnemonic that is placed before the arithmetic operation is performed?
5) What is IDIV?
6) Explain different registers used in 8086.
7) Give the advantages of general purpose registers?
8) Explain instruction format of MUL and DIV instruction?
9) Give the difference between IMUL and MUL?
10) Elaborate use of Pipeline architecture in 8086.

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 22


Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 23
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 24
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 25
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 26
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 27
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 28
Practical No. 4 Title:- Shift and Rotate Instructions
Aim: Apply Shift and Rotate Instructions on given numbers to identify the logical arrangement of
bits. Find 31AX-7BX+BX/16.

Objective:
Students will be able to apply Shift and Rotate instruction on given numbers.

S/W REQUIRED: TASM, DOSBOX


Working of Shift Instruction:-
SAL – SAL Destination, Count SHL – SHL Destination, Count SAL and SHL are two
mnemonics for the same instruction. This instruction shifts each bit in the specified
destination some number of bit positions to the left. As a bit is shifted out of the LSB
operation, a 0 is put in the LSB position. The MSB will be shifted into CF. In the case of
multi-bit shift, CF will contain the bit most recently shifted out from the MSB. Bits shifted
into CF previously will be lost.
SHR – SHR Destination, Count This instruction shifts each bit in the specified destination
some number of bit positions to the right. As a bit is shifted out of the MSB position, a 0 is
put in its place. The bit shifted out of the LSB position goes to CF. In the case of multi-bit
shifts, CF will contain the bit most recently shifted out from the LSB. Bits shifted into CF
previously will be lost.
SAR – SAR Destination, Count This instruction shifts each bit in the specified destination
some number of bit positions to the right. As a bit is shifted out of the MSB position, a copy
of the old MSB is put in the MSB position. In other words, the sign bit is copied into the
MSB. The LSB will be shifted into CF. In the case of multiple-bit shift, CF will contain the
bit most recently shifted out from the LSB. Bits shifted into CF previously will be lost.
Working of Rotate Instruction:-
ROL – ROL Destination, Count This instruction rotates all the bits in a specified word or
byte to the left some number of bit positions. The data bit rotated out of MSB is circled back
into the LSB. It is also copied into CF. In the case of multiple-bit rotate, CF will contain a
copy of the bit most recently moved out of the MSB.
ROR – ROR Destination, Count This instruction rotates all the bits in a specified word or
byte some number of bit positions to right. The operation is desired as a rotate rather than
shift, because the bit moved out of the LSB is rotated around into the MSB. The data bit
moved out of the LSB is also copied into CF. In the case of multiple bit rotates, CF will
contain a copy of the bit most recently moved out of the LSB.
RCL – RCL Destination, Count This instruction rotates all the bits in a specified word or
byte some number of bit positions to the left. The operation circular because the MSB of the
operand is rotated into the carry flag and the bit in the carry flag is rotated around into LSB of
the operand. For multi-bit rotates, CF will contain the bit most recently rotated out of the
MSB.
RCR – RCR Destination, Count This instruction rotates all the bits in a specified word or
byte some number of bit positions to the right. The operation circular because the LSB of the
operand is rotated into the carry flag and the bit in the carry flag is rotate around into MSB of
the operand. For multi-bit rotate, CF will contain the bit most recently rotated out of the LSB.
Sample Viva Questions:-
1) What is the difference between shift and rotate instruction?

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 29


2) What is ASL?
3) What is SAR?
4) Define SHLD & SHRD with example
5) Define ROL & ROR with example.
6) Define addressing modes of 8086.
7) How shift and rotate instructions relate with the mul and div instruction?
8) Explain logical instructions.
9) What is difference between SHIFT and ROTATE Instruction?
10) Explain direct addressing mode using an example.
(Space for program, Output, Conclusion & Viva Answers)

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 30


Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 31
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 32
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 29
Practical No. 5 Title:- Logical Group of Instructions
Aim: Verify that whether given Eight bits numbers are Positive or Negative using Logical
Group of Instructions. Objective:
Students will learn how to verify that given eight bits numbers are Positive or Negative using
Logical group of instruction.

S/W REQUIRED: TASM, DOSBOX


Working of AND instruction:- AND
– AND Destination, Source
This instruction ANDs each bit in a source byte or word with the same numbered bit in a
destination byte or word. The result is put in the specified destination. The content of the
specified source is not changed. The source can be an immediate number, the content of a
register, or the content of a memory location. The destination can be a register or a memory
location. The source and the destination cannot both be memory locations. CF and OF are
both 0 after AND. PF, SF, and ZF are updated by the AND instruction. To find out the
number is positive or negative, number is first moved into AL. Then AL is AND with 80h If
ZF = 1 that means number is positive and if ZF = 0 means the number is negative.

Sample Viva Questions:- 1)


Define AND with example.
2) Define XOR with example.
3) Define NAND with example.
4) Define the logic of number is Positive or Negative program.
5) What is the significance of MSB? 6) Define Assembler
7) Define interpreter.
8) Define function of CPU.
9) What are mnemonics?
10) What is BUS?
(Space for program, Output, Conclusion & Viva Answers)

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 34


Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 35
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 36
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 37
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 38
Practical No. 6 Title:- Memory to Memory Transfer
Aim: WAP to transfer N bytes of block starting from address 1000H in the memory to
another block of memory location at an offset address 2000H. Assume both the blocks are
available in same data segment that’s starting point, is define by the data segment value
C000H. Write above program by making use of branch instructions.

Objective:
1. Students will be able to implement the programm for transfer the data from one memory
block to another block of memory location using branch instruction.
2. Students will define the different data transfer instructions.
S/W REQUIRED: TASM, DOSBOX
 SI - source index register: o Can be used for pointer
addressing of data o Used as source in some string
processing instructions o Offset address relative to DS
 DI - destination index register:
o Can be used for pointer addressing of data
o Used as destination in some string processing instructions
o Offset address relative to ES Sample Viva Questions:-

1) What are the different data tranafer instructions?


2) Define MOV with example.
3) Define XCHG with example.
4) Define the XLAT with example.
5) Define PUSH & POP with example.
6) Explain Mem to Mem operation?
7) Define address bus, data bus and control bus.
8) What is nibble, byte and word.
9) Why is the data bus bidirectional?
10) What is the function of the accumulator?
(Space for program, Output, Conclusion & Viva Answers)

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 39


Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 40
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 41
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 42
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 43
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 44
Practical No. 7
Title:- Square and Cube of N numbers
Aim:
Define procedure SQUARE to find square of numbers present in the array. Take the Ten numbers
from the user in an array and call SQUARE procedure to find square of these numbers.
Write macros CUBE to find cube of numbers present in the array. Take the Ten numbers
from the user in an array and call CUBE macro to find cube of these numbers.
Objective:
Students will be able to write a program to find out square or cube of numbers present in the
array.
S/W REQUIRED: TASM, DOSBOX
Theory:- Procedure Declaration
 The syntax of procedure declaration is the
following: PROC name type ; body of procedure
ret ENDP name
 type can be NEAR (in same segment) or FAR (in a different segment) -- if
omitted, NEAR is assumed
The CALL Instruction
• CALL invokes a procedure
• CALL has two forms, direct call name
where name is the name of a procedure, and indirect call
address_expression (not generally recommended)
where address_expression specifies a register or memory location containing
the address of a procedure
Executing a CALL
• The return address to the calling program (the current value of the IP) is saved on the
stack
• IP get the offset address of the first instruction of the procedure (this transfers control
to the procedure)
• FAR procedures must process CS:IP instead of just IP
Sample Viva Questions:-
1) Define the logic of Square of 10 numbers.
2) Define the logic of cube of 10 numbers.
3) Define JNZ.
4) Define recursion.

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 45


5) Define Subroutines. 6) What are directives.
7) Define two pass assembler.
8) What are the advantages of modular programming.
(Space for program, Output, Conclusion & Viva Answers)

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 46


Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 47
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 48
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 49
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 50
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 51
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 52
Practical No. 8 Title:- Length of String
Aim: Find out the Length of string given by user. Write a procedure to take string from the
user and then write a procedure to find the length of the string.
Objective:
Students will learn about find out the length of string which is given by user.
S/W REQUIRED: TASM, DOSBOX
String - a byte or word array.
Operations that can be performed with string instructions:
• copy a string into another string
• search a string for a particular byte or word
• store characters in a string
• compare strings of characters alphanumerically
Sample Viva Questions:-
1) What is the reset address of 8086?
2) What is the size of flag register in 8086? Explain all.
3) What is the difference between 08H and 01H functions of INT 21H?
4) Which is faster- Reading word size data whose starting address is at even or at odd
address of memory in 8086?
5) Which is the default segment base: offset pairs?
6) What is linking and relocation.
7) What are stack operated instructions. Explain.
8) Define Procedure.
9) Explain about CALL and RETURN instructions.
10) What is recursive procedure.
(Space for program, Output, Conclusion & Viva Answers)

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 53


Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 54
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 55
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 56
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 57
Practical No. 9 Title:- String Palindrome
Aim: PALINDROME is the procedure that finds out whether the string is palindrome or not.
Take the string from the user and check the entered string is palindrome or not using
PALINDROME procedure.
Objective:
Students will be able to implement the programm by take the string from the user and check
the entered string is palindrome or not using PALINDROME procedure.
S/W REQUIRED: TASM, DOSBOX
Theory:-
A series of data byte or word available in memory at consecutive locations, to be referred as
Byte String or Word String. A String of characters may be located in consecutive memory
locations, where each character may be represented by its ASCII equivalent. The 8086
supports a set of more powerful instructions for string manipulations for referring to a string,
two parameters are required.
I. Starting and End Address of the String.
II. Length of the String.
The length of the string is usually stored as count in the CX register.The incrementing or
decrementing of the pointer, in string instructions, depends upon the Direction Flag (DF)
Status. If it is a Byte string operation, the index registers are updated by one. On the other
hand, if it is a word string operation, the index registers are updated by two.

Sample Viva Questions:-


1) What is the size of instruction queue in 8086?
2) Which are the pointers register present in 8086?
3) What do you mean by pipelining in 8086?
4) How many 16 bit registers are available in 8086?
5) Specify register relative addressing modes for any instruction?
6) What is an interrupt. Explain.
7) What are the different functional units in 8086?
8) What is the function of EU?
(Space for program, Output, Conclusion & Viva Answers)

Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 58


Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 59
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 60
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 61
Microprocessor and Assembly Lang. Programming Lab (4KS08)//CSE//PRMIT&R, Badnera Page 62

You might also like