EC8681-Microprocessors and Microcontrollers Lab Manual
EC8681-Microprocessors and Microcontrollers Lab Manual
THAZHAMBUR, CHENNAI
ENGINEERING
(Regulation 2017)
VI SEMESTER-ECE
EC8681- MICROPROCESSORS AND MICROCONTROLLERS LABORATORY
LAB MANUAL
Prepared by
LIST OF EXPERIMENTS
TOTAL: 45 PERIODS
LIST OF EXPERIMENTS
CYCLE I
4. MATRIX OPERATION
5. STRING MANIPULATION
a.Copy a string
b.Reverse a string
6. SORTING
a. Ascending and Descending order
7. SEARCHING
a. Search for a given data
CYCLE II
Ex. NO: 01
DATE:
16 BIT ADDITION USING ARITHMETIC OPERATION OF 8086 MICROPROCESSOR
AIM:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
ALGORITHM:
16- bit addition
FLOW
CHART:ADDITI
ON:
3
ADDRESS DATA
INPUT 1200
1201
1202
1203
1204
OUTPUT 1205
1206
RESULT:
Thus the assembly language program to perform addition of two 16 bit
numbers using 8086 Performed and the result is stored.
4
Ex. NO: 02
DATE:
16 BIT SUBTRACTION
USING ARITHMETIC OPERATION OF 8086 MICROPROCESSOR
AIM:
To write an assembly language program to perform subtraction of two 16bit
numbers using 8086.
APPARATUS REQUIRED:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
ALGORITHM:
FLOECHART:
SUBTRACTION:
6
ADDRESS DATA
1300
1301
INPUT 1302
1303
1304
OUTPUT 1305
1306
RESULT:
Ex. NO: 03
DATE:
16BITMULTIPLICATIONUSINGARITHMETICOPERATIONOF8086
MICROPROCESSOR
AIM:
To write an assembly language program to perform Multiplication of two 16
bit numbers using 8086.
APPARATUS REQUIRED:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
ALGORITHM:
16- bit MULTIPLICATION
FLOECHART:
MULTIPLICATION:
9
PROGRAM FORMULTIPLICATION:
OUTPUT FORVMULTIPLICATION:
INPUT
OUTPUT
RESULT:
Ex. NO: 04
DATE:
16 BIT DIVISION USING ARITHMETIC OPERATION OF 8086 MICROPROCESSOR
AIM:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
ALGORITHM:
16- bitdivision
Division of 16-bit numbers:
➢ Get the dividend and divisor.
➢ Initialize the quotient to0.
➢ Dividend =dividend–divisor
➢ If the divisor is greater, store the quotient
➢ Go to step3
➢ If dividend is greater, quotient = quotient+ repeat from step4.
11
FLOECHART:
DIVISION:
12
ADDRESS DATA
1200
1201
INPUT
1202
1203
1208
OUTPUT
1209
RESULT:
Thus the assembly language program to perform division of two 16 bit
numbers using 8086 Performed and the result is stored.
13
EX. NO: 05
DATE :
LOGICAL OPERATIONS USING 8086 MICROCONTROLLER
AIM:
To perform logical operations like AND, OR, NOT & EX-OR using 8086
microprocessor Kit.
APPARATUS REQUIRED:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
ALGORITHM:
➢ Increment B register.
MEMORY
ADDRESS OPCODE LABEL MNEMONICS COMMENTS
OUTPUT:
NOT
AND
OR
EX-OR
RESULT:
Thus the assembly language program to perform logical operations AND, OR
& EX-OR using 8086 Performed and the result is stored.
17
EX. NO: 06
DATE :
MOVE A DATA BLOCK WITHOUT OVERLAP
AIM:
To move a data block without overlap
APPARATUS REQUIRED:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
ALGORITHM:
➢ Increment B register.
PROGRAM:
OUTPUT:
INPUT OUTPUT
1400 1450
1401 1451
1402 1452
1403 1453
1404 1454
RESULT:
Thus the output for the Move a data block without overlap was executed
successfully.
19
EX. NO: 07
DATE :
CODE CONVERSION-DECIMAL TO HEXADECIMAL
AIM:
To convert a given decimal number to hexadecimal.
ALGORITHM:
➢ Initialize the memory location to the datapointer.
➢ Increment Bregister.
➢ Increment accumulator by 1 and adjust it to decimal everytime.
➢ Compare the given decimal number with accumulatorvalue.
➢ When both match, the equivalent hexadecimal value is in Bregister.
➢ Store the resultant in memorylocation.
20
FLOWCHART:
20
PROGRAM:
OUTPUT:[DECIMAL TO HEXADECIMAL]
INPUT
OUTPUT
21
RESULT:
Thus the code conversion of decimal to hexadecimal was executed
successfully.
22
EX. NO: 08
DATE :
CODE CONVERSION –HEXADECIMAL TO DECIMAL
AIM:
To convert a given hexadecimal number to decimal
ALGORITHM:
➢ Initialize the memory location to the datapointer.
➢ Increment Bregister.
➢ Increment accumulator by 1 and adjust it to decimal everytime.
➢ Compare the given hexadecimal number with B registervalue.
➢ When both match, the equivalent decimal value is in Aregister.
➢ Store the resultant in memorylocation.
23
PROGRAM;
OUTPUT:
INPUT OUTPUT
MEMORY
DATA
RESULT:
EX. NO: 09
DATE :
STRING MANIPULATION - SORTING & SEARCHING
APPARATUS REQUIRED:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
PROBLEM STATEMENT:
An array of length 05 is given from the location. Sort it into descending and
ascending order and store the result.
26
ALGORITHM:
FLOECHART:[ASCENDING]:
28
FLOWCHART :[DECENDING]:
29
Number of comparisons in
9002 MOV CL,[SI]
CL
Go to next memory
9007 INC SI
location
Go to next memory
900B L3 : INC SI
location
Compare BC and AL
900F CMP AL,BC
register
DATA
INPUT
OUTPUT
DATA
INPUT
OUTPUT
RESULT:
Thus the given array of numbers are sorted in ascending & descendingorder.
33
EX. NO: 10
DATE :
LARGEST & SMALLEST
AIM:
To write an Assembly Language Program(ALP) to find the Largest and
Smallest number in a given array.
APPARATUS REQUIRED:
2. POWER SUPPLY + 5 V DC 1
3. KEY BOARD - 1
PROBLEM STATEMENT:
An array of length 5 is given from the location. Find the largest and smallest
number and store the result.
34
ALGORITHM:
FLOECHART:[LARGEST]
36
FLOECHART:[SMALLEST]
37
1018 MOV [DI],AL Else store the biggest number in 1300 location
DATA
INPUT
OUTPUT
DATA
INPUT
OUTPUT
RESULT:
EX. NO: 11
DATE :
PASSWORD CHECKING
AIM:
APPARATUS REQUIRED:
PROGRAM:
; PASSWORD ISMASM1234
DATA SEGMENT
PASSWORD DB'MASM1234'
MSG2DB10,13,'WELCOMETOELECTRONICSWORLD!!$' MSG3
DB 10, 13,'INCORRECTPASSWORD!$'
INST DB 10 DUP(0)
DATA ENDS
CODE SEGMENT
41
START:
MOV DS, AX
INT 21H
MOV SI, 00
UP1:
MOV AH,08H
INT21H
CMP AL,0DH
JEDOWN
MOV [INST+SI],AL
MOV DL,'*'
INT 21H
INC SI
JMPUP1
DOWN:
MOV BX, 00
MOV CX,LEN
CHECK:
MOV AL,[INST+BX]
MOVDL,[PASSWORD+BX]
CMP AL, DL
JNE FAIL
42
INC BX
LOOPCHECK
INT 21H
JMP FINISH
FAIL:
INT 21H
FINISH:
INT 3
CODEENDS
ENDSTART
END
RESULT:
Thus the output for the Password checking, Print RAM size and system date
was executed successfully
43
EXP.NO: 12
DATE :
AIM:
APPARATUS REQUIRED:
2. Power Supply +5 V dc 1
PROGRAM;
➢ Log intoSystem.
➢ Select controltype.
➢ If Automatic mode select then go to step 4th else go to step8.
➢ If Automatic controlactivated.
➢ Assign time period for green, yellowsignal.
➢ If emergency vehicle is over then go to step4.
➢ If rally come then go to step8.
➢ Manual control activated.
➢ Assign time period for green, yellow signal according to that particularroad.
➢ If emergency over then go to step4.
44
100B INX H
100E MOV A, M
1012 INX H
1019 INX H
101A DCR E
1026 L1 DCR C
1028 JNZ L1
1029 DCR D
1000 MOV A, D
1002 ORA E
1004 JNZ L2
1006 RET
▪
46
RESULT:
Thus the assembly language program for traffic light control is verified
47
EX. NO: 13
DATE :
AIM:
APPARATUS REQUIRED:
PROBLEM STATEMENT:
Write a code for achieving a specific angle of rotation in a given time and
particular number of rotations in a specific time.
THEORY:
A motor in which the rotor is able to assume only discrete stationary
angular position is a stepper motor. The rotary motion occurs in a stepwise manner
from one equilibrium position to the next. Two-phase scheme: Any two adjacent
stator windings are energized. There are two magnetic fields active in quadrature
and none of the rotor pole faces can be in direct alignment with the stator poles. A
partial but symmetric alignment of the rotor poles is of coursepossible.
48
ALGORITHM:
4500 1 0 0 0 09 H
4501 0 1 0 1 05 H
4502 0 1 1 0 06 H
4503 1 0 1 0 0A H
49
FLOWCHART:
50
DELAY SUBROTINE
RESULT:
Thus the assembly language program for rotating stepper motor in both
clockwise and anticlockwise directions is written and verified.
52
EX. NO: 14
DATE :
INTERFACING PRGRAMMABLE KEYBOARD
ANDDISPLAY CONTROLLER 8279
AIM :
APPARATUS REQUIRED:
ALGORITHM :
PROGRAM:
MEMORY
LOCATION OPCODES PROGRAM COMMENDS
FLOWCHART:
55
SEGMENT DEFINITION:
DATA BUS D7 D6 D5 D4 D3 D2 D1 D0
SEGMENTS d c B A d g f e
RESULT:
Thus the rolling message “2” is displayed using 8279 interface kit.
56
EX. NO: 15
DATE :
INTERFACING ANALOG TO DIGITAL CONVERTER USING 8086
AIM:
APPARATUS REQUIRED:
THEORY:
An ADC usually has two additional control lines: the SOC input to tell the
ADC when to start the conversion and the EOC output to announce when the
conversion iscomplete.
ALGORITHM:
➢ Select the channel and latch theaddress.
➢ Send the start conversionpulse.
➢ Read EOC signal.
➢ If EOC = 1 continue else go to step(iii)
➢ Read the digitaloutput.
➢ Store it in a memorylocation.
57
PROGRAM:
MEMORY
OPCODES PROGRAM COMMENTS
LOCATION
Load accumulator
1000 MOV DX,FF26 with value for ALE
high
Send through output
1000 MOV AL,90
port
Load accumulator
1003 OUT DX,AL with value for ALE
low
Send through output
1006 MOV DX,FF24
port
Store the value to
1009 MOV AL,FF make SOC high in
the accumulator
Send through output
100B OUT DX,AL
port
FLOWCHART:
60
OUTPUT:
RESULT:
Thus the ADC was interfaced with 8086 and the given analog inputs were
converted into its digital equivalent.
61
EX. NO: 16
DATE :
INTERFACING DIGITAL – TO – ANALOG
CONVERTERUSING 8086
AIM:
APPARATUS REQUIRED:
PROBLEM STATEMENT:
The program is executed for various digital values and equivalent analog
voltages are measured and also the waveforms are measured at the output ports
usingCRO.
THEORY:
Since DAC 0800 is an 8 bit DAC and the output voltage variation is
between –5v and +5v. The output voltage varies in steps of 10/256 = 0.04
(approximately). The digital data input and the corresponding output voltages are
presented in the table. The basic idea behind the generation of waveforms is the
continuous generation of analog output of DAC. With 00 (Hex) as input to DAC2
the analog output is –5v. Similarly with FF H as input, the output is +5v.
Outputting digital data 00 and FF at regular intervals, to DAC2, results in a square
wave of amplitude 5v.Output digital data from 00 to FF in constant steps of 01 to
DAC2. Repeat this sequence again and again. As a result a saw-tooth wave will be
generated at DAC2 output. Output digital data from 00 to FF in constant steps of
01 to DAC2. Output digital data from FF to 00 in constant steps of01 to DAC2.
62
FLOECHART
63
ALGORITHM
Waveform generation
Square Waveform:
MEMORY
OPCODES PROGRAM COMMENTS
LOCATION
Load accumulator
1000 MOV DX,FF26 with value for ALE
high
Send through output
1000 MOV AL,80 port
Load accumulator
1003 OUT DX,AL with value for ALE
low
Send through output
1006 MOV DX,FF22 port
Store the value to
1009 MOV AL,FF make SOC high in
the accumulator
Send through output
100B OUT DX,AL
port
DELAY SUOUTINEBR
Decrement CX
2105 DEC CX
register
Return to main
2108 RET
address
RESULT
Thus the DAC was interfaced with 8086 and different waveforms have been
generated.
66
EX. NO: 17
DATE :
8 BIT ADDITION USING ARITHMETIC OPERATION 8051
MICROCONTROLLER
AIM:
To write an ALP program to add two 8-bit numbers using 8051
microcontroller.
ALGORITHM:
FLOW CHART
68
PROGRAM
OUTPUT:
INPUT OUTPUT
MEMORY MEMORY
DATA DATA
RESULT:
Thus the 8051 ALP for addition of two 8 bit numbers is executed.
69
EX. NO: 18
DATE :
8 BIT SUBTRACTION USING ARITHMETIC OPERATION
8051 MICROCONTROLLER
AIM:
To perform subtraction of two 8 bit data and store the result in memory.
ALGORITHM:
➢ Clear the carryflag.
➢ Initialize the register forborrow.
➢ Get the first operand into theaccumulator.
➢ Subtract the second operand from theaccumulator.
➢ If a borrow results increment the carryregister.
➢ Store the result inmemory.
70
FLOECHART:
71
8 BIT SUBTRACTION
8105 INCDPTR
Initialize the
memory Location
OUTPUT:
INPUT OUTPUT
Memory Memory
Data Data
RESULT:
Thus the 8051 ALP for subtraction of two 8 bit numbers is executed.
72
EX. NO: 19
DATE :
8 BIT MULTIPLICATION USING ARITHMETION OPERATION 8051
MICROCONTROLLER
AIM:
To perform multiplication of two 8 bit data and store the result in memory.
ALGORITHM:
FLOWCHART:
74
8 BIT MULTIPLICATION
OUTPUT:
INPUT OUTPUT
Memory Memory
Data Data
Location location
4500 4502
4501 4503
RESULT:
Thus the 8051 ALP for multiplication of two 8 bit numbers is executed.
76
EX. NO: 20
DATE :
8 BIT DIVISION USING ARITHMETIC OPERATION 8051
MICROCONTROLLER
AIM:
To perform division of two 8 bit data and store the result in memory
ALGORITHM:
FLOWCHART:
78
8 BIT DIVISION
OUTPUT:
INPUT OUTPUT
Memory Memory
Data Data
Location location
4500 4502
4501 4503
RESULT:
Thus the 8051 ALP for division of two 8 bit numbers is executed.
80
EX. NO: 21
DATE :
LOGICAL OPERATIONS
USING8051
MICROCONTROLLER
AIM:
To perform logical operation using 8051 microcontroller AND, OR & EX-OR.
ALGORITHM:
OUTPUT:
AND
OR
EX-OR
RESULT:
Thus the assembly language program to perform logical operations AND, OR
& EX-OR using 8051 Performed and the result is stored.
83
EX. NO: 22
DATE :
FIND 2’S COMPLEMENT OF A NUMBER
AIM:
To Finding 2’s complement of a number using 8051 micro controller
RESOURCES REQUIERED:
➢ 8051 microcontrollerkit
➢ Keyboard
➢ Powersupply
84
PROGRAM:
OUTPUT:
RESULT;
EX. NO: 23
DATE :
COVERSION OF BCD TO ASCII
AIM:
To convert BCD number into ASCII by using 8051 micro controller
RESOURCES REQUIERED:
➢ 8051 microcontrollerkit
➢ Keyboard
➢ Powersupply
ALGORITHM:
59 AAM
00 08 09
AH AL AH AL
NOTE;59H TO 89 DECIMAL
ADD
08 09 38 39
AX,3030
H
AH AL AH AL
NOTE; 38h and 39h are the ASCII equivalents of 8 and 9 respectively
FLOWCHART:
87
PROGRAM;
ROUTINE: convert binary for number less than 100 passing parameter
AAM
ADD AX,3030H
MOV BX, AX
MOVDL, BH
MOV AH, 02
INT21H
MOV DL, BL
INT 21H
POPAX
POPBX
POPDX
RET
ENDP
88
RESULT:
Thus the given number is BCD number converted into ASCII using 8051
microcontroller kit.
89
1. What is a microprocessor ?
2. Tell Something about Bit, Byte and Word.
3. Mention the different functional units in 8086.
4. What is the function of BIU?
5. What are the main functional units in 8086 ?
6. What is the function of EU ?
7. What is the maximum size of segment in 8086 Microprocessor ?
8. What are the four general purpose registers in 8086 ?
9. What is the special purpose register?
38. What shall be the position of the Stack Pointer after the PUSH instruction is used?
39. What shall be the position of the Stack Pointer after the POP instruction is used?
40. Which type of registers in 8086 are responsible for performing logical operations?
41. What are the examples for Microcontroller?
42. What are the address lines for the hardware interrupts?
43. Which Flags can be set or reset by the programmer and also used to control the operation
of the processor?
44. What does EU do?
45. Which microprocessor accepts the program written for 8086 without any changes?
46. What is meant by cross-compiler?
47. Which is the tool used to connect the user and the computer?
48. What do you mean by the term‘state’ in 8031/8051 microcontroller?
49. How many machine cycles are needed to execute an instruction in 8031/8051 controller?
50. How to estimate the time taken to execute an instruction in 8031/8051 controller?
51. What is the size of 8031/8051 instructions?
52. List the various machine cycles of 8031/8051 controller.
91
53. How the 8051 microcontroller differentiates external program memory access and data
memory access?
54. What are the addressing modes available in 8051 Controller?
55. Explain the register indirect addressing in 8051.
56. Explain the relative addressing in 8051
57. How the 8051 instructions can be classified?
58. List the instructions of 8051 that affect all the flags of 8051.
59. List the instructions of 8051 that affect overflow flag in 8051.
60. List the instructions of 8051 that affect only carry flag.
61. List the instructions of 8051 that always clear carry flag.
62. What are the operations performed by Boolean variable instructions of 8051?
63. Give some examples for 8 / 16 / 32 bit Microprocessor?
64. What do you mean by 1st / 2nd / 3rd / 4th generation processor?
65. What is the difference between microprocessor and microcontroller?
66. What is meant by the term ‘LATCH’?
67. What are the differences between primary & secondary storage device?
68. Classify static and dynamic RAM?
69. What is meant by the cache memory?
70. What is meant by the flag?
71. Name the flags used in 8086.
72. What is meant by the term’ Stack’?
73. What is the position of the Stack Pointer after the PUSH instruction?
74. What is the position of the Stack Pointer after the POP instruction?
75. What is NV-RAM?
76. Can a Processor structure be pipelined? Justify your answer.