MPMC LAB MANUAL
Department of Electronics & Communication Engineering
VEMU INSTITUTE OF TECHNOLOGY::P.KOTHAKOTA NEAR PAKALA, CHITTOOR-517112
(Approved by AICTE, New Delhi & Affiliated to JNTUA, Anantapuramu)
MPMC LAB MANUAL
Name:_____________________________________________
H.T.No:____________________________________________
Year/Semester:______________________________________
Department of Electronics & Communication Engineering
VEMU INSTITUTE OF TECHNOLOGY::P.KOTHAKOTA NEAR PAKALA, CHITTOOR-517112
(Approved by AICTE, New Delhi & Affiliated to JNTUA, Anantapuramu)
VEMU Institute of Technology Dept. of Electronics and Communication Engineering
Vision of the institute
To be one of the premier institutes for professional education producing dynamic and
vibrant force of technocrats with competent skills, innovative ideas and leadership qualities to
serve the society with ethical and benevolent approach.
Mission of the institute
Mission_1: To create a learning environment with state-of-the art infrastructure, well equipped
laboratories, research facilities and qualified senior faculty to impart high quality technical
education.
Mission_2: To facilitate the learners to inculcate competent research skills and innovative ideas
by Industry-Institute Interaction.
Mission_3: To develop hard work, honesty, leadership qualities and sense of direction in
learners by providing value based education.
Vision of the Department
To develop as a center of excellence in the Electronic and Communication Engineering
field and produce graduates with Technical Skills, Competency, Quality, and Professional Ethics
to meet the challenges of the Industry and evolving Society.
Mission of the Department
Mission_1: To enrich Technical Skills of students through Effective Teaching and Learning
practices to exchange ideas and dissemination of knowledge.
Mission_2: To enable students to develop skill sets through adequate facilities, training on core
and multidisciplinary technologies and Competency Enhancement Programs.
Mission_3: To provide training, instill creative thinking and research attitude to the students
through Industry-Institute Interaction along with Professional Ethics and values.
Programme Educational Objectives ( PEOs)
PEO_1: To prepare the graduates to be able to plan, analyze and provide innovative ideas to
investigate complex engineering problems of industry in the field of Electronics and
Communication Engineering using contemporary design and simulation tools.
PEO_2: To provide students with solid fundamentals in core and multidisciplinary domain for
successful implementation of engineering products and also to pursue higher studies.
PEO_3: To inculcate learners with professional and ethical attitude, effective communication
skills, teamwork skills, and an ability to relate engineering issues to broader social context at
work place. Programme Outcome (POs)
PO_1: Engineering knowledge: Apply the knowledge of mathematics, science, engineering fundamentals, and an engineering specialization to the solution of complex engineering problems.
PO_2: Problem analysis: Identify, formulate, review research literature, and analyze complex engineering problems reaching substantiated conclusions using first principles of mathematics, natural sciences, and engineering sciences.
PO_3: 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.
PO_4: 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.
PO_5: 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.
PO_6: 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.
PO_7: 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.
PO_8: Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms of the engineering practice.
PO_9: Individual and team work: Function effectively as an individual, and as a member or leader in diverse teams, and in multidisciplinary settings.
PO_10: 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.
PO_11: 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.
PO_12: 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.
Programme Specific Outcome (PSOs)
PSO_1: Responsive to ideas: Apply the fundamentals to design and analysis of complex electronic systems to meet the challenges in contemporary business environment.
PSO_2: Domain Expertise: Proficiency in specialized software packages and computer programming useful for the analysis/design of electronic engineering systems.
JAWAHARLAL NEHRU TECHNOLOGICAL UNIVERSITY ANANTAPUR
III B.Tech. II-Sem (EEE)
(15A04607) MICROPROCESSORS AND MICROCONTROLLERS LABORATORY
Part-A: MPMC Lab
COURSE OUTCOMES (COs)
C327.1 How to write 8086 assembly language programs.
C327.2 Make use of programmable peripheral devices and their Interfacing in assembly programming.
C327.3 How to write 8051 assembly language programs
C327.4 Develop and simulate programs using MASM / TASM software
C327.5 How to input operational codes into 8086 & 8051 trainer kits and execute programs
List of Experiments:
Note: Use MASM/8086 microprocessor kit
1. Introduction to MASM Programming.
2. Programs using arithmetic and logical operations.
3. Programs using string operations and Instruction prefix: Move Block, Reverse string, sorting,
String comparison.
4. Programs for code conversion.
5. Multiplication and Division programs.
6. Sorting and multi byte arithmetic.
7. Programs using CALL and RET instructions.
Part-B: Embedded C Experiments using MSP430:
1. Interfacing and programming GPIO ports in C using MSP430 (blinking LEDs, push buttons).
2. Usage of Low Power Modes: (Use MSPEXP430FR5969 as hardware platform and
demonstrate the low power modes and measure the active mode and standby mode current)
3. Interrupt programming examples through GPIOs.
4. PWM generation using Timer on MSP430 GPIO.
5. Interfacing potentiometer with MSP430.
6. PWM based Speed Control of Motor controlled by potentiometer connected to MSP430
GPIO.
7. Using ULP advisor in Code Composer Studio on MSP430.
8. Low Power modes and Energy trace++:
a. Enable Energy Trace and Energy Trace ++ modes in CCS
b. Compute Total Energy, and Estimated lifetime of an AA battery.
VEMU INSTITUTE OF TECHNOLOGY::P.KOTHAKOTA NEAR PAKALA, CHITTOOR-517112
(Approved by AICTE, New Delhi & Affiliated to JNTUA, Anantapuramu) Department of Electronics &Communication Engineering
LIST OF EXPERIMENTS TO BE CONDUCTED
Part-A: MPMC Lab
List of Experiments:
Note: Use MASM/8086 microprocessor kit
1. Introduction to MASM Programming.
2. Programs using arithmetic and logical operations.
3. Programs using string operations and Instruction prefix: Move Block, Reverse string, sorting,
String comparison.
4. Programs for code conversion.
5. Multiplication and Division programs.
6. Sorting and multi byte arithmetic.
Part-B: Embedded C Experiments using MSP430:
1. Interfacing and programming GPIO ports in C using MSP430 (blinking LEDs, push buttons).
2. Usage of Low Power Modes: (Use MSPEXP430FR5969 as hardware platform and
demonstrate the low power modes and measure the active mode and standby mode current)
3. Interrupt programming examples through GPIOs.
4. PWM generation using Timer on MSP430 GPIO.
5. Interfacing potentiometer with MSP430.
6. PWM based Speed Control of Motor controlled by potentiometer connected to MSP430
GPIO.
Part-C: Advanced Experiments:
Interfacing Potentiometer MSP 430
VEMU INSTITUTE OF TECHNOLOGY
P.KOTHAKOTA, NEAR PAKALA, CHITTOOR, AP
Department of Electronics &Communication Engineering
CONTENTS
S. NO. NAME OF THE EXPERIMENT PAGE NO
1 Introduction to MASM Programming. 1-6
2 Arithmetic and logical operations 6-30
3 String operations 31-39
4 Code conversion 40-45
5 Multiplication and Division 46-51
6 Sorting and multi byte arithmetic 52-63
7 Blinking an On Board Led Using MSP-430 64-65
8 Led Control Using a Switch Using MSP-430 66-67
9 Low and High Power Mode Current Measurement 68-72
10 Interrupt Programming through GPIO 73-74
11 Pulse Width Modulation with MSP 430 75-76
ADVANCED EXPERIMENTS
12 Interfacing Potentiometer MSP 430 77-78
DOS & DONTS IN LABORATORY
1. While entering the Laboratory, the students should follow the dress code (Wear shoes, White
Apron & Female students should tie their hair back).
2. The students should bring their observation note book, Lab manual, record note book,
calculator, and necessary stationary items.
3. While sitting in front of the system, check all the cable connections and Switch on the
computer.
4. If a student notices any fluctuations in power supply, immediately the same thing is to be
brought to the notice of technician/lab in charge.
5. At the end of practical class the system should be switch off safely and arrange the chairs
properly.
6. Each program after completion should be written in the observation note book and should be
corrected by the lab in charge on the same day of the practical class.
7. Each experiment should be written in the record note book only after getting signature from
the lab in charge in the observation note book.
8. Record should be submitted in the successive lab session after completion of the experiment.
9. 100% attendance should be maintained for the practical classes.
SCHEME OF EVALUVATION
S NO DATE NAME OF
EXPERIMENT
TOTAL (20M)
Observation
(10M)
Viva voce
(10M) Sign. Total
1
Introduction to MASM
Programming.
2
Arithmetic and logical
operations
3 String operations
4 Code conversion
5
Multiplication and
Division
6
Sorting and multi byte
arithmetic
7
Blinking an On Board Led
Using MSP-430
8
Led Control Using a
Switch Using MSP-430
9
Low and High Power
Mode Current
Measurement
10
Interrupt Programming
through GPIO
11
Pulse Width Modulation
With MSP 430
Signature of Lab In-charge
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 1
EXP. NO : 1 DATE:
INTRODUCTION TO MASM PROGRAMMING
The microprocessor development system consists of a set of hardware and software tools.
The hardware of development systems usually contains a standard PC (Personal Computer),
printer and an emulator. The software tools are also called program development tools and they
are Editor, Assembler, Library builder, Linker, Debugger and Simulator. These software tools
can be run on the PC in order to write, assemble, debug, modify and test the assembly language
programs.
EDITOR (TEXT EDITOR):
The Editor is software tool which, when run on a PC, allow the user to type/enter and
modify the assembly language program. The editor provides a set of commands for insertion,
deletion, modifications of letters, characters, statements, etc., The main faction of an editor is to
help the user to constrict the assembly language program in the right format. The program
created using editor is known as source program and usually it is saved with file extension
“ASM”.
ASSEMBLER:
The assembler is a software tool which run on a PC, converts the assembly language
program to machine language program. Several types of assemblers are available and they are
one pass assembler, two pass assembler, macro assembler, cross assembler, resident assembler
and Meta assembler.
One Pass Assembler: In the one pass assembler source code is processed only once, and we can
use only backward reference.
Two Pass Assembler: Most of the popularly used assemblers are two pass assembler. In two
pass assembler, the first pass is made through source code for the purpose of assigning an
address to all the labels and to store this information in a symbol table. The second pass is made
to actually translate the source code into machine code.
Some examples of assemblers are TASM (Borland’s Turbo Assembler), MASM
(Microsoft Macro Assembler), ASM86 (INTEL’S 8086 Assembler), etc,.
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 2
TASM:
The Turbo Assembler (TASM) mainly PC-targeted assembler package was Borland’s
offering in the X86 assembler programming tool market. As one would expect, TASM worked
well with Borland’s high-level language compilers for the PC, such as Turbo Pascal, Turbo Basic
and Turbo C. Along with the rest of the Turbo suite, Turbo Assembler is no longer maintained.
The Turbo Assembler package came bundled with the linker Turbo Linker, and was
interoperable with the Turbo Debugger. For compatibility with the common Microsoft Macro
Assembler (MASM), TASM was able to assemble such source code files via its MASM mode. It
also had an ideal mode that enabled a few enhancements.
The effective execution of a program in assembly language we need the following
1. MASM assembler
2. NE (Norton’s Editor) editor (or) Edlin editor
3. Linker
4. Debug utility of DOS
How to use TASM:
Install the specified TASM software on PC with DOS operating system. The program
implementation and its execution are illustrated in four stages, there are
1. Editing of program
2. Assembling the program
3. Linking the program
4. Debugging and execution of the program
C:\ tasm>edit (file name).asm
>tasm (file name).asm
Assembling
Turbo assembler version 3.2 copy right (C) 1988, 1992 Borland International
Assembling file : (file name)
Error messages : None
Warning messages : None
Passes : 1
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 3
PROGRAM:
Remaining memory : 392K
C:\ tasm>tlink (file name).obj Turbo Linking
Turbo link version 5.1 copy right (C) 1992 Borland International the Program
C:\ tasm>debug (file name).exe Debugging & Operation
- r of the
- p Program
- q
DEBUG COMMANDS:
Command Command Character
& Syntax Description
Assembler - A [address] Assembles the instructions at a particular address.
Quit - q Quits from debug
Compare - C range address Compares two memory ranges
Display - D range Displays the contents of memory
Enter - E address [List] Enters new or modifies old memory contents
Fill - F range list Fills in a range of memory
Go - G – address Executes a program in memory
Hex - H V1V2 Adds & Subtracts two hex values (V1 & V2)
Load - L [address] [drive] Load disk data into memory
Trace - T Traces disk data into memory
Un assemble - U Un assembles hex bytes into assembler instructions
MASM:
The Microsoft Macro Assembler (abbreviated MASM) is an x86 high-level assembler for
DOS and Microsoft Windows. Currently it is the most popular x86 assembler. It supports a wide
variety of macro facilities and structured programming idioms, including high-level functions for
looping and procedures. Later versions added the capability of producing programs for
Windows. MASM is one of the few Microsoft development tools that target 16-bit, 32-bit and
64-bit platforms. Earlier versions were MS-DOS applications. Versions 5.1 and 6.0 were OS/2
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 4
applications and later versions were Win32 console applications. Versions 6.1 and 6.11 included
Phar Lap’s TNT DOS extender so that MASM could run in MS-DOS.
MASM can be used along with a link program to structure the codes generated by
MASM in the form of an executable file. This assembler reads the source program as its inputs
and provides an object file. The link accepts the object file produced by this MASM assembler as
input and produces an EXE file.
The effective execution of a program in assembly language we need the following
1. MASM assembler
2. NE (Norton’s Editor) editor (or) Edlin editor
3. Linker
4. Debug utility of DOS
LIBRARY BUILDER:
The library builder is used to create library files which are collection of procedures of
frequently used functions.
The input to library builder is a set of assembled object of program modules/procedures.
The library builder combines the program modules/procedures into a single file known as
library file and it is saved with file extension “.LIB”. Some examples of library builder are
Microsoft’s LIB Borland’s TLIB, etc,.
LINKER:
The linker is a software tool which is used to combine releasable object files of program
modules and library functions into a single executable file.
The linker also generates a link map file which contains the address information about the
linked files. Some examples of linkers Microsoft’s linker LINK, Borland’s Turbo linker TLINK,
etc,.
DEBUGGER:
The debugger is a software tool that allows the execution of a grogram in single step or
break-point mode under the control of user. The process of locating and correcting the errors in a
program using a debugger is known as debugging.
The debugger tools can help the user to isolate a problem in the program. Once the
problem/errors are identified, the algorithm can be modified. Then the user can the editor to
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 5
correct the source program, reassemble the corrected source program, relink and run the program
again.
SIMULATOR:
The simulator is a program which can be run on the development system (Personal
computer) to simulate the operations of the newly designed system. Some of the operations that
can be simulated are given below.
Execute a program and display result.
Single step execution of a person.
Break – point execution of a program.
Display the contents of register/memory.
EMULATOR:
An emulator is a combination of hardware and software. It is usually used to test and
debug the hardware and software of a newly designed microprocessor based system. The
emulator has a multi core cable which connects the PC of development system and the newly
designed hardware of microprocessor system.
VARIABLES AND CONSTRAINTS USED IN ASSEMBLERS:
Variables: The variables are symbols (or terms) used in assembly language program statements
in order to represent variable data and address. While running a program, a value has to be
attached to each variable in the program. The advantage of using variables is that the value of the
variable can be dynamically varied while running program.
Rules of Framing Variable names:
1. The variable name can have any of the following characters. A to Z a to z, 0 to 9
@ , _ (underscore).
2. The first character in the variable name should be an alphabet (A to Z or a to z) or an
underscore.
3. The length of variable name depends on assembler and normally the maximum length
of variable name is 32 characters.
4. The variable name are case insensitive. Therefore the assembler do not distinguish
between the upper and lower case letters/alphabets.
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 6
Constraints: The decimal, binary or hexadecimal number used to represent the data address in
assembly language program statement are called constants or numerical constants. When
constants are used to represent the address the address the address/data then their values are fixed
and cannot be changed while running a program. The binary, hexadecimal and decimal constants
can be differentiated by placing a specific alphabet at the end of the constant.
Example of Valid Constant:
1011 --------- Decimal (BCD) constant
1060 D ------ Decimal constant
Examples of invalid Constant:
1131 B ------ The character 3 should not be used in binary constant.
0E2 ---------- The character H at the end of hexadecimal number in missing.
VIVA QUESTIONS:
1. What is MASM/TASM?
2. What is Linker?
3. What is Assembler?
4. What is Compiler?
5. What is Simulator?
RESULT:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 7
EXP. NO : 2 DATE:
ARITHMETIC AND LOGICAL OPERATIONS
A. ADDITION OF TWO 8 BIT NUMBERS
1. AIM: To write an ALP for the addition of two 8 bit numbers using MASM
software.
2. APPARATUS REQUIRED: i) PC
ii) MASM software
3. ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 8
4. PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
OPR1 DB 0F8H
OPR2 DB 67H
RES DB 2 DUP(?),’$’
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AL,OPR1
MOV BL,OPR2
ADD AL,BL
MOV RES,AL
MOV AL, 00H
RCL AL,01
MOV [RES+1],AL
MOV AH,09H
MOV DX,OFFSET RES
INT 21H
MOV AH,4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 9
5. RESULT: Thus the addition of two 8 bit numbers was successfully executed
using MASM software.
INPUT: 1 OPR1 = 0F8H
OPR2 = 67H
OUTPUT: RES = 015FH
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 10
B. SUBTRACTION OF TWO 8 BIT NUMBERS
1. AIM:-To write an ALP for the subtraction of two 8 bit numbers using MASM
software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 11
4.PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
OPR1 DB 0F8H
OPR2 DB 67H
RES DB 2 DUP(?),’$’
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AL,OPR1
MOV BL,OPR2
SUB AL,BL
MOV RES,AL
MOV AL, 00H
RCL AL,01
MOV [RES+1],AL
MOV AH,09H
MOV DX,OFFSET RES
INT 21H
MOV AH,4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 12
5.RESULT: Thus the subtraction of two 8 bit numbers was successfully executed
using MASM software.
INPUT: 1 OPR1 = 0F8H
OPR2 = 67H
OUTPUT: 2 RES = 91H
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 13
C. MULTIPLICATION OF TWO 8 BIT NUMBERS
1.AIM: To write an ALP for the multiplication of two 8 bit numbers using MASM
software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 14
4. PROGRAM: .MODEL SMALL
.STACK 100
.DATA
OPR1 DB 05H
OPR2 DB 03H
RES DB 2 DUP(?),’$’
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AL,OPR1
MOV BL,OPR2
MUL AL,BL
MOV RES,AX
MOV AH,09H
MOV DX,OFFSET RES
INT 21H
MOV AH,4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 15
5. RESULT:-Thus the multiplication of two 8 bit numbers was successfully
executed using MASM software.
INPUT: 1 OPR1 = 05H
OPR2 = 03H
OUTPUT: RES = 000FH
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 16
D. DIVISION OF TWO 8 BIT NUMBERS
1.AIM: To write an ALP for the division of two 8 bit numbers using MASM
software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 17
4.PROGRAM: .MODEL SMALL
.STACK 100
.DATA
OPR1 DB 31H
OPR2 DB 02H
RES DB 2 DUP(?),’$’
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AL,OPR1
MOV BL,OPR2
DIV AL,BL
MOV RES,AL
MOV [RES+1],AH
MOV AH,09H
MOV DX,OFFSET RES
INT 21H
MOV AH,4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 18
5.RESULT: Thus, the division of two 8 bit numbers was executed successfully
using MASM software
INPUT: 1 OPR1 = 31 H
OPR2 = 02 H
OUTPUT: QUE = 18H
REM = 01 H
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: QUE =
REM =
.
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 19
E. ADDITION OF TWO 16 BIT NUMBERS
1.AIM: To write an ALP for the addition of two 16 bit numbers using MASM
software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 20
4.PROGRAM: .MODEL SMALL
.STACK 100
.DATA
OPR1 DW 8888H
OPR2 DW 6666H
RES DB 3 DUP(?),’$’
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AX,OPR1
MOV BX,OPR2
ADD AX,BX
MOV RES,AX
MOV AL, 00H
RCL AL,01
MOV [RES+2],AL
MOV AH,09H
MOV DX,OFFSET RES
INT 21H
MOV AH,4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 21
5.RESULT: Thus, the addition of two 16 bit numbers was executed successfully
using MASM software.
INPUT: 1 OPR1 = 8888 H
OPR2 = 6666 H
OUTPUT: RES = 00EEEE H
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 22
F. SUBTRACTION OF TWO 16 BIT NUMBERS
1.AIM: To write an ALP for the subtraction of two 16 bit numbers using TASM
software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 23
4.PROGRAM: .MODEL SMALL
.STACK 100
.DATA
OPR1 DW 8888H
OPR2 DW 6666H
RES DB 3 DUP(?),’$’
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AX,OPR1
MOV BX,OPR2
SUB AX,BX
MOV RES,AX
MOV AL, 00H
RCL AL,01
MOV [RES+2],AL
MOV AH,09H
MOV DX,OFFSET RES
INT 21H
MOV AH,4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 24
5.RESULT: Thus, the subtraction of two 16 bit numbers was executed
successfully using MASM software.
INPUT: 1 OPR1 = 8888 H
OPR2 = 6666 H
OUTPUT: RES = 2222 H
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 25
G. MULTIPLICATION OF TWO 16 BIT NUMBERS
1.AIM: To write an ALP for the multiplication of two 16 bit numbers using
MASM
Software.
2.APPARATUS REQUIRED: i) PC
ii) TASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 26
4.PROGRAM: .MODEL SMALL
.STACK 100
.DATA
OPR1 DW 7777H
OPR2 DW 8888H
RES DW 2 DUP(?),’$’
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AX,OPR1
MOV BX,OPR2
MUL AX,BX
MOV RES,AX
MOV [RES+2],DX
MOV AH,09H
MOV DX,OFFSET RES
INT 21H
MOV AH,4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 27
5.RESULT: Thus, the multiplication of two 16 bit numbers was executed
successfully using MASM software.
INPUT: 1 OPR1 = 7777 H
OPR2 = 8888 H
OUTPUT: RES = 3FB6AF38 H
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 28
H. DIVISION OF TWO 8 BIT NUMBERS
1.AIM: To write an ALP for the division of two 16 bit numbers using MASM
software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 29
4.PROGRAM: .MODEL SMALL
.STACK 100
.DATA
OPR1 DW 0FFFE H
OPR2 DW 3333 H
RES DW 2 DUP(?),’$’
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AX,OPR1
MOV BX,OPR2
DIV AX,BX
MOV RES,AX
MOV [RES+2],DX
MOV AH,09H
MOV DX,OFFSET RES
INT 21H
MOV AH,4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 30
5.RESULT: Thus, the division of two 16 bit numbers was executed successfully
using MASM software.
INPUT: 1 OPR1 = 0FFFE H
OPR2 = 3333 H
OUTPUT: QUE = 0004 H
REM = 3332 H
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: QUE =
REM =
6.VIVA QUESTIONS:
1. What is INT 21H?
2. Define SEGMENT?
3. List the Different Directives?
4. What are the arithmetic instructions supports by 8086?
5. Define Micro Processor?
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 31
EXP. NO : 3 DATE:
STRING OPERATIONS
A. REVERSAL OF GIVEN STRING
1.AIM: To write an assembly language program to reverse the given string by
using MASM software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 32
4.PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
LIST DB ‘MICRO PROCESSOR’
COUNT EQU ($-LIST)
.CODE
MOV AX, @DATA
MOV DS, AX
MOV ES, AX
MOV CX, COUNT
MOV AX, CX
MOV SI, OFFSET LIST
MOV DI, (COUNT-1)
MOV BX, 02H
DIV BX
MOV CX, AX
BACK: MOV AL,[SI]
XCHG AL,[DI]
MOV [SI], AL
INC SI
DEC DI
LOOP BACK
MOV AH, 09H
MOV DX,OFFSET LIST
INT 21H
MOV AH, 4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 33
5.RESULT: Thus, the reverse of the given string was done by using MASM
software.
INPUT: 1 STRING = MICRO PROCESSOR
OUTPUT: 1 REVERSE STRING = ROSSECORP ORCIM
INPUT: 2
OUTPUT: 2
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 34
B. LENGTH OF THE GIVEN STRING
1.AIM: To write an assembly language program to find the length of the given
string by using MASM software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 35
4.PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
LIST DB ‘MICRO PROCESSOR$’
LEN DB 01 DUP(?),’$’
.CODE
MOV AX, @DATA
MOV DS, AX
MOV ES, AX
MOV AL,’$’
LEA SI, LIST
MOV DX, 0000H
BACK: SCASB
JE EXIT
INC DX
JMP BACK
EXIT: MOV LEN, DX
MOV AH,09H
MOV DX,LEN
INT 21H
MOV AH, 4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 36
5.RESULT: Thus, the length of the given string is done by using MASM software
INPUT: 1 STRING = MICRO PROCESSOR
OUTPUT: 1 LENGTH = 0FH
INPUT: 2
OUTPUT: 2
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 37
C. COMPARISON OF TWO STRINGS
1.AIM: To write an assembly language program to compare the given strings by
using MASM software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 38
4.PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
LIST1 DB ‘MICRO PROCESSOR’
LEN1 EQU ($-LIST1)
LIST2 DB ‘MICRO PROCESSOR’
LEN2 EQU ($-LIST2)
MSG1 DB 0DH,0AH,"STRINGS ARE EQUAL",0DH,0AH,"$"
MSG2 DB 0DH,0AH,"STRIANGS ARE NOT EQUAL",0DH,0AH,"$"
.CODE
MOV AX,@DATA
MOV DS, AX
MOV ES, AX
MOV AX,LEN1
MOV BX, LEN2
CMP AX, BX
JNE EXIT
MOV CX, AX
MOV SI, OFFSET LIST1
MOV DI, OFFSET LIST2
REP CMPSB
JNE EXIT
MOV AH,09H
MOV DX,MSG1
INT 21H
JMP NEXT
EXIT: MOV AH,09H
MOV DX,MSG2
INT 21H
NEXT: MOV AH, 4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 39
5.RESULT: Thus, the comparison of the given strings is done by using MASM
software
INPUT: 1 STRING1 = MICRO PROCESSOR
STRING2 = MICRO PROCESSOR
OUTPUT: 1 STRINGS ARE EQUAL
INPUT: 2
OUTPUT: 2
6.VIVA QUESTIONS:
1. What are the flags available in 8086?
2. What is Program counter and its functionality?
3. What is Non-Maskable interrupts?
4. Write logic to perform string reverse?
5. What are the string instructions supported by 8086?
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 40
EXP. NO : 4 DATE:
CODE CONVERSION
A. BCD to ASCII Conversion
1.AIM: To write an ALP to convert BCD number to ASCII number using
MASM software.
2.APPARATUS REQUIRED:- i) PC
ii) TASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 41
4.PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
BCD DB 17H
ASCII DW 1 DUP(?),'$'
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AL,BCD
MOV CL,04H
MOV AH,AL
AND AL,0FH
AND AH,0F0H
ROR AH,CL
OR AL,30H
OR AH,30H
MOV ASCII,AX
MOV AH,09H
MOV DX, OFFSET ASCII
INT 21H
MOV AH, 4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 42
5.RESULT: Thus, the conversion of BCD number to ASCII number was done
successfully by using MASM software.
INPUT: 1 BCD = 17H
OUTPUT: 1 ASCII 1= 37 H
ASCII 2= 31 H
INPUT: 2 BCD =
OUTPUT: 2 ASCII 1=
ASCII 2=
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 43
B. ASCII to BCD Conversion
1.AIM: To write an ALP to convert ASCII number to BCD number by using
TASM software.
2.APPARATUS REQUIRED: i) PC
ii) TASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 44
4.PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
ASCII1 DB ‘1’
ASCII2 DB ‘7’
BCD DB 01 DUP(?),’$’
.CODE
MOV AX,@DATA
MOV DS, AX
MOV CL, 04H
MOV AL, ASCII1
MOV BL, ASCII2
AND AL, 0FH
AND BL, 0FH
ROR AL, CL
OR AL, BL
MOV BCD, AL
MOV AH,09H
MOV DX,OFFSET BCD
INT 21H
MOV AH, 4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 45
5.RESULT: Thus, the conversion of ASCII number to BCD number was done
successfully by using MASM software.
INPUT: 1 ASCII 1 = 31 H
ASCII 2 = 37 H
OUTPUT: 1 BCD = 17H
INPUT: 2 ASCII 1 =
ASCII 2 =
OUTPUT: 2 BCD =
6.VIVA QUESTIONS:
1. Explain about AAA,DAA?
2. What are the logical instructions supported by 8086?
3. Name 5 different addressing modes?
4. What are Hardware interrupts in 8085?
5. What is meant by a bus?
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 46
EXP. NO : 5 DATE:
MULTIPLICATION AND DIVISION
A. MULTIPLICATION OF TWO 16-BIT SIGNED NUMBERS
1.AIM: To write an ALP for the multiplication of two 16- bit signed numbers
using MASM software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 47
4.PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
OPR1 DW -7593H
OPR2 DW 6845H
RES DW 02 DUP(?),’$’
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AX,OPR1
IMUL OPR2
MOV RES,AX
MOV [RES+2],DX
MOV AH,09H
MOV DX,RES
INT 21H
MOV AH,4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 48
5.RESULT: Thus, the conversion of ASCII number to BCD number was done
successfully by using MASM software.
.
CASE I: Two positive numbers
INPUT: OPR1 = 7593H
OPR2 = 6845H
OUTPUT: RESLW = 689FH (AX)
RESHW = 2FE3H (DX)
CASE II: one positive number & one negative number
INPUT: OPR1 = 8A6DH 2’s Complement of (-7593H)
OPR2 = 6845H
OUTPUT: RESLW = 9761H (AX) 2’s Complement
RESHW = D01CH (DX) of (- 2FE3689FH)
CASE III: two negative numbers
INPUT: OPR1 = 8A6DH 2’s Complement of (-7593H)
OPR2 = 97BBH 2’s Complement of (-6845H)
OUTPUT: RESLW = 689FH (AX)
RESHW = 2FE3H (DX)
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 49
B. DIVISION OF TWO 16-BIT SIGNED NUMBERS
1.AIM: To write an ALP for the division of 16 bit signed numbers using
MASM software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 50
4.PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
OPR1 DW -26F8H
OPR2 DB 56H
RES DW 02 DUP(?),’$’
.CODE
MOV AX,@DATA
MOV DS,AX
MOV AX,OPR1
IDIV OPR2
MOV RES,AX
MOV [RES+2],DX
MOV AH,09H
MOV DX,RES
INT 21H
MOV AH,4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 51
5.RESULT: Thus, the division of 16- bit signed numbers was executed
successfully using MASM software.
CASE I: two positive numbers
INPUT: OPR1 = 26F8H (DIVIDEND)
OPR2 = 56H (DIVISOR)
OUTPUT: RESQ = 74H (AL)
RESR = 00H (AH)
CASE II: one positive number & one negative number
INPUT: OPR1 = D908H 2’s Complement of (-26F8H)
OPR2 = 56H
OUTPUT: RESQ = 8CH (AL) 2’s Complement of (- 74H)
RESR = 00H (AH)
CASE III: one positive number & one negative number
INPUT: OPR1 = 26F8H
OPR2 = AAH 2’s Complement of (-56H)
OUTPUT: RESQ = 8CH (AL) 2’s Complement of (- 74H)
RESR = 00H (AH)
6.VIVA QUESTIONS: 1. Define IMUL &IDIV?
2. What is the BX &DX register roles in multiplication and division?
3. Why 8086 is called as 16 bit microprocessor?
4. What is the clock rate of 8086?
5. What is the use of source index(SI)?
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 52
EXP. NO : 6 DATE:
SORTING AND MULTI BYTE ARITHMETIC
A. SORTING OF ‘N’ NUMBERS IN AN ASCENDING ORDER
1.AIM: To write an assembly language program to sorting of numbers in an
ascending in a given series by using MASM software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 53
4.PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
LIST DB 56H, 12H, 72H, 32H, 13H
COUNT EQU ($-LIST)
.CODE
MOV AX, @DATA
MOV DS, AX
MOV CX, COUNT
MOV DX, CX
AGAIN:MOV SI, OFFSET LIST
MOV CX, DX
BACK:MOV AL, [SI]
INC SI
CMP AL, [SI]
JC NEXT
XCHG [SI], AL
DEC SI
MOV [SI], AL
INC SI
NEXT: LOOP BACK
DEC DX
JNZ AGAIN
MOV AH, 09H
MOV DX,OFFSET LIST
INT 21H
MOV AH, 4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 54
5.RESULT: Thus, the sorting of given ‘N’ numbers in an ascending order is done
by using MASM software.
INPUT: 1 LIST = 56H, 12H, 72H, 32H, 13H
OUTPUT: 1 SORTING LIST IS = 12H,13H,32H,56H,72H
INPUT: 2
OUTPUT: 2
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 55
B. SORTING OF ‘N’ NUMBERS IN AN DESCENDING ORDER
1.AIM: To write an assembly language program to sorting of numbers in an
descending in a given series by using MASM software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 56
4.PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
LIST DB 56H, 12H, 72H, 32H, 13H
COUNT EQU ($-LIST)
.CODE
MOV AX, @DATA
MOV DS, AX
MOV CX, COUNT
MOV DX, CX
AGAIN:MOV SI, OFFSET LIST
MOV CX, DX
BACK:MOV AL, [SI]
INC SI
CMP AL, [SI]
JC NEXT
XCHG [SI], AL
DEC SI
MOV [SI], AL
INC SI
NEXT: LOOP BACK
DEC DX
JNZ AGAIN
MOV AH, 09H
MOV DX,OFFSET LIST
INT 21H
MOV AH, 4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 57
5.RESULT: Thus, the sorting of given ‘N’ numbers in an descending order is
done by using MASM software.
INPUT: 1 LIST = 56H, 12H, 72H, 32H, 13H
OUTPUT: 1 SORTING LIST IS = 72H,56H,32H,13H,12H
INPUT: 2
OUTPUT: 2
C. MULTIBYTE ADDITION OF 8 BIT NUMBERS
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 58
1.AIM: To write an ALP for the Multibyte addition of 8 bit numbers using
MASM
software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 59
4.PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
N1 DB 77H, 88H, 77H
N2 DB 99H, 88H, 99H
COUNT EQU 0003H
SUM DB 4 DUP(?),'$'
DIFF DB 3 DUP(?),'$'
.CODE
MOV AX,@DATA
MOV DS,AX
MOV CX,COUNT
MOV BX,0002H
CLC
BACK:MOV AL,N1[BX]
ADC AL,N2[BX]
MOV [SUM+1][BX],AL
DEC BX
LOOP BACK
MOV AL,00H
RCL AL,01
MOV SUM,AL
MOV AH,09H
MOV DX,OFFSET SUM
INT 21H
MOV AH,4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 60
5.RESULT: Thus, the multi byte addition of 8 bit numbers was executed
successfully using MASM software.
INPUT: 1 OPR1 = 77 88 77 H
OPR2 = 99 88 99 H
OUTPUT: RES = 01 11 11 10H
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 61
D. MULTIBYTE SUBTRACTION OF 8 BIT NUMBERS
1.AIM: To write an ALP for the Multibyte subtraction of 8 bit numbers using
MASM software.
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 62
4.PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
N1 DB 77H, 88H, 77H
N2 DB 99H, 88H, 99H
COUNT EQU 0003H
RES DB 4 DUP(?),'$'
DIFF DB 3 DUP(?),'$'
.CODE
MOV AX,@DATA
MOV DS,AX
MOV CX,COUNT
MOV BX,0002H
CLC
BACK:MOV AL,N1[BX]
SBB AL,N2[BX]
MOV [RES+1][BX],AL
DEC BX
LOOP BACK
MOV AL,00H
RCL AL,01
MOV RES,AL
MOV AH,09H
MOV DX,OFFSET RES
INT 21H
MOV AH,4CH
INT 21H
END
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 63
5.RESULT: Thus, the Multi byte subtraction of 8 bit numbers was executed
successfully using MASM software.
INPUT: 1 OPR1 = 77 88 77 H
OPR2 = 99 88 99 H
OUTPUT: RES = DD FF DE with Borrow (or) 01 DD FF DE
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
6.VIVA QUESTIONS:
1. What are the loop instructions supported by 8086?
2. What are the conditional instructions?
3. What is the use of destination index(DI)?
4. Write the addressing modes of 8086
5. Write some data transfer instructions in 8086
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 64
Exp .No: 7 Date:
BLINKING AN ONBOARD LED
1.AIM :
To blink the RED on-board LED using C language.
2.SOFTWARE REQURIED :
Code Composer Studio
MSP430G2553 LaunchPad plugged into your PC via USB
3.PROCEDURE: Open code composer studio
Create new project
Open new file and type the program
Compile and run the program
Dump the program in the hardware (i.e MSP 430)
Check for the output in the hardware
4.PROGRAM:
#include<msp430.h>
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0x01; // Set P1.0 to output direction
while(1) {
volatile unsigned long i; // Volatile to prevent
//optimization
P1OUT ^= 0x01; // Toggle P1.0 using XOR
i = 50000; // SW Delay
do i--;
while(i != 0);
}
}
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 65
5.RESULT:
OUTPUT:
LED ON:
LED OFF:
7.VIVA QUESTIONS:
1. Draw the address space of MSP430 microcontroller. 2. Mention various timers present in MSP430 microcontroller. 3. What is the purpose of Watchdog Timer?
4. Write about Watchdog Timer counter(WDTCNT) register.
5. What meant by GPIO?
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 66
Exp .No: 8 Date:
LED CONTROL USING A SWITCH
1.AIM:
To control the on-board Green LED by taking the input from an on-board SWITCH.
2.EQUIPMENT AND SOFTWARE:
Code Composer Studio
MSP430G2553 Launch Pad plugged into your PC via USB
3.PROCEDURE:
Open code composer studio
Create new project
Open new file and type the program
Compile and run the program
Dump the program in the hardware (i.e MSP 430)
Check for the output in the hardware
4.PROGRAM:
#include<msp430.h>
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR |= 0x40; // Set P1.6 to output direction
P1REN |= 0x08;
P1OUT |= 0X08;
while(1) {
if ((P1IN & BIT3)) { // If button is open(P1.3 HIGH)
P1OUT = P1OUT | BIT6; // ... turn on LED
} // or P1OUT |= BIT0;
else {
P1OUT = P1OUT & ~BIT6; // ... else turn it off.
// or P1OUT &= ~BIT0
}
}
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 67
5.RESULT:
OUTPUT:
6.VIVA QUESTIONS:
1. Explain the purpose of EEM (Embedded Emulation Module) in MSP430 microcontroller.
2. What is the function of hardware multiplier?
3. Write a short note on Interrupts processing.
4. Write the definitions of ISR,VECTOR,VECTOR TABLE?
5. Explain the function of #pragma, vector, __interrupt keywords used in MSP430 programming.
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 68
Exp .No: 9 Date:
LOW POWER MODES AND CURRENT MEASUREMENT
1.AIM: To learn the various low power modes and measure current consumption both in active
and standby mode.
2.SOFTWARE REQURIED :
Code Composer Studio
MSP430G2553 Launchpad plugged into your PC via USB
Digital Multimeter
3.PROCEDURE:
Open code composer studio
Create new project
Open new file and type the program
Compile and run the program
Dump the program in the hardware (i.e MSP 430)
Check for the output in the hardware
4.PROGRAM:
Main_active.c
#include <msp430g2553.h>
#ifndef TIMER0_A1_VECTOR
#define TIMER0_A1_VECTOR TIMERA1_VECTOR
#define TIMER0_A0_VECTOR TIMERA0_VECTOR
#endif
volatile long tempRaw;
volatile unsigned int i;
void FaultRoutine(void);
void ConfigWDT(void);
void ConfigClocks(void);
void ConfigPins(void);
void ConfigADC10(void);
void ConfigTimerA2(void);
void main(void)
{
ConfigWDT();
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 69
ConfigClocks();
ConfigPins();
ConfigADC10();
ConfigTimerA2();
_BIS_SR(GIE);
void ConfigWDT(void)
{
WDTCTL = WDTPW + WDTHOLD;
}
void ConfigClocks(void)
{
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
FaultRoutine();
BCSCTL1 = CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
BCSCTL3 |= LFXT1S_2;
IFG1 &= ~OFIFG;
BCSCTL2 |= SELM_0 + DIVM_3 + DIVS_3;
}
void FaultRoutine(void)
{
P1OUT = BIT0;
while(1);
}
void ConfigPins(void)
{
P1DIR = ~BIT3;
P1OUT = 0;
P2SEL = ~(BIT6 + BIT7);
P2DIR |= BIT6 + BIT7;
P2OUT = 0;
}
void ConfigADC10(void)
{
ADC10CTL1 = INCH_10 + ADC10DIV_0;
}
void ConfigTimerA2(void)
{
CCTL0 = CCIE;
CCR0 = 36000;
TACTL = TASSEL_1 + MC_2;
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
{
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON;
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 70
_delay_cycles(4);
ADC10CTL0 |= ENC + ADC10SC;
P1OUT |= BIT6;
_delay_cycles(100);
ADC10CTL0 &= ~ENC;
ADC10CTL0 &= ~(REFON + ADC10ON);
tempRaw = ADC10MEM;
P1OUT &= ~BIT6; CCR0 +=36000;
}
Main_standby.c:
#include <msp430g2553.h>
#ifndef TIMER0_A1_VECTOR
#define TIMER0_A1_VECTOR TIMERA1_VECTOR
#define TIMER0_A0_VECTOR TIMERA0_VECTOR
#endif
volatile long tempRaw;
//volatile unsigned int i;
void FaultRoutine(void);
void ConfigWDT(void);
void ConfigClocks(void);
void ConfigPins(void);
void ConfigADC10(void);
void ConfigTimerA2(void);
void main(void)
{
ConfigWDT();
ConfigClocks();
ConfigPins();
ConfigADC10();
ConfigTimerA2();
// _BIS_SR(GIE);
while(1)
{
_bis_SR_register(LPM3_bits + GIE)
}
}
void ConfigWDT(void)
{
WDTCTL = WDTPW + WDTHOLD;
}
void ConfigClocks(void)
{
if (CALBC1_1MHZ ==0xFF || CALDCO_1MHZ == 0xFF)
FaultRoutine();
BCSCTL1 = CALBC1_1MHZ;
MP&MC LABORATORY III B.Tech II Sem
VEMU INSTITUTE OF TECHNOLOGY, Dept of ECE. Page 71
DCOCTL = CALDCO_1MHZ;
BCSCTL3 |= LFXT1S_2;
IFG1 &= ~OFIFG;
BCSCTL2 |= SELM_0 + DIVM_3 + DIVS_3;
}
void FaultRoutine(void)
{
P1OUT = BIT0; // P1.0 on (red LED)
while(1); // TRAP
}
void ConfigPins(void)
{
P1DIR = ~BIT3; // P1.6 and P1.0 outputs
P1OUT = 0;
P2SEL = ~(BIT6 + BIT7);
P2DIR |= BIT6 + BIT7;
P2OUT = 0;// LEDs off
}
void ConfigADC10(void)
{
ADC10CTL1 = INCH_10 + ADC10DIV_0;
}
void ConfigTimerA2(void)
{
CCTL0 = CCIE;
CCR0 = 36000;
TACTL = TASSEL_1 + MC_2;
}
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A (void)
{
ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON;
_delay_cycles(4);
ADC10CTL0 |= ENC + ADC10SC; P1OUT |= BIT6; // P1.6 on (green LED)
_delay_cycles(100);
ADC10CTL0 &= ~ENC;
ADC10CTL0 &= ~(REFON + ADC10ON);
tempRaw = ADC10MEM;
P1OUT &= ~BIT6;
CCR0 +=36000;
_bic_SR_register_on_exit(LPM3_bits);
}
MICROPROCESSORS & MICROCONTROLLERS LAB III B.Tech II Sem
VEMU Institute of Technology, Dept of E C E. Page 72
5.RESULT:
OUTPUT:
Platform Active current
consumption
Stand by current
consumption
MSP430G2553 123 uA 1.2 Ua
6.VIVA QUESTIONS:
1. . Write about Low Power Mode 0 & Low Power Mode 1.
2. . Write about Low Power Mode 2 & Low Power Mode 3.
3. . Write about active mode & Low Power Mode 4.
4. Write about PxIN, PxOUT, PxDIR registers?
5. Write about PORTs of MSP430 controller.
MICROPROCESSORS & MICROCONTROLLERS LAB III B.Tech II Sem
VEMU Institute of Technology, Dept of E C E. Page 73
Exp .No: 10 Date:
INTERRUPT PROGRAMMING THROUGH GPIO
1.AIM:
To learn on-chip Timer and Interrupts. Configuration of Timer, Interrupts and its operations.
2.SOFTWARE REQURIED:
Code Composer Studio
MSP430G2553 Launchpad plugged into your PC via USB
.
3.PROCEDURE: Open code composer studio
Create new project
Open new file and type the program
Compile and run the program
Dump the program in the hardware (i.e MSP 430)
Check for the output in the hardware
4.PROGRAM:
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
P1DIR |= BIT6; // Set P1.6 to output direction
P1REN |= BIT3; // Enable P1.3 internal resistance
P1OUT |= BIT3; // Set P1.3 as pull up resistance
P1IES |= BIT3; // P1.3 High/Low Edge
P1IFG &= ~BIT3; // P1.3 IFG Cleared
P1IE |= BIT3; // P1.3 Interrupt Enabled
_bis_SR_register(LPM4_bits + GIE); // Enter LPM4 w/ interrupt
_no_operation(); // For debugger
}
MICROPROCESSORS & MICROCONTROLLERS LAB III B.Tech II Sem
VEMU Institute of Technology, Dept of E C E. Page 74
#pragma vector=PORT1_VECTOR __interrupt void Port_1 (void)
{
P1OUT ^= BIT6; // Toggle P1.6
P1IFG &= ~BIT3; // P1.3 IFG Cleared
}
5.RESULT:
6.VIVA QUESTIONS: 1. Write about PORT2 of MSP430 controller.
2. Write a short note on Flash memory
3. Write a short note on FRAM.
4. What are the features of Timer_A & Timer_B?
5. What are the operating modes of Timers in MSP430x5xx microcontroller?
MICROPROCESSORS & MICROCONTROLLERS LAB III B.Tech II Sem
VEMU Institute of Technology, Dept of E C E. Page 75
Exp .No: 11 Date:
PULSE WIDTH MODULATION
1.AIM:
To implement Pulse Width Modulation using the onboard green LED.
2.SOFTWARE REQURIED:
Code Composer Studio
MSP430G2553 Launchpad plugged into your PC via USB
3.PROCEDURE: Open code composer studio
Create new project
Open new file and type the program
Compile and run the program
Dump the program in the hardware (i.e MSP 430)
Check for the output in the hardware
4.PROGRAM:
#include <msp430g2553.h>
int pwmDirection = 1;
void main(void){
WDTCTL = WDT_MDLY_32;
IE1 |= WDTIE;
P1DIR |= BIT6;
P1SEL |= BIT6;
TA0CCR0 = 1000;
TA0CCR1 = 1;
TA0CCTL1 = OUTMOD_7;
TA0CTL = TASSEL_2 + MC_1;
_BIS_SR(LPM0_bits + GIE);
}
#pragma vector=WDT_VECTOR
ISR
__interrupt void watchdog_timer(void)
{
TA0CCR1 += pwmDirection*20;
if( TA0CCR1 > 980 )
TA0CCR1 = 1;
}
MICROPROCESSORS & MICROCONTROLLERS LAB III B.Tech II Sem
VEMU Institute of Technology, Dept of E C E. Page 76
5.RESULT:
OUTPUT:
6.VIVA QUESTIONS: 1. What are the uses of Capture and Compare output modes.?
2. What are the operating modes of capture/compare blocks in Timers?
3. What are the similarities and differences between Timer_A and Timer_B?
4. What are the features of real time clock?
5. What are the interrupts of real time clock in calendar and counter modes?
MICROPROCESSORS & MICROCONTROLLERS LAB III B.Tech II Sem
VEMU Institute of Technology, Dept of E C E. Page 77
Exp .No: 12 Date:
INTERFACING POTENTIOMETER WITH MSP 430
1.AIM:
To control the on-board RED LED by taking the analog input from a Potentiometer.
2.SOFTWARE REQURIED:
Code Composer Studio
MSP430G2553 LaunchPad plugged into your PC via USB
10,000 Ohm Potentiometer
3.PROCEDURE: Open code composer studio
Create new project
Open new file and type the program
Compile and run the program
Dump the program in the hardware (i.e MSP 430)
Check for the output in the hardware
4.PROGRAM:
#include <msp430g2553.h>
int main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
ADC10CTL0 = SREF_0 + ADC10SHT_2 + ADC10ON;
ADC10CTL1 = INCH_3; // input A3
ADC10AE0 |= 0x08; // PA.3 ADC option select
P1DIR |= 0x01; // Set P1.0 to output direction
While (1)
{
ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start
if (ADC10MEM < 512) // ADC10MEM = A3 > 512?
P1OUT &= ~0x01; // Clear P1.0 LED off
else P1OUT |= 0x01; // Set P1.0 LED on
MICROPROCESSORS & MICROCONTROLLERS LAB III B.Tech II Sem
VEMU Institute of Technology, Dept of E C E. Page 78
5.RESULT:
OUTPUT:
6.VIVA QUESTIONS:
1. How to interface an external device to microcontroller in UART mode
2. What is the purpose of software UART?.
3. Write a Short note on the three MSP430 microcontroller system clocks.
4. Define MSP430.
5. How many number of I/Os supported by MSP430.