22EC2106 - P&C LAB Manual
22EC2106 - P&C LAB Manual
LABORATORY MANUAL
22EC2106
Processors & Controllers
LABORATORY MANUAL
22EC2106
Processors & Controllers
STUDENT NAME
REG.NO
YEAR
SEMESTER
SECTION
FACULTY
COURSE INTRODUCTION
Course Title : Processors & Controllers
Course Code : 22 EC 2106
L-T-P-S structure : 3-0-2-2
Credits :4
Pre-Requisite : COA
Course Coordinator : Dr.N.Prabakaran
Team of Instructors :
Dr. N.Prabakaran (CC) 4966
Dr.Syed.Shameem 2497
Dr.S.S.Aravinth 6619
Dr.T.Anuradha 6728
Course Objective:
This course provides comprehensive knowledge on the working of Microprocessor
Intel 8086 Microprocessor, Intel 8051 microcontrollers and provides a basic understanding of
advanced microcontrollers like ARM 7, PIC, CORTEX STM-32. The course will give an idea
about different architectures and the programming skills for microprocessor and
microcontrollers. The course gives the practical idea to interface different application modules
using microcontrollers.
Course Rationale:
The purpose of this course is to teach students the fundamentals of microprocessor and
microcontroller systems. The student will be able to incorporate these concepts into their
electronic designs for other courses where control can be achieved via a
microprocessor/controller implementation. Upon gaining the fundamental knowledge of
microprocessor and microcontroller architecture and programming, the students will be able to
design systems for embedded applications like home appliances, consumer electronics, and the
telephone industry and in the field of instrumentation control.
ACKNOWLEDGEMENT
Hereby acknowledge the following faculty members and lab manual prepared faculties for their
fruitful efforts for the establishment of “Processors & Controllers Lab” for the subject titled
“Processors & Controllers -22EC2106”.
2 (a) Write an 8086 ALP to find the POSITIVE and NEGATIVE numbers in an array.
(b) Write an ALP to find the EVEN and ODD numbers in an array using 8086
programming
3 Write an ALP to Sort the Array of Numbers in ascending and descending order using
8086 Programming.
7 a) To Develop an ALP to generate a square wave of frequency 5kHz on P2.3, assume that
XTAL=11.052 MHz
b) To Develop an ALP to generate a square wave of frequency 5kHz with ON time on
P2.3 and OFF time on P3.3. Assume that XTAL=11.052 MHz (post lab)
8 Develop an ALP to Display Numbers using a 7-Segment Display and Timers
9 Write an ALP to interface 16X2 LCD to 8051 microcontrollers, then display your name
and ID number.
10 To Develop an ALP to count the number of events that occurred and to Display the count
on LCD
11 To Develop an ALP to accept the external interrupt and toggle the LED.
12 To develop an 8051 ALP to interface the stepper motor using an 8051 controller in the
clockwise and anti-clockwise direction
13 Project work
The laboratory framework includes a creative element but shifts the time-intensive aspects
outside of the Two-Hour closed laboratory period. Within this structure, each laboratory
includes three parts: Prelab, In-lab, and post-lab.
A. Pre-Lab
The Prelab exercise is a homework assignment that links the lecture with the laboratory period
- typically takes 2 hours to complete. The goal is to synthesize the information they learn in
lecture with material from their Text book to produce a working piece of software. Prelab
Students attending a two-hour closed laboratory are expected to make a good-faith effort to
complete the Prelab exercise before coming to the lab. Their work need not be perfect, but their
effort must be real (roughly 80 percent correct).
B. In-Lab
The In-lab section takes place during the actual laboratory period. The First hour of the
laboratory period can be used to resolve any problems the students might have experienced in
completing the Prelab exercises. The intent is to give constructive feedback so that students
leave the lab with working Prelab software - a significant accomplishment on their part. During
the second hour, students complete the In-lab exercise to reinforce the concepts learned in the
Prelab. Students leave the lab having received feedback on their Prelab and In-lab work.
C. Post-Lab
The last phase of each laboratory is a homework assignment that is done following the
laboratory period. In the Post-lab, students analyse the efficiency or utility of a given system
call. Each Post-lab exercise should take roughly 120 minutes to complete.
S.NO DATE NAME OF THE PRE- IN-LAB POST- VIVA TOTAL FACULTY
EXPERIMENT LAB (35M) LAB SIGNATURE
Logic Execution Result Analysis WITH DATE
(5M)
(10M) (10M) (10M) (5M) (5M) (5M) (50M)
1
6
Processors & Controllers (22 EC 2106) LABORATORY MANUAL 2023-2024
S.NO DATE NAME OF THE PRE- IN-LAB POST- VIVA TOTAL FACULTY
EXPERIMENT LAB (35M) LAB SIGNATURE
Logic Execution Result Analysis WITH DATE
10
11
12
S.NO DATE NAME OF SKILLING IMPLEMENTATION DEMONSTRATION RESULTS VIVA TOTAL FACULTY
THE REPORT & METHODOLOGY & VOCE SIGNATURE
SKILLING ANALYSIS WITH DATE
10
11
12
EXPERIMENT NO.1:
PRE-REQUISITE:
Assembly Language Programming (ALP)
Embedded C Programming
Pre-Lab Work:
8086 has 16-bit flag register, and there are 9 valid flag bits. The format of flag register is like below.
Bit D D D D D D D D D D D D D D D D
s 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
Fla O D I T S Z A P C
gs C Y
In 8086 there are 6 different flags which are set or reset after 8-bit or 16-bit operations. These flags
and their functions are listed below.
Flag Bit Function
S After any operation if the MSB is 1, then it indicates that the number is negative. And
this flag is set to 1
AC When some arithmetic operations generates carry after the lower half and sends it to
upper half, the AC will be 1
P This is even parity flag. When result has even number of 1, it will be set to 1, otherwise
0 for odd number of 1s
CY This is carry bit. If some operations are generating carry after the operation this flag is
set to 1
O The overflow flag is set to 1 when the result of a signed operation is too large to fit.
PROGRAM:
a) PROGRAM:
ORG 100H
.DATA
NUM1 DB 01H,00H,02H,00H
NUM2 DB 00H,00H
.CODE
MOV AX,@DATA
MOV DS,AX
LEA SI,NUM1
LEA DI,NUM2
MOV AX,[SI]
INC SI
INC SI
MOV BX,[SI]
ADD AX,BX
MOV [DI],AX
RET
B) PROGRAM :
ORG 100H
.DATA
NUM1 DB 02H,00H,01H,00H
NUM2 DB 00H,00H
.CODE
MOV AX,@DATA
MOV DS,AX
LEA SI,NUM1
LEA DI,NUM2
MOV AX,[SI]
INC SI
INC SI
MOV BX,[SI]
SBB AX,BX
MOV [DI],AX
RET
Department of ECE| KLEF (Deemed to be University), NAAC - “A++”, Guntur, AP
Processors & Controllers (22 EC 2106) LABORATORY MANUAL 2023-2024
C) PROGRAM:
ORG 100H
.DATA
NUM1 DB 02H,01H,01H,04H
NUM2 DB 00H,00H
.CODE
MOV AX,@DATA
MOV DS,AX
LEA SI,NUM1
LEA DI,NUM2
MOV AX,[SI]
INC SI
INC SI
MOV BX,[SI]
MUL BX
MOV [DI],AX
INC DI
INC DI
MOV [DI],DX
RET
d) PROGRAM :
ORG 100H
.DATA
NUM1 DB 00H,00H,07H,00H,02H,00H
NUM2 DB 00H,00H
.CODE
MOV AX,@DATA
MOV DS,AX
LEA SI,NUM1
LEA DI,NUM2
MOV DX,[SI]
INC SI
INC SI
MOV AX,[SI]
INC SI
INC SI
MOV BX,[SI]
DIV BX
MOV [DI],AX
INC DI
INC DI
MOV [DI],DX
RET
Department of ECE| KLEF (Deemed to be University), NAAC - “A++”, Guntur, AP
Processors & Controllers (22 EC 2106) LABORATORY MANUAL 2023-2024
1. Save the screenshot/Pictures of Program and output obtained and bring the same in next lab.
Evaluator’s Observation
EXPERIMENT NO.2:
EXPERIMENT NO.2:
AIM: To Develop an Assembly language Program to find No. of Positive numbers and No. of
Negative numbers in a given Array
Pre-Lab Work:
Standard numbers, anything greater than zero, are described as ‘positive’ numbers. We don’t put a
plus sign (+) in front of them because we don’t need to since the general understanding is that
numbers without a sign are positive.
Numbers that are less than zero are known as 'negative' numbers. These have a minus sign (−) in
front of them to indicate that they are less than zero (for example, -10 or 'minus 10').
PROGRAM:
ORG 100H
.DATA
NUM1 DB 85H,0D2H,50H,32H,0A6H,79H,98H,0F7H
LEN EQU 08H
.CODE
MOV AX,@DATA
MOV DS,AX
LEA SI,NUM1
MOV BX,0000H
MOV CL,LEN
AGAIN: MOV AL,[SI]
RCL AL,01
JNC PLUS
INC BL
JMP NXT
PLUS: INC BH
NXT: INC SI
DEC CL
JNZ AGAIN
RET
RESULT:
EXPERIMENT NO.2 B:
AIM: To Develop an Assembly language Program to find No. of Even numbers and No. of ODD
numbers.
ORG 00H
MOV SI,5000H
MOV CL,08H ; COUNT
MOV BL,00H ; INITIALIZE THE RESULT BECOME 00H (COUNT FOR +VE NO)
MOV BH,00H ; INITIALIZE THE RESULT BECOME 00H (COUNT FOR -VE NO)
LOOP: MOV AL,[SI]
RCR AL,01H ;( ROTATE THE ACCUMULATOR LOWER BYTE (AL) RIGHT WITH CARRY BY 1 BIT POSITION)
JC NEGATIVE ; cy = 1 then it jumps otherwise it goto next step
INC BL
JMP REPEAT ; jump
NEGATIVE:INC BH ;(BH= ADD 1 IN LSB)
REPEAT:INC SI ; SI = 5001 AND SO ON
DEC CL ; COUNT = 07H
JNZ LOOP ; JUMP IF NO ZERO FOR PREVIOUS INSTRUCTION
HLT
Viva Questions:
1. What is the difference between min mode and max mode of 8086?
2. What is the difference between near and far procedure?
3. What is the difference between Macro and procedure?
4. What is the difference between instructions RET & IRET?
5. What is the difference between instructions MUL & IMUL?
Evaluator’s Observation
EXPERIMENT NO.3:
AIM: Write ALP to Sort the Array of Numbers in ascending and descending order using 8086
Programming.
PRE-REQUISITE:
Embedded C Programming
Assembly Language Programming (ALP)
Pre-Lab Work:
Here we are sorting the number in bubble sorting technique. In this sorting technique there will be
n passes for n different numbers. In ith pass the ith largest element will be placed at the end. This is
comparison-based sort. We are taking two consecutive numbers, compare them, and then swap
them if the numbers are not in correct order. The following diagram is showing how the sorting is
working.
Flow Diagram:
PROGRAM:
org 100h
.data
STR DB 0D2H,3EH,76H,12H,0E3H,44H,2AH,69H
LEN EQU ($-STR)
.code
MOV AX,@data
MOV DS,AX
MOV CL,LEN-1
AGAIN:MOV DL,CL
LEA SI,STR
UP:MOV AL,[SI]
CMP AL,[SI+1]
JBE NXT
XCHG AL,[SI+1]
XCHG AL,[SI]
NXT: INC SI
DEC DL
JNZ UP
DEC CL
JNZ AGAIN
ret
RESULT:
Before Execution
After Execution
1. Save the screenshot/Pictures of Program and output obtained and bring to the same in next lab.
Viva Questions:
1. What is the size of instruction queue in 8086?
2. Which are the registers present in 8086?
3. What is pipelining in 8086?
4. How many 16-bit registers are available in 8086?
5. Specify addressing modes for any
instruction? Evaluator’s Observation
EXPERIMENT NO.4:
PROGRAM:
org 00h
mov dptr,#num1
mov r0,#05h
clr a
movc a,@a+dptr
mov b,a
back : inc dptr
mov a,#00h
movc a,@a+dptr
add a,b
mov b,a
djnz r0, back
sjmp back
here:
here :sjmp here
org 200h
num1: db 1h,2h,3h,4h,5h
end
Evaluator’s Observation
EXPERIMENT NO.5:
AIM: a) To Develop an ALP Involving Bit/Byte Manipulations to Toggle a LED with random delay
(using Set, Clear and Complement)
PROGRAM:
a)Bit Manipulation Programs
a) Toggling Pin
clr p1.0
back:setb p1.0
acall delay
clr p1.0
acall delay
sjmp back
delay: mov r0,#5d
here1:mov r1,#2d
here:djnz r1,here
djnz r0,here1
ret
end
OUTPUT:
Toggling pin
b) Toggling Port
mov p1,#00h
mov a,#55h
back:mov p1,a
acall delay
cpl a
sjmp back
delay: mov r0,#5d
here1:mov r1,#2d
here:djnz r1,here
djnz r0,here1
ret
end
Output:
Toggling port:
Evaluator’s Observation
AIM:
To Develop an ALP Creating Patterns using 8 LED's
PROGRAM:
Bit Manipulation Programs
Pattern Generation (Sending values individually)
mov p1,#00h
back:mov p1,#01h acall delay
mov p1,#03h
acall delay
mov p1,#07h
acall delay
mov p1,#0Fh
acall delay
mov p1,#1Fh
acall delay
mov p1,#3Fh
acall delay
mov p1,#7Fh
acall delay
mov p1,#0FFh
acall delay
mov p1,#7Fh
acall delay
mov p1,#3Fh
acall delay
mov p1,#1Fh
acall delay mov
p1,#0Fh
acall delay
mov p1,#07h
acall delay
mov p1,#03h
acall delay
mov p1,#01h
acall delay
mov p1,#00h
acall delay s
jmp back
Processors & Controllers (22 EC 2106) LABORATORY MANUAL 2023-2024
Output:
Pattern generation:
Evaluator’s Observation
EXPERIMENT NO.7:
AIM: a) To Develop an ALP to generate a square wave of frequency 5kHz on P2.3 , assume
that XTAL=11.052 MHz.
a) To Develop an ALP to generate a square wave of frequency 5kHz with ON time on
P2.3 and OFF time on P3.3. Assume that XTAL=11.052 MHz
SOFTWARE USED: MCU8051
Pre-Lab Work:
a) PROGRAM:
ORG 00H
MOV TMOD,#10H
CLR P2.3
MOV TH1,#0FFH
SETB TR1
CLR TR1
CPL P2.3
CLR TF1
SJMP BACK
END
b) PROGRAM:
ORG 00H
MOV TMOD,#10H
CLR P2.3
SETB P3.3
MOV TH1,#0FFH
SETB TR1
CLR TR1
CPL P2.3
CPL P3.3
CLR TF1
SJMP BACK
END
1. Save the screenshot/Pictures of Program and output obtained and bring the same in next
lab.
Viva Questions:
1. Along with an 8-bit timer what are the other timer modes present in an 8051
microcontroller
2. Which of the following bit of TMOD register in an 8051 microcontroller decides whether it
is a delay generator
3. What is the source of crystal frequency in an 8051 microcontroller
4. What is the value of TMOD register to operate timer in Mode1,Timer1 in an 8051
microcontroller
5. What is the timer's clock frequency if the crystal frequency is 16MHz in an 8051
microcontroller
6. What is the time period if the crystal frequency is 16MHz in an 8051 microcontroller
7. What is the source of clock for timer if C/T=0 in an 8051 microcontroller
8. The 8051 system communicates with IBM PC without any errors with the following crystal
frequency
9. What are the means of starting and stopping a timer in an 8051 microcontroller
10. Which of the following bits in TCON register in an 8051 microcontroller are responsible
for starting and stopping the timer
Evaluator’s Observation
EXPERIMENT NO.8:
Hardware Required:
1. Microcontroller 8051 Kit
2. 16X2 LCD
3. Push Button
4. Connecting Wires
5. Bread Board
Pre-Lab Work:
A Seven segment display is the most basic electronic display. It consists of eight LEDs which
are associated in a sequence manner so as to display digits from 0 to 9 when proper
combinations of LEDs are switched on.
A 7-segment display uses seven LEDs to display digits from 0 to 9 and the 8th LED is used for
dot. A typical seven segment looks likes as shown in figure below.
The 7-segment displays are used in a number of systems to display the numeric information.
They can display one digit at a time. Thus the number of segments used depends on the
number of digits to display. Here the digits 0 to 9 are displayed continuously at a predefined
time delay.
The 7-segment displays are available in two configurations which are common anode and
common cathode. Here common anode configuration is used because output current of the
microcontroller is not sufficient enough to drive the LEDs. The 7-segment display works on
negative logic, we have to provide logic 0 to the corresponding pin to make on LED glow.
The 7-segment displays are used in a number of systems to display the numeric information.
They can display one digit at a time. Thus the number of segments used depends on the
number of digits to display. Here the digits 0 to 9 are displayed continuously at a predefined
time delay.
The 7-segment displays are available in two configurations which are common anode and
common cathode. Here common anode configuration is used because output current of the
microcontroller is not sufficient enough to drive the LEDs. The 7-segment display works on
negative logic, we have to provide logic 0 to the corresponding pin to make on LED glow.
PROGRAM:
mov p1,#00h
main: mov dptr,#codes
back: clr a
movc a,@a+dptr
jz next
mov p1,a
acall delay
inc dptr
sjmp back
next: sjmp main
delay: mov r0,#5d
here1:mov r1,#2d
here:djnz r1,here
djnz r0,here1
ret
codes: db 3Fh,06h,5Bh,4Fh,66h,6Dh,7Dh,07h,7Fh,6Fh,0
end
Evaluator’s Observation
EXPERIMENT NO.9:
AIM: Write an ALP to interface 16X2 LCD to 8051 microcontroller and then display your
name and ID number
Hardware Required:
1. Microcontroller 8051 Kit
2. 16X2 LCD
3. Push Button
4. Connecting Wires
5. Bread Board
Pre-Lab Work:
We come across LCD displays everywhere around us. Computers, calculators, television sets,
mobile phones, digital watches use some kind of display to display the time. An LCD is an
electronic display module which uses liquid crystal to produce a visible image. The 16×2 LCD
display is a very basic module commonly used in DIYs and circuits. The 16×2 translates o a
display 16 characters per line in 2 such lines. In this LCD each character is displayed in a 5×7
pixel matrix.
RS (Register select)
A 16X2 LCD has two registers, namely, command and data. The register select is used to
switch from one register to other. RS=0 for command register, whereas RS=1 for data register.
Command Register
The command register stores the command instructions given to the LCD. A command is an
instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting
the cursor position, controlling display etc. Processing for commands happens in the
command register.
Data Register
The data register stores the data to be displayed on the LCD. The data is the ASCII value of
the character to be displayed on the LCD. When we send data to LCD it goes to the data
register and is processed there. When RS=1, data register is selected.
PROGRAM:
ORG 00H
AGAIN:
MOV A,#38H
ACALL COMMAND
ACALL DELAY
MOV A,#0EH
ACALL COMMAND
ACALL DELAY
MOV A,#01H
ACALL COMMAND
ACALL DELAY
MOV A,#06H
ACALL COMMAND
ACALL DELAY
MOV A,#84H
ACALL COMMAND
ACALL DELAY
MOV A,#”K”
ACALL NEXT
ACALL DELAY
MOV A,#”L”
ACALL NEXT
ACALL DELAY
MOV A,#”U”
ACALL NEXT
ACALL DELAY
MOV A,#”E”
ACALL NEXT
ACALL DELAY
MOV A,#”C”
ACALL NEXT
ACALL DELAY
MOV A,#”E”
ACALL NEXT
ACALL DELAY
SJMP AGAIN
COMMAND:
MOV P1,A
CLR P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET
NEXT:
MOV P1,A
SETB P2.0
CLR P2.1
SETB P2.2
ACALL DELAY
CLR P2.2
RET
DELAY:
MOV R3,#05h
HERE2:MOV R4,#02h
HERE:DJNZ R4,HERE
DJNZ R3,HERE2
RET
END
CIRCUIT DIAGRAM:
1. Save the screenshot/Pictures of Program and output obtained and bring the same in next
lab.
Viva Questions:
1. How many rows and columns are present in a 16*2 alphanumeric LCD?
5. Which command of an LCD is used to shift the entire display to the right?
7. For reading operation from an LCD what changes in the software are introduced?
Evaluator’s Observation
EXPERIMENT NO.10:
AIM: Design a System to count the number of students entering to a class. And then:
(a) Display the same on 16X2 LCD.
Hardware Required:
1. Microcontroller 8051 Kit
2. 16X2 LCD
3. Push Button
4. Connecting Wires
5. Bread Board
Pre-Lab Work:
We come across LCD displays everywhere around us. Computers, calculators, television sets,
mobile phones, digital watches use some kind of display to display the time. An LCD is an
electronic display module which uses liquid crystal to produce a visible image. The 16×2 LCD
display is a very basic module commonly used in DIYs and circuits. The 16×2 translates o a
display 16 characters per line in 2 such lines. In this LCD each character is displayed in a 5×7
pixel matrix.
RS (Register select)
A 16X2 LCD has two registers, namely, command and data. The register select is used to
switch from one register to other. RS=0 for command register, whereas RS=1 for data register.
Command Register
The command register stores the command instructions given to the LCD. A command is an
instruction given to LCD to do a predefined task like initializing it, clearing its screen, setting
the cursor position, controlling display etc. Processing for commands happens in the
command register.
Data Register
The data register stores the data to be displayed on the LCD. The data is the ASCII value of
the character to be displayed on the LCD. When we send data to LCD it goes to the data
register and is processed there. When RS=1, data register is selected.
PROGRAM:
org 00h
mov tmod,#06h
mov tl0,#00h
setb p3.4
acall l2
mov p1,#84h
acall l1
acall l2
mov a,#'C'
mov p1,a
acall l3
acall l2
mov a,#'O'
mov p1,a
acall l3
acall l2
mov a,#'U'
mov p1,a
acall l3
acall l2
mov a,#'N'
mov p1,a
acall l3
acall l2
mov a,#'T'
mov p1,a
acall l3
acall l2
mov a,#':'
mov p1,a
acall l3
acall l2
mov a,tl0
add a,#48d
mov p1,a
acall l3
acall l2
sjmp back
jnb tf0, wait
clr p2.2
ret
CIRCUIT DIAGRAM:
1. Save the screenshot/Pictures of Program and output obtained and bring the same in next
lab.
Viva Questions:
1. How many rows and columns are present in a 16*2 alphanumeric LCD?
5. Which command of an LCD is used to shift the entire display to the right?
7. For reading operation from an LCD what changes in the software are introduced?
Evaluator’s Observation
EXPERIMENT NO.11:
AIM: To Develop an ALP to accept the external interrupt and to toggle the LED
mov r0,#0ffh
here1: mov r1,#0ffh
here: djnz r1,here
djnz r0,here1
ret
END
RESULT: An ALP is developed to accept the external interrupt and accordingly the LED’s were
made to toggle.
Evaluator’s Observation
EXPERIMENT NO.12:
AIM: To develop an 8051 ALP to interface the stepper motor using an 8051 controller in the
clockwise and anti-clockwise direction
PROGRAM:
ORG 0H
MOV A,#00110011B
LOOP1: MOV P2,A
ACALL DELAY
RL A;RR A ROTATE LEFT OR ROTATE RIGHT
SJMP LOOP1
DELAY: MOV R7,#0FFH
HERE2: MOV R6,#0FFH
HERE1: DJNZ R6,HERE1
DJNZ R7,HERE2
RET
END
OUTPUT:
Evaluator’s Observation
EXPERIMENT NO.13:
Project Review 1
Outcome: