Microprocessor and Microcontroller Laboratory
Microprocessor and Microcontroller Laboratory
ENGINEERING
II YEAR/ IV SEMESTER
REGULATION 2021
3
MARK SIGNATURE
S.No DATE NAME OF THE EXPERIMENT
10
11
12
13
Completed date:
4
EE3413 MICROPROCESSOR AND MICROCONTROLLER LABORATORY
LIST OF EXPERIMENTS
CYCLE-1
division.
order, Maximum / Minimum of numbers, Rotate instructions, Hex / ASCII / BCD code
conversions.
5. Displaying a moving/ rolling message in the student trainer kit’s output device.
CYCLE-2
multiplication/ division.
order, Maximum / Minimum of numbers, Rotate instructions, Hex / ASCII / BCD code
conversions.
10. Displaying a moving/ rolling message in the student trainer kit’s output device.
5
CONTENTS
7
1.A. 8 BIT ADDITION USING 8085
AIM:
ALGORITHM:
PROGRAM:
RESULT:
Thus the 8 bit numbers stored at two memory locations were added and the result was displayed.
8
1.B. 8 BIT SUBTRACTION USING 8085
AIM:
ALGORITHM:
OBSERVATION:
INPUT OUTPUT
RESULT:
Thus the 8 bit numbers stored at two memory locations were subtracted and the result was displayed.
9
1. C. 8 BIT MULTIPLICATION USING 8085
AIM:
To multiply two 8 bit numbers stored at two memory locations and store the result.
ALGORITHM:
1. Start the program.
2. Initialize memory pointer to data location.
3. Move multiplicand to a register.
4. Move the multiplier to another register.
5. Clear the accumulator.
6. Add multiplicand to accumulator
7. Decrement multiplier
8. Repeat step 5 till multiplier comes to zero.
9. The result, which is in the accumulator, is stored in a memory location.
10. Stop the program.
PROGRAM:
OBSERVATION:
INPUT OUTPUT
RESULT:
Thus the 8-bit multiplication was done in 8085 p using repeated addition method.
10
1. D. 8 BIT DIVISION USING 8085
AIM:
ALGORITHM:
450F LOOP 1 STA 5000 32,00,50 Store the remainder in the address 5000
4513 STA 5001 32,01,50 Store the quotient in the address 5000
OBSERVATION:
INPUT OUTPUT
RESULT:
Thus an ALP was written for 8-bit division using repeated subtraction method and executed using
8085 p kit.
11
2. A. 16 BIT ADDITION USING 8085
AIM:
To add two 16-bit numbers stored at memory locations and display the result.
ALGORITHM:
PROGRAM:
OBSERVATION:
INPUT OUTPUT
RESULT:
Thus an ALP program for 16-bit addition was written and executed in 8085 p using special
instructions.
12
2. B. 16 BIT SUBTRACTION USING 8085
AIM:
ALGORITHM:
OBSERVATION:
INPUT OUTPUT
RESULT:
Thus an ALP program for subtracting two 16-bit numbers was written and executed.
13
2. C. 16 BIT MULTIPLICATION USING 8085
AIM:
ALGORITHM:
OBSERVATION:
INPUT OUTPUT
RESULT:
Thus the 16-bit multiplication was done in 8085 p using repeated addition method.
14
2.D. 16 BIT DIVISION USING 8085
AIM:
To divide two 16-bit numbers and store the result in memory using 8085 mnemonics.
ALGORITHM:
1. Start the program.
2. Get the dividend and divisor.
3. Initialize the register for quotient.
4. Repeatedly subtract divisor from dividend till dividend becomes less than divisor.
5. Count the number of subtraction which equals the quotient.
6. Store the result in memory.
7. Stop the program.
PROGRAM:
OBSERVATION:
INPUT OUTPUT
RESULT:
Thus the 16-bit Division was done in 8085 p using repeated subtraction method.
15
3. A. SORTING IN ASCENDING ORDERUSING 8085
AIM:
To sort the given number in the ascending order using 8085 microprocessor.
ALGORITHM:
PROGRAM:
OBSERVATION:
INPUT OUTPUT
RESULT:
Thus the ascending order program is executed and thus the numbers are arranged in ascending
order.
16
3. B. SORTING IN DESCENDING ORDERUSING 8085
AIM:
To sort the given number in the descending order using 8085 microprocessor.
ALGORITHM:
1. Start the program.
2. Get the numbers to be sorted from the memory locations.
3. Compare the first two numbers and if the first number is smaller than second then
interchange the number.
4. If the first number is larger, go to step 5.
5. Repeat steps 2 and 3 until the numbers are in required order.
6. Stop the program.
PROGRAM:
OBSERVATION:
INPUT OUTPUT
RESULT:
Thus the descending order program is executed and thus the numbers are arranged in descending
order.
17
4.A. SEARCHING THE SMALLEST NUMBER USING 8085
AIM:
To find the smallest element in an array.
ALGORITHM:
1. Start the program.
2. Place all the elements of an array in the consecutive memory locations.
3. Fetch the first element from the memory location and load it in the accumulator.
4. Initialize a counter (register) with the total number of elements in an array.
5. Decrement the counter by 1.
6. Increment the memory pointer to point to the next element.
7. Compare the accumulator content with the memory content (next element).
8. If the accumulator content is smaller, then move the memory content (largest element) to the
accumulator. Else continue.
9. Decrement the counter by 1 and repeat steps 5 to 8 until the counter reaches zero
10. Store the result (accumulator content) in the specified memory location.
11. Stop the program.
PROGRAM:
OBSERVATION:
INPUT OUTPUT
RESULT:
Thus the smallest number in the given array is found out.
18
4. B. SEARCHING THE LARGEST NUMBER USING 8085
AIM:
To find the largest element in an array.
ALGORITHM:
1. Start the program.
2. Place all the elements of an array in the consecutive memory locations.
3. Fetch the first element from the memory location and load it in the accumulator.
4. Initialize a counter (register) with the total number of elements in an array.
5. Decrement the counter by 1.
6. Increment the memory pointer to point to the next element.
7. Compare the accumulator content with the memory content (nextelement).
8. If the accumulator content is smaller, then move the memory content(largest element) to the
accumulator. Else continue.
9. Decrement the counter by 1 and repeat steps 5 to 8 until the counter reaches zero
10. Store the result (accumulator content) in the specified memory location.
11. Stop the program.
PROGRAM:
OBSERVATION:
INPUT OUTPUT
RESULT:
Thus the largest number in the given array is found out.
19
5. A. ASCII TO DECIMAL CONVERSION USING 8085
AIM:
To convert the given ASCII value to decimal number.
ALGORITHM:
4100 LXI H,4150 21,50,41 Load the immediate data to BC register pair
OBSERVATION:
INPUT OUTPUT
RESULT:
Thus an ALP program for conversion of ASCII to decimal was written and executed.
20
5. B. BCD TO HEXA CONVERSION USING 8085
AIM:
To convert the given BCD value to Hexadecimal number.
ALGORITHM:
1. Start the program.
2. Load the immediate data to BC register pair
3. Move the content of memory to accumulator
4. Add the content of A with A and store the result in accumulator
5. Move the content of accumulator to B register
6. Add the content of A with A and store the result in accumulator
7. Add the content of A with A and store the result in accumulator
8. Add the content of B register with A and store the result in accumulator
9. Increment the HL register pair
10. Add the content of memory with A and store the result in accumulator
11. Increment the HL register pair and move the content of accumulator to memory
12. Stop the program
PROGRAM:
ADDRESS LABEL MNEMONICS OPCODE COMMENTS
4100 LXI H,4150 21,50,41 Load the immediate data to BC register pair
4103 MOV A,M 7E Move the content of memory to accumulator
Add the content of A with A and store the result
4104 ADD A 87
in accumulator
4105 MOV B,A 47 Move the content of accumulator to B register
Add the content of A with A and store the result
4106 ADD A 87
in accumulator
Add the content of A with A and store the result
4107 ADD A 87
in accumulator
Add the content of B register with A and store
4108 ADD B 80
the result in accumulator
4109 INX H 23 Increment the HL register pair
Add the content of memory with A and store the
410A ADD M 86
result in accumulator
410B INX H 23 Increment the HL register pair
410C MOV M,A 77 Move the content of accumulator to memory
410D HLT 76 End the program
OBSERVATION:
INPUT OUTPUT
RESULT:
Thus an ALP program for conversion of BCD value to Hexadecimal number was written and
executed.
21
6. A INTERFACING A/D AND D/A CONVERTER WITH 8085
AIM:
To write an assembly language program to convert an analog signal into a digital signal
and a digital signal into an analog signal using an ADC interfacing and DAC interfacing
respectively.
ADC INTERFACING WITH 8085
PROBLEM STATEMENT:
To program starts from memory location 4100H. The program is executed for various
values of analog voltage which are set with the help of a potentiometer. The LED display is
verified with the digital value that is stored in the memory location 4150H.
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 is complete. The
following program initiates the conversion process, checks the EOC pin of ADC 0419 as to
whether the conversion is over and then inputs the data to the processor. It also instructs the
processor to store the converted digital data at RAM 4200H.
ALGORITHM:
1. Select the channel and latch the address.
2. Send the start conversion pulse.
3. Read EOC signal.
4. If EOC =1 continue else go to step (3)
5. Read the digital output.
6. Store it in a memory location.
ADC CIRCUIT:
22
PROGRAM:
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 (Hex) as input, the output is +5V. Outputting digital data 00 and FF at
regular intervals, to DAC2, results in a square wave of amplitude I5 Volts
23
ALGORITHM:
1. Load the initial value (00) to Accumulator and move it to DAC.
2. Call the delay program
3. Load the final value (FF) to accumulator and move it to DAC.
4. Call the delay program.
5. Repeat steps 2 to 5.
PROGRAM:
24
(c) TRIANGULAR WAVE GENERATION:
ALGORITHM:
1. Load the initial value (00) to Accumulator.
2. Move the accumulator content to DAC
3. Increment the accumulator content by 1.
4. If accumulator content is zero proceed to next step. Else go to step 3.
5. Load value (FF) to accumulator.
6. Move the accumulator content to DAC.
7. Decrement the accumulator content by 1.
8. If accumulator content is zero go to step 2. Else go to step 2.
The following program will generate a triangular wave at DAC2 output.
PROGRAM:
DAC CIRCUIT:
25
WAVEFORMS:
OBSERVATION:
RESULT:
Thus the conversion of an analog signal into a digital signal and a digital signal into an
analog signal was done using interfacing of ADC and DAC respectively with 8085.
26
7.B TRAFFIC LIGHT CONTROLLER WITH 8085
AIM
To write an assembly language program to simulate the traffic light at an intersection
using a traffic light interface.
ALGORITHM:
1. Initialize the ports.
2. Initialize the memory content, with some address to the data.
3. Read data for each sequence from the memory and display it through the ports.
4. After completing all the sequences, repeat from step2.
A SAMPLE SEQUENCE:
1. (a) Vehicles from south can go to straight or left.
(b) Vehicles from west can cross the road.
(c) Each pedestrian can cross the road.
(d) Vehicles from east no movement.
(e) Vehicles from north, can go only straight.
2. All ambers are ON, indicating the change of sequence.
3. (a) Vehicles from east can go straight and left.
(b) Vehicles from south, can go only left.
(c) North pedestrian can cross the road.
(d) Vehicles from north, no movement.
(e) Vehicles from west, can go only straight.
4. All ambers are ON, indicating the change of sequence.
5. (a) Vehicles from north can go straight and left.
(b) Vehicles from east, can go only left.
(c) West pedestrian can cross the road.
(d) Vehicles from west, no movement.
(e) Vehicles from south, can go only straight.
6. All ambers are ON, indicating the change of sequence.
7. (a) Vehicles from west can go straight and left.
(b) Vehicles from north, can go only left.
(c) South pedestrian can cross the road.
(d) Vehicles from south, no movement.
(e) Vehicles from east, can go only straight.
8. All ambers are ON, indicating the change of sequence.
27
9. (a) All vehicles from all directions no movement.
(b) All pedestrian can cross the road.
BIT ALLOCATION:
PATH REPRESENTATION:
28
29
30
RESULT:
Thus an assembly language program to simulate the traffic light at an intersection using a
traffic light interfaces was written and implemented.
31
8051 MICROCONTROLLER
32
9A. 8-BIT ADDITION
AIM:
To write a program to add two 8-bit numbers using 8051 microcontroller and also to
verify the result.
APPARATUS REQUIRED:
ALGORITHM:
33
OBSERVATION:
OUTPUT
MEMORY LOCATION DATA
RESULT:
Thus the 8051 ALP for addition of two 8 bit numbers is executed and the result is
verified.
34
9.B. 8-BIT SUBTRACTION
AIM:
To perform subtraction of two 8 bit data using the 8051 microcontroller and store the
result in memory.
APPARATUS REQUIRED:
ALGORITHM:
PROGRAM:
35
OBSERVATION:
OUTPUT
MEMORY LOCATION DATA
RESULT:
Thus the 8051 ALP for subtraction of two 8 bit numbers is executed and the result is
verified.
36
9.C. 8-BIT MULTIPLICATION
AIM:
To perform multiplication of two 8 bit data using 8051 microcontroller and to store the
result in memory.
APPARATUS REQUIRED:
ALGORITHM:
PROGRAM:
Data1:04
Data 2:02
37
OBSERVATION:
OUTPUT
MEMORY LOCATION DATA
4500 08
4501 00
RESULT:
Thus the 8051 ALP for multiplication of two 8 bit numbers is executed and the result is
verified.
38
9.D. 8-BIT DIVISION
AIM:
To perform division of two 8 bit data using 8051 microcontroller and to store the result in
memory.
APPARATUS REQUIRED:
ALGORITHM:
PROGRAM:
Data 1: 08
Data 2 :02
39
OBSERVATION:
OUTPUT
MEMORY LOCATION DATA
4500 (remainder) 00
4501 (quotient) 04
RESULT:
Thus the 8051 ALP for division of two 8 bit numbers is executed and the result is
verified.
40
10.A. INCREMENT / DECREMENT OPERATION
AIM:
Writing an assembly language program to demonstrate the increment and decrement operations using the
8051 microcontroller.
APPARATUS REQUIRED:
1. Start.
2. Initialize a register (e.g., register A) with an initial value of 0.
3. Implement a loop to continuously increment the register value until it reaches the maximum value of
20.
4. Within the loop:
• Use the INC instruction to increment the register value by 1.
• Perform desired operations with the incremented value.
5. Check if the register value has reached the maximum value of 20 using conditional branching
instructions.
6. If the maximum value is reached, implement a loop to continuously decrement the register value
until it reaches the minimum value of 0.
7. Within the loop:
• Use the DEC instruction to decrement the register value by 1.
• Perform desired operations with the decremented value.
8. Repeat the process indefinitely to create a continuous loop.
9. .Stop.
PROGRAM:
41
0002H 04 LOOP_INCREMENT INC A Increment the
value of A
0003H ; Perform operation with A
0004H B4 FD 14 CJNE A, #14H, Continue
LOOP_INCREMENT looping until A
reaches 14H
OUTPUT:
- - - -
RESULT:
42
The output values correspond to the incremented and decremented values of register A in
the 8051 microcontroller program, with the initial input value being 00H and the maximum
value being 14H.The output was verified.
APPARATUS REQUIRED:
ALGORITHM
1. Start.
2. Initialize register A with 00H and register B with 01H.
3. Implement a loop for ascending operation:
• Increment the value of register A by 1.
• Perform desired operations with register A if needed.
• Continue the loop until register A reaches 20H.
4. Implement a loop for descending operation:
• Decrement the value of register A by 1.
• Perform desired operations with register A if needed.
• Continue the loop until register A reaches 00H.
5. Repeat the process indefinitely.
6. Stop.
PROGRAM:
ASCENDI
0005H Ascending loop label
NG
0005H 05 INC A Increment value of A
Perform operations with A if
0006H
needed
43
CJNE A, #20H, Continue loop until A reaches
0007H B4 FB 05
ASCENDING 20H
LOOP_DE AJMP
000AH 02 Jump to descending loop
SC DESCENDING
DESCEND
000BH Descending loop label
ING
000BH 05 DEC A Decrement value of A
Perform operations with A if
000CH
needed
CJNE A, #00H, Continue loop until A reaches
000DH B4 F8 0BH
DESCENDING 00H
Jump back to the start of the
0010H 80 F4 SJMP START
program
OUTPUT:
Memory Address" column represents the memory address where the input or output value is stored.
"Input Values" column represents the values of register A before any operation is performed.
"Memory Address" column represents the memory address where the next operation takes place.
"Output Values" column represents the values of register A after the operation is performed.
RESULT:
44
10.C. MAXIMUM / MINIMUM NUMBERS OPERATION
AIM:
To demonstrate program and determine the maximum and minimum numbers among the
given input values using the 8051 microcontroller.
APPARATUS REQUIRED:
ALGORITHM
4. Load register A with the value from register R7 to find the maximum number.
6. Move the value from register R7 to the program status word (PSW).
8. Load register A with the value from register R7 to find the minimum number.
10. Move the value from register R7 to the program status word (PSW).
0008H
LOOP_MI Load register A with register
0009H 7F MOV A, R7
N R7
Move value from register A to
000AH FE MOV R7, A
R7
Move value from register R7 to
000BH 8C MOV PSW, R7
PSW
000CH END End of program
This table represents an assembly language program for the 8051 microcontroller that demonstrates
maximum and minimum number operations. The program initializes register A with 00H and register B with
01H, then loads register A with register R7 for maximum number operation and loads register A with register
R7 for minimum number operation. Finally, it ends the program.
OUTPUT:
Memory Address" column represents the memory address where the input or output value is stored.
"Input Values" column represents the values of registers or memory locations before any operation is
performed.
"Memory Address" column represents the memory address where the next operation takes place.
"Output Values" column represents the values of registers or memory locations after the operation is
performed.
RESULT:
The program effectively determines the maximum and minimum values among the provided input values
using the 8051 microcontroller.
46
10.D. ROTATE INSTRUCTIONS
AIM:
To demonstrate rotate instructions (RLC and RRC) using the 8051 microcontroller.
APPARATUS REQUIRED:
ALGORITHM
7. Decrement register B.
PROGRAM:
47
0007H 74 05H MOV A, #05H Load accumulator with 05H
Rotate accumulator right
0009H 01 RRC A
through carry
Perform additional operations
000AH
if needed
000BH END End of program
This table represents an assembly language program for the 8051 microcontroller that demonstrates rotate
instructions. The program loads accumulator A with 55H and register B with 03H, then performs rotate left
through carry (RLC) operation on accumulator A and rotate right through carry (RRC) operation on
accumulator A. Finally, it ends the program.
OUTPUT:
Memory Address" column represents the memory address where the input or output value is stored.
"Input Values" column represents the values of registers or memory locations before any operation is
performed.
"Memory Address" column represents the memory address where the next operation takes place.
"Output Values" column represents the values of registers or memory locations after the operation is
performed.
RESULT:
The program successfully performs rotate left through carry (RLC) and rotate right through carry (RRC)
operations on given input values using the 8051 microcontroller.
48
10.E. Hex / ASCII / BCD code .
AIM:
To demonstrate hex to ASCII conversion using the 8051 microcontroller ,and also to verify the
result.
APPARATUS REQUIRED:
ALGORITHM:
1. Start the program.
7. Decrement register R5 and jump back to the loop if it's not zero.
PROGRAM:
49
0007H END End of program
OUTPUT:
In this table:
The "Input Values" column represents the initial values present in memory or registers before any operation is
performed.
For this particular program, the input value is the hexadecimal value '41H' stored in memory location 0004H.
The "Output Values" column represents the values after the specified operations are executed. In this case, it's
the ASCII representation of the input value, which is 'A' stored in memory location 0006H.
Result :
The program successfully converts the hexadecimal value '41H' to its corresponding ASCII
representation 'A' using the 8051 microcontroller and also the result is verified.
50
10.F. BCD code Conversion .
AIM:
To demonstrate BCD to binary conversion using the 8051 microcontroller also to verify the
result.
APPARATUS REQUIRED:
ALGORITHM:
9. Start the program.
15. Decrement register R5 and jump back to the loop if it's not zero.
PROGRAM:
51
OUTPUT:
0000H - 0000H -
0002H - 0002H -
0006H - 0006H -
In this table:
The "Memory Address" column represents the memory address where the input or output value is stored.
The "Input Values" column represents the initial values present in memory or registers before any operation is
performed. In this case, there are no input values specified.
The "Output Values" column represents the values of registers or memory locations after the operation is
performed. In this case, it represents the output values after the BCD to binary conversion operation.
Result :
The program successfully converts the BCD value 78H to its binary representation.
52
11.A. INTERFACING STEPPER MOTOR CONTROL USING 8051
AIM:
To interface a stepper motor with 8051 microcontroller and operate it.
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 step-wise manner from one equilibrium position to the
next. Stepper Motors are used very wisely in position control systems like printers, disk drives, process
control machine tools, etc.
The basic two-phase stepper motor consists of two pairs of stator poles. Each of the four poles
has its own winding. The excitation of any one winding generates a North Pole. A South Pole gets
induced at the diametrically opposite side. The rotor magnetic system has two end faces. It is a
permanent magnet with one face as South Pole and the other as North Pole.
The Stepper Motor windings A1, A2, B1, and B2 are cyclically excited with a DC current to run
the motor in clockwise direction. By reversing the phase sequence as A1, B2, A2, B1, anticlockwise
stepping can be obtained.
BLOCK DIAGRAM:
ANTICLOCKWISE CLOCKWISE
53
ADDRESS DECODING LOGIC:
The 74138 chip is used for generating the address decoding logic to generate the device select
pulses; CS1 & CS2 for selecting the IC 74175.The 74175 latches the data bus to the stepper motor
driving circuitry.
Stepper Motor requires logic signals of relatively high power. Therefore, the interface circuitry that
generates the driving pulses uses silicon Darlington pair transistors. The inputs for the interface circuit are
TTL pulses generated under software control using the Microcontroller Kit. The TTL levels of pulse
sequence from the data bus are translated to high voltage output pulses using a buffer 7407 with open
collector.
PROCEDURE:
Enter the above program starting from location 4100.and execute the same. The stepper motor
rotates. Varying the count at R4 and R5 can vary the speed. Entering the data in the look-up TABLE in the
reverse order can vary direction of rotation.
54
PROGRAM:
RESULT:
Thus a stepper motor was interfaced with 8051 and run in forward and reverse directions at
various
speeds.
40
11.B. INTERFACING DAC WITH 8051
AIM:
To interface DAC with 8051 to demonstrate the generation of square wave, triangular
wave and sawtooth wave
APPARATUS REQUIRED:
ALGORITHM:
41
WAVEFORMS:
PROGRAM:
42
4107 LCALL DELAY Call delay
43
4107 MOV A,#FF Load FF A
RESULT:
Thus the square, triangular and saw tooth wave form were generated by interfacing
DAC with 8051 trainer kit.
44
11.C. TRAFFIC LIGHT CONTROLLER - INTERFACING WITH 8051
AIM:
To design traffic light controller using 8051 microcontroller
APPARATUS REQUIRED:
8051 kit, DC regulated power supply, Traffic light controller interface board.
PROGRAM:
ADDRESS OPCODES LABEL MNEMONICS OPERAND COMMENTS
0000H START Entry point of the program
Initialize GPIO ports for traffic
0000H
lights
Load accumulator with initial
0000H 74 FFH MOV A, #FFH #FFH
signal
Move accumulator data to
0002H 8E MOV P1, A
GPIO port P1
0003H Loop for traffic light sequence
0003H RED_ON Red light ON
Load accumulator with red
0003H 74 80H MOV A, #80H #80H
light signal
Move accumulator data to
0005H 8E MOV P1, A
GPIO port P1
0006H Delay for red light
(Implement appropriate delay
0006H
subroutine)
YELLOW
0010H Yellow light ON
_ON
Load accumulator with yellow
0010H 74 40H MOV A, #40H #40H
light signal
Move accumulator data to
0012H 8E MOV P1, A
GPIO port P1
0013H Delay for yellow light
(Implement appropriate delay
0013H
subroutine)
GREEN_
0018H Green light ON
ON
Load accumulator with green
0018H 74 20H MOV A, #20H #20H
light signal
Move accumulator data to
001AH 8E MOV P1, A
GPIO port P1
001BH Delay for green light
(Implement appropriate delay
001BH
subroutine)
0020H 1B DEC R3 Decrement loop counter
Jump back to loop until
0021H D5 DJNZ R3, LOOP LOOP
counter is zero
45
This table outlines an assembly language program for a traffic light controller interfaced with the 8051
microcontroller. It initializes the GPIO ports for the traffic lights, sequences through the red, yellow, and
green lights with appropriate delays, and repeats the sequence for a specified number of times before ending
the program.
ALGORITHM:-
1. Start.
2. Initialize the GPIO ports for the traffic lights.
3. Set the initial signal to activate all the lights (e.g., FFH).
4. Enter a loop for the traffic light sequence.
5. Turn on the red light.
6. Wait for a predetermined time (e.g., delay for red light).
7. Turn off the red light.
8. Turn on the yellow light.
9. Wait for a predetermined time (e.g., delay for yellow light).
10. Turn off the yellow light.
11. Turn on the green light.
12. Wait for a predetermined time (e.g., delay for green light).
13. Turn off the green light.
14. Decrement a loop counter.
15. If the loop counter is not zero, jump back to step 4 to repeat the sequence.
16. End the program.
OUTPUT:
46
0022H N/A 0022H End of program
This table represents the sequence of traffic light signals outputted by the program at different memory
addresses during its execution. The input values column is not applicable (N/A) as there are no explicit
input values in this scenario.
RESULT:
The program effectively controls the sequence of traffic lights, simulating a traffic light system using
8051 microcontroller .
47
12 . DISPLAYING A MOVING/ ROLLING MESSAGE USING 8051
AIM:
To display a moving/rolling message "WELCOME" using the 8051 microcontroller.
APPARATUS REQUIRED:
8051 kit, DC regulated power supply, Traffic light controller interface board.
PROGRAM:
ADDRESS OPCODES LABEL MNEMONICS OPERAND COMMENTS
0000H START Entry point of the program
Initialize memory locations for
0000H
message
Load accumulator with ASCII
0000H 74 57H MOV A, #57H #57H
code for 'W'
Initialize starting position on
0002H 75 00H MOV P0, #00H #00H
display
Loop for displaying the moving
0004H LOOP
message
Move current display position to
0004H E6 MOV A, P0
A
Move character from A to
0005H F6 MOV @R0, A
current display
0006H 04 INC A Increment display position
0007H 75 F0H MOV P0, #F0H #F0H Move display position leftwards
0009H A3 INC R0 Increment memory pointer
Check if end of message, skip if
000AH B4 07H CJNE R0, #07H, SKIP #07H
not
000CH 80 F6H SJMP LOOP Jump back to loop
000EH SKIP Skip point if end of message
Reset memory pointer to
000EH A3 MOV R0, #00H #00H
beginning
0010H END End of program
This table outlines an assembly language program for displaying a moving/rolling message "WELCOME" using
the 8051 microcontroller. It initializes the memory locations with the characters of the message, then
continuously moves the message across the display.
ALGORITHM:-
1. Start.
2. Initialize the memory locations with the ASCII codes for each character of the message "WELCOME".
3. Set the starting position on the display to the first character of the message.
4. Enter a loop to continuously display the moving message.
5. Move the current display position to the accumulator.
48
6. Move the character from the memory location pointed by the memory pointer to the current display
position.
7. Increment the display position to move the message.
8. Move the display position leftwards to create the effect of a moving message.
9. Increment the memory pointer to point to the next character of the message.
10. Check if the end of the message has been reached.
11. If not, repeat the loop by jumping back to step 4.
12. If the end of the message has been reached, reset the memory pointer to the beginning of the message.
13. End the program.
OUTPUT:
RESULT:
The program successfully displays the message "WELCOME" in a rolling fashion on the display using
8051 microcontroller .
49
13 . PROGRAMMING PIC ARCHITECTURE WITH SOFTWARE TOOLS.
Aim:
To create an assembly language program for a PIC microcontroller using MPLAB X IDE that blinks an
LED connected to pin RB0 in a continuous loop.
APPARATUS REQUIRED:
ALGORITHM
1. Initialize the microcontroller and configure the I/O pins.
2. Set the direction of the pin connected to the LED as output.
3. Enter a loop to continuously toggle the state of the LED.
4. Turn the LED on by setting the corresponding pin high.
5. Implement a delay to control the blinking rate.
6. Turn the LED off by setting the pin low.
7. Implement another delay.
8. Repeat the loop indefinitely.
PROGRAM:
ADDRESS OPCODES LABEL MNEMONICS OPERAND COMMENTS
0000h Start of program memory
0000h START Start of main program
0000h BANKSEL TRISB Select bank for TRISB register
0001h 0186 BSF TRISB,0 Set RB0 pin as output
0003h LOOP Start of loop
0003h 0185 BSF PORTB,0 Turn on LED connected to RB0
0005h CALL DELAY Call delay subroutine
0006h 0184 BCF PORTB,0 Turn off LED connected to RB0
0008h CALL DELAY Call delay subroutine
0009h 2802 GOTO LOOP Jump to LOOP
000Bh DELAY Start of delay subroutine
000Bh 3000 MOVLW 0xFF Load W register with delay count
50
000Dh 00FE MOVWF COUNT Move W to COUNT register
000Fh DELAY_L Start of delay loop
OOP
000Fh 18FF DECFSZ COUNT,F Decrement COUNT
0011h 280C GOTO DELAY_LOOP Continue loop if COUNT is not
zero
0013h 0009 RETURN Return from subroutine
End of program
This table provides a structured representation of the assembly language program for the PIC
microcontroller, including memory addresses, opcodes, labels, mnemonics, operands, and comments.
RESULT :
The result of the assembly language program execution is the LED connected to pin RB0 blinking on and
off repeatedly, indicating successful program execution.
51
8085 OPCODE SHEET
52
53
54
55
56