MPMC Lab
MPMC Lab
DEPARTMENT OF
ELECTRONICS & COMMUNICATOIN ENGINEERING
2015-2016
INCHARGE HOD
(M.Laxmi) (Dr. P. Srihari)
1|Page
Geethanjali College Of Engineering And Technology, Cheeryal
Microprocessors and Microcontrollers lab Dept of ECE
1) Name : 1) Name :
2) Sign : 2) Sign :
3) Desg : 3) Desg :
4) Date : 4) Date :
Approved by : (HOD )
1) Name : Dr.P.Srihari
2) Sign :
3) Date :
GCET 2|Page
Microprocessors and Microcontrollers lab Dept of ECE
List of Experiments
The following programs/experiments are written for assembler and execute the
same with8086 and 8051 kits
1. Programs for 16 bit arithmetic operations for 8086 (using various addressing
modes)
2. Program for sorting an array for 8086
3. Program for searching for a number or character in a string for 8086
4. Program for String manipulations for 8086
5. Program for digital clock design using 8086.
6. Interfacing ADC and DAC to 8086.
7. Parallel communication between two microprocessors using 8255.
8. Serial communication between two microprocessor kits using 8251.
9. Interfacing to 8086 and programming to control stepper motor.
10. Programming using arithmetic, logical and bit manipulation instructions of 8051
11. Program and verify Timer/Counter in 8051.
12. Program and verify interrupt handling in 8051.
13. UART operation in 8051.
14. Communication between 8051 kit and PC.
15. Interfacing LCD to 8051.
16. Interfacing matrix or keyboard to 8051.
17. Data transfer from peripheral to memory through DMA controller 8237/8257
GCET 3|Page
Microprocessors and Microcontrollers lab Dept of ECE
GCET 4|Page
Microprocessors and Microcontrollers lab Dept of ECE
GCET 5|Page
Microprocessors and Microcontrollers lab Dept of ECE
Course Overview:
Course Outcomes:
GCET 6|Page
Microprocessors and Microcontrollers lab Dept of ECE
3. While coming to the lab bring the lab manual cum observation book,
record etc.
4. Take only the lab manual, calculator (if needed) and a pen or pencil to
the work area.
5. Before coming to the lab, prepare the prelab questions. Read through
the lab experiment to familiarize yourself with the components and
assembly sequence.
GCET 7|Page
Microprocessors and Microcontrollers lab Dept of ECE
10. Of the 25 marks for internal, 15 marks shall be awarded for day-to-day
work and 10 marks to be awarded by conducting an internal laboratory
test.
1. Observation book and lab records submitted for the lab work are to be
checked and signed before the next lab session.
2. Students should be instructed to switch ON the power supply after the
connections are checked by the lab assistant / teacher.
3. The promptness of submission should be strictly insisted by awarding the
marks accordingly.
4. Ask viva questions at the end of the experiment.
5. Do not allow students who come late to the lab class.
6. Encourage the students to do the experiments innovatively.
GCET 8|Page
Microprocessors and Microcontrollers lab Dept of ECE
LIST OF EXPERIMENTS
CYCLE-I (MICROPROCESSOR PROGRAMS)
1. Study of TASM/MASM
2. 16-bit arithmetic Operations
3. Sorting an Array
4. Searching for Character in a String
5. Sting Manipulations
6. Digital Clock Design
7. Interfacing DAC
8. Interfacing ADC
GCET 9|Page
Microprocessors and Microcontrollers lab Dept of ECE
INDEX
CYCLE -I
0 Study of TASM/MASM 14
3 Sorting an Array 34
5 Sting Manipulations 43
7 53
Interfacing DAC
8 58
Interfacing ADC
9 61
Serial communication between two 8086
microprocessors
10 Interfacing stepper motor 65
GCET 10 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
CYCLE-II
12 Introduction to 8051 70
15 Interrupt Handling 91
GCET 11 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
INTRODUCTION TO TASM
EDITOR:
ASSEMBLER:
LINKER:
A linker is a program used to join several object files into one large object file
GCET 12 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
and convert to an exe file. The linker produces a link file, which contains the binary
codes for all the combined modules. The linker however doesn’t assign absolute
addresses to the program, it assigns is said to be relocatable because it can be put
anywhere in memory to be run. In TASM, TLINK source filename is used to link the
file.
DEBUGGER:
A debugger is a program which allows you to load your object code program
into system memory, execute the program and troubleshoot are debug it the
debugger allows you to look at the contents of registers and memory locations after
your program runs. It allows you to change the contents of register and memory
locations and return the program. A debugger also allows you to set a break point at
any point in the program. If you inset a breakpoint the debugger will run the program
upto the instruction where the breakpoint is set and stop execution. You can then
examine register and memory contents to see whether the results are correct at that
point. In TASM, td filename is issued to debug the file.
DEBUGGER FUNCTIONS:
DEBUGGER COMMANDS:
GCET 13 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
ASSEMBLE:
To write assembly language program from the given address
A starting address <cr>
Eg: a 100 <cr>
Starts program at an offset of 100.
DUMP:
To see the specified memory contents
D memory location first address last address
(While displays the set of values stored in the specified range, which is given above)
Eg: d 0100 0105 <cr>
Display the contents of memory locations from 100 to 105(including).
ENTER:
To enter data into the specified memory locations(s).
E memory location data data data data data …<cr>
Eg: e 1200 10 20 30 40 ….
Enters the above values starting from memory locations 1200 to 1203, by loading 10
into 1200,20 into 1201 and soon.
GO:
To execute the program
G: one instruction executes (address specified by IP)
G address <cr>: executes from current IP to the address specified
G first address last addresses <cr>: executes a set of instructions specified between
the given addresses
MOVE:
Moves a set of data from source location to destination location
M first address last address destination address
Eg: m100 104 200
Transfers block of data (from 100 to 104) to destination address 200.
GCET 14 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
QUIT:
To exit from the debugger.
Q <cr>
REGISTER:
Shows the contents of Registers
R register name
Eg: r ax
Shows the contents of register.
TRACE:
To trace the program instruction by instruction.
T = 0100 <cr>: traces only the current instruction. (Instruction specified by IP)
T = 0100 02 <cr>: Traces instructions from 100 to 101, here the second argument
specifies the number of instructions to be traced.
UNASSEMBLE:
To unassembled the program.
Shows the opcodes along with the assembly language program.
GCET 15 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
8086 ARCHITECTURE:
GCET 16 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
PIN DIAGRAM:
GCET 17 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Arithmetic Instructions
ADD, SUB : Add, subtract byte or word
ADC, SBB : Add, subtract byte or word and carry (borrow)
INC, DEC : Increment, decrement byte or word
NEG : Negate byte or word (two's complement)
CMP : Compare byte or word (subtract without storing)
MUL, DIV : Multiply, divide byte or word (unsigned)
IMUL, IDIV : Integer multiply or divide byte or word (signed)
CBW, CWD : Convert byte to word, word to double word (useful before
multiply/divide)
AAA, AAS, AAM, AAD: ASCII adjust for addition, subtraction, multiplication,
division (ASCII codes 30-39)
DAA, DAS : Decimal adjust for addition, subtraction (binary coded
decimal numbers)
Transfer Instructions
JMP : Unconditional jump
JA (JNBE) : Jump if above (not below or equal)
JAE (JNB) : Jump if above or equal (not below)
JB (JNAE) : Jump if below (not above or equal)
JBE (JNA) : Jump if below or equal (not above)
JE (JZ) : Jump if equal (zero)
JG (JNLE) : Jump if greater (not less or equal)
JGE (JNL) : Jump if greater or equal (not less)
JL (JNGE) : Jump if less (not greater nor equal)
JLE (JNG) : Jump if less or equal (not greater)
JC, JNC : Jump if carry set, carry not set
JO, JNO : Jump if overflow, no overflow
GCET 18 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
String Instructions
MOVS : Move byte or word string
MOVSB, MOVSW : Move byte, word string
CMPS : Compare byte or word string
SCAS : Scan byte or word string
LODS, STOS : Load, store byte or word string
REP : Repeat
REPE, REPZ : Repeat while equal, zero
REPNE, REPNZ : Repeat while not equal (zero)
GCET 19 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
CYCLE-I
GCET 20 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
EXPERIMENT NO.1
OBJECTIVE:
To write an assembly language program for performing addition of two 16-bit signed and
unsigned numbers.
ALGORITHM:
Step I : Initialize the data memory.
Step II : Load the first number into AX register.
Step II : Load the second number into BX register.
Step IV : Add two lower digits.
Step V : Adjust result to valid BCD number.
Step VI : Store the result in BL.
Step VI : Add the two upper digits with carry.
Step VIII : Adjust result to valid BCD number.
Step IX : Store the result in BH.
Step X : Display the result.
Step XI : Stop.
GCET 21 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOW CHART:
START
INITIALIZATION OF DATA
SEGMENT
AXOPR1
AXAX+OPR2
RESAX
RESULT: STOP
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=0, s=0, z=0, o=0, p=1, a=0, i=1, d=0.
SIGNED NUMBERS
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=1, s=0, z=0, o=1, p=0, a=0, i=1, d=0.
GCET 22 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
OUTCOME
Upon completion of this experiment, the student will be able to:
1. Employ the arithmetic instructions in various programs.
GCET 23 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
OBJECTIVE
To write an assembly language program to perform subtraction of two 16-bit signed and
unsigned numbers.
ALGORITHM:
FLOW CHART:
START
INITIALIZATION OF DATA
SEGMENT
AXOPR1
AXAX-OPR2
RESAX
STOP
RESULT
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=0, s=0, z=0, o=0, p=1, a=0, i=1, d=0.
GCET 24 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
: OPR2 = 1000H
OUTPU : RES = 3269H
SIGNED NUMBERS
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=0, s=0, z=0, o=0, p=1, a=0, i=1, d=0.
OUTCOME:
GCET 25 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
OBJECTIVE:
ALGORITHM:
Step I : Initialize the data memory.
Step II : Load the first number into AX register.
Step III : Load the second number into BX register.
Step IV : Multiply AX with BX.
Step V : store lower byte in accumulator.
Step VI : Store Upper byte in DX register
Step VII : Display the result.
Step VIII : Stop.
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
AXOPR1
AXAX*OPR2
RESLWAX
RESHWDX
STOP
GCET 26 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
RESULT:
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=1, s=0, z=0, o=1, p=0, a=0, i=1, d=0.
OUTCOME:
Upon completion of this experiment, the student will be able to:
GCET 27 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
OBJECTIVE:
To write an assembly language program to perform division of 16-bit unsigned
number by 8-bit unsigned number.
ALGORITHM:
Step I : Initialize the data memory.
Step II : Load the first number into AX register.
Step III : Load the second number into BX register.
Step IV : Divide AX by BX.
Step V : store Quotient in AL register.
Step VI : Store reminder in AH register
Step VII : Display the result.
Step VIII : Stop.
FLOW CHART:
START
INITIALIZATION OF DATA
SEGMENT
DIVISION OF AX BY OPR2
AXAX/OPR2
RESQAL
RESRAH
STOP
GCET 28 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
RESULT:
FLAGS:
Before execution, c=0, s=0, z=0, o=0, p=0, a=0, i=1, d=0.
After execution, c=0, s=0, z=0, o=0, p=0, a=1, i=1, d=0.
INPUT:
OPR1 = 2C58H (DIVIDEND)
OPR2 = 56H (DIVISOR)
OUTPUT:
RESQ = 84H (AL)
RESR = 00H (AH)
VIVA QUESTIONS:
OUTCOME
Upon completion of this experiment, the student will be able to:
1. Employ the arithmetic instructions in various programs.
GCET 29 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
EXPERIMENT NO.2
I.ASCENDING ORDER
OBJECTIVE:
To write an assembly language program to arrange the given numbers in ascending
order.
ALGORITHM:
GCET 30 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
DXCOUNT-1
BACK : CXDX
SIOFFSET
ADDRESS OF LIST
AGAIN: AX[SI]
IF TRUE
AX < [SI+2]
FALSE
EXCHANGE
[SI] &[SI+2]
INCREMENT SI BY 2
FALSE
IF
CX=0
TRUE
DECREMENT DX
FALSE
IF
DX=0
TRUE
STOP
GCET 31 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
RESULT:
OUTCOME:
Upon completion of this experiment the student will be able to:
1. Demonstrate the control transfer instructions.
2. Explain number searches and differentiates bigger and smaller numbers from
large database.
GCET 32 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
ALGORITHM:
GCET 33 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOW CHART:
START
INITIALIZATION OF
DATA SEGMENT
DXCOUNT-1
BACK : CXDX
SIOFFSET
ADDRESS OF LIST
AGAIN: AX[SI]
IF TRUE
AX < [SI+2]
FALSE
EXCHANGE
[SI] &[SI+2]
INCREMENT SI BY 2
FALSE
IF
CX=0
TRUE
DECREMENT DX
FALSE
IF
DX=0
TRUE
GCET 34 |
Page STOP
Microprocessors and Microcontrollers lab Dept of ECE
RESULT:
VIVA QUESTIONS:
OUTCOME:
Upon completion of this experiment the student will be able to:
1. Demonstrate the control transfer instructions.
2. Explain number searches and differentiates bigger and smaller numbers from
large database.
GCET 35 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
EXPERIMENT NO.3
PROGRAM FOR SEARCHING FOR A NUMBER/CHARACTER IN A STRING FOR
8086 MICROPROCESSOR
OBJECTIVE:
To find whether the given byte is in given string or not & find its relative address
ALGORITHM:
Step V : Scan for the byte in ES. If the byte is found ZF=0,move the address
pointed by S:DI to BX
.
Step VI : Store the result
GCET 36 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOWCHART:
START
INITIALIZATION OF DATA
SEGMENT
ALBYTE CLCOUNT,
BX=00,SI, OFFSET LIST
Yes
IF AL=[SI]
Increment BX
Increment SI,Decrement CL
no
If
yes
CL=0
NOP
STOP
RESULT:
GIVEN DATA:
N=19H,99H,45H,46H,34H
BYTE= 45H
FLAGS:
INITIALLY: C=0,Z=0,S=0,O=0,P=0,A=0,I=1,D=0
AFTER EXECUTION: C=0,Z=1,S=0,O=0,P=1,A=0,I=1,D=0
GCET 37 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
OUTPUT:
RES: 45H
ADDRESS: BX----0002
VIVA QUESTIONS:
OUTCOME:
Upon completion of this experiment the student will be able to:
1. .Demonstrate the control transfer instructions.
2. Explain number searches and differentiates bigger and smaller numbers from
large database.
GCET 38 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
EXPERIMENT NO.4
OBJECTIVE:
To write an assembly language program to find the length of the given string.
ALGORITHM:
GCET 39 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOW CHART
START
INITIALIZATION OF
DATA SEGMENT
AL24H CL00H
SI OFFSET ADDRESS
OF STR1
TRUE
AL=[SI]
FAL
SE
Increment CL
Increment SI
NOP Uncon
ditional
Jump
NOP
LENGTHCL
STOP
GCET 40 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
RESULT:
OUTPUT: LENGTH =
OUTCOME:
Upon completion of this experiment the student will be able to:
1. Describe the memory management and select the proper memory.
2. Demonstrate the control transfer instructions
GCET 41 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
OBJECTIVE:
To write an assembly language program to display the given string.(DOS PROGRAMMING)
ALGORITHM:
GCET 42 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOWCHART
RESULT
WELCOME TO MICROPROCESSORS LAB
OUTCOME:
Upon completion of this experiment the student will be able to:
1.Describe the memory management and select the proper memory.
2.Demonstrate the DOS Interrupts.
GCET 43 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
OBJECTIVE:
To write an assembly language program to reverse the given string.
ALGORITHM:
Step III : In code segment move the data segment value to data segment
register
Step IV : Move count value (count +1) to count register and define offset
address of destination to DI and move 04 H to DX
Step V : Define offset address of src to SI then move SI to BX and then BX to
DX
Step VI : Decrement the destination index then subtract source index value
GCET 44 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOW CHART:
START
INITIALIZATION OF DATA
SEGMENT
CLCOUNT
SIoffset address of STR1
DICOUNT-1
[DI]=[SI]
INC SI
DEC DI
DEC CL
FALS If
E CL=0
TRUE
STOP
RESULT:
GCET 45 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
VIVA QUESTIOS:
4) What is the relation between 8086 processor frequency & crystal Frequency?
OUTCOME: Upon completion of this experiment the student will be able to:
1.Describe the memory management and select the proper memory.
2.Demonstrate the control transfer instructions
GCET 46 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
EXPERIMENT NO.5
OBJECTIVE:
To write an assembly language program to display current system time.(DOS
PROGRAMMING)
ALGORITHM:
GCET 47 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
VIVA QUESTIONS:
1) Functions of BX register?
2) Functions of CX register?
3) Functions of DX register?
OUTCOME:
Upon completion of this experiment the student will be able to Demonstrate
displaying current system time using DOS programming.
GCET 48 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
EXPERIMENT NO.6
OBJECTIVE:
To write a Program to generate following wave forms
a. Ramp waveform
b. Square waveform
c. Step waveform
d. Triangle waveform
GCET 49 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
ALGORITHM:
Waveform generation:
GCET 50 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOWCHART
Saw-tooth waveform:
FLOWCHART
GCET 51 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Triangular waveform:
FLOWCHART
RESULT: Thus the DAC was interfaced with 8085 and different
waveforms have been generated.
GCET 52 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Outcome: Upon completion of this experiment the student will be able to:
1.Demonstrate and 8255 PPI how the 8086 microprocessor is interfaced.
2.Design 8086 microprocessor system by using the peripheral devices
3. Interpret the data transfer from 8086 microprocessor to the peripheral device and
vice versa.
GCET 53 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
EXPERIMENT NO.7
ALGORITHM
GCET 54 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOWCHART
RESULT:
Thus the ADC was interfaced with 8086 and the givenanalog inputs were converted
into its digital equivalent
VIVA QUESTIONS:
GCET 55 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Outcome: Upon completion of this experiment the student will be able to:
1.Demonstrate and 8255 PPI how the 8086 microprocessor is interfaced.
2.Design 8086 microprocessor system by using the peripheral devices
3. Interpret the data transfer from 8086 microprocessor to the peripheral device and
vice versa.
GCET 56 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
EXPERIMENT NO.8
PROCEDURE :
Transmission
1. Connect 8086 kit PC using RS232 cable.
2. Connect Power supply to 8086 kit and 8251 interfacing kit(only blue(+5v) and
black(0v) lines Power cable to power supply)
3. Connect 8251 to 8086 using 50pin and 26pin bus.
4. Short 5 & 6 pins of JP9 in 8251 kit
5. Keep the DIP switch in 1 & 7 on (8086kit), open TALK, and go to options select
target device as 8086 and Connect.
6. Change dip switch into 1 & 5on, once reset 8086 kit.
7. Go to file →Download hex file
8. G-4000(on system keyboard), we can observe the output on 8251 kit.
9. Remove RS232 cable from 8086kit and connect it to 8251, transmitted data
displayed on PC Monitor
RECEIVEING
GCET 57 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
ALGORITHM
Step I Initialize 8253 and 8251 to check the transmission and reception of a
character
Step II Initialize8253 to give an output of 150Khz at channel 0 which will give a
9600 baud rate of 8251.
Step III The command word and mode word is written to the 8251 to set up for
subsequent operations
Step IV The status word is read from the 8251 on completionof a serial I/O
operation, or when the host CPU is checking the status of the device before starting
the next I/O operation
GCET 58 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOWCHART
VIVA-VOCE QUESTIONS:
1. Expand USART?
2. Where do we prefer the serial communication?
3. What is the function of instruction pointer (IP) register?
4. What is the difference between IN and OUT instructions?
5. What is MODEM?
OUTCOME: Upon completion of this experiment the student will be able to:
1.Demonstrate and 8255 PPI how the 8086 microprocessor is interfaced.
2.Design 8086 microprocessor system by using the 8251 peripheral devices
GCET 59 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
3. Interpret the data transfer from 8086 microprocessor to the peripheral device and
vice versa.
Fig1.8251 CONNECTIONS
GCET 60 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
EXPERIMENT NO.9
OBJECTIVE: Write a program in ALP to interface stepper motor to 8086 and rotate it
in clockwise And anticlockwise direction.
ALGORITHM:
GCET 61 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
GCET 62 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
RESULT:
Thus the assembly language program for rotating stepper motor in both clockwise
and anticlockwise directions is written and verified.
VIVA QUESTIONS:
1) What is the difference between min mode and max mode of 8086?
Outcome: Upon completion of this experiment the student will be able to:
1.Demonstrate and 8255 PPI how the 8086 microprocessor is interfaced.
2.Design 8086 microprocessor system by using the peripheral devices
3. Interpret the data transfer from 8086 microprocessor to the peripheral device and
vice versa.
GCET 63 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
EXPERIMENT NO.10
PROCEDURE:
ALGORITHM:
Step I : DMA request is made.
Step II : As ACK is received, load DMA address register with starting
address.
Step III : Load terminal count register with number of bytes to transfer
Step IV : Mode set register must be loaded with master/slave mode
information
Step V : Transfer data. If data transfer completed ,then terminate DMA.
GCET 64 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOWCHART
Viva Questions:
1. What is DMA?
2. What is the difference between processor and controller?
3. How the control transfers?
4. What is the advantage of DMA controller?
5. What is the working of DMA controller?
Outcome: Upon completion of this experiment the student will be able to:
1.Demonstrate DMA controller operation and data transfer methods.
2.Design 8086 microprocessor system by using the peripheral devices
3. Interpret the data transfer from 8086 microprocessor to the peripheral device and
vice versa.
GCET 65 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
INTRODUCTION TO 8051
The Intel 8051 is Harvard architecture, single chip microcontroller (µC) which was
developed by Intel in 1980 for use in embedded systems. 8051 is an 8-bit micro
controller. The Important features of 8085 Architecture:
GCET 66 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
GCET 67 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
/INT0 /INT1 T0 T1
Other
interrupts
8051 CPU
From Crystal
Oscillator or RC ALE /PSEN P3 P2 P1 P0 TxD RxD
network (Address/data)
Architecture of 8051
Types of instructions:
Depending on operation they perform, all instructions are divided in several groups:
Arithmetic Instructions
Branch Instructions
Data Transfer Instructions
Logic Instructions
Bit-oriented Instructions
Arithmetic instructions:
ADD A,R1 - The result of addition (A+R1) will be stored in the accumulator.
GCET 68 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Mnemonic Description
ADD A,Rn Adds the register to the accumulator
ADD A,direct Adds the direct byte to the accumulator
ADD A,@Ri Adds the indirect RAM to the accumulator
ADD A,#data Adds the immediate data to the accumulator
ADDC A,Rn Adds the register to the accumulator with a carry flag
ADDC A,direct Adds the direct byte to the accumulator with a carry flag
ADDC A,@Ri Adds the indirect RAM to the accumulator with a carry flag
ADDC A,#data Adds the immediate data to the accumulator with a carry flag
SUBB A,Rn Subtracts the register from the accumulator with a borrow
SUBB A,direct Subtracts the direct byte from the accumulator with a borrow
SUBB A,@Ri Subtracts the indirect RAM from the accumulator with a borrow
SUBB A,#data Subtracts the immediate data from the accumulator with a borrow
INC A Increments the accumulator by 1
INC Rn Increments the register by 1
INC Rx Increments the direct byte by 1
INC @Ri Increments the indirect RAM by 1
DEC A Decrements the accumulator by 1
DEC Rn Decrements the register by 1
DEC Rx Decrements the direct byte by 1
DEC @Ri Decrements the indirect RAM by 1
INC DPTR Increments the Data Pointer by 1
MUL AB Multiplies A and B
DIV AB Divides A by B
DA A Decimal adjustment of the accumulator according to BCD code
Branch Instructions:
Unconditional jump instructions: upon their execution a jump to a new location from
where the program continues execution is executed.
GCET 69 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Mnemonic Description
ACALL addr11 Absolute subroutine call
LCALL addr16 Long subroutine call
RET Returns from subroutine
RETI Returns from interrupt subroutine
AJMP addr11 Absolute jump
LJMP addr16 Long jump
Short jump (from –128 to +127 locations relative to the following
SJMP rel
instruction)
JC rel Jump if carry flag is set. Short jump.
JNC rel Jump if carry flag is not set. Short jump.
JB bit,rel Jump if direct bit is set. Short jump.
JBC bit,rel Jump if direct bit is set and clears bit. Short jump.
JMP @A+DPTR Jump indirect relative to the DPTR
JZ rel Jump if the accumulator is zero. Short jump.
JNZ rel Jump if the accumulator is not zero. Short jump.
Compares direct byte to the accumulator and jumps if not equal.
CJNE A,direct,rel
Short jump.
Compares immediate data to the accumulator and jumps if not
CJNE A,#data,rel
equal. Short jump.
Compares immediate data to the register and jumps if not equal.
CJNE Rn,#data,rel
Short jump.
CJNE Compares immediate data to indirect register and jumps if not
@Ri,#data,rel equal. Short jump.
DJNZ Rn,rel Decrements register and jumps if not 0. Short jump.
DJNZ Rx,rel Decrements direct byte and jump if not 0. Short jump.
NOP No operation
GCET 70 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Data transfer instructions move the content of one register to another. The
register the content of which is moved remains unchanged. If they have the suffix “X”
(MOVX), the data is exchanged with external memory.
Mnemonic Description
MOV A,Rn Moves the register to the accumulator
MOV A,direct Moves the direct byte to the accumulator
MOV A,@Ri Moves the indirect RAM to the accumulator
MOV A,#data Moves the immediate data to the accumulator
MOV Rn,A Moves the accumulator to the register
MOV Rn,direct Moves the direct byte to the register
MOV Rn,#data Moves the immediate data to the register
MOV direct,A Moves the accumulator to the direct byte
MOV direct,Rn Moves the register to the direct byte
MOV direct,direct Moves the direct byte to the direct byte
MOV direct,@Ri Moves the indirect RAM to the direct byte
MOV direct,#data Moves the immediate data to the direct byte
MOV @Ri,A Moves the accumulator to the indirect RAM
MOV @Ri,direct Moves the direct byte to the indirect RAM
MOV @Ri,#data Moves the immediate data to the indirect RAM
MOV DPTR,#data Moves a 16-bit data to the data pointer
MOVC Moves the code byte relative to the DPTR to the accumulator
A,@A+DPTR (address=A+DPTR)
Moves the code byte relative to the PC to the accumulator
MOVC A,@A+PC
(address=A+PC)
MOVX A,@Ri Moves the external RAM (8-bit address) to the accumulator
MOVX A,@DPTR Moves the external RAM (16-bit address) to the accumulator
MOVX @Ri,A Moves the accumulator to the external RAM (8-bit address)
MOVX @DPTR,A Moves the accumulator to the external RAM (16-bit address)
PUSH direct Pushes the direct byte onto the stack
POP direct Pops the direct byte from the stack/td>
XCH A,Rn Exchanges the register with the accumulator
XCH A,direct Exchanges the direct byte with the accumulator
GCET 71 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Logic Instructions:
Mnemonic Description
ANL A,Rn AND register to accumulator
ANL A,direct AND direct byte to accumulator
ANL A,@Ri AND indirect RAM to accumulator
ANL A,#data AND immediate data to accumulator
ANL direct,A AND accumulator to direct byte
ANL direct,#data AND immediate data to direct register
ORL A,Rn OR register to accumulator
ORL A,direct OR direct byte to accumulator
ORL A,@Ri OR indirect RAM to accumulator
ORL direct,A OR accumulator to direct byte
ORL direct,#data OR immediate data to direct byte
XRL A,Rn Exclusive OR register to accumulator
XRL A,direct Exclusive OR direct byte to accumulator
XRL A,@Ri Exclusive OR indirect RAM to accumulator
XRL A,#data Exclusive OR immediate data to accumulator
XRL direct,A Exclusive OR accumulator to direct byte
XORL direct,#data Exclusive OR immediate data to direct byte
CLR A Clears the accumulator
CPL A Complements the accumulator (1=0, 0=1)
SWAP A Swaps nibbles within the accumulator
RL A Rotates bits in the accumulator left
RLC A Rotates bits in the accumulator left through carry
RR A Rotates bits in the accumulator right
RRC A Rotates bits in the accumulator right through carry
GCET 72 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Bit-oriented Instructions
A - accumulator;
Rn - is one of working registers (R0-R7) in the currently active RAM memory
bank;
Direct - is any 8-bit address register of RAM. It can be any general-purpose
register or a SFR (I/O port, control register etc.);
@Ri - is indirect internal or external RAM location addressed by register R0 or
R1;
#data - is an 8-bit constant included in instruction (0-255);
#data16 - is a 16-bit constant included as bytes 2 and 3 in instruction (0-
65535);
GCET 73 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
GCET 74 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
EXPERIMENT NO. 11
PROCEDURE:
GCET 75 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
1. Connect the 8051 kit to the processor of desktop with Rs232 cable and power
supply to the 8051 Kit.
2. Open the TALK icon which is on desktop now Talk window appears.
3. In that window go to options → Target Board → 8051 → ok.
4. Go to options →Connect.
5. Press E on kit keyboard to activate serial port of the kit. Now ‘SERIAL PORT’
displays on the kit and ‘ALS 8051 STA’ displays on talk window.
6. Go to file → Download Hex file. Select the HEX file which is generated by
following the path D drive →driver → X8051 → filename.hex. Now I appears on Talk
window to indicate that file is downloaded.
7. Type G and Starting address of HEX file and press enter.
8. Now program gets executed and register status will be displayed.
9. To generate opcode Press Z starting address of hex file and enter.
I.ARITHEMATIC OPERATIONS
ALGORITHM:
GCET 76 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOWCHART
GCET 77 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOWCHART
GCET 78 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Multiplication
FLOWCHART
GCET 79 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Division
FLOWCHART
GCET 80 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
II.LOGICAL OPERATIONS
ALGORITHM:
Step 1 : Initialize content of accumulator as FFH
FLOW CHART
GCET 81 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
ALGORITHM:
Step 1 : Initialize content of accumulator as FFH
FLOW CHART
GCET 82 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
VIVA QUESTIONS:
RESULT:
OUTCOME:
Upon completion of this experiment the student will be able to perform Arithmetic,
logical and bit manipulation operations.
GCET 83 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
EXPERIMENT NO.12
OBJECTIVE:
To program and verify Timer/counter in 8051(Timer 0 mode 2 counter).
PROCEDURE:
1. Connect the 8051 kit to the processor of desktop with Rs232 cable and power
supply to the 8051 Kit.
2.Short 1 & 2 pins of JP1 of Study card.
3.Connect NIFC 26 study card to the 8051 using 50 line bus (P2 of 8051 kit to study
card) and 10 line bus (JP12 of 8051 kit to JP3 of Study card).
4.Now switch on the power supply.
5. Open the TALK icon which is on desktop now Talk window appears.
6. In that window go to options → Target Board → 8051 → ok.
7. Go to options →Connect.
8. Press E on kit keyboard to activate serial port of the kit. Now ‘SERIAL PORT’
displays on the kit and ‘ALS 8051 STA’ displays on talk window.
9. Go to file → Download Hexfile. Select the HEX file by following the path E drive
→Talk → MC COMM → Nifc26→Nifc26. Now I appears on TALk window to indicate
that file is downloaded.
10. Type G 9200 (Starting address) and press enter.
11. Now program gets executed
12. Now data location displays on the LCD display of Kit and by pressing SW1 of
study card we can observe the increment in the data field displayed.
GCET 84 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
ALGORITHM:
Step 1 : Load TMOD register with mode of operation and timer to be used.
FLOWCHART
VIVA QUESTIONS:
GCET 85 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
RESULT:
OUTCOME:
GCET 86 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
EXPERIMENT NO.13
OBJECTIVE:
To program and verify interrupt handling in 8051
PROCEDURE:
1.Connect the 8051 kit to the processor of desktop with Rs232 cable and power
supply to the 8051 Kit.
2.Short 1 & 2 pins of JP5 and JP6 of Study card.
3.Connect NIFC 26 study card to the 8051 using 50 line bus (P2 of 8051 kit to study
card) and 10 line bus (JP12 of 8051 kit to JP3 of Study card).
4.Now switch on the power supply.
5. Open the TALK icon which is on desktop now Talk window appears.
6. In that window go to options → Target Board → 8051 → ok.
7. Go to options →Connect.
8. Press E on kit keyboard to activate serial port of the kit. Now ‘SERIAL PORT’
displays on the kit and ‘ALS 8051 STA’ displays on talk window.
9. Go to file → Download Hexfile. Select the HEX file by following the path E drive
→Talk → MC COMM → Nifc26→Nifc26. Now I appears on TALk window to indicate
that file is downloaded.
10. Type G 9700 (Starting address) and press enter.
11. Now program gets executed
12. Now data location displays on the LCD display of Kit (continues swapping of bits
26)
13. Give an external interrupt by pressing sw3 on study card now you can observe
that data field counts from 0 to 2 and continues swapping of bits 26
GCET 87 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
ALGORITHM :
Step1 : Load IE register with respect to interrupts to be handled
Step 2 : Load TMOD register with MOD and Timer information.
Step 3 : Load timer registers
Step 4 : Wait for an interrupt. If interrupt occurs, the control has to be
passed to sub-routine by calculating interrupt vector
Step 5 : By executing RETI instruction the control will execute the main
program.
FLOWCHART:
GCET 88 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
VIVA QUESTIONS:
RESULT:
OUTCOME:
This program demonstrates the usage of priority bit and external internal type bit to
handle the interrupt.
GCET 89 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
ADDITIONAL EXPERIMENTS
GCET 90 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Step 1: Give a double click on µvision3 icon on the desktop, it will generate a
window as shown below:
GCET 91 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Step 8: After selecting chip click on OK then it will display some window asking to
add STARTUP file. Select YES.
Step 9: A target is created and startup file is added to your project target and is
shown below.
Step 10: To write your project code select a new file from FILE menu bar.
Step 11: It will display some text editor, to save that file select SAVE option from
FILE menu bar.
GCET 92 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Step 15:It will displays some window there select the file you have to add and
click on ADD option.
Step 16: The file will be added to target and it is shown in the project window.
Step 17: Now give a right click on target in the project window and select “Options
for Target”.
GCET 93 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Step 18: It will show some window, in that go to output option and choose Create
Hex file option by selecting that box.
Step 19: In the same window go to Linker option and choose use memory layout
from target dialog by selecting the box, and Click OK.
Step 20: Now to compile your project Select build target option or press F7.
Step 21: In the build OUTPUT window, you can see the errors and warnings of the
code. Project HEX file will be created.
GCET 94 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Experiment No: 14
SERIAL TRANSMISSION FROM PC TO 8051µC
OBJECTIVE:
To transmit characters from PC to 8051uc serially and to see the output on terminal
window.
ALGORITHM:
Step1 : The TMOD register is loaded with the value 20H, indicating the
use of Timer 1 in mode 2 (8-bit auto-reload) to set the baud rate
.
Step2 : The TH1 is loaded with one of the values TO set the baud rate
For serial data transfer (assuming XTAL = 11.0592 MHz).
Step 3 : The SCON register is loaded with the value 50H, indicating
serial mode 1,where an 8-bit data is framed with start and stop
bits.
GCET 95 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOWCHART
RESULT:
By connecting 8051 to PC students can transmit data serially.
OUTCOME:
Students will be able to understand
1) Demonstration of serial communication
2) How to interface UART.
GCET 96 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
Experiment No: 15
PORT PROGRAMMING OF 8051
OBJECTIVE:
To write 8051 C program to toggle all the bits of P0 and P2 continuously with some
delay.
ALGORITHM
Step1 : The TMOD register is loaded with the value 20H, indicating the
Step 2 : TH1 is loaded with one of the values in to set the baud rate
Step 3 : The SCON register is loaded with the value 50H, indicating
serial mode 1,where 8-bit data is framed with start and stop
Step 6 : The RI flag bit is monitored with the use of the instruction “JNB
step 7 : When RI is raised, SBUF has the byte. Its contents are moved
GCET 97 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
FLOW CHART
RESULT:
By this program students are able to toggle all the bits of two ports with some delay.
OUTCOME:
By the end of this program students will be able to understand the port
programming.
GCET 98 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
1. Define microprocessor.
A) A microprocessor is a multipurpose, programmable, clock-driven, register-based
electronic device that reads binary instructions from a storage device called memory
accepts binary data as input and processes data according to instructions, and
provides result as output.
2. Define microcomputer.
A) A computer that is designed using a microprocessor as its CPU, It includes
microprocessor, memory, and I/O.
3. Define ROM.
A) A memory that stores binary information permanently, the information can be
read from this memory but cannot be altered.
4. What is an ALU?
A) The group of circuits that provides timing and signals to all the operations in the
computer also controls data flow.
6. What is an instruction?
A) An instruction is a binary pattern entered through an input device in memory to
command the microprocessor to perform specific function.
GCET 99 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
A) The 8085 MPU with its 14-bit address is capable of addressing 214 =16,384 (ie)
16K memory locations.
14. Why are the program counter and the stack pointer 16-bit registers?
A) Memory locations for the program counter and stack pointer have 16-bit
addresses. So the PC and SP have 16-bit registers.
16. Specify the number of registers and memory cells required in a 128 x 4
memory chip.
A) Number of registers = 128
Memory cells required is 128 x 4=512
17. Explain the function of ALE and IO/M signals in the 8086 architecture.
A) The ALE signal goes high at the beginning of each machine cycle indicating the
availability of the address on the address bus, and the signal is used to latch the
low- order address bus. The IO/M signal is a status signal indicating whether the
machine cycle is I/O or memory operation. The IO/M signal is combined with the RD
and WR control signals to generate IOR, IOW, MEMW,MEMR .
18. Specify the contents of the accumulator and the status of the S, Z, and CY
flags, if 8086 adds 87H and 79H.
A) The sum of 87H and 79H is 100H. Therefore, the accumulator will have 00H, and
the flags will be S=0, Z = 1, CY = 1
S Z AC P CY
GCET 101 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
First byte
MVI A, Data 011 1110 3E
Data Data SecondByte
6. Write an instruction to load the hexadecimal numbers 65H in register C, and 92H
in the accumulator A, and display the number 65H at PORT0 and 92H at PORT1?
C,
MVI
65H
A,
MVI
92H
OUT PORT1 ; DISPLAY 92H
; COPY C INTO A FOR
MOVA, C
DISPLAY
OUT PORT0 ; DISPLAY 65H
HLT
1-byte instruction
2-byte instruction
3-byte instruction
GCET 102 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
A) ASCII code is a 7-bit code that represents both decimal numbers, alphabets.
Extended ASCII is an 8-bit code.
45. Why the number of out ports in the peripheral-mapped I/O is restricted to
256 ports?
A) The number of output ports in the peripheral I/O is restricted to 256 ports because
the operand of the OUT instruction is 8-bits; it can have only 256 combinations
GCET 103 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
46. If an input and output port can have the same 8-bit address how does the
8085 differentiate between the ports.
A) In The 8085 differentiates between the input and output ports of the same
address by the control signal. The input port requires the RD and the output port
requires the WR signal.
47. What are the control signals necessary in the memory mapped I/O?
A) RD, WR, I/O (low)
48. Why a latch is used for the output port and a tri-state buffer is used for the
input port?
A) A latch is necessary to hold the output data for display. The input data byte is
obtained by enabling a tri-state buffer and placed in the accumulator.
49. What happens when the 8086 execute the out instruction?
A) When the 8086 executes the out instruction, in the third machine cycle, it places
the output port address on the low-order address bus, duplicates the same port
address on the high-order bus, places the contents of the accumulator on the data
bus and asserts the control signal WR.
50. How does the port number be affected if we decode the higher-order
address lines A15 – A8 rather than lower-order address lines A7 – A0?
A) The port address will remain the same because the I/O port address is duplicated
on both segments of the address bus.
GCET 104 |
Page
Microprocessors and Microcontrollers lab Dept of ECE
56. Specify the bit of a control word for the 8255, which differentiates between
the I/O mode and the BSR mode.
A) BSR mode D7= 0, and I/O mode D5 = 1
57. Write the input/output feature in Mode 0 for the 8255A PPI?
A) Outputs are latched
Inputs are not latched
Ports do not have handshake or interrupt capability
BSR
Not used Set = 1
mode
Generally
Set= 0
59. Write down the output control signals used in 8255A PPI.
A) OBF output Buffer Full
ACK Acknowledge
INTR Interrupt request
INTE Interrupt Enable
GCET 105 |
Page