MPMC Lab
MPMC Lab
Name:_____________________________________________
H.T.No:____________________________________________
Year/Semester:______________________________________
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_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_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.
PSO_1: Responsive to ideas: Apply the fundamentals to design and analysis of complex
electronic systems to meet the challenges in contemporary business environment.
C327.2 Make use of programmable peripheral devices and their Interfacing in assembly programming.
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:
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.
CONTENTS
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
TOTAL (20M)
NAME OF
S NO DATE Observation Viva voce
EXPERIMENT Sign. Total
(10M) (10M)
Introduction to MASM
1 Programming.
Arithmetic and logical
2 operations
3 String operations
4 Code conversion
Multiplication and
5 Division
Sorting and multi byte
6 arithmetic
Blinking an On Board Led
7 Using MSP-430
Led Control Using a
8 Switch Using MSP-430
Low and High Power
9 Mode Current
Measurement
Interrupt Programming
10 through GPIO
Pulse Width Modulation
11 With MSP 430
EXP. NO : 1 DATE:
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,.
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
PROGRAM:
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
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
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.
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:
EXP. NO : 2 DATE:
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:
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
5. RESULT: Thus the addition of two 8 bit numbers was successfully executed
using MASM software.
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
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:
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
5.RESULT: Thus the subtraction of two 8 bit numbers was successfully executed
using MASM software.
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
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:
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
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
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:
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
5.RESULT: Thus, the division of two 8 bit numbers was executed successfully
using MASM software
INPUT: 1 OPR1 = 31 H
OPR2 = 02 H
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: QUE =
REM =
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:
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
5.RESULT: Thus, the addition of two 16 bit numbers was executed successfully
using MASM software.
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
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:
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
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
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:
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
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
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:
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
5.RESULT: Thus, the division of two 16 bit numbers was executed successfully
using MASM software.
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?
EXP. NO : 3 DATE:
STRING OPERATIONS
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
4.PROGRAM:
.MODEL SMALL
.STACK 100
.DATA
LIST DB ‘MICRO PROCESSOR’
COUNT EQU ($-LIST)
.CODE
5.RESULT: Thus, the reverse of the given string was done by using MASM
software.
INPUT: 2
OUTPUT: 2
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:
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
5.RESULT: Thus, the length of the given string is done by using MASM software
INPUT: 2
OUTPUT: 2
2.APPARATUS REQUIRED:
i) PC
ii) MASM software
3.ALGORITHM:
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
5.RESULT: Thus, the comparison of the given strings is done by using MASM
software
INPUT: 2
OUTPUT: 2
6.VIVA QUESTIONS:
EXP. NO : 4 DATE:
CODE CONVERSION
2.APPARATUS REQUIRED:-
i) PC
ii) TASM software
3.ALGORITHM:
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
5.RESULT: Thus, the conversion of BCD number to ASCII number was done
successfully by using MASM software.
OUTPUT: 1 ASCII 1= 37 H
ASCII 2= 31 H
INPUT: 2 BCD =
OUTPUT: 2 ASCII 1=
ASCII 2=
2.APPARATUS REQUIRED: i) PC
ii) TASM software
3.ALGORITHM:
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
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
INPUT: 2 ASCII 1 =
ASCII 2 =
OUTPUT: 2 BCD =
6.VIVA QUESTIONS:
EXP. NO : 5 DATE:
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:
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
5.RESULT: Thus, the conversion of ASCII number to BCD number was done
successfully by using MASM software.
.
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:
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
5.RESULT: Thus, the division of 16- bit signed numbers was executed
successfully using MASM software.
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)?
EXP. NO : 6 DATE:
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
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
5.RESULT: Thus, the sorting of given ‘N’ numbers in an ascending order is done
by using MASM software.
INPUT: 2
OUTPUT: 2
2.APPARATUS REQUIRED: i) PC
ii) MASM software
3.ALGORITHM:
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
INPUT: 2
OUTPUT: 2
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:
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
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
INPUT: 2 OPR1 =
OPR2 =
OUTPUT: RES =
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:
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
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
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
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);
}
}
5.RESULT:
OUTPUT:
LED ON:
LED OFF:
7.VIVA QUESTIONS:
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
}
}
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.
1.AIM:
To learn the various low power modes and measure current consumption both in active
and standby mode.
2.SOFTWARE REQURIED :
3.PROCEDURE:
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();
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;
_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;
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);
}
5.RESULT:
OUTPUT:
6.VIVA QUESTIONS:
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
}
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.
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;
}
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?
1.AIM:
To control the on-board RED LED by taking the analog input from a Potentiometer.
2.SOFTWARE REQURIED:
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
5.RESULT:
OUTPUT:
6.VIVA QUESTIONS: