IV Eee Ee3413 Microprocessor&Microcontroller Lab
IV Eee Ee3413 Microprocessor&Microcontroller Lab
E
DEPARTMENT OF ELECTRONICS AND
CO
COMMUNICATION ENGINEERING
CE
II Year / IV Semester
LAB MANUAL
1
EE3413-MPMC Lab
4931_Grace college of Engineering
INDEX
Name of the Student: Dept:
Roll No: Reg No:
Lab in Charge:
S. Date Title of the Programs Pg. Date of Mark Staff Sign Date
No No Sub
E
CO
CE
RA
G
2
EE3413-MPMC Lab
4931_Grace college of Engineering
LIST OF EXPERIMENTS
PROGRAMMING EXERCISES / EXPERIMENTS WITH μP8085:
[Link] arithmetic operations: addition / subtraction / multiplication / division.
2. Programming with control instructions:
(i) Ascending / Descending order, Maximum / Minimum of numbers
(ii) Programs using Rotate instructions
(iii) Hex / ASCII / BCD code conversions.
3. Interface Experiments: with 8085
(i) A/D Interfacing. & D/A Interfacing.
4. Traffic light controller.
5. Displaying a moving/ rolling message in the student trainer kit’s output device
E
6. Simple arithmetic operations with 8051: Multi precision addition / subtraction /
multiplication/ division.
conversions. CO
7. Programming with control instructions: Increment / Decrement, Ascending / Descending.
order, Maximum / Minimum of numbers, Rotate instructions, Hex / ASCII / BCD code
[Link]. Page
List of Experiments
No.
CYCLE I
RA
E
CO
CE
RA
G
4
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
SIMPLE ARITHMETIC OPERATIONS
a. ADDITION & SUBTRACTION OF TWO 8-BIT NUMBERS
AIM:
To write an Assembly Language Program (ALP) for performing the addition and subtraction
operation of two 8-bit numbers.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
1. Intel Microprocessor kit 8085 1
PROBLEM STATEMENT:
Store the first data in one memory location and the second data in the other location. Perform
the addition or subtraction and store the result in one memory location and the carry or borrow in
other location.
ALGORITHM:
(i) 8-bit addition
1. Initialize the MSBs of sum to 0.
2. Get the first number from the corresponding memory location.
E
3. Add the second number, which is in the corresponding memory location to the first number.
4. If there is any carry, increment MSBs of sum by 1.
5. Store LSBs of sum in the location.
6. Store MSBs of sum in the location.
(ii) 8-bit subtraction
1. Initialize the MSBs of difference to 0.
CO
2. Get the first number from the corresponding memory location.
3. Subtract the second number, which is in the location from the first number.
4. If there is any borrow, increment MSBs of difference by 1.
5. Store LSBs of difference in the location.
CE
6. Store MSBs of difference in the location.
FLOW CHART:
Addition Subtraction
RA
G
B
A
5
EE3413-MPMC Lab
4931_Grace college of Engineering
A B
E
CO
CE
Location.
SUB M Subtract first number from acc.
Content.
JNC L1 Jump to location if result does not
yield borrow.
INR C Increment C reg.
CMA Complement the Acc. content
ADI 01H Add 01H to content of acc.
L1 INX H Increment HL reg. to point next mem.
Location.
MOV M, A Transfer the result from acc. to
memory.
INX H Increment HL reg. to point next mem.
Location.
MOV M, C Move carry to mem.
HLT Stop the program
E
WITHOUT CARRY & BORROW: (Addition and Subtraction)
INPUT OUTPUT
MEMORY DATA MEMORY DATA DATA
LOCATION LOCATION
CO
ADDITION
(SUM)
(CARRY)
SUBTRACTION
(DIFFERENCE)
(BORROW)
WITH CARRY & BORROW: (Addition and Subtraction)
CE
INPUT OUTPUT
MEMORY DATA MEMORY DATA DATA
LOCATION LOCATION ADDITION SUBTRACTION
(SUM) (DIFFERENCE)
RA
(CARRY) (BORROW)
MANUAL CALCULATION:
ADDITION SUBTRACTION
G
RESULT:
REVIEW QUESTIONS:
1. What is LSB and MSB?
2. Give any two arithmetic instructions.
3. What is meant by ADI d8H?
4. What instruction is used to load the data in the accumulator?
5. What do you mean by carry flag?
7
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
b. MULTIPLICATION & DIVISION OF TWO 8-BIT NUMBERS
AIM:
To write an Assembly Language Program (ALP) for performing the multiplication and
division operation of two 8-bit numbers.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
1. Intel Microprocessor kit 8085 1
PROBLEM STATEMENT:
Store the first data in one memory location and the second data in the other location. Perform
the multiplication or division and store the result in one memory location and the quotient & reminder
in their corresponding locations.
ALGORITHM:
(i) Multiplication of 8-bit numbers:
1. Get the multiplier and multiplicand.
2. Initialize the product to 0.
3. Product = product + multiplier.
4. Decrement the multiplicand by 1.
5. If multiplicand is not equal to 0, repeat from step (4) otherwise store the product.
E
(ii) Division of 8-bit numbers:
1. Get the dividend and divisor.
2. Initialize the quotient to 0.
3. Dividend = dividend – divisor.
4. If the divisor is greater, store the quotient.
CO
5. If dividend is greater, quotient = quotient + 1, then repeat from step (4).
8
EE3413-MPMC Lab
4931_Grace college of Engineering
MULTIPLICATION DIVISION
E
CO
CE
RA
G
9
EE3413-MPMC Lab
4931_Grace college of Engineering
MULTIPLICATION:
E
INPUT OUTPUT
MEMORY DATA MEMORY DATA
LOCATION
DIVISION:
MULTIPLICAND
MULTIPLIER
CO
LOCATION
INPUT OUTPUT
CE
MEMORY DATA MEMORY DATA
LOCATION LOCATION
DIVIDEND REMAINDER
DIVISOR QUOTIENT
RA
MANUAL CALCULATION:
MULTIPLICATION DIVISION
G
RESULT:
REVIEW QUESTIONS:
1. Write arithmetic instructions for multiplication and division.
2. Which are the instructions that affect the carry flag?
3. What is the use of DAD instruction?
4. The bit position of parity flag in 8085 flag register is what?
5. How many & what are the machine cycles needed for execution of MOV A, M?
10
EE3413-MPMC Lab
4931_Grace college of Engineering
E
5. Decrement count and if count is not zero, repeat from step (4), otherwise store the max (min).
FLOWCHART:
MAXIMUM OF ‘n’ NUMBER MINIMUM OF ‘n’ NUMBER
CO
CE
RA
G
11
EE3413-MPMC Lab
4931_Grace college of Engineering
E
LXI H,4100 Initialize HL reg. to 4100H
MVI B,04 Initialize B reg with no. of
CO
comparisons(n-1)
MOV A,M Transfer first data to acc.
LOOP1 INX H Increment HL reg. to point next
memory location
CMP M Compare M & A
JC LOOP If A is lesser than M then go to loop
MOV A,M Transfer data from M to A reg
CE
LOOP DCR B Decrement B reg
JNZ LOOP1 If B is not Zero go to loop1
STA 4105 Store the result in a memory location.
HLT Stop the program
RA
INPUT OUTPUT
MEMORY MAXIMUM
LOCATION NUMBER
RESULT:
REVIEW QUESTIONS:
1. What is the purpose of branch instructions in 8085 microprocessor?
2. Name 5 different addressing modes?
3. What are the various flags used in 8085?
4. Auxiliary carry is usually used when _____________________
5. When XCHG command will be used?
12
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
b. SORTING ‘n’ NUMBERS
AIM:
To write an Assembly Language Program (ALP) to arrange a given array in ascending and
descending order.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
1. Intel Microprocessor kit 8085 1
PROBLEM STATEMENT:
An array of numbers given in various memory locations. From that the numbers are arranged
in descending and ascending order within these locations.
FLOWCHART:
ASCENDING ORDER DESCENDING ORDER
E
CO F
CE
RA
G
13
EE3413-MPMC Lab
4931_Grace college of Engineering
E
ALGORITHM:
(i) Sorting in ascending order:
1. Load the array count in two registers C1 and C2.
2. Get the first two numbers.
4. Decrement C2. CO
3. Compare the numbers and exchange if necessary so that the two numbers are in ascending order.
5. Get the third number from the array and repeat the process until C2 is 0.
6. Decrement C1 and repeat the process until C1 is 0.
(ii) Sorting in descending order:
1. Load the array count in two registers C1 and C2.
CE
2. Get the first two numbers.
3. ompare the numbers and exchange if necessary so that the two numbers are in descending order.
4. Decrement C2.
5. Get the third number from the array and repeat the process until C2 is 0.
6. Decrement C1 and repeat the process until C1 is 0.
RA
comparisons(n-1)
LOOP2 MOV A,M Transfer first data to acc.
INX H Increment HL reg. to point next
memory location
CMP M Compare M & A
JC LOOP1 If A is less than M then go to loop1
MOV D,M Transfer data from M to D reg
MOV M,A Transfer data from acc to M
DCX H Decrement HL pair
MOV M,D Transfer data from D to M
INX H Increment HL pair
LOOP1 DCR C Decrement C reg
JNZ LOOP2 If C is not zero go to loop2
DCR B Decrement B reg
JNZ LOOP3 If B is not Zero go to loop3
HLT Stop the program
14
EE3413-MPMC Lab
4931_Grace college of Engineering
E
LOOP1 DCR C Decrement C reg
JNZ LOOP2 If C is not zero go to loop2
INPUT
MEMORY
DCR
JNZ
HLT
ASCENDING ORDER
OUTPUT
DATA MEMORY
B
LOOP3
DATA MEMORY
INPUT
CO
Decrement B reg
If B is not Zero go to loop3
Stop the program
DESCENDING ORDER
DATA MEMORY
OUTPUT
DATA
LOCATION LOCATION LOCATION LOCATION
CE
RESULT:
RA
REVIEW QUESTIONS:
1. What is the addressing mode used in instruction MOV M, C?
2. Which interrupt has the lowest priority?
G
15
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
c. CONVERSION OF HEXADECIMAL TO ASCII AND VICE VERSA
AIM:
To write an Assembly Language Program (ALP) for performing conversion of Hexadecimal
to ASCII and vice-versa.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
1. Intel Microprocessor kit 8085 1
PROBLEM STATEMENT:
a) A Hexadecimal number is stored in the memory location. Convert the number into a ASCII
number and store the result in the memory locations.
b) An ASCII number is stored in the memory location. Convert the number into hex number and
store the result in the memory location
ALGORITHM:
a) Conversion of Hexadecimal to ASCII.
1. Get the data byte from the memory location to the accumulator.
2. Shift the higher order nibble to lower order nibble.
3. Call conversion subroutine.
4. Retrieve the byte again and repeat the conversion process for lower order nibble.
E
Subroutine
1. Mask higher order nibble and compare with 0AH.
from A to F.
3. Return to calling program.
b) Conversion of ASCII to Hexadecimal.
1. Get the first ASCII code.
2. Call the conversion subroutine.
3. Save as higher order nibble.
CO
2. If the digit is less than 10, add base number 30H,otherwise add 37H to obtain code for digits
Start
G
Start
YES
Go to subroutine A=A+30
16 Stop
EE3413-MPMC Lab
4931_Grace college of Engineering
E
STA 4502 Store the result
HLT
SUB 1
SKIP ADI
RET
CPI
JC
ADI
30
0A
SKIP
07 CO
Compare Data in A with 0A
Jump if carry is less than zero to SKIP
Add the 07 value with accumulator
JC SKIP
SUI 07
SKIP STA 4501 Store Hexa value
HLT
Hexadecimal to ASCII ASCII to Hexadecimal
HEX TO ASCII ASCII TO HEX
G
(ASCII) (ASCII)
RESULT:
17
EE3413-MPMC Lab
4931_Grace college of Engineering
REVIEW QUESTIONS
1. What is the ASCII value of 0?
2. What comparison is done for HEX to ASCII conversion?
3. What is the use of CMP instruction?
4. What is RLC?
5. What is RAR?
E
CO
CE
RA
G
18
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
d. CONVERSION OF BCD TO HEXADECIMAL
AND VICE – VERSA
AIM:
To write an Assembly Language Program (ALP) for performing conversion of BCD to
Hexadecimal and vice-versa.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
E
2. Multiply MSD by 10 and add with LSD.
3. Get the data and rotate it right four times.
4. Perfom the EX-OR operation and multiply with [Link] the count and if no zero
repeat the operation.
b) Conversion of Hexadecimal to BCD.
1. Get Hex data as input. CO
2. If the number is less than 100 and check whether the number is less than 10, otherwise
divide by 100(64H) or subtract 100 repeatedly until the remainder is less than [Link]
quotient is the most significant BCD digit BCD3.
3. If the number is less than 10(0AH), store the number as BCD1, otherwise divide by 10
CE
repeatedly until the remainder is less than [Link] quotient is BCD2.
PROGRAM TABLE:
BCD to HEXADECIMAL
Address Opcode Operand Comments
LXI H,4150
RA
HEXADECIMAL to BCD
Address Label Opcode Operand Comments
LXI H,4150 Initialize memory pointer
MVI D,00 Clear D: reg for MSB
XRA A Clear Accumulator
MOV C,M Get HEX data
LOOP2 ADI 01 Count the number one by one
DAA Adjust for BCD count
JNC LOOP1
19
EE3413-MPMC Lab
4931_Grace college of Engineering
INR D
LOOP1 DCR C
JNZ LOOP2
STA 4151 Store the Least Significant Byte
MOV A,D
STA 4152 Store the Most Significant Byte
HLT
FLOWCHART
BCD to Hexadecimal Hexadecimal to BCD
E
CO
CE
(ones)
G
(Hundreds)
MANUAL CALCULATION:
RESULT:
REVIEW QUESTIONS:
1. Compare Stack & RAM.
2. Explain DAA instruction.
3. Give the difference between PUSH & POP.
4. What are the machine cycles in NOP?
5. Give the difference between RET & End statement.
20
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
INTERFACING EXPERIMENTS
a. INTERFACING ANALOG TO DIGITAL CONVERTER
AIM:
To write an assembly language program to convert an analog signal into a digital signal using an ADC
interfacing.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
1. Intel Microprocessor kit 8085 1
2. ADC Interface board - 1
PROBLEM STATEMENT:
The program starts from a memory location. 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.
E
THEORY:
An ADC usually has two additional control lines: the SOC input to tell the ADC when to start
XRA A
XRA A
XRA A
MVI A,00 Initialise A reg
OUT D0 Send through output port
LOOP IN D8 Send through input port
ANI 01
CPI 01
JNZ LOOP Jump if not zero to LOOP
IN C0 Send through input port
STA 4150
HLT Stop the program
FLOWCHART
21
EE3413-MPMC Lab
4931_Grace college of Engineering
E
OUTPUT :
ANALOG DIGITAL DATA ON HEX CODE IN
VOLTAGE
RESULT:
LED DISPLAY
STOP CO
LOCATION
CE
REVIEW QUESTIONS:
1. What is a serial interface?
2. What are SOC and EOC?
[Link] is the technique used for ADC?
4. What is the clock frequency of ADC?
RA
22
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
b. INTERFACING DIGITAL – TO – ANALOG CONVERTER
AIM:
To write an assembly language program for digital to analog conversion
a. To convert digital inputs into analog outputs using DAC.
b. To generate different types of waveforms using DAC.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
1. Intel Microprocessor kit 8085 1
2. DAC Interface board - 1
PROBLEM STATEMENT:
a. The program starts from a memory location, where the input data is available. The output is
measured at pin numbers 13 and 26 of DAC chip.
b. The program starts from a memory location. The digital value is given in the memory locations.
E
The output is sent to the output ports. The waveforms are measured at the output ports using CRO.
THEORY:
Since DAC 0800 is an 8 bit DAC and the output voltage variation is between –5V and +5V. The
CO
output voltage varies in steps of 10/256 = 0.04 (approximately). The digital data input and the
corresponding output voltages are presented in the table. 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 H as input, the output is +5V. Outputting digital data 00
and FF at regular intervals, to DAC2, results in a square wave of amplitude 5V. Output digital data
from 00 to FF in constant steps of 01 to DAC2. Repeat this sequence again and again. As a result a
saw-tooth wave will be generated at DAC2 output. Output digital data from 00 to FF in constant steps
CE
of 01 to DAC2. Output digital data from FF to 00 in constant steps of 01 to DAC2. Repeat this
sequence again and again. As a result a triangular wave will be generated at DAC2 output.
ALGORITHM:
SQUARE WAVEFORM:
1. Send low value (00) to the DAC.
RA
4. Repeat step (2) and (3) until accumulator value reaches FF.
5. Repeat the above steps.
TRIANGULAR WAVEFORM:
1. Load the low value (00) in accumulator.
2. Send this accumulator content to DAC.
3. Increment the accumulator.
4. Repeat step 2 and 3 until the accumulator reaches FF, decrement the accumulator and send the
accumulator contents to DAC.
5. Repeat the above steps.
FLOWCHART:
23
EE3413-MPMC Lab
4931_Grace college of Engineering
Start
Start
Initialize the Accumulator, Send
Send the digital Value
Accumulator Content to DAC
toAccumulator
Delay
Stop
E
SAW-TOOTH WAVEFORM TRIANGULAR WAVEFORM
Start
Initialize CO Start
Initialize
Increment Increment
Accumulator Accumulator
RA
YES
NO YES
Is Acc ≤ FF Is Acc ≤ FF
NO
G
Decrement
Accumulator
Send Accumulator
content to DAC
YES NO
Is Acc ≤ 00
24
EE3413-MPMC Lab
4931_Grace college of Engineering
ADDRESS LABEL
START MNEMONICS
MVI OPERAND
A,00 Initialize ACOMMENTS
register
OUT C0 Write count to register
CALL DELAY
MVI A,FF Initialize FF to A reg
OUT C0 Write count to register
CALL DELAY
JMP START Jump to START
DELAY MVI B,05 Initialize 05 to B reg
L1 MVI C,FF Initialize FF to C reg
L2 DCR C Decrement C reg
JNZ L2 If C is not zero go to L2
DCR B Decrement B reg
JNZ L1 If B is not zero go to L1
RET
PROGRAM TABLE: Triangular Wave
E
ADDRESS LABEL MNEMONICS OPERAND COMMENTS
START MVI L,00 Initialize L register
L1
L2
MOV
OUT
INR
JNZ
MVI
MOV
CO
A,L
C0
L
L1
L,FF
A,L
Transfer data in L reg to A Reg
Write count to register
Increment A reg
If A is not zero go to L1
Initialize L reg to FF
Transfer data in L reg to A Reg
OUT C0 Write count to register
CE
DCR L Decrement L reg
JNZ L2 If L is not zero go to L2
JMP START Jump to START
PROGRAM TABLE: Saw tooth Wave
RA
Square
Waveform
Saw-tooth
waveform
Triangular
waveform
25
EE3413-MPMC Lab
4931_Grace college of Engineering
MODEL GRAPH:
Square Waveform Saw-tooth Waveform
Triangular waveform
E
RESULT:
REVIEW QUESTIONS:
1. How many control lines does DAC has?
2. What is a parallel interface?
3. What are the applications of DAC & ADC ?
4. What is the technique used in DAC?
CO
5. What is the clock frequency of DAC?
CE
RA
G
26
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
TRAFFIC LIGHT CONTROLLER
AIM:
To write an assembly language program to simulate the traffic lights at an intersection using a
traffic light interface.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
1. Microprocessor kit 8085 Vi Microsystems 1
2. Power Supply +5 V dc, +12 V dc 1
3. Traffic light interface kit. Vi Microsystems 1
PROBLEM STATEMENT:
The program starts from memory location [Link] input data should be available from 5000H
to [Link] output is displayed in traffic light interface kit.
ALGORITHM:
1. Initialise the ports.
2. Initialise the memory content, with some address to the data.
3. Read data for each sequence from the memory and display it through the ports.
E
4. After completing all the sequences, repeat from step2.
A SAMPLE SEQUENCE:
1.(a) Vechicles from south can go straight or left.
E
CONTRL
PORT A
EQU
EQU
0F
0C
CO
PORTB EQU 0B
CE
PORTC EQU 0E
PROGRAM TABLE
Address Label Mnemonic Operands
START LXI H,DATA
MVI C,0C
RA
MOV A,M
OUT CONTRL
INX H
LOOP1 MOV A,M
OUT PORT A
INX H
G
MOV A,M
OUT PORT B
CALL DELAY
INX H
DCR C
JNZ LOOP1
JMP START
DELAY PUSH B
MVI C,05
LOOP3 LXI D,FFFF
LOOP2 DCX D
MOV A,D
ORA E
JNZ LOOP2
DCR C
JNZ L
POP B
RET
28
EE3413-MPMC Lab
4931_Grace college of Engineering
ORG 4500
4500 80,1A,A1,64
4504 A4,81,5A,64
4508 54,8A,B1,A8
450C BA,88,DA,68
4510 D8,1A,E8,46
4514 E8,83,78,86,74
4519 END
RESULT:
E
REVIEW QUESTION:
1. List the software and hardware interrupts of 8085?
2. How clock signals are generated in 8085 and what is the frequency of the internal clock?
5. List the various peripheral devices used in traffic light controller interfacing.
CE
RA
G
29
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
INTERFACING EXPERIMENTS
a. INTERFACING USART 8251
AIM:
To study interfacing technique of 8251 (USART) with microprocessor 8085 and write an
8085 ALP to transmit and receive data between two serial ports with RS232 cable.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
1. Intel Microprocessor kit 8085 2
2. RS232 Cable - 1
PROBLEM STATEMENT:
The program starts from the memory location [Link] input data is given at location 4500H and
the same is received at the receiver side location 4500H.
THEORY:
The 8251 is used as a peripheral device for serial communication and is programmed by the
CPU to operate using virtually any serial data transmission technique. The USART accepts data
characters from the CPU in parallel format and then converts them into a continuous serial data
stream for transmission. Simultaneously, it can receive serial data streams and convert them into
E
parallel data characters from the CPU. The CPU can read the status of the USART at any time. These
include data transmission errors and control signals. The control signals define the complete
CO
functional definition of the 8251. Control words should be written into the control register of
[Link] control words are split into two formats: 1) Mode instruction word & 2) Command
instruction word. Status word format is used to examine the error during functional operation.
CE
RA
G
30
EE3413-MPMC Lab
4931_Grace college of Engineering
E
CO
CE
RA
G
ALGORITHM:
1. Initialize 8253 and 8251 to check the transmission and reception of a character.
2. Initialize 8253 to give an output of 150 KHz at channel 0 which will give a 9600 baud rate of 8251.
3. The command word and mode word is written to the 8251 to set up for subsequent operations.
4. The status word is read from the 8251 on completion of a serial I/O operation or when the host
CPU is checking the status of the device before starting the next I/O operation.
31
EE3413-MPMC Lab
4931_Grace college of Engineering
FLOW CHART:
TRANSMISSION AND RECEPTION
Start
No
Is it High
YES
E
Stop
E
RESULT:
CO
REVIEW QUESTIONS:
CE
1 .What is USART?
2. Is 8251 is memory mapped or I/O mapped?
3. What is serial communication?
4. What is baud rate?
5. What are the interrupt signals used between 8251 and processor?
RA
G
33
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
PROGRAMMING PRACTICES WITH SIMULATORS/
EMULATORS/OPEN SOURCE
AIM:
To write an Assembly Language Program (ALP) for performing the addition, subtraction,
multiplication and division operation of 8-bit numbers using 8085 simulation tool.
APPARATUS REQUIRED:
System With 8086 simulation tool.
ALGORITHM:
16-bit addition
1. Initialize the MSBs of sum to 0
2. Get the first data in a register pair.
3. Get the second data in a register pair.
4. Add the contents of both the register pairs.
5. If there is any carry, increment MSBs of sum by 1.
E
6. Store LSBs of sum.
7. Store MSBs of sum.
FLOWCHART:
Start
Stop
OUTPUT:
Memory Input Memory Output
Location Data Location Data
RESULT:
REVIEW QUESTIONS:
1. Differentiate between 8085 and 8086 processor?
2. Give some examples for 16-bit processors.
3. What are the functional blocks of 8086 processor?
4. What is an assembler and what type of assembler is used in 8086 based systems?
5. Compare the bus status of 8085 & 8086 during instruction execution?
E
CO
CE
RA
G
35
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
b. INTERFACING PROGRAMMABLE KEYBOARD AND DISPLAY CONTROLLER- 8279
AIM:
To Write an ALP in 8085 to display the rolling message “HELP US “.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
1. Intel Microprocessor kit 8085 1
PROBLEM STATEMENT:
The program starts from memory location 4100H. The input data is available at 4500H. The output is
displayed in 8279-interface kit.
Theory:
The 8279 interfaces a matrix keyboard and a multiplexed display of microprocessor. It has two
segments keyboard and display. It has 8 byte FIFO RAM to store key codes and has a 16 character
display. using this,64 contact key matrix can be interfaced with shift and control keys.
1. Display Mode Setup:Control word-10 H
E
0 0 0 0 1 0 0 0
0
DD
0 0 D
CO K K
1 1 0 1 1 1 0 0
CE
1 1 0 CD CD CD CF CA
RA
4. Read a Key:
0 0 E E E X X X
36
EE3413-MPMC Lab
4931_Grace college of Engineering
CNTL SHIFT
FLOW CHART:
E
CO
CE
RA
G
ALGORITHM:
(i) Display of rolling message “HELP US “
1. Initialize the counter.
2. Set 8279 for 8 digit character display, right entry.
3. Set 8279 for clearing the display.
4. Write the command to display.
5. Load the character into accumulator and display it.
[Link] the [Link] the above steps.
(ii) Accepting a key and to display it
1. Initialize the counter.
2. Set 8279 for 8 digit character display, right entry.
3. Set 8279 for clearing the display.
4. Write the command to display.
[Link] in the character and load it into the accumulator. Repeat the above steps.
37
EE3413-MPMC Lab
4931_Grace college of Engineering
PROGRAM TABLE:
ORG 4100
CNT EQU C2
DAT EQU C0
POINTER EQU 412C
E
MVI A,90H Write Display
LOOP MOV
OUT
OUT
CALL
INX
CNT
A,M
DAT
DELAY
H
CO Increment the pointer
CE
DCR D Decrement the counter
JNZ LOOP Jump if non zero to display
JMP START the next character
DELAY MVI B,0A0H
RA
JNZ LOOP1
RET
INPUT DATA:
MEMORY 7-SEGMENT LED FORMAT HEX DATA
LOCATION
D c b a dp e g f
38
EE3413-MPMC Lab
4931_Grace college of Engineering
E
RESULT:
REVIEW QUESTIONS:
1. What is the clock frequency of 8279?
2. Which is used as DMA CONTROLLER?
3. What are level-triggering interrupt in 8085?
CO
4. Which one is raising edge-triggering interrupt in 8085?
5 .How do you represent a. seven segment display?
CE
RA
G
39
EE3413-MPMC Lab
4931_Grace college of Engineering
8051 MICROCONTROLLER
[Link]: Date:
DEMONSTRATION OF BASIC INSTRUCTIONS
a. 8 BIT ADDITION
AIM:
To write an ALP for performing the addition of two 8-bit numbers using 8051microcontroller.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
1. Microcontroller kit 8051 1
PROBLEM STATEMENT:
Store the first data in one memory location and the second data in the other location. Perform
the addition and store the result in one memory location and the carry in other location.
THEORY:
8051 consists of Accumulator (ACC)
B Register
Stack Pointer (SP)
E
Program Counter (PC)
Program Status Word (PSW)
Data pointer Register (DPTR)
8 – bit registers
ACCUMULATOR:
CO
It is a 8-bit register. It is usually referred as A. It is very important register to store the result of data
operations of Arithmetic and Logical operations. It is also used for data transfer between the device &
external memory.
B-REGISTER:
It is used for multiplication & division operations. At the time of execution, it keeps one of the 2
CE
inputs and the portion of the result is retained in the register.
STACK POINTER (SP):
It is an 8-bit register. Generally stack pointer is initialized to RAM address 07H after a rest. It is
automatically incremented (or) decremented for PUSH, POP instructions.
ARITHMETIC LOGIC UNIT (ALU):
It is used to perform arithmetic and logical instructions such as addition, AND, bit operations etc.,
RA
40
EE3413-MPMC Lab
4931_Grace college of Engineering
FLOW CHART:
8 BIT ADDITION
Start
E
Stop
ADDITION:
MEMORY
INPUT
LOCATION
DATA MEMORY
LOCATION
(SUM)
CO
OUTPUT
DATA
CE
(CARRY)
RESULT:
RA
G
41
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
b. 8 BIT SUBTRACTION
AIM:
To write an ALP for performing the subtraction of two 8-bit numbers using
8051microcontroller.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
1. Microcontroller kit 8051 1
PROBLEM STATEMENT:
Store the first data in one memory location and the second data in the other location. Perform the
subtraction and store the result in one memory location and borrow in other location.
ALGORITHM:
1. Clear the carry flag.
2. Initialize the register for borrow.
3. Get the first operand into the accumulator.
4. Subtract the second operand from the accumulator.
5. If a borrow results, then increment the carry register.
E
6. Store the result in memory.
FLOWCHART
Start
CO
Get subtrahend&
minuend
CE
subtrahend
Store the
difference
G
Stop
PROGRAM TABLE:
ADDRESS LABEL MNEMONICS OPERAND COMMENTS
CLR C Clear the PSW
MOV A,# data1 Load 1st number in accumulator
SUBB A,# data2 Subtract data1 from data2
MOV DPTR,#4500 Load destination address in
DPTR
MOVX @ DPTR, A Store difference
L1 SJMP L1 Terminate the program
42
EE3413-MPMC Lab
4931_Grace college of Engineering
MANUAL CALCULATION
SUBTRACTION:
INPUT OUTPUT
MEMORY DATA MEMORY LOCATION DATA
LOCATION
(DIFFERENCE)
(BORROW)
RESULT:
E
REVIEW QUESTIONS: (8 bit addition and subtraction)
1. What is the difference between microprocessor & microcontroller?
2. How many bits are 8051 microcontroller?
3. What is the use of DPTR?
4. Give one example of arithmetic instruction.
5. What is ADD A,R0?
CO
CE
RA
G
E
7. Decrement the counter and if it reaches 0, stop. Otherwise increment the memory
pointer by1 and go to step 4.
PROGRAM TABLE
ADDRESS LABEL MNEMONICS
MOV
CO
OPERAND
DPTR,#4200
COMMENTS
Load DPTR with the count
value.
MOVX A,@DPTR Move the DPTR value to the
CE
accumulator.
MOV R0,A Move the accumulator value to
R0 register.
MOV B,#00 Clear the B register.
MOV R1,B Move the B value to R1 register.
RA
44
EE3413-MPMC Lab
4931_Grace college of Engineering
E
OUTPUT:
Memory location Values
CO
CE
RESULT:
RA
REVIEW QUESTIONS:
1. How many parallel I/O ports does 8051 has?
2. What is the total external data memory that can be interfaced to the 8051?
3. What is an alternate function of port pin P3.1 in the 8051?
4. Which I/O port does not have a dual-purpose role in 8051?
5. State true or False: Data transfer from I/O to external data memory can only be done with the MOV
G
command
45
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
INTERFACING DC MOTOR WITH 8051 MICROCONTROLLER
AIM:
To write an 8051 assembly language program to rotate stepper motor in
Clockwise/Anticlockwise direction.
APPARATUS REQUIRED:
[Link] EQUIPMENT SPECIFICATION QUANTITY
1. Microcontroller kit 8051 1
2. Digital i/o interface chord - 1
FLOWCHART:
E
CO
CE
RA
G
PROBLEM STATEMENT:
Dc motor is interfaced to 8051 microcontroller and speed of the dc motor is recorded by
making use of the count value stored in the timer. It can be repeated for different speed by loading the
count value into timer.
ALGORITHM:
1. For running Stepper motor in clockwise and anti clockwise direction.
2. Get the data from the look up table
3. Initialize the counter and move data in to the accumulator.
4. Drive the stepper motor circuitry and introduce Delay.
5. Decrement the counter if it is not zero and repeat from step 3.
6. Repeat the above procedure for continuous rotation.
Clockwise direction Anti Clockwise direction
Memory A1 A2 B1 B2 Hex
Location code
46
EE3413-MPMC Lab
4931_Grace college of Engineering
Memory A1 A2 B1 B2 Hex
Location code
PROGRAM TABLE
Address Opcode & Label Mnemonics Comments
Operand
ORG 4100H
START: MOV DPTR,#4500H Load address to DPTR
MOV R0,#04H Move 04 to R0 reg
MOVX A, @DPTR Move Data from DPTR
REPEAT:
Location to Acc
PUSH DPH
E
PUSH DPL
MOV DPTR,#FFC0H
DLY 1:
DLY 2:
DLY 3:
CO
MOV R1,#04H
MOV R2,#FFH
MOV R3,#FFH
DJNZ R3,DLY3
DJNZ R2,DLY2
Delay Program
DJNZ R1,DLY1
CE
MOVX @DPTR,A Delay Program
POP DPL
POP DPH
INC DPTR
DJNZ R0, REPEAT
RA
RESULT:
REVIEW QUESTIONS:
1. Give the applications of stepper motor?
2. What is excitation code?
3. What are the differences between microprocessor and microcontroller?
4. What is operating frequency of microcontroller?
5. How many interrupts are associated with 8051 serial ports?
47
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
STUDY ON INTERFACE ANALOG TO DIGITAL CONVERTER
AIM:
To study interfacing of A/D converter using 8051 Microcontroller.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
1. Intel Microprocessor kit 8051 1
PROBLEM STATEMENT:
The program starts from a memory location. The program is executed for various values of
E
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.
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).
CO
5. Read the digital [Link] it in a memory location.
PROGRAM TABLE:
Address Label Mnemonic Operands Comments
CE
MOV A,#90H Move the data to the accumulator
MOV DPTR,#4003H Move the data to DPTR
MOVX @DPTR,A Move the accumulator content to DPTR
MOV DPTR,#4001H Move the data to DPTR
MOV A,#01H Move the data to the accumulator
RA
FLOWCHART:
48
EE3413-MPMC Lab
4931_Grace college of Engineering
E
OUTPUT :
Analog voltage
Stop
CO
Digital data on led display Hex code in location
CE
RESULT:
REVIEW QUESTIONS:
RA
49
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
b. INTERFACING DIGITAL – TO – ANALOG CONVERTER
AIM:
To write an assembly language program for digital to analog conversion and to generate
different waveforms using 8051 microcontroller.
APPARATUS REQUIRED:
[Link] ITEM SPECIFICATION QUANTITY
1. Intel Microcontroller kit 8051 1
2. DAC Interface board Microsystems 1
PROBLEM STATEMENT:
A) The program starts from memory location 4100H. The input data is at 4101H. The output is
measured at pin numbers 13 and 26 of DAC chip. B) The program starts from memory location
4100H. The is given in the memory locations 4101H and 4108 H. The output is sent to the output
ports. The waveforms are measured at the output ports using CRO.
THEORY:
E
Refer Experiment No.3.b.
FLOWCHART:
SQUARE WAVEFORM
Start
Start
Initialize
Send Accumulator Content
CE
to DAC
Send Accumulator
Delay content to DAC
RA
Delay NO
Is Acc ≤ FF YES
G
TRIANGULAR WAVEORM:
50
EE3413-MPMC Lab
4931_Grace college of Engineering
Start
Initialize
Send Accumulator
content to DAC
Increment
Accumulator
YES
Is Acc ≤ FF
NO
E
Decrement
Accumulator
Yes
CO
Send Accumulator
content to DAC
NO
Is Acc ≤ 00
CE
ALGORITHM:
Waveform generation:
Square Waveform:
1. Send low value (00) to the DAC.
RA
51
EE3413-MPMC Lab
4931_Grace college of Engineering
E
MOVX @DPTR,A Move data from accumulator to DPTR
INC A Call the delay
DELAY
LOOP
JNC
MOVA
MOVX
DEC
JNZ
LJMP
LOOP1
A
LOOP2
START
CO
@DPTR,FF
@DPTR,A
Move FF into accumulator
Move data from accumulator to DPTR
Call the delay
Jump to start
Move 05 value into R1 register
Move FF value into R2 register
LOOP1 DJNZ R2,LOOP Decrement R2 and jump on non zero to loop
CE
DJNZ R1,LOOP1 Decrement R1 and jump on non zero to loop
RET
SJMP START Jump to start
Saw tooth waveform:
Address Label Mnemonic Operands Comments
RA
Square Waveform
Saw-tooth waveform
Triangular waveform
MODEL GRAPH:
Saw tooth Waveform Triangular waveform
Square Waveform
52
EE3413-MPMC Lab
4931_Grace college of Engineering
RESULT:
REVIEW QUESTIONS:
1. How many bits is DAC 0808?
2. What are different program development tools?
3. Explain the use of assembler and linker.
4. Explain different types of memory models used.
5. What is the use of EOC and SOC signals?
E
CO
CE
RA
G
53
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
FIBONACCI SERIES
AIM:
To write an assembly language program to displace Fibanocci Series.
APPARATUS REQUIRED:
8085 microprocessor kit
(0-5V) DC battery
ALGORITHM:
Step 1 : Start the microprocessor
Step 2 : Load the length of series in the accumulator and decrement it by 2
Step 3 : Move the value to register ‘D’
Step 4 : Load the starting value of data value address
Step 5 : Intialise the 1st number as 00
Step 6 : Move the pointer to 2nd data and intialise them as ‘01’
Step 7 : Move the pointer to next position for next data
Step 8 : Intialise B as ‘00’ and C as ‘01’ for calculations
Step 9 : Copy the contents of ‘B’ to accumulator
Step 10 : Add the content of ‘C’ register to accumulator
E
Step 11 : Move the content ‘C’ to ‘B’ and ‘A’ to C
Step 12 : Now store the result to memory pointed by ‘HL’ pair
Step 13 : Move the pointer to next pointer
Step 14 : Decrement 0 by 1 for counter
Step 15 : If ‘D’ is not zero, go to step 9
Step 16 : if ‘D’ is zero, end the program
PROGRAM TABLE:
Address Label Mnemonics
CO
Hex Code Comments
4200 LDA 4300 3A, 00, 43 Store the length of series in ‘A’
CE
4203 SUI 02 D6, 02 Decrement ‘A’ by 02
4205 MOV D,A 57 Move ‘A’ to ‘D’ (counter)
4206 LXI H, 4301 21,01,43 Load the starting address of array
4209 MVI M,00 36,00 Intialise 4301 as ‘00’
420B INX H 23 Increment pointer
Initialize 2nd as ‘01’
RA
54
EE3413-MPMC Lab
4931_Grace college of Engineering
E
CO
CE
RA
INPUT:
55
EE3413-MPMC Lab
4931_Grace college of Engineering
[Link]: Date:
FLASHING DISPLAY
AIM:
To write an assembly language program to obtain the following flashing display of a particular data.
APPARATUS REQUIRED:
8085 micro processing kit
(0-5V) power supply
ALGORITHM:
Step 1 : Get the control words in accumulator and output words through 8 bit address
Step 2 : Load ‘HL’ register pair with memory address
Step 3 : Get the count value in ‘C’ register
Step 4 : Increment the register pair by one and display the character and call for delay.
Step 5 : Clear the display and call delay routine to step 7
Step 6 : Go to step 7
E
Step 7 : Load ‘DE’ register pair with memory address
Step 8 : Decrement ‘DE’ pair with memory address
Step 9 : If the content is not equal to zero, go to step 8
Step 10 : Return to main program
Memory
Location
4300
4302
Hex Code Label
MVI
OUT
Mnemonics
Op code
A,00
01
CO
Operand
3E,00
DE,01
Comments
56
EE3413-MPMC Lab
4931_Grace college of Engineering
E
CO
CE
RA
G
INPUT
57
EE3413-MPMC Lab
4931_Grace college of Engineering
RESULT:
REVIEW QUESTION:
1. What happens when HLT instruction is executed in processor?
2. Which Stack is used in 8085?
3. What is Tri-state logic?
4. What are the various flags in 8085?
5. What are the hardware interrupts?
E
CO
CE
RA
G
58
EE3413-MPMC Lab
4931_Grace college of Engineering
E
CO
CE
RA
G
59
EE3413-MPMC Lab