EE8681-Microprocessors and Microcontrollers-Lab Manual-Converted11
EE8681-Microprocessors and Microcontrollers-Lab Manual-Converted11
SYLLABUS
OBJECTIVES:
LIST OF EXPERIMENTS:
TOTAL: 60 PERIODS
OUTCOMES:
AIM:
To write an assembly language program to add, subtract, multiply and divide the given
data stored at two consecutive locations using 8085 microprocessor.
a. 8 BIT DATAADDITION:
ALGORITHM:
[C]00H
[HL]4500H
[A] [M]
[HL] [HL]+1
[A] [A]+[M]
Is there a
NO
Carry ?
YE S
[C][C]+1
[HL][HL]+1
[M] [A]
[HL] [HL]+1
[M][C]
STOP
PROGRAM:
ALGORITHM:
[C]00H
[HL]4500H
[A][M]
[HL][HL]+1
[A][A]-[M]
Is there a N
Borrow? O
YES
Complement [A]
Add 01H to [A]
[C][C]+1
[HL][HL]+1
[M][A]
[HL] [HL]+1
[M][C]
STOP
EE8681 – Microprocessors and Microcontrollers Laboratory
PROGRAM:
8
c. 8 BIT DATA MULTIPLICATION:
ALGORITHM:
9
FLOW CHART:
START
[HL] 4500
BM
[HL] [HL]+1
A 00
Is there NO
any
carry YES
C C+1
B B-1
N
O IS B=0
YES
10
A
[HL][HL]+1
[M] [A]
[HL] [HL]+1
[M][C]
STOP
11
PROGRAM:
12
d. 8 BIT DIVISION:
ALGORITHM:
13
START
FLOWCHART:
B 00
[HL] 4500
AM
[HL] [HL]+1
M A-M
[B] [B] +1
IS No
A<0
Yes
AA+ M
YES
B B-1
[HL] [HL]+1
[M] [A]
[HL] [HL]+1
[M][B]
STOP
14
PROGRAM:
15
OBSERVATION:
ADDITION:
SUBTRACTION:
MULTIPLICATION:
DIVISION:
16
Viva Questions
1. What is Microprocessor?
2. Define Bus. What are the buses used in 8085 Microprocessor?
3. What Are The Various Registers In 8085?
4. What Are The Various Flags Used In 8085?
5. Define Program counter and Stack Pointer.
6. Define Tristate Logic?
7. What is the use of ALE?
8. What are the Addressing Modes used in 8085 microprocessor?
9. Operation of 8085 microprocessor.
10. What are the addressing capacity of 8085 microprocessor?
11. What are different data types in microprocessor?
12. What is the word or data length of 8085 microprocessor?
13. Why it is called 8085 microprocessor?
14. What is the function of an address bus and a data bus in a microprocessor 8085?
15. List the allowed register pairs of 8085.
16. What is an Opcode?
17. What is an instruction?
18. How does the microprocessor communicate with the memory and input / output
devices?
19. What is mnemonic?
20. In how many groups can the signals of 8085 be classified?
21. Why crystal is preferred for clock source?
22. Principles used in Multiplication and Division Program used in 8085 microprocessor
RESULT:
Thus the addition, subtraction, multiplication and division of two numbers were performed
using the 8085 microprocessor.
17
Ex. No: 2 Ascending / Descending order, Maximum / Minimum of numbers
AIM:
a. ASCENDING ORDER
ALGORITHM:
18
FLOWCHART: START
[HL] 4200H
[C] [HL]
[C] [C] -1
[D] [C]
[HL] 4201H
[A]
[HL]
[HL [HL] +
1
Ye
Is
s
[A] < [HL]?
No
[B]
[HL]
[HL] [HL] - 1
[HL] [A]
[HL] [B]
[HL] [HL] + 1
[D] [D] – 01 H
19
A
IS No
[D] = 0?
Yes
[C] [C]-1
IS No
[C] = 0?
Yes
STOP
20
PROGRAM:
21
b. DESCENDING ORDER
ALGORITHM:
22
FLOWCHART: START
[HL] 4200H
[C] [HL]
[C] [C] -1
[D] [C]
[HL] 4201H
[A]
[HL]
[HL [HL] +
1
N
Is
o
[A] < [HL]?
Yes
[B]
[HL]
[HL] [HL] - 1
[HL] [A]
[HL] [B]
[HL] [HL] + 1
[D] [D] – 01 H
23
A
IS No
[D] = 0?
Yes
[C] [C]-1
IS No
[C] = 0?
Yes
STOP
24
PROGRAM:
25
c. LARGEST ELEMENT IN AN ARRAY
ALGORITHM:
1. Place all the elements of an array in the consecutive memory locations.
2. Fetch the first element from the memory location and load it in the accumulator.
3. Initialize a counter (register) with the total number of elements in an array.
4. Decrement the counter by 1.
5. Increment the memory pointer to point to the next element.
6. Compare the accumulator content with the memory content (next
element).
7. If the accumulator content is smaller, then move the memory content
(largest element) to the accumulator. Else continue.
8. Decrement the counter by 1.
9. Repeat steps 5 to 8 until the counter reaches zero
10. Store the result (accumulator content) in the specified memory location.
26
FLOW CHART:
START
[HL] [4200H]
[B] M , [B ]= [B ] – 1
[A] [HL]
[HL [HL] + 1
NO IS
[A] < [HL]?
YES
[A] [HL]
[B] [B]-1
NO
IS
[B] = 0?
YES
[4300] [A]
STOP
27
PROGRAM:
28
d. SMALLEST ELEMENT IN AN ARRAY
ALGORITHM:
1. Place all the elements of an array in the consecutive memory locations.
2. Fetch the first element from the memory location and load it in the accumulator.
3. Initialize a counter (register) with the total number of elements in an array.
4. Decrement the counter by 1.
5. Increment the memory pointer to point to the next element.
6. Compare the accumulator content with the memory content (next
element).
7. If the accumulator content is smaller, then move the memory content
(largest element) to the accumulator. Else continue.
8. Decrement the counter by 1.
9. Repeat steps 5 to 8 until the counter reaches zero
10. Store the result (accumulator content) in the specified memory location.
29
FLOW CHART:
START
[HL] [4200H]
[A] [HL]
[HL [HL] + 1
YES IS
[A] > [HL]?
NO
[A] [HL]
[B] [B]-1
IS NO
[B] = 0?
YES
[4300] [A]
STOP
30
PROGRAM:
31
OBSERVATION:
A. ASCENDING ORDER
INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
4200(Array Size) 05
4201 08 4201 02
4202 02 4202 08
4203 1F 4203 10
4204 2A 4204 1F
4205 10 4205 2A
B. DESCENDING ORDER
INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
4200(Array Size) 05
4201 08 4201 2A
4202 02 4202 1F
4203 1F 4203 10
4204 2A 4204 08
4205 10 4205 02
32
C. SMALLEST ELEMENT
INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
4200(Array Size) 05
4201 08
4202 02 4300 02
4203 1F
4204 2A
4205 10
D. LARGEST ELEMENT
INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
4200(Array 05
Size)
4201 08
4202 02 4300 2A
4203 IF
4204 2A
4205 10
33
Viva Questions
1. What are the ways used to clear the accumulator? Atleast three
2. When does the carry flag is set?
3. Explain CMP instruction?
4. Explain about STA and LDA?
5. Specify the type of addressing mode for following instructions.
(i) STA 4000
(ii) LXI H, 4300
(iii) ADI 32
(iv) ADD B
(v) MOV B,C
(vi) MOV B,M
(vii) LDA 4000
(viii) MVI C, 00
6. How many machine cycles needed for following instructions.
(ix) STA 4000
(x) LXI H, 4300
(xi) ADI 32
(xii) ADD B
(xiii) MOV B,C
(xiv) MOV B,M
(xv) LDA 4000
(xvi) MVI C, 00
7. Difference between MVI and LXI instruction
8. Difference between INX and INR
9. H=00, L=00
INX H INR H
H=? H=?
L=? L=?
RESULT:
Thus the sorting operations of arranging an array in ascending, descending order and the
largest and smallest element were found using the 8085 microprocessor.
34
Ex. No: 3 FIND THE NUMBER OF EVEN AND ODD NUMBER IN A
BLOCK OF DATA
AIM:
To find the number of even and odd number, and number of positive and negative
numbers in a block of data.
ALGORITHM:
1. Start.
2. Load the given data.
3. Clear the data in accumulator.
4. Move the content of accumulator to D and B register.
5. Increment HL register pair and move the content of memory to accumulator.
6. Rotate the obtain data in the form of RAR.
7. If carry occur increment B else increment D.
8. Decrement C, if C ≠0 go to step 5. Else increment HL pair.
9. Move the content of D to memory and increment HL pair and move the content B to
memory.
10. Stop.
35
START
[HL] [4200H]
[C] [HL]
[A]
00H
[B] [A]
[D] [A]
[HL [HL] + 1
[A] [HL]
Yes No
Is CY=1
[B] [B]+1, for odd [D] [D]+1, for even
[C] [C]-1
Is No
[C] = 0?
Yes
STOP
36
ADDRE OPCO LABEL MNEM OPER COMMENTS
SS DE ONICS AND
4100 21 LXI H,4200 Load the number of data
4101 00
4102 42
4103 4E MOV C, M Move M to C
4104 AF XRA A Exclusive OR Reg A
4105 57 MOV D, A Move A to D
4106 47 MOV B, A Move A to B
4107 23 L3 INX H H Increment H
4108 7E MOV A,M Move M to A
4109 1F Rotate right through
RAR carry
410A D2 JNC L1 Jump no carry
410B 11
410C 41
410D 14 INR D Increment D
410E C3 JMP L2 Jump to L2
410F 12
4110 41
4111 04 L1 INR B Increment B
4112 0D L2 DCR C Decrement C
4113 C2 JNZ L3 Jump non Zero
4114 07
4115 41
4116 23 INX H Increment H
4117 72 LOOP MOV M, D Move D to M
4118 24 INX H H Increment H
4119 70 MOV M, B Move B to M
411A 76 HLT Halt the program
37
b. Positive and Negative Number
ALGORITHM:
1. Start.
2. Load the given data.
3. Clear the data in accumulator.
4. Move the content of accumulator to D and B register.
5. Increment HL register pair and move the content of memory to accumulator.
6. Rotate the obtain data in the form of RAL.
7. If carry occur increment B else increment D.
8. Decrement C, if C ≠0 go to step 5. Else increment HL pair.
9. Move the content of D to memory and increment HL pair and move the content B to
memory.
10. Stop.
38
START
[HL] [4200H]
[C] [HL]
[A]
00H
[B] [A]
[D] [A]
[HL [HL] + 1
[A] [HL]
Yes No
Is CY=1
[B] [B]+1, [D] [D]+1, positive
negative
[C] [C]-1
Is No
[C] = 0?
Yes
STOP
39
ADDRE OPCO LABEL MNEM OPER COMMENTS
SS DE ONICS AND
4100 21 LXI H,4200 Load the number of data
4101 00
4102 42
4103 4E MOV C, M Move M to C
4104 AF XRA A Exclusive OR reg A
4105 57 MOV D, A Move A to D
4106 47 MOV B, A Move A to B
4107 23 L3 INX H H Increment H
4108 7E MOV A,M Move M to A
4109 17 RAL Rotate left through carry
410A D2 JNC L1 Jump no carry
410B 11
410C 41
410D 14 INR D Increment D
410E C3 JMP L2 Jump to L2
410F 12
4110 41
4111 04 L1 INR B Increment B
4112 0D L2 DCR C Decrement C
4113 C2 JNZ L3 Jump non Zero
4114 07
4115 41
4116 23 INX H Increment H
4117 72 LOOP MOV M, D Move D to M
4118 23 INX H H Increment H
4119 70 MOV M, B Move B to M
411A 76 HLT Halt the program
40
Observation
a. Odd and even number
INPUT: OUTPUT:
4200 = 04 (Array Size) 4205=03(Odd numbers)
4201= 01 4206=01(Even numbers)
4202 =05
4203 =03
4204 =04
Viva Questions
1. Difference between RAR and RRC
2. Difference between RAL and RLC
3. A=99, CY=0
RAR RRC RAL RLC
A=? A=? A=? A=?
4. A=66, CY=0
RAR RRC RAL RLC
A=? A=? A=? A=?
5. A=99, CY=1
RAR RRC RAL RLC
A=? A=? A=? A=?
6. A=66, CY=1
RAR RRC RAL RLC
A=? A=? A=? A=?
7. Explain about logic concepts used for Positive & Negative and Odd & Even program in
8085
RESULT:
Thus the number of even and odd number, and positive and negative number has been
found from the given numberof list.
41
Ex. No: 4 CODE CONVERSIONS
AIM:
a. ASCII TO HEXADECIMAL
ALGORITHM:
We know that the ASCII of number 00H is 30H (48D), and ASCII of 09H is39H (57D). So all
other numbers are in the range 30H to 39H. The ASCII value of 0AH is 41H (65D) and ASCII
of 0FH is 46H (70D), so all other alphabets (B, C, D, E, F) are in the range 41H to 46H
42
FLOWCHART:
Start
Subtract 30 from A
Compare No
“Acc”
with 0AH
Subtract 07 from A
Yes
Stop
43
PROGRAM:
44
b. HEXADECIMAL TO ASCII
ALGORITHM:
We know that the ASCII of number 00H is 30H (48D), and ASCII of 09H is39H
(57D). So all other numbers are in the range 30H to 39H. The ASCII value of
0AH is 41H (65D) and ASCII of 0FH is 46H (70D), so all other alphabets (B, C,
D, E, F) are in the range 41H to 46H.
1. Start the program
2. Load the data from address 4200 to A
3. Compare Accumulator value with 0A
4. If Carry is set, Add 30 and 07 to Accumulator
Else, Add 30 to Accumulator
5. Store the result to 4300
6. Stop the Execution
45
FLOWCHART:
Start
Compare No
“Acc”
with 0AH
Add 07 to A
Yes
Add 30 to A
Stop
46
PROGRAM:
47
c. HEXADECIMAL TO BINARY
ALGORITHM:
48
FLOWCHART:
Start
Initialize counter B to 08
NO
Decrement B register
If B=0?
YES
Stop
49
PROGRAM:
50
d. BCD TO HEXADECIMAL
ALGORITHM:
51
FLOWCHART:
Clear AReg
A=A+E
Stop
52
PROGRAM:
4111 00
4112 C6 L1 ADI 0A Add immediate data
OAHto the accumulator
4113 0A
4114 15 DCR D Decrement the D
register
4115 C2 JNZ L1 Jump if no zero to
4112H
4116 12
4117 41
4118 83 ADD E Add the content of E
register to Accumulator
53
4119 32 STA 4300 Store the accumulator
content at 4300h
411A 00
411B 43
411C 76 HLT Halt the execution
e. HEXADECIMAL TO DECIMAL
ALGORITHM:
54
FLOWCHART:
Start
Initialize D register
Clear accumulator
Move HL to C register
Add 01 with A
Adjust A to BCD
YES
Check
Carry?
NO
Increment D register
Increment C register
NO
Check
Carry?
YES
Store A in 4151 H
Move D to accumulator
Store A in 4150 H
Stop
55
PROGRAM:
56
4127 77 MOV M, A Move content of A to M
4128 76 HLT Stop the program
OBSERVATION:
a. ASCII TO HEXADECIMAL
INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
4200 42 4300 0B
4200 35 4300 05
b. HEXADECIMAL TO ASCII
INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
4200 06 4300 36
4200 0C 4300 43
c. HEXADECIMAL TO BINARY
INPUT OUTPUT
MEMORY DATA MEMORY DATA MEMORY DATA
LOCATION LOCATION LOCATION
A9 4201 01 4205 00
4200 4202 00 4206 01
4203 00 4207 00
4204 01 4208 01
d. BCD TO HEXADECIMAL
INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
1D
4200 29 4300
57
e. HEXADECIMAL TO DECIMAL
INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION LOCATION
4150 21 4151 00
4152 33
Viva Questions
1. Explain the concepts used in 8085 ALP for following program
(i) ASCII to hexadecimal number,
(ii) hexadecimal to ASCII,
(iii) hexadecimal to decimal number,
(iv) decimal number to hexadecimal number and
(v) hexadecimal to binary number.
2. Covert 4F into binary
3. Convert 43 into hexadecimal
4. Convert 4F into decimal
5. Convert 0F and 08 into ASCII
6. Convert 39 and 44 into Hexadecimal
RESULT:
Thus the assembly language programs for various code conversions are executed using
8085 microprocessor.
EX.No:5 INTERFACING A/D AND D/A CONVERTER WITH 8085
58
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.
APPARATUS REQUIRED:
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.
PROGRAM:
59
ADDRESS OPCODE LABEL MNEMON ICS OPERA COMMENTS
ND
4100 3E MVI A, 10 Select channel 0 and to
make accumulator low
4101 10
4102 D3 OUT C8 Output the data
4103 C8
4104 3E MVI A, 18 Make accumulator high
4105 18
4106 D3 OUT C8 Display the data
4107 C8
4108 3E MVI A, 01 Make 01 to accumulator
4109 01
410A D3 OUT D0 Display the data
410B D0
410C 00 NOP
410D 00 NOP
410E 00 NOP
410F 3E MVI A, 00 Make 00 to accumulator
4110 00
4111 D3 OUT D0 Load D0 in output port
4112 D0
4113 DB LOOP IN D8
4114 D8
4115 E6 ANI 01 Do and operation directly
4116 01
4117 FE CPI 01 Compare with accumulator
4118 01
4119 C2 JNZ LOOP Jump to specified address
411A 13
411B 41
411C DB IN C0
411D C0
411E 32 STA 4150 Store the data
411F 50
4120 41
4121 76 HLT End the program
60
ADC- CIRCUIT:
61
OBSERVATION
62
b. DAC INTERFACING WITH 8085
APPARATUS REQUIRED:
SOFTWARE EXAMPLES
The following examples illustrate how to control the DAC using 8085 and generate sine
wave, saw tooth wave by means of software.
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
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:
63
410C 11
410D 41
410E C3 JMP START START Jump to start of address
410F 00
4110 41
4111 06 DELAY MVI B, 05 Move 05 to B register
4112 05
4113 OE L1 MVI C, FF Move FF to C register
4114 FF
4115 0D L2 DCR C Decrement C
4116 C2 JNZ L2 Jump to L2 if no zero
4117 15
4118 41
4119 05 DCR B Decrement B register
411A C2 JNZ L1 Jump to L1 if no zero
411B 13
411C 41
411D C9 RET
Execute the program and using a CRO, verify that the waveform at the DAC2 output is a
square-wave. Modify the frequency of the square-wave, by varying the time delay.
(b) SAW TOOTH 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. Repeat steps 3 and 4.
Output digital data from 00 to FF constant steps of 01 to DAC1 repeat this sequence again and
again. As a result a saw – tooth wave will be generated at DAC1 output.
PROGRAM:
64
4108 C3 JMP START Go to START unconditionally
4109 00
410A 41
ALGORITHM:
65
DAC - CIRCUIT:
WAEFORMS:
66
OBSERVATION:
Viva Questions
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.
67
EX.No:6 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.
APPARATUS REQUIRED:
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.
68
6. All ambers are ON, indicating the change of sequence.
BIT ALLOCATION:
69
PATH REPRESENTATION:
70
PROGRAM:
71
412C C9 RET Return to subroutine
4500 80,1A, A1, 64 DATA 80, 1A, A1,
64
4504 A4, 81, 5A, 64 A4,81,5A,64
4508 54, 8A, B1, A8 54,8A,B1,A8
450C B4, 88, DA, 68 B4,88,DA,68
4510 D8, 1A, E8, 46 D8,1A,E8,46
4514 E8, 83, 78, 86 E8,83,78,86,
74 74
Viva Questions
RESULT:
Thus an assembly language program to simulate the traffic light at an intersection using
a traffic light interfaces was written and implemented.
72
EX.No:7 INTERFACING 8251 WITH 8085
AIM:
To write a program to initiate 8251 and to check the transmission and reception
of character.
APPARATUS REQUIRED:
Prior to starting data transmission or reception, the 8251 must be loaded with a
set of control words generated by the CPU.These control signals define the complete
functional definition of the 8251 and must immediately follow a RESET operation. Control
words should be written in to the control register of 8251. Words should be written in to the
control register of 8251.words should be written in to the control register of
8251.Thesecontrol words are split into two formats.
1. MODE INSTRUCTION WORD
2. COMMAND INSTRUCTION WORD.
This format defines the BAUD rate, character length, parity and stop bits required to
work with asynchronous data communication. By selecting the appropriate BAUD
factor synchronous mode, the 8251 can be operated in synchronous mode.
8 bit data
No parity
Baud rate factor (16X)
1 stop bit
Gives a mode command word of 01001110=4E(X)
73
ALGORITHM
1. Initialize timer (8253) IC
2. Move the Mode command word (4EH) to A reg.
3. Output it port address C2
4. Move the command instruction word (37H) to A reg.
5. Output it to port address C2
6. Move the data to be transfer to A reg.
7. Output it to port address C0.
8. Reset the system
9. Get the data through input port address C0.
10. Store the value in memory
11. Reset the system
PROGRAM:
74
SYNCHRONOUS MODE:
EP PEN L2 L1 B2 B1
0 1 0 1
0 0 1 1
5 6 7 8
BIT BIT BIT BIT
PARITY ENABLE
1-Enable 0-Disable
EVEN PARITY GENERATION
0-Odd 1-Even
EXTERNAL SYNC DETECT
1-Sysdetect is an input 0-
Sysdetect is an output
75
ASYNCHRONOUS MODE:
S2 S1 EPPENL2 L1 B2 B1
0 1 0 1
0 0 1 1
Synch (1 X) (16 X) (64 X)
mode
0 1 0 1
0 0 1 1
5 6 7 8
BIT BIT BIT BIT
PARITY ENABLE
1-Enable 0-
Disable
0101
0011
Invalid61BIT1.5BIT2 BIT
76
OBSERVATION:
Viva Questions
1. What are the differences between Serial communication and Parallel Communication?
2. What are the differences between Synchronous communication and Asynchronous
Communication?
3. Explain the command word format of 8251
4. Explain the mode word format of 8251
5. Define BAUD rate.
6. Explain the structure of Asynchronous mode format.
7. How to choose the baud rate with 8051?
RESULT:
Thus the program to initiate 8251 was written and the transmission and reception of
character was checked by interfacing 8251 with 8085.
77
Ex No. 8 INTERFACING 8279 WITH 8085
AIM:
To interface 8279 Programmable Keyboard Display Controller to 8085 Microprocessor.
APPARATUS REQUIRED:
PROGRAM:
a) Rolling Display
78
411C C3,00,41 JMP START START Jump to START address
411F 06,A0 DELAY MVI B, A0 Move a to B register
4121 0E,FF LOOP2 MVI C, FF Move FF to C register
4123 0D LOOP1 DCR C Decrement C register
4130 FF
4131 FF
4132 FF
4133 FF
4134 FF
4135 FF
4136 FF
4137 FF
4138 98
4139 68
413ª 7C
413B C8
413C 1C
413D 29
413E FF
413F FF
79
SEGMENT DEFINITION:
DATA BUS D7 D6 D5 D4 D3 D2 D1 D0
SEGMETS d c b a dp g f e
OBSERVATION:
H fegbc 1 0 0 1 1 0 0 0 98
E fegad 0 1 1 0 1 0 0 0 68
L fed 0 1 1 1 1 1 0 0 7C
P fegab 1 1 0 0 1 0 0 0 C8
U fedbc 0 0 0 1 1 1 0 0 1C
S fgacd 0 0 1 0 1 0 0 1 29
80
b) Accept a Key and display the same (Two key lock out)
81
c) Accept a Key and display the same( N Key rollover)
ADDRESS OPCO LABEL MNEMON ICS OPERAN COMMENT
DE D
82
Viva Questions
RESULT:
Thus 8279 controller was interfaced with 8085 and program for read a key and display
and rolling display were executed successfully.
83
MICROCONTROLLER
84
Ex. No: 9 8051 –BASIC SIMPLE PROGRAM
AIM:
To write an assembly language program to add, subtract, multiply and divide the given
data stored at two consecutive locations using 8051 microcontroller.
Algorithm:
85
Start
Yes
If INCREMENT R0 REG
CY=1
No
Stop
86
Label Program Comments
MOV DPTR,#4500 Load address of 1st data in DPTR
MOVX A,@DPTR Move the 1st data to A
MOV R1,A Save the first data in R1
INC DPTR Increment DPTR to point 2nd data
MOVX A,@DPTR Load the 2nd data in A
MOV R0,#00 Clear R0 for the account of carry
ADD A,R1 Get the sum in A reg
JNC AHEAD Check carry flag
INC R0 If carry is set increment R0
AHEAD: INC DPTR Increment DPTR
MOVX @DPTR, A Save the sum in external memory
INC DPTR Increment DPTR
MOV A,R0 Move carry to A reg
MOVX @DPTR, A Save the carry in external memory
HERE: SJMP HERE Remain idle in infinite loop
Observation:
Input:
4500: 05 [Addend]
4501: 06 [Augend]
Output:
4502: 0B [Sum]
4503: 00 [Carry]
87
Start
INCREMENT R0 REG
No
Stop
88
b. SUBTRACTION OF TWO 8 BIT NUMBERS
Algorithm:
89
Label Program Comments
MOV DPTR,#4500 Load address of minuend in DPTR
MOVX A,@DPTR Move the minuend to A
MOV R1,A Save the minuend in R1
INC DPTR Increment DPTR to point subtrahend
MOVX A,@DPTR Load the subtrahend in A
XCH A,R1 Get minuend in A and Subtrahend in R1
MOV R0,#00 Clear R0 for the account of Sign
CLR C Clear carry
SUBB A,R1 Subtract R1 from A
JNC AHEAD Check Carry flag. If carry is set then
CPL A Get 2’s complement of result in A
INC A
INC R0 Set R0 to indicate negative sign
AHEAD: INC DPTR Increment DPTR
MOVX @DPTR,A Save the result in external memory
INC DPTR Increment DPTR
MOV A,R0 Move sign bit to A reg
MOVX @DPTR,A Save the sign in external memory
HERE: SJMP HERE Remain idle in infinite loop
Observation:
Input:
4500: 09 [Minuend]
4501: 04 [Subtrahend]
Output:
4502: 05 [Difference]
4503: 00 [Sign Bit]
90
Start
INCREMENT DPTR
INCREMENT DPTR
91
c. MULTIPLICATION OF TWO 8 BIT NUMBERS
Algorithm:
92
Observation:
Input:
Output:
93
Start
INCREMENT DPTR
INCREMENT DPTR
INCREMENT DPTR
Stop
94
d. DIVISION OF TWO 8 BIT NUMBERS
Algorithm:
95
Observation:
Input:
4500: 99 [Dividend]
4501: 12 [Divisor]
Output:
4502: 08 [Quotient]
4503: 09 [Remainder]
Viva Questions
1. Define Microcontroller
2. Difference Between Microprocessor and Microcontroller
3. What are the features of Microcontroller
4. Explain the ports of 8051
5. Explain the memory structure of RAM in 8051
6. Specify the RAM and ROM size of 8051 Microcontroller
7. What is the use of EA pin?
8. What is the use of DPTR?
9. Specify the type of addressing mode for following instruction
i. MOV A, RO
ii. MOV A,55
iii. MOV A,#55
iv. MOVX A, @DPTR
10. Explain MUL and DIV instruction.
Result:
Thus the addition, subtraction, multiplication and division of two numbers were
performed using the 8051 microcontroller.
96
Ex. No. 10 A) SUM OF ELEMENTS IN AN ARRAY
AIM:
To find the sum of elements in an array.
ALGORITHM:
1. Load the array in the consecutive memory location and initialize the
memory pointer with the starting address.
2. Load the total number of elements in a separate register as a counter.
3. Clear the accumulator.
4. Load the other register with the value of the memory pointer.
5. Add the register with the accumulator.
6. Check for carry, if exist, increment the carry register by 1. otherwise,
continue
7. Decrement the counter and if it reaches 0, stop. Otherwise increment the
memory pointer by 1 and go to step 4.
97
START
[DPTR] [4200H],
Clear B, R1 and CY
[A] [DPTR+1]
No
Is Cy=1
Yes
[R1] [R1]+1
[R0] [R0]-1
No
IS [R0] = 0?
Yes
STOP
98
PROGRAM:
99
OBSERVATION:
INPUT OUTPUT
4200(Array Size) 05 4500
60
4201 15
4202 20 00
4501
4203 1A
4204 09
4205 08
RESULT:
The sum of elements in an array is calculated.
100
Exp. No 10 B) 8051–Check Odd or Even using Call Option
AIM:
To checkwhether given number is Odd or Even using call function.
ALGORITHM:
1. Start
2. Move the data to DPTR
3. Move the data to accumulator
4. Call check function whether given number is odd or even
5. Increment DPTR
6. Resultant value stored in DPTR-4201
7. Halt
Check Function
8. Rotate right through carry
9. If carry copy 00 to B reg (odd number)
10. Else copy EE to B reg (even number)
11. return
101
START
[DPTR] [4200H]
[A] [DPTR]
[DPTR] [DPTR] +1
[A] [B][DPTR] [A]
STOP
Yes No
Is CY=1
Return
102
PROGRAM:
Label Program Comments
MOV DPTR, #4200 Load 4200 to DPTR, get a number
MOVX A, @DPTR Copy value to A
ACALL CHECK_EV_OD Call check function whether given number is
odd or even
INC DPTR
MOV A,B
MOVX @DPTR, A Resultant value stored in DPTR-4201
HERE SJMP HERE
OBSERVATION:
INPUT OUTPUT
4200 20 4201 EE
Viva Questions
1. Explain the different types of jumps instruction used in 8051 microcontroller
2. Explain DJNZ instruction
3. Explain the different types of CALL instruction used in 8051 microcontroller
4. Difference between JUMP and CALL instructions
RESULT:
Thus the given number is either even or odd has been found using 8051 microcontroller.
103
Ex. No: 11 INTERFACING A/D & D/A CONVERTER WITH 8051
APPARATUS REQUIRED:
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:
PROGRAM:
104
Label Program Comments
MOV DPTR, #FFC8
MOV A,#10 Select Channel 0 and make ALE Low
MOVX @DPTR, A
MOV A,#18 make ALE High
MOVX @DPTR, A
MOV DPTR, #FFD0
MOV A,#01 SOC signal High
MOVX @DPTR, A
MOV A,#00 SOC signal low
MOVX @DPTR, A
MOV DPTR,
WAIT #FFD8 MOVX
A,@DPTR JNB Check for EOC
E0,WAIT MOV Read ADC data
DPTR,#FFC0
MOVX A,@DPTR Store the data in memory location
MOV DPTR,#4150
HERE MOVX @DPTR, A
SJMP HERE
ADC- CIRCUIT:
105
SOC JUMPER SELECTION:
OBSERVATION
106
ANALOG VOLTAGE DIGITAL DATA ON HEX CODE IN
LED DISPLAY LOCATION 4150
107
APPARATUS REQUIRED:
THEORY:
SOFTWARE EXAMPLES
After going through the software examples you can learn how to control the
DAC using 8051 and generate sine wave, saw tooth wave etc by means of software.
ALGORITHM:
DAC - CIRCUIT:
108
WAVEFORMS:
OBSERVATION:
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.
109
ADDRESS LABEL MNEMON ICS OPCODE OPERAND COMMENT
MOV DPTR,#FFC8
START MOV A,#00
MOVX @DPTR,A
LCALL DELAY
MOV A,# FF
MOVX @DPTR,A
LCALL DELAY
LJMP START
DELAY MOV R1,#05
LOO[P MOV R2,#FF
DJNZ R2,HERE
DJNZ R1,LOOP
RET
SJMP START
Execute the program and using a CRO, verify that the waveform at the DAC2 output is
a square-wave. Modify the frequency of the square-wave, by varying the time delay.
PROGRAM:
110
(c) TRIANGULAR WAVE GENERATION
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. The program is
self explanatory.
OBSERVATION:
Result:
Thus the square, triangular and saw tooth wave form were generated by interfacing
DAC with 8051 trainer kit
111
Ex.No:14 INTERFACING 8253 TIMER WITH 8085
AIM:
APPARATUS REQUIRED:
.
PROGRAM:
Set the jumper, so that the clock 0 of 8253 is given a square wave of frequency 1.5
MHz. This program divides this PCLK by 10 and thus the output at channel 0 is 150 KHz.
Vary the frequency by varying the count. Here the maximum count is FFFF H. So, the
square wave will remain high for 7FFF H counts and remain low for 7FFF H counts. Thus
with the input clock frequency of 1.5 MHz, which corresponds to a period of 0.067
microseconds, the resulting square wave has an ON time of 0.02184 microseconds and an OFF
time of 0.02184 microseconds.
To increase the time period of square wave, set the jumpers such that CLK2 of 8253 is
connected to OUT 0. Using the above-mentioned program, output a square wave of frequency
150 KHz at channel 0. Now this is the clock to channel 2.
112
CONTROL WORD:
SC-SELECT COUNTER:
M-MODE:
M2 M1 M0 MODE
0 0 0 Mode 0
0 0 1 Mode 1
X 1 0 Mode 2
X 1 1 Mode 3
1 0 0 Mode 4
1 0 1 Mode 5
READ/WRITE:
RW1 RW0
0 0 Counter latch command
0 1 R/W least significant bit only
1 0 R/W most significant bit only
113
BCD:
Result:
Thus the 8253 has been interfaced to 8085 p and with different modes of 8253 have
been studied.
114
Ex.No:15 STEPPER MOTOR INTERFACING WITH 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, 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.
ANTICLOCKWISE CLOCKWISE
STEP A1 A2 B1 B2 DATA STEP A1 A2 B1 B2 DATA
1 1 0 0 1 9h 1 1 0 1 0 Ah
2 0 1 0 1 5h 2 0 1 1 0 6h
3 0 1 1 0 6h 3 0 1 0 1 5h
4 1 0 1 0 Ah 4 1 0 0 1 9h
115
BLOCK DIAGRAM:
8051
MICROCONTROLLER 8255
DRIVER CIRCUIT STEPPER MOTOR
REPRESENTATION:
116
PROGRAM :
PROCEDURE:
1. Enter the above program starting from location 4100.and execute the same.
2. The stepper motor rotates.
3. Varying the count at R4 and R5 can vary the speed.
4. Entering the data in the look-up TABLE in the reverse order can vary direction of
rotation.
RESULT:
Thus a stepper motor was interfaced with 8051 and run in forward and reverse
directions at various speeds.
117
Ex.No:12 8085 Programming Practices with Simulators/ Jubin Open source Software
Aim
To write an assembly language program to multiply the given data stored at two consecutive
locations using 8085 microprocessor simulator.
Motivation
Understanding of Intel 8085 microprocessor is fundamental to getting insight into the Von-
Neumann Architecture. It was first introduced in 1976, since then many generations of
computer architecture have come up, some still persists while others are lost in history. This
microprocessor still survives because it is still popular in university and training institutes to
get students acquainted with basic computer architecture. For this purpose 8085 trainer kit are
available on the market.
With this academic learning purpose in mind 8085 simulator software is designed. It helps in
get started easily with example codes, and to learn the architecture playfully. It also provides a
trainer kit as an appealing functional alternative to real hardware. The users can write
assembly code easily and get results quickly without even having the actual hardware.
Jubin 8085 simualor is open source software which is available
at https://8085simulator.codeplex.com/downloads/get/86234
Features
1.Assembler Editor
• Can load Programs written in other simulator
• Auto-correct and auto-indent features
• Supports assembler directives
• Number parameters can be given in binary, decimal and hexadecimal format
• Supports writing of comments
• Supports labeling of instructions, even in macros
• Has error checking facility
• Syntax Highlighting
2.Disassembler Editor
• Supports loading of Intel specific hex file format
• It can successfully reverse trace the original program from the assembly code,
in most of the cases
• Syntax Highlighting and Auto Spacing
118
3.Assembler Workspace
• Contains the Addressfield, Label, Mnemonics, Hex-code, MnemonicSize, M-Cycles
and T-states
• Static Timing diagram of all instruction sets are supported
• Dynamic Timing diagram during step by step simulation
• It has error checking facility also
4.Memory Editor
• Can directly update data in a specified memory location
• It has 3 types of interface, user can choose from it according to his need.
–Show entire memory content
–Show only loaded memory location
–Store directly to specified memory location
• Allows user to choose memory range
5.I/O Editor
• It is necessary for peripheral interfacing.
• Enables direct editing of content
6.Interrupt Editor
• All possible interrupts are supported. Interrupts are triggered by pressing the
appropriate column (INTR,TRAP,RST7.5,RST6.5,RST5.5) on the interrupt table.
The simulation can be reset any time by pressing the clear memory in the settings
tab.
7.Debugger
• Support of breakpoints
• Step by step execution/debugging of program.
• It supports both forward and backward traversal of programs.
• Allows continuation of program from the
breakpoint. 8.Simulator
• There are 3 level of speed for simulation:
–Step-by-step −→Automatic line by line execution with each line highlighting.
The time to halt at each line is be decided by the user.
–Normal−→Full execution with reflecting intermittent states periodically.
–Ultimate−→Full execution with reflecting final state directly.
119
• There are 2modes of simulator engine:
–Run all at a Time−→It takes the current settings from the simulation speed
level and starts execution accordingly.
-StepbyStep−→It is manual mode of control of FORWARD and BACKWARD
traversal of instruction set. It also displays the in-line comment if available for
currently executed instruction.
• Allows setting of starting address for the simulator.
• Users can choose the mnemonic where program execution should
terminate. 9.Helper
• Help on the mnemonics is integrated.
• CODEWIZARD is a tool added to enable users with very little knowledge of
assembly code could also 8085 assembly programs.
• Already loaded with plenty SAMPLE programs.
• Dynamic loading of user code if placed in user_code folder.
• It also includes a user manual.
10.Printing
• Assembler Content
• Workspace Content
11.Register Bank−→Each register content is accompanied with its equivalent binary value
• Accumulator, RegB, RegC, RegD, RegE, RegH, RegL, Memory(M)
• Flag Register
• Stack Pointer(SP)
• Memory Pointer(HL)
• Program Status Word(PSW)
• Program Counter(PC)
• Clock Cycle Counter
• Instruction Counter\
• Special blocks for monitoring Flag register and the usage of SIM and RIM
instruction.
12.Crash Recovery
• Can recover programs lost due to sudden shutdown or crash of
application. 13.8085 TRAINER KIT
120
• It simulates the kit as if the user is working in the lab. It basically uses the same
simulation engine at the back-end.
14.TOOLS
• Insert DELAY Subroutine TOOL
–It is a powerful wizard to generate delay subroutine with user defined delay
using any sets of register for a particular operating frequency of 8085
microprocessor.
• Interrupt Service Subroutine TOOL
–It is a handy way to set memory values at corresponding vector interrupt
address.
• Number Conversion Tool
–It is a portable interconversion tool for Hexadecimal, decimal and binary
numbers. So, that user do not need to open separate calculator for it.
Directives
Assembler
Directives Example Description
121
Debugging Mode
The debug mode allows the user to view and/or manipulate the program’s internal state
for the purpose of debugging. The software allows stepwise or block wise line monitor with
both forward and backward traversal facility.
PROGRAM
#ORG 2000
#BEGIN 2000
LXI H, 4200
MOV B,M
INX H
MVI C,00
MVI A,00
L2: ADD M
JNC L1
INR C
L1: DCR B
JNZ L2
INX H
MOV M,A
INX H
MOV M,C
HLT
#ORG 4200
#DB 23,42
Click
ASSEMBLE, Run all at a Time and then Memory
Observation
Input Output
4200 4202
4201 4203
Result
Thus the multiplication of two numbers was performed using the 8085 microprocessor
simulator.
122
Appendix A - 8085 Instruction set and Opcodes (Hex code)
123
124