Micro Processsor and Micro Controller: Laboratory Manual
Micro Processsor and Micro Controller: Laboratory Manual
Micro Processsor and Micro Controller: Laboratory Manual
LABORATORY MANUAL
R 19
LABORATORY MANUAL
LIST OF EXPERMENTS
Pg. No
S. No Name Of The Experiment
Part - A: 8086 PROGRAMS
1 A. Multibyte addition
B. Multibyte subtraction
2 A. Multiplication of 16-bit
B. Division of 16-bit
3 A. Sorting in Ascending order
B. Sorting in descending order
4 Array of BCD addition
5 Factorial of numbers
PART –B : 8086 INTERFACE
1 Sawtooth wave
2 Square wave
3 Triangular wave generation
4 Seven segment display
5 Stepper motor
Part - C: 8051 PROGRAMS
1 Even sum in array of data
2 Counting no of 1’s and 0’s
3 Sorting in 8051
4 Average of array numbers
Part - D: 8051 INTERFACE
1 Sawtooth wave
2 Square wave
3 Seven segment display
4 Stepper motor
Add On Experiments
1
2
3
FLOWCHART:
START
≠0 count
stop
DATE:
EXP NO:
AIM:
Write An Assembly Language Programme For Perform The Multibyte Number Addition.
APPARATUS:
MASM 32 Assembler, ESA-86/88 Kit.
ALGORITHM:
Step1: Set SI Register As Pointer For Data.
Step2: Clear The Carry Register (Cl)
Step3: Initialize The Augend And Sum Array Pointer.
Step4: Access The Count Value From The Pointer.
Step5: Access The Augend And Addend Data From Next Pointer.
Step6: Perform The Byte Addition And Store In Sum Pointer.
Step7: Increment The Augend Pointer, Adder Pointer And Sum Pointer.
Step8: Decrement The Count Value.
Step9: Check The Count If It Zero Go To Next Step If Not Go To Step5.
Step10: Check The Carry If No Go To Step12 Else Go To Next Step.
Step11: Increment Carry Register Values.
Step12: Store The Carry.
For N= 4
addend
2100 2101 2102 2103
2204
2200 2201 2202 2203
sum/carry
For N=
6
RESULT:
FLOWCHART:
START
≠0
count
=0
stop
For N= 4
For N=
6
RESULT:
FLOWCHART:
START
STOP
OUTPUT:
RESULT:
FLOWCHART:
START
STOP
DATE:
EXP.NO:
AIM:
Write An Assembly Language Programme To Divide The Two 16-Bit Numbers
Stored In 2000h And 2002h Memory Locatins And Store The Result In 2004h And
2006h Memory Loctions.
APPARATUS:
MASM 32 Assembler, ESA-86/88 Kit
ALGORITHM:
Step1: Set The SI Register As Pointer For Data.
Step2: Get Dividend Lower 16-Bit Data Into AX Register.
Step3: Get The Dividend Hogher 16-Bit Data Into DX Register.
Step4: Get The Divisor 16-Bit Data Into BX Register.
Step5: Perform The 16-Bit Division Operation.
Step6: Store The Quotient In Memory.
Step7: Store The Remainder In Memory.
Step8: Stop.
OUTPUT:
RESULT:
START
=0 =1
carry Load the highest value
into accumulator
≠0 count =0 Decrement
iteration count
≠0
count
=0
stop
Aim:
Write an assembly language progmme to perform the sorting of an array.
Apparatus:
MASM 32 assembler
ESA -82/86 kit
Algorithm:
Step 1: Set SI register as pointer for data.
Step 2: Load the count value
Step 3: Decrement the count value
Step 4: Load it into iteration register then into comparison register
Step 5: Access the data from the storing of arrays into accumulator.
Step 6: Compare with next data of the array pointer.
Step 7: Check array if array exist store highest value into accumulator then go to
step 9, if carry doesn’t exist go to next step.
Step 8: Swap the memory contents.
Step 9: Decrement the comparison count if it zero go to next step. If it does not
zero
go to step6.
Step 10: Decrement the iteration count.
Step 11:If it non zero go to step 4. If it zero go to next step.
Step 12:Stop the program.
OUTPUT:
Data Count 2001 2002 2003 2004 2005 2006
no. 2000
Result:
START
=0 =1
carry Load the highest value
into accumulator
≠0 =0 Decrement
count
iteration count
≠0
count
=0
stop
APPARATUS:
MASM 32 Assembler, ESA-86/88 Kit
ALGORITHM:
Step1: set SI register as pointer for data
Step2: load the count value.
Step3: decrement the count value.
Step4: load it into iteration register then into comparison register.
Step5: access the data from the starting of array into accumulator.
Step6: compare with the next data of the array pointer
Step7: check the carry if carry exists store highest value into accumulator then go
to step9,if carry doesn’t exists next step.
Step8: swap the memory contents
Step 9:Decrement the comparison count if it zero go to next step. If it not zero go to
step6.
Step 10: Decrement the iteration count.
Step 11: If it non zero go to step 4. If it zero go to next step.
Step 12: Stop the program.
OUTPUT:
Data Count
no. 2000 2001 2002 2003 2004 2005 2006
RESULT:
FLOWCHART:
START
yes
Decrement count
no Count=
0
yes
STOP
S.NO 1 2 3 4 5
RESULT:
START
READ N
M=1, F=1
F= F *M
M= M+1
No
IS
M=N ?
Yes
PRINT F
STOP
AIM:
Write An Assembly Language Programmeto find the factorial of a given number
stored in 2000H memory location and store the resulting in memory location.
APPARATUS:
MASM 32 Assembler, ESA-86/88 Kit.
ALGORITHM:
Step1: set SI register as pointer for data
Step2: get given data(N)
Step3: Initialize the multiplicand with 1
Step4: Initialize the multiplier with 1.
Step5: perform the multiplication.
Step6: compare with multiplier with given number, if true go to step 9, if not go to
STEP7
Step7: increment multiplier valve with 1
Step8: go to step 5.
Step9:store the factorial in memory.
Step10:stop
RESULT:
AIM:- Write an Assembly Language Program to generate sawtooth wave using DAC
through 8255 PPI
APPARATUS :-
MASM 32 ASSEMBLER , ESA-86/88 KIT, DAC card and CRO
THEORY:-
In this circuit the 8086 processor is interfaced with 8255 in mode-0 and set all the
ports are set to output. The output of port-A is connected to DAC which converts the
digital input to corresponding analog output. The is send to CRO to display. Initially
the port-A is loaded with 00 and the corresponding analog output is send to CRO.
And increment port-A value continuously until the maximum value. If the maximum
value is 0FF no need to compare. Once it is reached to maximum value then it will
reached to initial value. And repeated the same. If the maximum is not FF then for
each and every increment we should compare with maximum value if is equal or less
than we should send to port-A to display. After that again start from 00 and repeat.
The wave amplitude and frequency are depends on maximum count value to send to
Port-A.
ALGORITHM :-
step1: Set all ports as output of 8255 in mode-0
Step2: Load control word into controlword register.
Step3: Initialize port-a with 00 and output to port-a
Step4: send to display through DAC
Step5: Increment the port-a value and go to step 4
MOV DX,0FFE6H
MOV AL,80H
OUT DX,AL
MOV DX,0FFE0H
MOV AL,00H
LOOP1: OUT DX,AL
INC A
JMP LOOP1
ADDRESS OP CODE
MNEMONICSOPERAND COMMENT
IN HEXA IN HEXA
RESULT:-
Result:- Generating the sawtooth wave with different amplitudes and frequencies.
FLOW CHART:
AIM:-
Write an Assembly Language Program to generate the square wave using
8255 ppi in mode-0
APPARATUS :-
ESA-86/88 KIT, CRO, DAC
THEORY:-
In this circuit the 8086 processor is interfaced with 8255 in mode-0 and set all the
ports are set to output. The output of port-A is connected to DAC which converts the
digital input to corresponding analog output. The is send to CRO to display. Initially
the port-A is loaded with FF and the corresponding analog output is send to CRO.
And call the delay as per frequency requirement for on time. For off time
complement the count and then send to display. Repeat the above continuously. The
square wave having duty cycle 50%. So ontime and off time are equal , for this we
are calling same delay routine.
ALGORITHM :-
MOV DX,0FFE6H
MOV AL,80H
OUT DX,AL
MOV DX,0FFE0H
MOV AL,FFH
LOOP1: OUT DX,AL
CALL 2041H(DELAY)
NOT AL
JMP LOOP1
ADDRESS OP CODE
MNEMONICSOPERAND COMMENT
IN HEXA IN HEXA
DELAY PROGRAM
2041 B9,0F,00 MOV CX,00500
2044 49 DEC CX
2045 75,F7 JNZ LOOP2
(2044)
2047 C3 RET
RESULT :-
Generating the different square wave with different frequencies.
FLOWCHART
AIM:-
write an assembly language program to generate triangular wave using DAC
through 8255 PPI
APPARATUS:-
THEORY:-
In this circuit the 8086 processor is interfaced with 8255 in mode-0 and set all the
ports are set to output. The output of port-a is connected to DAC which converts the
digital input to corresponding analog output. This send to CRO to display. Initially
the port-A is loaded with 00 and the corresponding analog output is send to CRO.
And increment count and then compare to maximum value. If it is less than the
maximum count then send to display. After that the count value is decremented, after
decrement compare with minimum value. If it is greater than minimum value then
send to display. Once it is reached to minimum then again start increment the count .
this process is repeat .
ALGORITHM:-
Step1: set all ports as output of 8255 in mode-0
Step2: Load control word into control word register.
Step3: initialize port-A with 00 and output to port-A
Step4: send to display through DAC
Step5: Increment the port-A value and compare with maximum count
Step6: If it is less than the maximum count go to step4 if no goto next step
Step7: send to display count through DAC
Step8:Decrement count and compare to minimum count
Step9: If it is greater than the minimum count goto step 7, if no goto step 3
Note:- The amplitude and frequency depends upon maximum and minimum count
to be loaded into port-A
FLOW CHART
AIM:-
Write an Assembly Language Program to interface the sevensegment display and
print the required characters using 8086 through 8255
APPARATUS :-
THEORY:
There are four digit 7 segment display driven by the outputs of four cascaded serial-
in-parallel-out shift registers. Data to be displayer is transmitted serially, bit by bit, to
the interface over the port line PB0. Each bit is clocked into the shift registers by
providing a common clock through the port line PC0. Thus , information for all the
four digits is provided by 32 bits clocked into the shift registers serially.
DELAY PROGRAM
2040 51 DELAY PUSH CX Delay subroutine
PUSH DX
2041 B9,FF,00 MOV CX,00FF
2044 BA,FF,FF LOOP2 MOV DX,0FFFF
2047 4A LOOP1 DEC DX
2048 75,FD JNZ LOOP1
(2047)
204A 49 DEC CX
204B 75,F7 JNZ LOOP2
(2044)
204D 5A POP DX
204E 59 POP CX
204F C3 RET
STRING
C r r --
C O E --
A S E C
E L r --
O O O 7
FLOW CHART
AIM:-
Write an Assembly Language Program to rotate the stepper motor using 8255 ppi in
mode-0
APPARATUS :-
THEORY:-
In this circuit the 8086 processor is interfaced with 8255 in mode-0 and set all the
ports are set to output. The output of port-A is connected to stepper motor And call
the delay as per speed requirement. As per direction rotate stepper and shift the pole
action with speed requirement. And repeat the same for continuously rotating the
motor.
ALGORITHM :-
MOV DX,0FFE6H
MOV AL,80H
OUT DX,AL
MOV DX,0FFE0H
MOV AL,88H
LOOP1: OUT DX,AL
CALL 2050H(DELAY)
ROR AL,1
JMP LOOP1
ADDRESS OP CODE
MNEMONICSOPERAND COMMENT
IN HEXA IN HEXA
DELAY PROGRAM
2041 B9,0F,00 MOV CX,00FF
2044 BA,FF,FF LOOP2 MOV DX,0FFFF
2047 4A LOOP1 DEC DX
2048 75,FD JNZ LOOP1
(2047)
204A 49 DEC CX
204B 75,F7 JNZ LOOP2
(2044)
204D C3 RET
RESULT :-
Rotating the stepper motor with different directions and with different speeds.
start
odd even
Add the number to
number the accumulator
and check carry
Decrement count
≠0
count
=0
Store even number
sum with carry
stop
EXP NO:
DATE:
AIM:To find the sum of even numbers in the given array of data.
APPARATUS:
KEIL µVISION
ALGORITHM:
ADDRESS OP CODE
IN HEXA IN MNEMONICS &
COMMENTS
OPERAND
HEXA
0000 C3 CLR C Clear Carry
0001 7B00 MOV R3, #00H Initialize Register
0003 7840 MOV R0,#40H Initialize The Data Pointer
0005 E6 MOV A,@R0 Load The Data Into Accumulator
0006 F9 MOV R1,A Load Data Into Count Reg.
0007 7A00 MOV R2,#00 Initialize Temprory Register
0009 08 LOOP2 INC R0 Increment Next Memory Location
000A E6 MOV A,@R0 Load The Data Into Acc.
0 000B B RRC A Rotate Acc. Right Through Carry.
000C 4006 JC LOOP1 If Carry Go To Loop
000E 33 RLC A If There Is No Carry Rotate Left
000F 2A ADD A,R2 Add Acc Data & Temp Register
0010 FA MOV R2,A Store Added Data In R2 Register
0011 5001 JNC LOOP1 Jump If Not Zero Loop1
0013 0B INC R3 Increment Or Store Data R3 Register
0014 D9F3 LOOP1 DJNZ
Decrement Count And Repeat The
R1,
LOOP2
0016 08 INC R0 Increment Data Pointer
0017 EA MOV A,R2 Load Temporary Register Data
0018 F6 MOV @R0,A Move Accumulator Data Into Data
Pointer.
0019 08 INC R0 Increment
001A E8 MOV A,R3 Load Sum Of Even Numbers Into
Accumulator
001B F6 MOV @R0, A Store The Sum Of Even Numbers
END End Of The Program
S.NO COUNT(40H) 41H 42H 43H 44H 45H 46H 47H 48H
RESULT:
FLOWCHART:
START
Increment zero’s
register
≠0
count
stop
EXP NO:
DATE:
AIM:
To Find The Number Of Zero’s And Number Of One’s In The Given Data
APPARATUS:
KEIL µVISION
ALGORITHM:
ADDRESS OP CODE
IN HEXA IN MNEMONICS &
COMMENTS
OPERAND
HEXA
0000 7840
MOV R0, #40H Initialization Of Data Pointer.
0002 E6
MOV A,@R0 Load The Data Into Accumulator.
0003 7900
MOVR1,#00 Initialization Of One’s Count Register.
0005 7A00
MOV R2,#00 Initialization Of Zero’s Count
0007 7B08
MOV R3, #08 Initializing Count Register.
0009 B
LOOP3 RRC A Locate The Acc Right Through carry
000A . 4003 LOOP1 JC If Carry Exists Go To Loop1
To Inc Check 0 Or 1.
000C 0A
INC R2 Increment One’s Register.
000D 001 SJMP LOOP2 After Checking Condition Go To
loop2
.000F O9
LOOP1 INC R1 Increment One’s Register
0010 DBF3 LOOP2 R3,
If Count To Repeat Loop3.
LOOP3
0012 8A41
MOV 41H, R1 Put No Of One’s In R1 Of 42h memory
0014 8A42
MOV 42H, R2 Put No Of Zero’s In R2 Of 42h memory
RESULT:
FLOWCHART:
START
Decrement
comparison count
≠0 =0
count Decrement iteration
count
≠0
count
stop
AIM:
Write an assembly language program for 8051 to perform sorting of the array.
APPARATUS:
1. KEIL µVISION
ALGORITHM:
STEP1: SET SI register as pointer for data.
STEP2: load the count value.
STEP3: Decrement The Count Value.
STEP4: Load If Into Iteration Register Then Into Comparison Register.
STEP5: Access The Data From The Sorting Of The Array Into Accumulator.
STEP6: Compare With The Next Data Of The Array Pointer.
STEP7: Check The Carry If Carry Exists Stores Highest Value Into The
Accumulator Then Go To Next Step9. If Carry Does Not Exists Go To Next
Step.
STEP8:Swap The Memory Contents.
STEP9: Decrement The Comparison Count
If It Is Zero Go To Next Step
If It Not Zero Go To Step 6
STEP10: decrement the iteration count
STEP11: If It Non-Zero Go To Step4, If It Is Zero Go To Next Step.
STEP12: Stop The Program.
0011 4005 LOOP1 JNC Carry Exist Go To next iteration if not swap
0013 F7 MOV @R1, A Load The Data Into R1register From Acc.
0014 19 DEC R1 Decrement count value
0015 A7F0 MOV @R1,B Move or load the data in R1 register from b
0017 09 INC R1 Increment count value
0018 DBF0 LOOP2DJNZ R3 Decrement the count if not Zero
S.NO COUNT(40H) 41H 42H 43H 44H 45H 46H 47H 48H
DESCENDING
S.NO COUNT(40H) 41H 42H 43H 44H 45H 46H 47H 48H
RESULT:
START
≠0 count
=0
AIM:
To write the assembly language program to find the average of given numbers.
APPARATUS:
KEIL µVISION
PROCEDURE:
STEP1: Initialize the data pointer, count register and carry register.
STEP2: Load the data from the memory location into accumulator.
STEP3: Move the data into register B.
STEP4: Increment the value in the accumulator by one and move it onto the
register.
STEP5: Initialize the register R2 with ‘0’.
STEP6: Increment data pointer and load the data into accumulator.
STEP7: Add the register to data and accumulator next data.
STEP8:Check the count register, If 0 go to next step else go to step 6 .
STEP9: Divide the accumulator with count register.
STEP10: Store the sum and carry in the memory location.
STEP11: End program.
S.NO DATA COUNT(40H) 41H 42H 43H 44H 45H 46H 47H
sum carry
RESULT:
FLOW CHART
AIM:-
Write an Assembly Language Program to generate sawtooth wave using DAC
through 8255 PPI
APPARATUS :-
THEORY:-
In this circuit the 8051 controller is interfaced with 8255 in mode-0 and set all the
ports are set to output.The output of port-A is connected to DAC which converts the
digital input to corresponding analog output. The is send to CRO to display. Initially
the port-A is loaded with 00 and the corresponding analog output is send to CRO.
And increment port-A value continuously until the maximum value. If the maximum
value is 0FF no need to compare. Once it is reached to maximum value then it will
reached to initial value. And repeated the same. If the maximum is not FF then for
each and every increment we should compare with maximum value if is equal or less
than we should send to port-A to display. After that again start from 00 and repeat.
The wave amplitude and frequency are depends on maximum count value to send to
Port-A.
ALGORITHM :-
Step1: Set all ports as output of 8255 in mode-0
Step2: Load control word into controlword register.
Step3: Initialize port-a with 00 and output to port-a
Step4: Send To Display Through DAC
Step5: Increment the port-a value and go to step 4
MOV 0A0,#0E8
MOV R0,#03
MOV A,#80
MOVX @R0,A
MOV A,#00H
MOV R0,#00
LOOP1: MOVX @R0,A
INC A
SJMP LOOP1
ADDRESS OP CODE
MNEMONICS OPERAND COMMENT
IN HEXA IN HEXA
RESULT:-
Result:- Generating the sawtooth wave with different amplitudes and frequencies.
FLOW CHART
DATE:-
EXP.NO:-
AIM:-
Write an Assembly Language Program to generate the square wave using 8255 ppi
in
mode-0
APPARATUS :-
THEORY:-
In this circuit the 8051 controller is interfaced with 8255 in mode-0 and set all the
ports are set to output. The output of port-A is connected to DAC which converts the
digital input to corresponding analog output. The is send to CRO to display. Initially
the port-A is loaded with FF and the corresponding analog output is send to CRO.
And call the delay as per frequency requirement for on time. For off time
complement the count and then send to display. Repeat the above continuously. The
square wave having duty cycle 50%. So ontime and off time are equal , for this we
are calling same delay routine.
ALGORITHM :-
ADDRESS OP CODE
MNEMONICSOPERAND COMMENT
IN HEXA IN HEXA
RESULT :-
FLOW CHART
AIM:-
Write an Assembly Language Program to interface the seven segment display and print
the required characters using 8086 through 8255
APPARATUS :-
ESA-51 KIT,7-segment card
ALGORITHM :-
THEORY:
There are four digit 7 segment display driven by the outputs of four
cascaded serial-in-parallel-out shift registers. Data to be displayer is transmitted
serially, bit by bit, to the interface over the port line PB0. Each bit is clocked into the
shift registers by providing a common clock through the port line PC0. Thus ,
information for all the four digits is provided by 32 bits clocked into the shift
registers serially.
STRING
FLOW CHART
AIM:-
Write an Assembly Language Program to rotate the stepper motor using 8255 ppi in mode-0
APPARATUS :-
8051 KIT, Stepper Motor
THEORY:-
In this circuit the 8051controller is interfaced with 8255 in mode-0 and set all the
ports are set to output. The output of port-A is connected to stepper motor And call
the delay as per speed requirement. As per direction rotate stepper and shift the pole
action with speed requirement. And repeat the same for continuously rotating the
motor.
ALGORITHM :-
MOV 0A0,#0E8
MOV R0,#03
MOV A,#80H
MOVX @R0,A
MOV A,#88
LOOP1: MOV R0,#00
: MOVX @R0,A
LCALL 8013H(DELAY)
R R A,1
SJMP LOOP1
ADDRESS OP CODE
MNEMONICS OPERAND COMMENT
IN HEXA IN HEXA
RESULT :-
Rotating the stepper motor with different directions and with different speeds.