Microprocessor & Microcontroller Lab
EXPERIMENT NO:-01
Name of the Experiment:- Hexadecimal addition of two 8-bits number.
Aim:- To write an Assembly Language Program for addition of two 8-bit
hexadecimal number using Microprocessor Kit.
Apparatus Required:- 8085 Microprocessor Kit.
Description:- The program execute from 2000, taken the content of 2501 adds it
to 2502 and store the result at 2503.
PROGRAM:-
Memory Machine Mnemonics Operands Comments
Address Code
2000 21,01,25 LXI H,2501 H Get address of 1st
number in H-L pair
2003 7E MOV A,M 1st number in
Accumulator
2004 23 INX H Increment content of
H-L pair
2005 86 ADD M Add 1st and 2nd
number
2006 32,03,25 STA 2503 H Store sum in 2503 H
2009 76 HLT Stop
DATA:-
2501--- 49 H
2502--- 56 H
The sum is stored in the memory location 2503H
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
Result:-
2503--- 9F H
The Assembly Language Program for two 8-bits addition of the number was
executed successfully by using 8085 Microprocessor Kit .
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
EXPERIMENT NO:-02
Name of the Experiment:- Hexadecimal subtraction of two 8-bits number.
Aim:- To write an Assembly Language Program for subtraction of two 8-bit
hexadecimal number using Microprocessor Kit.
Apparatus Required:- 8085 Microprocessor Kit.
Description:- The program execute from 2000, taken the content of 2501
subtracts it to 2502 and store the result at 2503.
PROGRAM:-
Memory Machine Mnemonics Operands Comments
Address Code
2000 21,01,25 LXI H,2501 H Get address of 1st
number in H-L pair
2003 7E MOV A,M 1st number in
Accumulator
2004 23 INX H Content of H-L pair
increases from 2501 to
2502 H
2005 96 SUB M 1st Number -2nd
number
2006 23 INX H Content of H-L pair
becomes 2503 H
2007 77 MOV M,A Store result in 2503 H
2008 76 HLT Halt
DATA:-
2501--- 49 H
2502--- 32 H
The sum is stored in the memory location 2503H
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
Result:-
2503--- 17 H
The Assembly Language Program for two 8-bits subtraction of the
number was executed successfully by using 8085 Microprocessor Kit.
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
EXPERIMENT NO:-03
Name of the Experiment:- Write an ALP to find the largest number in an data
array.
Aim:- To write an Assembly Language Program to find the largest number in
given data using Microprocessor Kit.
Apparatus Required:- 8085 Microprocessor Kit.
Description:- The program execute from 2000, taken the content of
2500,2501,2502,2503 compare and finds the largest number and store the result at
2450.
PROGRAM:-
Memory Machine Labels Mnemonics Operands Comments
Address Code
2000 21, 00, 25 LXI H,2501 H Address for
count in H-L
pair
2003 4E MOV C,M Count in
register C
2004 23 INX H Address of 1st
number in H-L
pair
2005 7E MOV A,M 1st Number in
accumulator
2006 0D DCR C Decrement
count
2007 23 LOOP INX H Address of next
number
2008 BE CMP M Compare next
number with
previous
maximum. Is
next number >
previous
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
maximum?
2009 D2, 0D,20 JNC AHEAD No, larger
number is in
accumulator.
Go to the lable
AHEAD
200C 7E MOV A, M Yes, get larger
number in
accumulator.
200D 0D AHEAD DCR C Decrement
count.
200E C2, 07, 20 JNZ LOOP
2011 32, 50, 24 STA 2450 H Store result in
2450 H.
2014 76 HLT Stop
DATA:-
2500--- 03
2501--- 98
2502--- 75
2503--- 99
Result:-
2450--- 99
The Assembly Language Program to find the largest number was executed
successfully by using 8085 Microprocessor Kit.
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
EXPERIMENT NO:-04
Name of the Experiment:- Write an ALP to arrange the number of data array in
ascending order.
Aim:- To write an Assembly Language Program to arrange the number in
ascending order in given data using Microprocessor Kit.
Apparatus Required:- 8085 Microprocessor Kit.
Description:- The program execute from 2000, taken the content of
2501,2502,2503,2504,2505 compare and arrange the number in ascending order.
PROGRAM:-
Memory Machine Labels Mnemonics Operands Comments
Address Code
2000 21, 00, 25 LXI H,2500 Address for
count.
2003 4E MOV C,M Count for
number of
passes in
register C.
2004 21, 00,25 BACK LXI H, 2500
2007 56 MOV D,M Count for
number of
comparisions in
register D.
2008 23 INX H
2009 7E MOV A, M 1st number in
accumulator
200A 23 LOOP INX H Address for
next number
200B 46 MOV B, M Next number in
register B.
200C B8 CMP B Compare next
number with
previous
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
greatest
number.
200D D2, 16,20 JNC AHEAD If previous
greatest number
> next number,
go to AHEAD
2010 2B DCX H
2011 77 MOV M, A Place smaller of
the two
compared
numbers in
memory.
2012 78 MOV A, B Place greater of
the two
numbers in
accumulator.
2013 C3, 18, 20 JMP GO
2016 2B AHEAD DCX H
2017 70 MOV M, B Place smaller of
the two
compared
numbers in
memory.
2018 23 GO INX H
2019 15 DCR D Decrease the
count for
comparisons
201A C2, 0A,20 JNZ LOOP
201D 77 MOV M, A Place the
greatest number
after address
pass in the
memory.
201E 0D DCR C Decrease the
count for passes
201F C2, 04, 20 JNZ BACK
2022 76 HLT Stop
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
DATA:- Result:-
2501--- 60 15
2502--- 40 25
2503--- 50 40
2504--- 15 50
2505--- 25 60
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
EXPERIMENT NO:-05
Name of the Experiment:- Write an ALP for hexadecimal multiplication of two
8-bits number.
Aim:- To write an Assembly Language Program for multiplication of two 8-bits
hexadecimal number using Microprocessor Kit.
Apparatus Required:- 8085 Microprocessor Kit.
Description:- The program execute from 2000, taken the content of 2501, 2502,
2503 multiply the data and store the result at 2504 and 2505.
PROGRAM:-
Memory Machine Labels Mnemonics Operands Comments
Address Code
2000 2A, 01, 25 LHLD 2501H Get
multiplicand in
H-L pair.
2003 EB XCHG Multiplicand in
D-E pair.
2004 3A, 03, 25 LDA 2503 H Multiplier in
accumulator
2007 21, 00, 00 LXI H, 0000 Initial value of
product=00 in
H-L pair.
200A 0E, 08 MVI C, 08 Count=8 in
register C.
200C 29 LOOP DAD H Shift partial
product left by1
bit.
200D 17 RAL Rotate
multiplier left 1
bit. Is
multiplier’s bit
= 1?
200E D2, 12, 20 JNC AHEAD No, go to
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
AHEAD.
2011 19 DAD D Product =
Product +
Multiplicand
2012 0D AHEAD DCR C Decrement
count.
2013 C2, 0C, 20 JNZ LOOP
2016 22, 04, 25 SHLD 2504 H Store result.
2019 76 HLT Stop
DATA:-
2501--- 84 H, LSBs of multiplicand.
2502--- 00, MSBs of multiplicand .
2503--- 56 H, Multiplier.
Result:-
2504--- 58 H, LSBs of product
2505--- 2C H, MSBs of product
The Assembly Language Program for two 8-bits multiplication of the number was
executed successfully by using 8085 Microprocessor Kit.
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
EXPERIMENT NO:-06
Name of the Experiment:- Write a program in assembly language to generate
1KHz square wave on port line of 8051.
Aim:- The main aims of this interfacing using microcontroller is to generate square
wave .
Apparatus Required:-
1. 8051 Microcontroller kit
2. 8- Bit Digital to Analog Converter Interface Board
3. Power Supply
4. Cables
5. CRO
Procedure:-
1. Enter the opcodes from 4100
2. Execute the program.
3. Obtain square waveforms by encoding program and observing the output in
an oscilloscope.
PROGRAM:-
Address Opcode Comment Mnemonic Operands
4100 90 FF C8 MOV DPTR,
#0FFC8H
4103 74 00 START MOV A,#00H
4105 F0 MOVX @ DPTR, A
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
4106 12 41 12 LCALL DELAY
4109 74 FF MOV A,#0FFH
410B F0 MOVX @DPTR,A
410C 12 41 12 LCALL DELAY
410F 02 41 03 LJMP START
4112 79 05 DELAY: MOV R1,#05H
4114 7A FF LOOP: MOV R2,#0FFH
4116 DA FE HERE: DJNZ R2,HERE
4118 D9 FA DJNZ R1,LOOP
411A 22 RET
411B 80 E6 SJMP START
Result:-
The above assembly language program is encoded in the 8051-microcontroller, the
square waveform is obtained at DAC-2.
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
EXPERIMENT NO:-07
Name of the Experiment:- Write a program in assembly language to display
message on LCD display..
Aim:- The main aims of this interfacing using microcontroller is to display the
rolling message “HELP US” in the display.
Apparatus Required:-
1. 8051 Microcontroller kit
2. 8279 Interface Board
3. Power Supply
4. Cables
Procedure:-
1. Enter the opcodes from 4100
2. Execute the program.
3. Observe the output in the display after execution program.
PROGRAM:-
Address Opcode Comment Mnemonic Operands
4100 90 FF C2 START: MOV DPTR,#FFC2
4103 78 00 MOV R0,#00
4105 79 44 MOV R1,#44
4107 74 10 MOV A,#10
4109 F0 MOVX @DPTR,A
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
410A 74 CC MOV A,#CC
410C F0 MOVX @DPTR,A
410D 74 90 MOV A,#90
410F F0 MOVX @DPTR,A
4110 89 83 LOOP: MOV DPH,R1
4112 88 82 MOV DPL,R0
4114 E0 MOVX A,@DPTR
4115 90 FF C0 MOV DPTR,#FFC0
4118 F0 MOVX @DPTR,A
4119 12 45 00 LCALL DELAY
411C 08 INC R0
411D B8 0F F0 CJNE R0,#0F,LOOP
4120 02 81 00 LJMP START
LOOK-UP TABLE FOR ROLLING DISPLAY “HELP US”:-
Address Opcode Comment Mnemonic Operands
4400 FF FF FF FF
4404 FF FF FF FF
4408 98 68 7C C8
440C FF 1C 29 FF DELAY:
SUBROUTINE:
4500 7C A0 MOV R4,#A0
4502 7D FF LOOP2: MOV R5,#FF
4504 00 LOOP1: NOP
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
4505 DD FD DJNZ R5,LOOP1
4507 DC F9 DJNZ R4,LOOP2
4509 22 RET
Result:-
The above assembly language programs are encoded in the microcontroller for
display consisting “HELP US” in the LCD display which is interfaced with the
8051 microcontroller.
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
EXPERIMENT NO:-08
Name of the Experiment:- Write a program in assembly language to rotate
stepper motor in clockwise direction.
Aim:- To run a stepper motor at different speed in clockwise direction using an
Assembly language program.
Apparatus Required:-
1. 8051 Microcontroller kit
2. Stepper Motor
3. Stepper Motor Interface Board
4. Power Supply
5. Cables
Procedure:-
1. Enter the opcodes from 4100 and the data from 412C.
2. Execute the program.
3. Obtain different speed of stepper motor by varying the values in location
411B and 411D.
PROGRAM:-
Address Opcode Comment Mnemonic Operands
4100 7C CA START : MOV R4, #05
4102 90 41 14 MOV DPTR,#LOOKUP
4105 78 04 JO: MOV R0, #04
4107 E0 MOVX A, @DPTR
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
4108 C0 83 PUSH DPH
410A C0 82 PUSH DPL
410C 90 FF C0 MOV DPTR, #FFC0H
410F F0 MOVX @DPTR, A
4110 DC 06 DJNZ R4, CALL
4112 80 FE HLT: SJMP HLT
4114 09 05 06 0A LOOKUP: DB 09H, 05H, 06H,
0AH
4118 7A 03 CALL: MOV R2, #03
411A 79 FF DLY2: MOV R1, #FFH
411C 7B FF DLY1: MOV R3, FFH
411E DB FE DLY: DJNZ R3, DLY
4120 D9 FA DJNZ R1, DLY1
4122 DA F6 DJNZ R2, DLY2
4124 D0 82 POP DPL
4126 D0 83 POP DPH
4128 A3 INC DPTR
4129 D8 DC DJNZ R0, JO
412B 80 D5 SJMP START
412D END
Result:-
Enter the above program starting from location 4100. Execute the same. The
Stepper motor rotates. Speed can be varied by varying the opcode of location
4112B and 411D.
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
EXPERIMENT NO:-09
Name of the Experiment:- Write a program in assembly language to read ADC.
Aim:- The main aims of this interfacing using microcontroller is to convert analog
data into digital data.
Apparatus Required:-
1. 8051 Microcontroller kit
2. 16-Channel 8-Bit Analog to Digital Converter Interface Board
3. Power Supply
4. Cables
Procedure:-
1. Place jumper J2 in C position.
2. Place jumper J5 in A position.
3. Enter the assembly program and execute it.
4. Vary the analog input (using trimpot) and view the corresponding digital
value in the LED display after execution of program.
PROGRAM:-
Address Opcode Comment Mnemonic Operands
4100 90 FF C8 CHANNEL MOV DPTR,#FFC8
SELECTION
4103 74 10 AND ALE MOV A,#10
LOW
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
4105 F0 MOVX @ DPTR, A
4106 74 18 ALE HIGH MOV A,#18
4108 F0 MOVX @DPTR,A
4109 74 10 ALE LOW MOV A,#10
410B F0 MOVX @DPTR,A
410C 80 FE HERE JMP HERE
Result:-
The above assembly language program is encoded in the 8051-microcontroller, the
analog to digital data conversion is shown in ADC interface board.
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
EXPERIMENT NO:-10
Name of the Experiment:- Write a program in assembly language to control the
traffic light system.
Aim:- To control a traffic light system using interfaced with microcontroller.
Apparatus Required:-
1. 8051 Microcontroller kit
2. Traffic light system
3. Power Supply
4. Cables
Procedure:-
1. Enter the opcodes from 4100 and the data from 41A4.
2. Execute the program
PROGRAM:-
Address Opcode Comment Mnemonic Operands
4100 74 80 MOV A,#80H
4102 90 FF 0F MOV DPTR,#CONTRL
4105 F0 MOVX @DPTR,A
4106 7C 04 START: MOV R4,#04H
4108 90 41 9B MOV DPTR,#LOOK1
410B AA 83 MOV R2,DPH
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
410D AB 82 MOV R3,DPL
410F 90 41 8F MOV DPTR,#LOOK
4112 A8 83 MOV R0,DPH
4114 A9 82 MOV R1,DPL
4116 GO:
4116 E0 MOVX A,@DPTR
4117 A8 83 MOV R0,DPH
4119 A9 82 MOV R1,DPL
411B 90 FF 0C MOV DPTR,#PORTA
411E F0 MOVX @DPTR,A
411F 09 INC R1
4120 88 83 MOV DPH,R0
4122 89 82 MOV DPL,R1
4124 E0 MOVX A,@DPTR
4125 A8 83 MOV R0,DPH
4127 A9 82 MOV R1,DPL
4129 90 FF 0D MOV DPTR,#PORTB
412C F0 MOVX @DPTR,A
412D 09 INC R1
412E 88 83 MOV DPH,R0
4130 89 82 MOV DPL,R1
4132 E0 MOVX A,@DPTR
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
4133 A8 83 MOV R0,DPH
4135 A9 82 MOV R1,DPL
4137 90 FF 0E MOV DPTR,#PORTC
413A F0 MOVX @DPTR,A
413B 09 INC R1
413C 12 41 75 LCALL DELAY
413F 8A 83 MOV DPH,R2
4141 8B 82 MOV DPL,R3
4143 E0 MOVX A,@DPTR
4144 AA 83 MOV R2,DPH
4146 AB 82 MOV R3,DPL
4148 90 FF 0C MOV DPTR,#PORTA
414B F0 MOVX @DPTR,A
414C 0B INC R3
414D 8A 83 MOV DPH,R2
414F 8B 82 MOV DPL,R3
4151 E0 MOVX A,@DPTR
4152 AA 83 MOV R2,DPH
4154 AB 82 MOV R3,DPL
4156 90 FF 0D MOV DPTR,#PORTB
4159 F0 MOVX @DPTR,A
415A 0B INC R3
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
415B 8A 83 MOV DPH,R2
415D 8B 82 MOV DPL,R3
415F E0 MOVX A,@DPTR
4160 AA 83 MOV R2,DPH
4162 AB 82 MOV R3,DPL
4164 90 FF 0E MOV DPTR,#PORTC
4167 F0 MOVX @DPTR,A
4168 0B INC R3
4169 12 41 82 LCALL DELAY1
416C 88 83 MOV DPH,R0
416E 89 82 MOV DPL,R1
4170 DC A4 DJNZ R4,GO
4172 12 41 06 LCALL START
4175 7D 12 DELAY: MOV R5,#12H
4177 7E FF L3: MOV R6,#0ffH
4179 7F FF L2: MOV R7,#0ffH
417B DF FE L1: DJNZ R7,L1
417D DE FA DJNZ R6,L2
417F DD F6 DJNZ R5,L3
4181 22 RET
4182 7D 12 DELAY1: MOV R5,#12H
4184 7E FF L6: MOV R6,#0ffH
K K College Of Engineering & Management, Dhanbad
Microprocessor & Microcontroller Lab
4186 7F FF L5: MOV R7,#0ffH
4188 DF FE L4: DJNZ R7,L4
418A DE FA DJNZ R6,L5
418C DD F6 DJNZ R5,L6
418E 22 RET
418F 44 27 12 LOOK: DB 44H,27H,12H
4192 92 2B 10 DB 92H,2BH,10H
4195 84 9D 10 DB 84H,9DH,10H
4198 84 2E 48 DB 84H,2EH,48H
419B 48 27 12 LOOK1: DB 48H,27H,12H
419E 92 4B 10 DB 92H,4BH,10H
41A1 84 9D 20 DB 84H,9DH,20H
41A4 04 2E 49 DB 04H,2EH,49H
END
Result:-
The above assembly language program is encoded in the 8051-microcontroller,
thus we observe the traffic light system.
K K College Of Engineering & Management, Dhanbad