0% found this document useful (0 votes)
57 views80 pages

MPMC Manual R20

The document is a lab manual for the Microprocessors and Microcontrollers course at Sagi Rama Krishnam Raju Engineering College, detailing course objectives, outcomes, and a syllabus that includes various assembly language programming experiments for 8085, 8086, and 8051 microprocessors. It provides an overview of programming concepts, instruction sets, and practical applications to enhance students' understanding of microprocessor operations. Additionally, it includes references and resources for further study.

Uploaded by

epsrkr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views80 pages

MPMC Manual R20

The document is a lab manual for the Microprocessors and Microcontrollers course at Sagi Rama Krishnam Raju Engineering College, detailing course objectives, outcomes, and a syllabus that includes various assembly language programming experiments for 8085, 8086, and 8051 microprocessors. It provides an overview of programming concepts, instruction sets, and practical applications to enhance students' understanding of microprocessor operations. Additionally, it includes references and resources for further study.

Uploaded by

epsrkr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 80

SAGI RAMA KRISHNAM RAJU ENGINEERING COLLEGE (A)

(AFFILIATED TO JNTUK, KAKINADA) (RECOGNISED BY ALL INDIA COUNCIL FOR TECH. EDN., NEW DELHI)
ACCREDITED BY NBA & NAAC ‘A+’ Grade
Recognized as a Scientific and Industrial Research Organization
CHINNA AMIRAM. (P.O): BHIMAVARAM: W.G.DT., A.P., INDIA: PIN: 534204

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Microprocessors and Microcontrollers Lab Manual

Prepared By

1. Prof. P Subba Rao


2. Sri M Vijaya Rama Raju
3. Sri N Kishore Chandra Dev
4. Sri T Nalini Prasad

Verified by Lab In-Charge

Signature:
Name: N.Kishore Chandra Dev
Microprocessors and Microcontrollers Lab Manual

Syllabus

Code Category L T P C I.M E.M Exam


B20EC3204 PC -- -- 3 1.5 15 35 3hrs

MICROPROCESSORS AND MICROCONTROLLERS LAB


(For ECE)
Course Objectives:
1. To Introduce ALP concepts, features, and Coding.
2. Get familiarized with 8085,8086 and 8051 instructions.
Developing Assembly Language Programs using the instruction sets of microprocessors
3.
(8085,8086) and 8051 Microcontroller
The accompanying lab is designed to provide practical hands-on experience with
4.
Microprocessor hardware kits and software applications

Course Outcomes: the students will be able to:


Knowledge
S.No Outcome
Level
Develop 8085 assembly language programs on data transfer, arithmetic, and
1. K4
logical operations
Develop 8086 assembly language programs using data transfer, arithmetic, and
2. K4
logical instructions
Develop 8051 assembly language programs on data transfer, arithmetic, and
3. K4
logical operations

SYLLABUS
Experiments Based On 8085:
a) Assume that a byte of data is stored in memory location ‘X’. Write an ALP that tests
bit5 of this data. Write ‘FF’ in the location ‘X+1’ if bit 5 is ‘1’ or Write ‘00’ if bit 5 is ‘0’.
1 b) For data value in the location ‘X’ compute the number of logic 1’s and store the result in
the location ‘Y+1’.

Write an ALP to transfer a block of data from one memory location to another memory
2
location
Two 16-bit numbers are stored at memory locations ‘X’ and ‘X+2’.Write an ALP to add
3 these numbers without using DAD instruction and store the result from location Y onwards
Two 8-bit numbers 34H and 43H are stored in locations ‘X’ and ‘X+1’ to compute the
4 product of these two numbers using the repetitive addition method.
The number of the bytes of a block of data is in location ‘X’ and data starts from location
5 ‘X+1’onwards. By defining a stack pointer, write an ALP to arrange this data sequence
in reverse order. Keep the reverse sequence from ‘Y’ onwards
SRKREC, ECE Department 1
Microprocessors and Microcontrollers Lab Manual

Experiments Based On 8086:


6 Write an 8086 µP ALP to perform the Addition/Subtraction operation of two-32 bit numbers
7 Write an 8086 µP ALP to perform Multiplication/Division of two 16-bit unsigned numbers
8 Write an 8086 µP ALP to find the factorial of a given number less than 9.
Write an 8086 µP ALP to convert 8 bit BCD number into Binary or Binary number into
9
BCD
10 Write an 8086 µP ALP to add two packed BCD numbers
11 Write an 8086 µP Assembly Program to find the largest/smallest element in given array
Sort the block of data in ascending order by using bubble sorting technique. Assume the
12 number of bytes of a block of data is at location ‘X’ and data starts from location
‘X+1’onwards
Experiments Based On 8051:
13 Write an 8051 µC ALPs on basic Data transfer instructions
14 Write an 8051 µC ALPs on basic Arithmetic instructions
15 Write an 8051 µC ALP to compute the number of logic 0’s in a given byte
16 Write an 8051 µC Assembly Program to find the largest element in given array
17 Write an 8051 µC Assembly Program to find the sum of first 10 natural numbers
18 Write an 8051 µC Assembly Program to find Average of N-bytes

Reference Books:
Microprocessors: The 8086/8088, 80186/80286, 80386/80486 and the Pentium Family.
1.
Nilesh B. Bahadure, Phi Learning Pvt. Ltd., 2010
The 8051 Microcontroller and Embedded Systems using assembly and C-Muhammad Ali
2.
Mazidi and Janice Gillespie Mazidi and Rollin D.Mc Kinlay; PHI, 2013/Pearson ,2013
3. Lab Manual
e-Resources:
1. www.sim8085.com

Additional Experiments:

1. By using 8279 in auto-increment mode, generate a message of 6 characters a make the


display ON and OFF for every 0.5 sec. (CO1, CO2).
2. By using the data field of a display unit, Obtain a count of 00 to 59 with a delay of 1 second
after every count. Keep the character code from location “X” onwards. (CO2)

SRKREC, ECE Department 2


Microprocessors and Microcontrollers Lab Manual

CHAPTER–I

8085-A PROGRAMMING OVERVIEW


This chapter provides an overview of 8-bit 8085 microprocessors which is the
gateway to the world of INTEL microprocessors.
INTRODUCTION
INTEL 8085 is a general-purpose 8-bit Microprocessor with a 16-bit address and
capable of addressing 64KB memory (precisely 216 = 65536bytes).
This microprocessor has a set of instructions (Appendix A) classified into different
functional categories.
1. Arithmetic & logical instructions
2. Data transfer instructions
3. Branch control instructions
4. Stack, I/O & machine control instructions
It can be programmed to perform a particular task on given data by using
necessary instructions from this set. The internal architecture defines how the
instructions perform the operations on the data. It requires ALU, registers, a
control unit, and internal address and data buses.

Data Transfer Group: The data transfer instructions move data between registers or
between memory and registers.
MOV Move
MVI Move Immediate
LDA Load Accumulator Directly from Memory
STA Store Accumulator Directly in Memory
LHLD Load H & L Registers Directly from Memory
SHLD Store H & L Registers Directly in Memory
An 'X' in the name of a data transfer instruction implies that it
deals with a register pair (16-bits);
LXI Load Register Pair with Immediate data
LDAX Load Accumulator from Address in Register Pair
STAX Store Accumulator in Address in Register Pair
XCHG Exchange HL Register Pair contents with DERegister Pair

SRKREC, ECE Department 3


Microprocessors and Microcontrollers Lab Manual

XTHL Exchange Top of Stack with H & L

Arithmetic Group: The arithmetic instructions add, subtract, increment, or


decrement data in registers or memory ADD Add to Accumulator
ADI Add immediate Data to Accumulator
ADC Add to Accumulator Using Carry Flag
ACI Add immediate data to Accumulator Using Carry
SUB Subtract from Accumulator
SUI Subtract Immediate Data from Accumulator
SBB Subtract from Accumulator Using Borrow (Carry) Flag
SBI Subtract Immediate from Accumulator Using Borrow (Carry) Flag I
NR Increment Specified Byte by One
DCR Decrement Specified Byte by One
INX Increment Register Pair by One
DCX Decrement Register Pair by One
DAD Double Register Add; Add Content of Register Pair to H & L Register
Pair

Logical Group: This group performs logical (Boolean) operations on data in registers
and memory and on condition flags. The logical AND, OR, and Exclusive OR
instructions enable you to set specific bits in the accumulator ON or OFF.
ANA Logical AND with Accumulator
ANI Logical AND with Accumulator Using Immediate Data
ORA Logical OR with Accumulator
OR Logical OR with Using Immediate Data
XRA Exclusive Logical OR with Accumulator
XRI Exclusive OR Using Immediate Data

Compare instructions compare the content of an 8-bit value with


the contents of the accumulator.

CMP Compare
CPI Compare Using Immediate Data
Rotate instructions shift the contents of the accumulator one-bit position

SRKREC, ECE Department 4


Microprocessors and Microcontrollers Lab Manual

to the left or right:


RLC Rotate Accumulator Left
RRC Rotate Accumulator Right
RAL Rotate Left through Carry
RAR Rotate Right through Carry
Complement and carry flag instructions:
CMA Complement Accumulator
CMC Complement Carry Flag
STC Set Carry Flag

Branch Group: The branching instructions alter normal sequential program flow,
either unconditionally or conditionally. The unconditional branching instructions
are as follows:
JMP Jump
CALL Call
RET Return
Conditional branching instructions examine the status of one of four condition
flags to determine whether the specified branch is to be executed. The conditions
that may be specified are as follows:
NZ Not Zero (Z = 0) Z Zero (Z = 1)
NC No Carry (C = 0) C Carry (C = 1)
PO Parity Odd (P = 0)
PE Parity Even (P = 1)
P Plus (S = 0)
M Minus (S = 1)
Thus, the conditional branching instructions are specified as follows:

Jumps Calls Returns


C CC RC (Carry)
INC CNC RNC (No Carry)
JZ CZ RZ (Zero)
JNZ CNZ RNZ (Not Zero)
JP CP RP (Plus)
JM CM RM (Minus)
JPE CPE RPE (Parity Even

SRKREC, ECE Department 5


Microprocessors and Microcontrollers Lab Manual

JP0 CPO RPO (Parity Odd


Two other instructions can affect a branch by replacing the contents or the
program counter:
PCHL Move H & L to Program Counter
RST Special Restart Instruction Used with Interrupts

Stack I/O, and Machine Control Instructions: The following instructions affect the
Stack and/or Stack Pointer:
PUSH Push Two bytes of Data onto the Stack
POP Pop Two Bytes of Data off the Stack
XTHL Exchange Top of Stack with H & L
SPHL Move content of H & L to Stack Pointer
I/0 instructions are as follows:
IN Initiate Input Operation
OUT Initiate Output
Operation Machine Control
instructions are as follows:
EI Enable Interrupt System
DI Disable Interrupt System
HLT Halt
NOP No Operation

SRKREC, ECE Department 6


Microprocessors and Microcontrollers Lab Manual

8086 Microprocessor - A Programming Overview

8086 Microprocessor is an enhanced version of 8085Microprocessor that was


designed by Intel in 1976. It is a 16-bit Microprocessor having 20 address lines and
16 data lines that provide up to 1MB of storage. It consists of a powerful instruction
set, which provides operations like multiplication and division easily.

The 8086 microprocessor supports 8 types of instructions −

➔ Data Transfer Instructions


➔ Arithmetic Instructions
➔ Bit Manipulation Instructions
➔ String Instructions
➔ Program Execution Transfer Instructions (Branch & Loop Instructions)
➔ Processor Control Instructions
➔ Iteration Control Instructions
➔ Interrupt Instructions

Let us now discuss these instruction sets in detail.

Data Transfer Instructions

These instructions are used to transfer the data from the source operand to the
destination operand. Following is the list of instructions under this group −

Instruction to transfer a word

➔ MOV − Used to copy the byte or word from the provided source to the
provided destination.
➔ PUSH − Used to put a word at the top of the stack.
➔ POP − Used to get a word from the top of the stack to the provided location.
➔ PUSHA − Used to put all the registers into the stack.
➔ POPA − Used to get words from the stack to all registers.
➔ XCHG − Used to exchange the data from two locations.
➔ XLAT − Used to translate a byte in AL using a table in the memory.

Instructions for input and output port transfer

➔ IN − Used to read a byte or word from the provided port to the accumulator.
SRKREC, ECE Department 7
Microprocessors and Microcontrollers Lab Manual

➔ OUT − Used to send out a byte or word from the accumulator to the provided
port.

Instructions to transfer the address

➔ LEA − Used to load the address of the operand into the provided register.
➔ LDS − Used to load DS register and other provided register from the memory
➔ LES − Used to load ES register and other provided register from the memory.

Instructions to transfer flag registers

➔ LAHF − Used to load AH with the low byte of the flag register.
➔ SAHF − Used to store AH register to low byte of the flag register.
➔ PUSHF − Used to copy the flag register at the top of the stack.
➔ POPF − Used to copy a word at the top of the stack to the flag register.

Arithmetic Instructions

These instructions are used to perform arithmetic operations like addition,


subtraction, multiplication, division, etc.

Following is the list of instructions under this group −

Instructions to perform addition

➔ ADD − Used to add the provided byte to byte/word to word.


➔ ADC − Used to add with carry.
➔ INC − Used to increment the provided byte/word by 1.
➔ AAA − Used to adjust ASCII after addition.
➔ DAA − Used to adjust the decimal after the addition/subtraction operation.

Instructions to perform subtraction

➔ SUB − Used to subtract the byte from byte/word from word.


➔ SBB − Used to perform subtraction with borrow.
➔ DEC − Used to decrement the provided byte/word by 1.
➔ NPG − Used to negate each bit of the provided byte/word and add 1/2’s
complement.
➔ CMP − Used to compare 2 provided bytes/words.
➔ AAS − Used to adjust ASCII codes after subtraction.
➔ DAS − Used to adjust decimals after subtraction.
SRKREC, ECE Department 8
Microprocessors and Microcontrollers Lab Manual

Instruction to perform multiplication

➔ MUL − Used to multiply unsigned byte by byte/word by word.


➔ IMUL − Used to multiply signed byte by byte/word by word.
➔ AAM − Used to adjust ASCII codes after multiplication.

Instructions to perform division

➔ DIV − Used to divide the unsigned word by byte or unsigned double word by
word.
➔ IDIV − Used to divide the signed word by byte or signed double word by
word.
➔ AAD − Used to adjust ASCII codes after division.
➔ CBW − Used to fill the upper byte of the word with the copies of sign bit of
the lower byte.
➔ CWD − Used to fill the upper word of the double word with the sign bit of the
lower word.

Bit Manipulation Instructions

These instructions are used to perform operations where data bits are involved, i.e.
operations like logical, shift, etc.

Following is the list of instructions under this group −

Instructions to perform logical operation

➔ NOT − Used to invert each bit of a byte or word.


➔ AND − Used for adding each bit in a byte/word with the corresponding bit
in another byte/word.
➔ OR − Used to multiply each bit in a byte/word with the corresponding bit in
another byte/word.
➔ XOR − Used to perform Exclusive-OR operation over each bit in a byte/word
with the corresponding bit in another byte/word.
➔ TEST − Used to add operands to update flags, without affecting operands.

Instructions to perform shift operations

➔ SHL/SAL − Used to shift bits of a byte/word towards left and put zero(S) in
SRKREC, ECE Department 9
Microprocessors and Microcontrollers Lab Manual

LSBs.
➔ SHR − Used to shift bits of a byte/word towards the right and put zero(S) in
MSBs.
➔ SAR − Used to shift bits of a byte/word towards the right and copy the old
MSB into the new MSB.

Instructions to perform rotate operations

➔ ROL − Used to rotate bits of byte/word towards the left, i.e. MSB to LSB and
to Carry Flag [CF].
➔ ROR − Used to rotate bits of byte/word towards the right, i.e. LSB to MSB
and to Carry Flag [CF].

➔ RCR − Used to rotate bits of byte/word towards the right, i.e. LSB to CF and
CF to MSB.
➔ RCL − Used to rotate bits of byte/word towards the left, i.e. MSB to CF and CF
to LSB.

String Instructions

String is a group of bytes/words and their memory is always allocated in

sequential order. Following is the list of instructions under this group −

➔ REP − Used to repeat the given instruction till CX ≠ 0.


➔ REPE/REPZ − Used to repeat the given instructions until CX = 0 or zero flag
ZF = 1.
➔ REPNE/REPNZ − Used to repeat the given instructions until CX = 0 or zero
flag ZF = 1.
➔ MOVS/MOVSB/MOVSW − Used to move the byte/word from one string to
another.
➔ COMS/COMPSB/COMPSW − Used to compare two string bytes/words.
➔ INS/INSB/INSW − Used as an input string/byte/word from the I/O port to the
provided memory location.
➔ OUTS/OUTSB/OUTSW − Used as an output string/byte/word from the
provided memory location to the I/O port.
➔ SCAS/SCASB/SCASW − Used to scan a string and compare its byte with a
byte in AL or string word with a word in AX.
➔ LODS/LODSB/LODSW − Used to store the string byte into AL or string word
SRKREC, ECE Department 10
Microprocessors and Microcontrollers Lab Manual

into AX.

Program Execution Transfer Instructions (Branch and Loop Instructions)

These instructions are used to transfer/branch instructions during execution. It


includes the following instructions −

Instructions to transfer the instruction during execution without any condition −

➔ CALL − Used to call a procedure and save their return address to the stack.
➔ RET − Used to return from the procedure to the main program.
➔ JMP − Used to jump to the provided address to proceed to the next
instruction.

Instructions to transfer the instruction during execution with some conditions −

➔ JA/JNBE − Used to jump if above/not below/equal instruction satisfies.


➔ JAE/JNB − Used to jump if above/not below instruction satisfies.
➔ JBE/JNA − Used to jump if below/equal/ not above instruction satisfies.
➔ JC − Used to jump if carry flag CF = 1
➔ JE/JZ − Used to jump if equal/zero flag ZF = 1
➔ JG/JNLE − Used to jump if greater/not less than/equal instruction satisfies.
➔ JGE/JNL − Used to jump if greater than/equal/not less than instruction
satisfies.
➔ JL/JNGE − Used to jump if less than/not greater than/equal instruction
satisfies.
➔ JLE/JNG − Used to jump if less than/equal/if not greater than instruction
satisfies.
➔ JNC − Used to jump if no carry flag (CF = 0)
➔ JNE/JNZ − Used to jump if not equal/zero flag ZF = 0
➔ JNO − Used to jump if no overflow flag OF = 0
➔ JNP/JPO − Used to jump if not parity/parity odd PF = 0
➔ JNS − Used to jump if not sign SF = 0
➔ JO − Used to jump if overflow flag OF = 1
➔ JP/JPE − Used to jump if parity/parity even PF = 1
➔ JS − Used to jump if sign flag SF = 1

Processor Control Instructions

SRKREC, ECE Department 11


Microprocessors and Microcontrollers Lab Manual

These instructions are used to control the processor action by

setting/resetting the flag values. Following are the instructions under this

group −

➔ STC − Used to set carry flag CF to 1


➔ CLC − Used to clear/reset carry flag CF to 0
➔ CMC − Used to put complement at the state of the carry flag CF.
➔ STD − Used to set the direction flag DF to 1
➔ CLD − Used to clear/reset the direction flag DF to 0
➔ STI − Used to set the interrupt enable flag to 1, i.e., enable INTR input.
➔ CLI − Used to clear the interrupt enable flag to 0, i.e., disable INTR input.

Iteration Control Instructions

These instructions are used to execute the given instructions for a number of
times. Following is the list of instructions under this group −

➔ LOOP − Used to loop a group of instructions until the condition is satisfied,


i.e., CX = 0
➔ LOOPE/LOOPZ − Used to loop a group of instructions till it satisfies ZF = 1 &
CX = 0
➔ LOOPNE/LOOPNZ − Used to loop a group of instructions till it satisfies ZF = 0
& CX = 0
➔ JCXZ − Used to jump to the provided address if CX = 0

Interrupt Instructions

These instructions are used to call the interrupt during program execution.

➔ INT − Used to interrupt the program during execution and calling service
specified.
➔ INTO − Used to interrupt the program during execution if OF = 1
➔ IRET − Used to return from interrupt service to the main program

SRKREC, ECE Department 12


Microprocessors and Microcontrollers Lab Manual

8051 MicroController - A Programming Overview


Based on the operation they perform, all the instructions in the 8051.
Microcontroller Instruction Sets are divided into five groups. They are
➔ Data Transfer Instructions
➔ Arithmetic Instructions
➔ Logical Instructions
➔ Boolean or Bit Manipulation Instructions
➔ Program Branching Instructions

Data Transfer Instructions


The Data Transfer Instructions are associated with transfer with data between
registers or external program memory or external data memory. The Mnemonics
associated with Data Transfer are given below.
➔ MOV
➔ MOVC
➔ MOVX
➔ PUSH
➔ POP
➔ XCH
➔ XCHD

SRKREC, ECE Department 13


Microprocessors and Microcontrollers Lab Manual

Arithmetic Instructions
Using Arithmetic Instructions, you can perform addition, subtraction,
multiplication, and division. The arithmetic instructions include increment by one,
decrement by one, and a special instruction called Decimal Adjust Accumulator.
Microcontroller Instruction Set is:
➔ ADD
➔ ADDC
➔ SUBB
➔ INC
➔ DEC
➔ MUL
➔ DIV
➔ DA A
The operations performed by the arithmetic instructions affect flags like carry,
overflow, zero, etc. in the PSW Register.

Logical Instructions
Logical Instructions are performed on Bytes of data on a bit-by-bit basis.
Mnemonics associated with Logical Instructions are as follows:
➔ ANL
➔ ORL

SRKREC, ECE Department 14


Microprocessors and Microcontrollers Lab Manual

➔ XRL
➔ CLR
➔ CPL
➔ RL
➔ RLC
➔ RR
➔ RRC
➔ SWAP

Boolean or Bit Manipulation Instructions

Boolean or Bit Manipulation Instructions will deal with bit variables.


There is a special bit-addressable area in the RAM and some of the Special
Function Registers (SFRs) are also bit-addressable.
➔ CLR
➔ SETB
➔ MOV
➔ JC
➔ JNC
➔ JB
➔ JNB
SRKREC, ECE Department 15
Microprocessors and Microcontrollers Lab Manual

➔ JBC
➔ ANL
➔ ORL
➔ CPL

Program Branching Instructions


These instructions control the flow of program logic. The mnemonics of the
Program Branching Instructions are as follows.
LJMP AJMP
SJMP JZ
JNZ CJNE
DJNZ NOP
LCALL ACALL
RET RETI
JMP
All these instructions, except the NOP (No Operation) affect the Program
Counter (PC) in one way or another.
Some of these instructions have decision-making capability before transferring
control to other parts of the program.

SRKREC, ECE Department 16


Microprocessors and Microcontrollers Lab Manual

CHAPTER2

GENERAL INFORMATION OF MICROPROCESSORS LABORATORY

1.1 Introduction: This manual provides all the necessary information to perform
simple software and hardware interface experiments based on INTEL 8085
Microprocessors by undergraduate engineering students.
1.2 General: This lab is mainly equipped with ALS-SDA-85M and VMC-85/9
single board Microprocessor Training Kits, which are provided with 8085-A as
CPU. The clock frequency for these systems is 3.07MHZ and is generated from a
crystal of 6.14MHZ.8085 has got 8 data lines & 16 address lines. The total memory
can be expanded up to 64K bytes.
1.3 User’s RAM: The user’s RAM of 2K bytes starts from C000 H for ALS and
2000 H for VMC kits.
1.4 Keyboard Description: The function of the keys in the keyboard which are
useful to perform experiments are explained below.

Key label Description

1. Reset Reset the system.


2. VECT (VECT INT) Hardware Interrupt
3. Next It increments the PC contents and
writes the Data lying in the data field
at the location specified in the address
field
4. Exec (.) The monitors commend the terminator.
5. Block Move Allows the user to move the block.
6. Sub Mem (Ex mem) Allows the user to examine any memory
location
7. Exam Reg (Ex. Reg) Examine Register.
8. Go To Execute the Program.
9. Pre (Pre) It decrements the PC Contents.
10. Single Step (SI) To execute the program in Single Step
mode

SRKREC, ECE Department 17


Microprocessors and Microcontrollers Lab Manual

11. Ins Select the monitor insert data byte


function.
12. Del Select the monitor delete data byte
function.
13. Fill Allows users to fill a Ram area with
consent.

Note: 1. For a more detailed explanation students are advised to refer to the user's
manual.
2. The Keys specified in parenthesis are meant for VMC-85 Kit.

SRKREC, ECE Department 18


Microprocessors and Microcontrollers Lab Manual

8085 KIT PROGRAMMING INSTRUCTIONS


To store the assembly program in memory

1. Press the Reset button it shows SDA 85


2. Press the SUBST MEM button. It shows one dot (.) on the screen.
3. Enter the program starting address from the keyboard. Ex. C000 or C100…
4. Press the Next button to enter 1st mnemonic of the program. And then press
the Next button to enter the 2nd mnemonic. And then press the Next button to
enter the 3rd mnemonic. Repeat this process until the end of the program. After
pressing the next button to observe the increment of the program address.

Substitute data in memory/ verify the output


5. Press the Reset button
6. And Press the SUBST MEM button. It shows one dot (.) on the screen.
7. Enter the program data memory address from the keyboard. Ex. C040 or C300…
8. Press the Next button to enter the 1st byte of the input data and again press the
Next button to enter the second byte…. and so on.

Program execution
9. Press the Reset button
10. Press the GO button Enter Starting address of the program (COOO) and then
press the EXEC button. It will show the E symbol on the screen.

SRKREC, ECE Department 19


Microprocessors and Microcontrollers Lab Manual

Experiments Based On ALP (8085)


1.a) Assume that byte of data is stored at memory location ‘X’. Write an ALP which tests bit 5
of this data. Write ‘FF’ in the location ‘X+1’ if the bit 5 is ‘1’ and ‘00’if bit 5 is ‘0’.
b) For data value in the location ‘X’ compute the number of logic 1’s and store the result in
the location ‘Y+1’.

Procedure:- (a)

Address Label Instruction Opcode Byte 2 Byte 3 Comments

C000 LXI H,C040 21 40 C0

C003 MOV A,M 7E

C004 MVI B,04 06 04

C006 AHEAD RAL 17

C007 DCR B 05

C008 JNZ AHEAD C2 06 C0

C00B JC BACK DA 12 C0

C00E INX H 23

C00F MVI M,00 36 00

C011 HLT 76

C012 BACK INX H 23

C013 MVI M,FF 36 FF

C015 HLT 76

C040 47 INPUT

C041 00 OUTPUT

SRKREC, ECE Department 20


Microprocessors and Microcontrollers Lab Manual

Procedure:b)

Address Label Instruction Opcode Byte2 Byte3 Comments

C000 LXI H, C040 21 40 C0

C003 MOV A,M 7E

C004 MVI B,08 06 08

C006 MVI D,00 16 00

C008 AHEAD RAL 17

C009 JNC BACK D2 0D C0

C00C INR D 14

C00D BACK DCR B 05

C00E JNZ AHEAD C2 08 C0

C011 MOV A,D 7A

C012 STA C061 32 61 C0

C015 HLT 76

C040 47 INPUT

C061 04 OUTPUT

SRKREC, ECE Department 21


Microprocessors and Microcontrollers Lab Manual

2.a) An array of data is stored from location X onwards. The first byte specifies the number of
data bytes in that array. The actual data starts from the next location. Write an ALP to
transfer the above data to another memory location.

Procedure:
a)

Address Label Instruction Opcode Byte 2 Byte 3 Comments

C000 LXI H, C040 21 40 C0

C003 MOV D, M 56

C004 INX H 23

C005 LXI B, C060 01 60 C0

C008 AHEAD MOV A, M 7E

C009 STAX B 02

C00A INX H 23

C00B INX B 03

C00C DCR D 15

C00D JNZ AHEAD C2 08 CO

C010 HLT 76

C040 07 INPUT

C041 01 INPUT

C042 02 INPUT

C043 03 INPUT

C044 04 INPUT

C045 05 INPUT

C046 06 INPUT

C047 07 INPUT

OUTPUT

C061 01 OUTPUT

C062 02 OUTPUT
SRKREC, ECE Department 22
Microprocessors and Microcontrollers Lab Manual

C063 03 OUTPUT

C064 04 OUTPUT

C065 05 OUTPUT

C066 06 OUTPUT

C067 07 OUTPUT

SRKREC, ECE Department 23


Microprocessors and Microcontrollers Lab Manual

3.a) Two 16-bit numbers are stored at memory locations ‘X’ and ‘X+1’.Write an ALP to add
these numbers without using DAD instruction and store the result from location Y onwards

Procedure:

Address Label Instruction Opcode Byte 2 Byte 3 Comments

C000 MVI D,00 16 00

C002 LXI H, C040 21 40 C0

C005 MOV A, M 7E

C006 INX H 23

C007 INX H 23

C008 ADD M 86

C009 JNC * D2 0E C0

C00C MVI D,01 16 01

C00E * STA C060 32 60 C0

C011 DCX H 2B

C012 MOV A, M 7E

C013 ADD D 82

C014 MVI D,00 16 00

C016 INX H 23

C017 INX H 23

C018 ADD M 86

C019 JNC** D2 1E C0

C01C MVI D,01 16 01

C01E ** STA C061 32 61 C0

C021 MOV A, D 7A

C022 STA C062 32 62 C0

C025 HLT 76

C040 34 INPUT

C041 12 INPUT

SRKREC, ECE Department 24


Microprocessors and Microcontrollers Lab Manual

C042 65 INPUT

C043 F7 INPUT

C060 99 OUTPUT

C061 09 OUTPUT

C062 01 OUTPUT

SRKREC, ECE Department 25


Microprocessors and Microcontrollers Lab Manual

4) Two 8 bit numbers 34 H and 43H are stored in locations ‘X’ and ‘X+1’ compute the product
of these two numbers using
a) Repetitive addition method b) Shift and add method

Procedur

a)

Address Label Instruction Opcode Byte 2 Byte 3 Comments

C000 MVI C,00 OE 00

C002 MVI A,00 3E 00

C004 LXI H,C040 21 40 C0

C007 MOV B,M 46

C008 INX H 23

C009 BACK ADD M 86

C00A JNC AHEAD D2 0E C0

C00D INR C 0C

C00E AHEAD DCR B 05

C00F JNZ BACK C2 09 C0

C012 STA C050 32 50 C0

C015 MOV A,C 79

C016 STA C051 32 51 C0

C019 HLT 76

C040 34 INPUT

C041 43

C050 9C OUTPUT

C051 0D

SRKREC, ECE Department 26


Microprocessors and Microcontrollers Lab Manual

b)

Address Label Instruction Opcode Byte 2 Byte 3 Comments

C000 LXI H,0000 21 00 00

C003 MVI D,00 16 00

C005 LDA C040 3A 40 C0

C008 M0V E,A 5F

C009 MVI C,08 0E 08

C00B LDA C041 3A 41 C0

C00E BACK DAD H 29

C00F RAL 17

C010 JNC AHEAD D2 14 C0

C013 DAD D 19

C014 AHEAD DCR C 0D

C015 JNZ BACK C2 0E C0

C018 SHLD C060 22 60 C0

C01B HLT 76

C040 34 INPUT

C041 43 INPUT

C060 9C OUTPUT

C061 0D OUTPUT

SRKREC, ECE Department 27


Microprocessors and Microcontrollers Lab Manual

5) The number of bytes of a block of data is in location ‘X’ and data starts from location
‘X+1’ onwards defining stack pointers. Write an ALP to arrange this sequence of data in
reverse order. Keep the reverse sequence from ‘Y’ onwards.

Procedure

Address Label Instruction Opcode Byte 2 Byte 3 Comments

C000 LXI H,C050 21 50 C0

C003 LXI SP,C080 31 80 C0

C006 MOV B,M 46

C007 MOV C,M 4E

C008 AHEAD INX H 23

C009 MOV A,M 7E

C00A PUSH PSW F5

C00B DCR B 05

C00C JNZ AHEAD C2 08 C0

C00F LXI H,C060 21 60 C0

C012 BACK POP PSW F1

C013 MOV M,A 77

C014 INX H 23

C015 DCR C 0D

C016 JNZ BACK C2 12 C0

C019 HLT 76

C050 04

C051 11 INPUT

C052 22

C053 33

C054 44

SRKREC, ECE Department 28


Microprocessors and Microcontrollers Lab Manual

C060 44
OUTPUT
C061 33

C062 22

C063 11

SRKREC, ECE Department 29


Microprocessors and Microcontrollers Lab Manual

Programming Instructions For ESA 8086 Trainer

To Store (write) Program (In Assembler)


➔ A space starting addresses of the program and press enter.
Eg: A 5000 press enter
➔ It shows 5000 address. Start loading 8086 instructions in Assembler . After
every instruction typing is completed press enter. It the shows machine the
code and next addresses location.
➔ Keep on doing the above process until end of the program.
➔ Press Shift 1 (!) come out from Assembler.

Verification Of Program: (Un assemble the program)

Z space starting address of the program, ending address of program and press enter
It shows the loaded program in the assembler. Keep on pressing enter it shows
the step by step of loaded program.

To Store Data in Memory and Verification of output in Memory


To store byte
S space 16 bit data address and press enter
It shows previous loaded data, then load new data from key board and press
comma(,) for the next data to be loaded.
keep on doing the above process until data storing is completed.
Press Shift 1 (!) or Press Enter to come out.
To store Word (two bytes)
SW space 16-bit data address and press enter
It shows previously loaded data, then load new data from the keyboard and
press comma(,) for the next data to be loaded.
keep on doing the above process until data storing is completed.
Press Shift 1 (!) or Press Enter to come out
EXECUTION:
G space Starting address of Program , Ending address of Program and enter
Eg. G 8000, 8023

SRKREC, ECE Department 30


Microprocessors and Microcontrollers Lab Manual

Programming Instructions For VI-Micro 8086 Trainer


To Store (write) Program (In Assembler)
➔ Press A and press enter.
Enter starting addresses of the program and press enter.
Eg: A enter
5000 enter
➔ It shows 5000 address. Start loading 8086 instructions in Assembler. After
every instruction typing is completed press enter, it shows the machine code
and after pressing next enter it shows new address's location for the next
instruction to be loaded.
➔ Keep on doing the above process until the end of the program.
➔ Press Dot (.) enter to come out from Assembler.

Verification Of Program: (Unassemble the program)


➔ Press U and press enter.
Enter starting addresses of the program and press enter twice.
Eg: U enter
5000 press enter twice
It shows the loaded program in the assembler. Keep on pressing enter it shows the
step by step of the loaded program.

To Store Data in Memory and Verification of output in Memory


To store byte (SB= Substitute Byte)
➔ Press SB space 16-bit data address and press enter
It shows previously loaded data, then load new data from the keyboard and
press enter for the next byte of data to be loaded.
keep on doing the above process till the last data byte.
➔ Press Dot (.) enter to come out.

To store Word (two bytes) (SW= Substitute Word)


➔ SW space 16-bit data address and press enter
It shows previously loaded data, then load new data from the keyboard and
press enter for the next word of data to be loaded.
keep on doing the above process till the last data word.
Press Dot (.) enter to come out.
SRKREC, ECE Department 31
Microprocessors and Microcontrollers Lab Manual

To Modify Or Change Instructions:


Modification of instructions in Assembler only. If you want to modify any
instruction, first know the address of the instruction then go to that address in the
assembler and rewrite the new instruction in that address location.
A enter and enter the address at which the instruction is to be changed, shows that
address location. Rewrite new instruction in that address location

FOR EXECUTION:
Go Space Starting Adress Of the Program And Then Press Enter
GO 5000 ENTER
It will show Executing….
To stop execution press INT Button on the kit.

SRKREC, ECE Department 32


Microprocessors and Microcontrollers Lab Manual

Experiments Based On ALP (8086)

6) Write an 8086 ALP to add two-32 bit numbers stored in the memory location 6000H and
6004H. Store the result at location 6008H.

Input: Output:

6000 H= Byte0 of the first number 6008 H = Byte0 of result

6001 H = Byte1 of the first number 6009 H = Byte1 of result

6002 H = Byte2 of first number 600A H = Byte2 of result

6003 H = Byte3 of first number 600B H = Byte3 of result

6004 H = Byte0 of second number 600C H = Carry byte of result

6005 H = Byte1 of the second number

6006 H = Byte2 of second number

6007 H =Byte3 of second number

Procedure:

MOV SI,6000 H

MOV AX,[SI]

INC SI

INC SI

MOV BX,[SI]

INC SI

INC SI

MOV CX,[SI]

INC SI

INC SI

MOV DX,[SI]

SRKREC, ECE Department 33


Microprocessors and Microcontrollers Lab Manual

ADD AX, CX

INC SI

INC SI

MOV [SI], AX

ADC BX, DX

INC SI

INC SI

MOV [SI], BX

MOV CL,00 H

ADC CL, CL

INC SI

INC SI

MOV [SI], CL

HLT

Write an 8086 ALP to subtraction of two-32 bit numbers stored in the memory location 6000H
and 6004H. Store the result at location 6008H.

Subtraction of two 32-bit binary numbers(A&B)

Input: Output:

6000 H = Byte0 of the first number 6008 H = Byte0 of result


6001 H= Byte1 of the first number 6009 H = Byte1 of result
6002 H = Byte2 of first number 600A H = Byte2 of result
6003 H = Byte3 of first number 600B H = Byte3 of result
6004 H = Byte0 of second number 600C H= Carry byte of result
6005 H= Byte1 of the second number
6006 H= Byte2 of the second number
6007 H= Byte3 of second number

SRKREC, ECE Department 34


Microprocessors and Microcontrollers Lab Manual

Procedure:

MOV SI,6000 H

MOV AX,[SI]

INC SI

INC SI

MOV BX,[SI]

INC SI

INC SI

MOV CX,[SI]

INC SI

INC SI

MOV DX,[SI]

SUB AX, CX

SBB BX, DX

MOV CL,00

JNC STORE

NOT AX

NOT BX

ADD AX,0001 H

ADC BX,0000 H

MOV CL,01 H

STORE: INC SI

INC SI

MOV [SI], AX

SRKREC, ECE Department 35


Microprocessors and Microcontrollers Lab Manual

INC SI

INC SI

MOV [SI], BX

INC SI

INC SI

MOV [SI], CL

HLT

SRKREC, ECE Department 36


Microprocessors and Microcontrollers Lab Manual

7) Write an 8086 ALP to multiply two 16-bit numbers stored in the memory location 9000H and
9002H. Store the result at location 9004H.

Multiplication of two 16-bit numbers

Input: Output:

6000 H = LSB of multiplicand 6004 H = Byte0 of result

6001 H = MSB of multiplicand 6005 H = Byte1 of result

6002 H = LSB of multiplier 6006 H = Byte2 of result

6003 H= MSB of multiplier 6007 H = Byte3 of result

Procedure:

MOV SI,9000 H

MOV AX,[SI]

INC SI

INC SI

MOV BX,[SI]

MUL BX

INC SI

INC SI

MOV [SI], AX

INC SI

INC SI

MOV [SI], DX

HLT

SRKREC, ECE Department 37


Microprocessors and Microcontrollers Lab Manual

Write an 8086 ALP to divide a 32-bit dividend with 16-bit divisor stored in the memory location
6000H and 6004H respectively. Store the quotient at location 6006H and the remainder at
location 6008H.
Input: Output:

6000 H = Byte0 of dividend 6006 H = LSB of quotient

6001 H = Byte1 of dividend 6007 H = MSB of quotient

6002 H = Byte2 of dividend 6008 H = LSB of remainder

6003 H = Byte3 of dividend 6009 H = MSB of remainder

6004 H= LSB of divisor

6005 H = MSB of divisor

Procedure:
MOV SI,6000 H

MOV AX,[SI]

INC SI

INC SI

MOV DX,[SI]

INC SI

INC SI

MOV BX,[SI]

DIV BX

INC SI

INC SI

MOV [SI], AX

INC SI

INC SI

MOV [SI], DX

HLT
SRKREC, ECE Department 38
Microprocessors and Microcontrollers Lab Manual

8) Write an 8086 µP ALP to find factorial of a given number (given number < 9) is at ‘X’ and
store the result at X+1 location

X: 6000H --- GIVEN NUMBER → Input

X+1: 6001H --- RESULT → Output

Procedure:
MOV SI, 6000H

MOV AX,[SI]

MOV BX, AL

DEC BX

UP: MUL BX

DEC BX

JNZ UP

INC SI

INC SI

MOV [SI], AX

INC SI

INC SI

MOV [SI], DX

HLT

SRKREC, ECE Department 39


Microprocessors and Microcontrollers Lab Manual

9) Write an 8086 μP ALP to convert 8 bit BCD number into HexaDecimal or HexaDecimal into

BCD

BCD number into HexaDecimal

X: 6000H --- GIVEN BCD NUMBER → Input

X+1: 6001H --- Hexadecimal → Output

Procedure:
MOV SI, 6000H

MOV AL,[SI] ; Load BCD Number into AL

MOV BL,00H ;To Store the Binary(Hex Form) Result

CMP AL,00H

JE DOWN 1 ;JE/JZ

UP: SUB AL,01H

DAS

INC BL

CMP AL,00H

JNE UP ;JNE/JNZ

INC SI

DOWN 1: MOV [SI], BL

HLT

SRKREC, ECE Department 40


Microprocessors and Microcontrollers Lab Manual

HexaDecimal number into BCD

X : 6000H --- GIVEN HexaDecimal Input

X+1: 6001H --- BCD Number Output

X+2: 6002H --- BCD Number Output

Procedure:
MOV AX,0000 H ;Clear AX Reg. to store output

MOV CL, [6000] ;Load Binary Number into CL Register

CMP CL,00 H

JZ DOWN1

UP: ADD AL,01H

DAA

JNC DOWN2

INC AH

DOWN2: DEC CL

JNZ UP

DOWN1: MOV [6001], AX

HLT

SRKREC, ECE Department 41


Microprocessors and Microcontrollers Lab Manual

10) Write an 8086 program to add four digit BCD numbers present in memory location 6000H
and 6002H. Store the result at memory location 6004H.

To add two 4-digit BCD numbers

Input: Output:

6000 H = LSB of first 16-bit BCD number 6004 H = Byte0 of BCD result

6001 H = MSB of first 16-bit BCD number 6005 H = Byte1 of BCD result

6002 H= LSB of second 16-bit BCD number 6006 H = Byte2 of BCD result (Carry)

6003 H = MSB of second 16-bit BCD number

Procedure:

MOV SI,6000 H

MOV AX,[SI]

INC SI

INC SI

ADD AL,[SI]

DAA

INC SI

INC SI

MOV [SI], AL

DEC SI

MOV AL,[SI]

DEC SI

DEC SI

ADC AL,[SI]

DAA

SRKREC, ECE Department 42


Microprocessors and Microcontrollers Lab Manual

MOV AH,00 H

ADC AH, AH

MOV SI,6005 H

MOV [SI], AX

HLT

SRKREC, ECE Department 43


Microprocessors and Microcontrollers Lab Manual

11) Write an 8086 μP Assembly Program to find the largest/smallest element in the given array/

6000H: NO.OF BYTES IN AN ARRAY


6001H: FIRST BYTE
6002H: SECOND BYTE
6003H: THIRD BYTE
6004H: FOURTH BYTE
AND SO ON
6050H: LARGEST/SMALLEST NUMBER IN GIVEN ARRAY

Procedure:
MOV SI, 6000H

MOV CL,[SI] ;NUMBER OF BYTES IN CL

MOV CH,00H

DEC CL ;(N-1) COMPARISONS

INC SI

MOV AL, [SI]

UP1:UP2: INC SI

CMP AL,[SI]

JNC UP1 ; use JC instead of JNC for Smallest Number

MOV AL, [SI] ; Load Largest/Smallest Number in AL

LOOP UP2 ;Decrease Value Of Register CX By 1 And


Jump To Address U2 If Value Of Register CX Is
Not Zero
MOV SI, 6050H

MOV [SI],AL

HLT

SRKREC, ECE Department 44


Microprocessors and Microcontrollers Lab Manual

12) Write an 8086 program to sort the given block of the data using the Bubble sorting
technique. Assuming a number of bytes of the block of data stored in location 6000H and actual
data stored on 6001H onwards.

Procedure:

MOV SI,6000H

MOV CL,[SI]

DEC CL

U2: MOV DL, CL

MOV SI,6001H

U1: MOV AL,[SI]

MOV BL,[SI+1]

CMP AL, BL

JC DOWN

MOV BL,[SI]

XCHG BL,[SI+1]

MOV [SI], BL

DOWN: INC SI

DEC DL

JNZ U1

DEC CL

JNZ U2

HLT

SRKREC, ECE Department 45


Microprocessors and Microcontrollers Lab Manual

Alternative Program:

INPUT: 6000H: NO OF ELEMENTS TO BE SORTED (Let it be 5)

6001H: UNSORTED 1ST NUMBER (BYTE)

6002H: UNSORTED 2ND NUMBER (BYTE)

6003H: UNSORTED 3RD NUMBER (BYTE)

6004H: UNSORTED 4TH NUMBER (BYTE)

6005H: UNSORTED 5TH NUMBER (BYTE)

OUTPUT: 6001H: SORTED 1ST NUMBER (BYTE)

6002H: SORTED 2ND NUMBER (BYTE)

6003H: SORTED 3RD NUMBER (BYTE)

6004H: SORTED 4TH NUMBER (BYTE)

6005H: SORTED 5TH NUMBER (BYTE)

Procedure:
MOV SI, 6000H

MOV CL, [SI]

DEC CL

UP2: MOV DL, CL

MOV SI, 6001H

UP1: MOV AL, [SI]

INC SI

MOV BL, [SI]

CMP AL, BL

JNC DOWN

MOV [SI], AL

DEC SI

MOV [SI], BL

DOWN: INC SI

SRKREC, ECE Department 46


Microprocessors and Microcontrollers Lab Manual

DEC DL

JNZ UP1

DEC CL

JNZ UP2

HLT

SRKREC, ECE Department 47


Microprocessors and Microcontrollers Lab Manual

Programming Instructions For ESA 8051 Trainer


To Store (write) Program (In Assembler)
➔ A space starting addresses of the program and press enter.
Eg: A 8000 press enter
➔ It shows an 8000 address. Start loading 8051 instructions in Assembler after
every instruction typing is completed, press enter. It shows the machine code and
the following address's location.
➔ Keep on doing the above process until the end of the program.
➔ Press the Escape button to come out from Assembler.

To Store Data in Memory and Verification of output in Memory


To Store Data in Internal Data Memory
➔ MI space 8bit data address and press enter
It shows previously loaded data, then load new data from the keyboard and press
enter for the next data to be loaded.
➔ keep on doing the above process until data storing is completed.
➔ Press the Escape button to come out
Eg. MI 60 press enter
To Store Data in External Data Memory
MD space 16-bit data address and press enter
➔ It shows previously loaded data, then load new data from the keyboard and
press enter for the next data to be loaded.
➔ keep on doing the above process until data storing is completed
Eg. MD 9000 press enter

EXECUTION:
G space Starting address of Program enter Break enter
Eg. G 8000 enter Break Enter

Verification Of Program: (Unassemble the program)


Z space starting address of the program, ending address of program and press
enter.
It shows the loaded program in the assembler. Keep on pressing enter it shows
the step by step of the loaded program.
Eg. Z 8000, 8023.

SRKREC, ECE Department 48


Microprocessors and Microcontrollers Lab Manual

Experiments based on Microcontroller (8051)

13) Programs on Data transfer instructions using 8051 Microcontroller


Data Transfer From Internal RAM Memory To Internal RAM Memory

Internal RAM address Internal RAM address

60H NO. OF BYTES → Input 70H NO.OF BYTES → Output

61H BYTE1, 71H BYTE1,

62H BYTE2, 72H BYTE2,

63H BYTE3,….. 73H BYTE3,…..

Procedure:

MOV R0,#60H ;Source Address

MOV R1,#70H ;destination Address

MOV A,@R0

MOV @R1, A

MOV R7,A ; count in R7

UP: INC R0

MOV A,@R0

INR R1

MOV @R1, A

DJNZ R7, UP

HERE: SJMP HERE

SRKREC, ECE Department 49


Microprocessors and Microcontrollers Lab Manual

Data Transfer from internal RAM memory to External Data Memory

Internal RAM address External Data Memory address

60H NO.OF BYTES → Input 9000H NO.OF BYTES → Output

61H BYTE1, 9001H BYTE1,


62H BYTE2, 9002H BYTE2,

63H BYTE3,….. 9003H BYTE3,…..

Procedure:

MOV R0,#60H

MOV DPTR,#9000H

MOV A,@R0

MOV R7, A

MOVX @DPTR, A

UP: INC RO

MOV A,@R0

INC DPTR

MOVX @DPTR, A

DJNZ R7, UP

HERE: SJMP HERE

SRKREC, ECE Department 50


Microprocessors and Microcontrollers Lab Manual

14) Programs on Arithmetic and Logical instructions using 8051 Microcontroller


a)Multiplication of two 8 bit numbers using 8051 Microcontroller

Two bytes are stored at 9000H and 9001H respectively and store the result at 9002H and

9003H

Input

9000H BYTE1

9001H BYTE2

Output

9002H RESULT LOWER ORDER BYTE

9003H RESULT HIGHER ORDER BYTE

MUL AB -->A*B= B A

Procedure: MOV DPTR,#9000H

MOVX A,@DPTR

MOV B, A

INC DPTR

MOVX A,@DPTR

MUL AB

INC DPTR

MOVX @DPTR, A

INC DPTR

MOV A, B

MOVX @DPTR, A

HERE: SJMP HERE

SRKREC, ECE Department 51


Microprocessors and Microcontrollers Lab Manual

Division of two 8 bit numbers using 8051 Microcontroller

Two bytes are stored at 9000H and 9001H respectively and store the result at 9002H (Quotient) and
9003H(Remainder)

Input

9000H BYTE1

9001H BYTE2

Output

9002H QUOTIENT

9003H REMAINDER

DIV AB -->A / B= A(Quotient) & B(Remainder)

Procedure:

MOV DPTR,#9000H

MOVX A,@DPTR

MOV B,A

INC DPTR

MOVX A,@DPTR

DIV AB

INC DPTR

MOVX @DPTR,A

INC DPTR

MOV A,B

MOVX @DPTR,A

HERE: SJMP HERE

SRKREC, ECE Department 52


Microprocessors and Microcontrollers Lab Manual

15) Write an ALP to count the number of logic one’s(1’s) zero’s(0’s) in a given byte at location
60H and store the result in the R5 register(number of 1’s) & R4 register (number of 0’s)

60H__ Given Byte → Input


R4__ Number Of One’s → Output
R5__ Number Of Zeros→ Output

Procedure:
MOV R0, #60H

MOV A, @R0

MOV R7,#08H

MOV R5,#00H ; Count the no of ones

MOV R4,#00H ; Count the no of zeros

UP: RRC A

JNC DOWN1

INC R5

SJMP DOWN 2

DOWN1: INC R4

DOWN2: DJNZ R7,UP

HERE: SJMP HERE

SRKREC, ECE Department 53


Microprocessors and Microcontrollers Lab Manual

16) Write an 8051 μC Assembly Program to find the largest element in given array

MOV DPTR,#2000H ;initialize pointer to memory where numbers are stored

MOV R0,#0AH ; initialize counter

MOV R3,#00H ;maximum=0

AGAIN: MOV A,@DPTR ;get the number from memory

CJNE A,R3,NE ;compare number wi maximum number

AJMP SKIP ;if equal go to SKIP

NE: JC SKIP ;if not equal check for carry, if carry go to skip

MOV R3,A ;otherwise maximum=[[DPTR]]

SKIP: INC DPTR ; Increment memory pointer

DJNZ R0,AGAIN ; Decrement count, if count=0 stop otherwise go to AGAIN

SRKREC, ECE Department 54


Microprocessors and Microcontrollers Lab Manual

17) Write an ALP to add the first ten natural numbers(1+2+3+…+A)and store the result at R5
register.

Procedure:

MOV A,#00H

MOV R7,#0AH ; count in R7

MOV R0,#00H

UP : INC R0

ADD A, R0

DJNZ R7, UP

MOV R5, A

HERE: SJMP HERE

SRKREC, ECE Department 55


Microprocessors and Microcontrollers Lab Manual

Additional Experiments:
1) By using 8279 in auto-increment mode, generate a message of 6 characters and make the
display ON and OFF for every 0.5 sec.

Procedure:

Address Label Instruction Opcode Byte 2 Byte 3 Comments


C000 RET MVI A,92 3E 92
C002 OUT D1 D3 D1
C004 MVI C,06 0E 06
C006 LXI H, C040 21 40 C0
C009 AHEAD MOV A, M 7E
C00A OUT D0 D3 D0
C00C INX H 23
C00D DCR C 0D
C00E JNZ AHEAD C2 09 C0
C011 CALL C060 CD 60 C0
C014 MVI A, DF 3E DF
C016 OUT D1 D3 D1
C018 CALL C060 CD 60 C0
C01B JMP RET C3 00 00
C060 LXI H, F9D6 21 D6 F9
C063 BACK DCX H 2B
C064 MOV A, L 7D

For ALS Kit:

D0 data display port address.


D1 8279 control reg. port address.
DF control byte for Blanking

97 96 95 94 93 92

SRKREC, ECE Department 56


Microprocessors and Microcontrollers Lab Manual

Control bytes of LEDs

dp g f e D c b a
LED Buffers

For VMC-85 Kit For LED’s


0 ON
1 OF
18 data display port addr.
19 8279 control reg. port addr
DF Control byte for Blanking
90 91 92 93 94 95

a b c d e F g dp
Control bytes of LEDs

SRKREC, ECE Department 57


Microprocessors and Microcontrollers Lab Manual

2)By using the data field of the display unit, Obtain a count of 00 to 59 with a delay of 1
second after every count. Keep the character code from location “X” onwards.

Procedure:

Address Label Instruction Opcode Byte 2 Byte 3 Comments


C000 LXI SP, C700 31 00 C7 Initializing stack pointer
C003 AHEAD MVI B,06 06 06
C005 LXI H, C040 21 40 C0 Activating the last but one display
C008 RET MVI A,83 3E 83
C00A OUT D1 D3 D1
C00C MOV A, M 7E
C00D OUT D0 D3 D0
C00F MVI C,0A 0E 0A
C011 PUSH H E5 Pushing the present value into the
stack
C012 LXI H, C040 21 40 C0
C015 BACK MVI A,82 3E 82 Activating the last 7 seg display
C017 OUT D1 D3 D1
C019 MVI A, M 7E
C01A OUT D0 D3 D0
C01C INX H 23
C01D CALL C060 CD 60 C0 Call to sub program to get 1 sec
delay
C020 DCR C 0D
C021 JNZ BACK C2 15 C0
C024 POP H E1 Get back the original values
C025 INX H 23
C026 DCR B 05
C027 JNZ RET C2 08 C0 to make the loop to repeat to get
final value as ‘59’
C03A JMP C3 00 C0
AHEAD

SRKREC, ECE Department 58


Microprocessors and Microcontrollers Lab Manual

Sol: D0: The count byte for the data port.


D1: The control byte for control Reg 8279

87 86 85 84 83 82

LED Buffer :

. g f e d c b a

LED Display Works on – ve logic.

Note: Stack has to be at the beginning of the program so that the registers used in the main program
can also be used in subroutines. This can be done by using PUSH & POP instructions with LIFO
logic

Delay Calculation:
Clock Frequency = 3.07 MHz
The total No.of T states = N[6+4+4+10]+10+10+7-10
To get 0.5 sec delay = N[24]+17 = 1535*103 => N = (63958)D = (F9D6)H5.

SRKREC, ECE Department 59


Microprocessors and Microcontrollers Lab Manual

3) The number of bytes of a block of data is location ‘X’ and data starts from location
‘X+1’onwards. Arrange this block of data in ascending order by using the bubble sorting
technique

Procedure:

Address Label Instruction Opcode Byte 2 Byte 3 Comments

C000 LXI H, C040 21 40 C0

C003 MOV C, M 4E

C004 DCR C 0D

C005 RETURN MOV B, C 41

C006 LXI H, C041 21 41 C0

C009 BACK M0V A, M 7E

C00A INX H 23

C00B CMP M BE

C00C JC AHEAD DA 15 C0

C00F MOV D, A 57

C010 MOV A, M 7E

C011 MOV M, D 72

C012 DCX H 2B

C013 MOV M, A 77

C014 INX H 23

C015 AHEAD DCR B 05

C016 JNZ BACK C2 09 C0

C019 DCR C 0D

C01A JNZ RETURN C2 05 C0

C01D HLT 76

C040 08

C041 40

SRKREC, ECE Department 60


Microprocessors and Microcontrollers Lab Manual

C042 20

C043 30

C044 10

C041 10

C042 20

C043 30

C044 40

SRKREC, ECE Department 61


Microprocessors and Microcontrollers Lab Manual

4) Using 8279 write an ALP to generate the message of 4 characters. Activate the LEDs
individually and make the display ON & OFF every 0.5 seconds.

Procedure:

Address Label Instruction Opcode Byte 2 Byte 3 Comments

C000 BACK MVI A,87 3E 87

C002 OUT D1 D3 D1

C004 MVI A,88 3E 88

C006 OUT D0 D3 D0

C009 MVI A,86 3E 86

C00A OUT D1 D3 D1

C00C MVI A,88 3E 88

C00D OUT D0 D3 D0

C00E MVI A,85 3E 85

C011 OUT D1 D3 D1

C014 MVI A,88 3E 88

C016 OUT D0 D3 D0

C018 MVI A,84 3E 84

C01B OUT D1 D3 D1

C01E MVI A,88 3E 88

C021 OUT D0 D3 D0

C022 CALL C060 CD 60 C0

C025 MVI A, DF 3E DF

C026 OUT D1 D3 D1

C027 CALL C060 CD 60 C0

C02A JMP BACK C3 00 C0

C060 LXIH, F9D6 21 D6 F9

C063 RETURN DCX H 2B

SRKREC, ECE Department 62


Microprocessors and Microcontrollers Lab Manual

C064 OR A, H 7D

C065 MOV A, L B4

C066 JNZ RETURN C2 63 C0

C069 RET C9

For ALS Kit:


D0 data display port address.
D1 8279 control Reg. Port address.
DF Control byte for Blanking.
87 86 85 84 83 82
Control bytes of LEDs
a

f b
g
e c

d .dp

dp g f e D c b a

LED Buffers

For VMC-85 Kit:


For LED’s

18 data display port address. 0 ON


19 8279 control Reg. Port address. 1 OFF
DF Control byte for Blanking.

Control bytes of LEDs

LED Buffers.
a b c d e F g dp

SRKREC, ECE Department 63


Microprocessors and Microcontrollers Lab Manual

For the display of A B C D using ALS Kit :

Dp g f e : d c b a

A 1 0 0 0 : 1 0 0 0 88

B 1 0 0 0 : 0 0 0 0 80

C 1 1 0 0 : 0 1 1 0 C6

D 1 1 0 0 : 0 0 0 0 C0

SRKREC, ECE Department 64


Microprocessors and Microcontrollers Lab Manual

5) Write an 8086 ALP to move the data using string

MOV SI, 5000 : load the value 5000 into offset SI.
MOV DI, 6000 : load the value 6000 into offset DI.
MOV CL, [SI] : load the data of offset SI into the CL register.
MOV CH, 00 : load value 00 into CH register.
INC SI : increment the value of SI by one.
CLD : clears the directional flag i.e. DF=0.
REP : repeat until value of CX is not equal to zero and decrement
the value of CX by one at each step.
MOVSB : transfer the data from the source memory location to the
destination memory location.
HLT : end.

MOVS/MOVSB/MOVSW
This instruction copies a byte or a word from a location in the data segment [DS:SI] to a location
in the extra segment [ES:DI]. The offset in the data segment for the source is to be stored in the SI
register and the offset for the destination in the extra segment is to be stored in the DI register.
For multiple byte/word movement, the value stored in the CX register by the user functions as a
counter. After each move, SI and DI are automatically adjusted to point to the next source and
destination respectively.
➔ The Direction Flag (DF) value determines whether SI and DI are to be incremented (DF = 0) or
decremented (DF = 1) after each move.
➔ The MOVSB instruction tells the assembler to move data as bytes; the MOVSW implies the string is
to be moved as words.
➔ MOVSB instruction is used to transfer bytes only from the source memory location (MADS) to the
destination memory location (MAES).
➔ CLD instruction is used to clear the directional flag, i.e., DF=0. Now, the value of SI and DI will be
increased.
➔ REP instruction is used to repeat the step until the value of CX is not equal to zero and the value of
CX is decremented by one at every step

Usage
MOVS dest, src (This usage is misleading; movement of data still happens from DS: SI to
ES: DI)
MOVSB

MOVSW

MOVSB moves contents of byte given by DS:SI into ES:DI


MOVSW moves contents of the word given by DS:SI into ES:DI
REP repeat the given instruction till CX != 0

SRKREC, ECE Department 65


Microprocessors and Microcontrollers Lab Manual

6)Write an ALP to count the Even and Odd numbers from the series of 100 numbers present in
the memory location from 6000:61000H . Store the even count in register BX and the odd count
in register DX.

MOV AX,6000H

MOV DS,AX

MOV SI,0100H

MOV CX, 100H

XOR BX,BX

XOR DX,DX

CLD

L1: LODSW

ROR AX, 1

JC ODD

INC BX :Count of Even Numbers

JMP NEXT

ODD: INC DX :Count of Even Numbers

NEXT: LOOP L1

HLT

SRKREC, ECE Department 66


Microprocessors and Microcontrollers Lab Manual

7) Write an 8051 μC Assembly Program to Sort n Numbers in Ascending Order

MOV R2,50H ; get n in R2

DEC R2 ; get an actual count on register R2

L3: MOV 03,O2 ; get the actual count from R2 to R3

MOV R0,#60H ; get memory location to be pointed on pointer register R0

L4: MOV A,@R0 ; copy [[R0]] into Accumulator

INC R0 ; Increment R0 to access next memory location

MOV 05,@R0 ; copy [[R0]] to register R5

CJNE A,05,L1 ; Compare[A] with [R5] and jump if not equal to L1

L1: JC L2 ; Is [A]<[R5]? Ye,s jump to L2. If there is a carry go to the next step.

MOV 04,@R0 ;copy [[R0]] to R4. Now the small number is in R4. Since [[R0]]=[R5]

MOV @R0,A ; copy a large number from A to the current memory location pointed by R0.

DEC R0 ; accessing previous memory location

MOV @R0,04 ; copy smallest number to [[R0]]

INC R0 ; come back to current memory location

L2: DJNZ R2,L4

DJNZ R2,L3 ; compare nc2 times using these two loops

SRKREC, ECE Department 67


Microprocessors and Microcontrollers Lab Manual

8) Write an 8051 μC Assembly Program to Hexadecimal to Decimal Conversion

MOV A,52H ; get the hexadecimal number from memory location 52H

MOV 0F0H,#64H ; load register B with 64H= 100 in decimal

DIV AB ; divide the number with 100

MOV 60H,A ; save a number of hundreds(quotient of previous division)

MOV A,0F0H ; Get remainder on A

MOV 0F0H,#0AH ; load register B with 0AH=10 in decimal

DIV AB ; divide the number with 10

MOV 61H,A ; save tens of the number

MOV 62H,0F0H ; save a number of ones of the number

SRKREC, ECE Department 68


Microprocessors and Microcontrollers Lab Manual

Architecture of 8085 MicroProcessor


The architecture of the 8085 microprocessor provides the idea about what are
operations to be executed and how these are performed.
It can perform operations that are given below:
1. Operates on and stores 8-bit data.
2. It executes arithmetic and logic operations.
3. 8085 also sequences the instructions to be executed.
4. Stores data temporarily.
However, in order to perform all such operations, the processor needs a control unit, arithmetic
logic unit, registers, buses, etc.

8085 Architecture
Arithmetic and Logic Unit: The ALU performs the actual numerical and logical operations
such as Addition (ADD), Subtraction (SUB), AND, OR etc.
➔ It uses data from memory and from the Accumulator to perform operations.
➔ The results of the arithmetic and logical operations are stored in the accumulator.

Registers: The 8085 includes six registers, one accumulator, and one flag register.
➔ In addition, it has two 16-bit registers: stack pointer and program counter.
➔ The 8085 has six general-purpose registers to store 8-bit data; these are identified as
B, C, D, E, H, and L.
➔ They can be combined as register pairs - BC, DE, and HL to perform some 16- bit
operations.
SRKREC, ECE Department 69
Microprocessors and Microcontrollers Lab Manual

➔ The programmer can use these registers to store or


copy data into the register by using data copy instructions.

Accumulator: The accumulator is an 8-bit register that is a


part of ALU.
➔ This register is used to store 8-bit data and to
perform arithmetic and logical operations.
➔ The result of an operation is stored in the
accumulator.
➔ The accumulator is also identified as register A.

Flag register: The Flag register is a Special Purpose Register.


➔ Depending upon the value of the result after any arithmetic and logical operation, the
flag bits become set (1) or reset (0).
➔ In an 8085 microprocessor, the flag register consists of 8 bits and only 5 of them are
useful.
➔ They are called
◆ Zero (Z),
◆ Carry (CY),
◆ Sign (S), Parity (P), and
◆ Auxiliary Carry (AC) flags

W and Z register : These registers are also used to hold temporary values. It is used by the
control section of the microprocessor to store the data during operations.

Program Counter (PC) This 16-bit register deals with sequencing the execution of
instructions.
➔ This register is a memory pointer. The microprocessor uses this register to sequence the
execution of the instructions.
➔ The function of the program counter is to point to the memory address from which the
next byte is to be fetched.
➔ When a byte is being fetched, the program counter is automatically incremented by one
to point to the next memory location.

Stack Pointer (SP) The stack pointer is also a 16-bit register, used as a memory pointer. It
points to a memory location in R/W memory, called the stack.
➔ The beginning of the stack is defined by loading a 16-bit address in the stack pointer.

SRKREC, ECE Department 70


Microprocessors and Microcontrollers Lab Manual

Instruction Register & Decoder: It is an 8-bit register that temporarily stores the current
instruction of a program.
➔ Latest instruction was sent here from memory prior to execution.
➔ The decoder then takes instruction and decodes or interprets the instruction. Decoded
instructions are then passed to the next stage.

Timing and control Unit: We use the Timing and Controlling unit in 8085 for the generation of
timing signals and the signals to control.
➔ This circuit basically sends the control signals to the various units of the microprocessor
to execute the instruction.
➔ All the operations and functions of both the interior and exterior of a microprocessor are
controlled by this unit.

Interrupt control: Whenever a microprocessor is executing the main program and if suddenly
an interrupt occurs, the microprocessor shifts the control from the main program to process the
incoming request.
➔ After the request is completed, the control goes back to the main program.
➔ There are 5 interrupt signals in 8085 microprocessors: INTR, TRAP, RST 7.5, RST 6.5,
and RST 5.5.
➔ Priorities of Interrupts: TRAP > RST 7.5 > RST 6.5 > RST 5.5 > INTR

Address bus and data bus: The data bus is bidirectional and carries the data which is to be
stored. The address bus is unidirectional and carries the location where data is to be stored.

Serial Input/output control: It controls the serial data communication by using Serial input
data and Serial output data.

SRKREC, ECE Department 71


Microprocessors and Microcontrollers Lab Manual

Architecture of 8086 MicroProcessor

The internal architecture of Intel 8086 is divided into 2 units:


➔ The Bus Interface Unit (BIU)
➔ The Execution Unit (EU).

Bus Interface Unit (BIU)


It provides the interface of 8086 to external memory and I/O devices via the System
Bus. It performs various machine cycles such as memory read, I/O read etc. to transfer data
between memory and I/O devices.
BIU performs the following functions:
➔ It generates the 20-bit physical address for memory access.
➔ It fetches instructions from memory.
➔ It transfers data to and from the memory and I/O.
➔ Maintains the 6 byte prefetch instruction queue(supports pipelining).

BIU mainly contains the 4 Segment registers, the Instruction Pointer, a prefetch queue and an
Address Generation Circuit.
Segment Registers: A segment register contains the addresses of instructions and data in
memory which are used by the processor to access memory locations. It points to the starting
address of a memory segment currently being used.
There are 4 segment registers in 8086 as given below:
➔ Code Segment Register (CS): The code segment of the memory holds the instruction
codes of a program.

SRKREC, ECE Department 72


Microprocessors and Microcontrollers Lab Manual

➔ Data Segment Register (DS): The data, variables, and constants given in the program
are held in the data segment of the memory.
➔ Stack Segment Register (SS): The stack segment holds addresses and data of
subroutines. It also holds the contents of registers and memory locations given in
PUSH instruction.
➔ Extra Segment Register (ES): Extra segment holds the destination addresses of some
data of certain string instructions.

Instruction Queue: It is a 6-byte queue (FIFO). Fetching the next instruction (by BIU from CS)
while executing the current instruction is called pipelining. It gets flushed whenever a branch
instruction occurs.

Instruction Pointer (IP): The instruction pointer in the 8086 microprocessor acts as a program
counter. It indicates the address of the next instruction to be executed.

Address Generation Circuit: The BIU has a Physical Address Generation Circuit. It generates
the 20-bit physical address using Segment and Offset addresses using the formula:

Physical Address = Segment Address x 10H + Offset Address

Execution Unit (EU)


The EU receives the opcode of an instruction from the queue, decodes it and then
executes it.
➔ While Execution, the unit decodes or executes an instruction, then the BIU fetches
instruction codes from memory and stores them in the queue.
➔ The BIU and EU operate in parallel and independently. This makes processing faster.

EU Contains
➔ General purpose registers,
➔ Stack pointer, Base pointer, and Index registers,
➔ ALU
➔ Flag Registers (FLAGS),
➔ Instruction decoder, and timing and control unit.

8086 has four 16-bit general-purpose registers AX, BX, CX, and DX. Store
intermediate values during execution. Each of these has two 8-bit parts (higher and lower).

SRKREC, ECE Department 73


Microprocessors and Microcontrollers Lab Manual

➔ AX register: It holds operands and results during multiplication and division


operations. Also an accumulator during String operations.
➔ BX register: It holds the memory address (offset address) in indirect addressing
modes.
➔ CX register: It holds the count for instructions like a loop, rotate, shift, and string
operations.
➔ DX register: It is used with AX to hold 32-bit values during multiplication and division.

Special purpose registers (16-bit):


Stack Pointer: Points to Stack top. Stack is in Stack Segment, used during instructions like
PUSH, POP, CALL, RET, etc.
Base Pointer: BP can hold an offset address of any location in the stack segment. It is used to
access random locations of the stack.
Source Index: It holds an offset address in Data Segment during string operations.
Destination Index: It holds offset addresses in Extra Segment during string operations.

Arithmetic Logic Unit (16 -bit): Performs 8 and 16-bit arithmetic and logic operations.

Instruction Register and Instruction Decoder: The EU fetches an opcode from the queue
into the instruction register. The instruction decoder decodes and sends the information to the
control circuit for execution.

Flag/Status register (16 bits): It has 9 flags that help change or recognize the state of the
microprocessor.

6 Status flags: Status flags are updated after every arithmetic and logic operation.
➔ carry flag(CF)
➔ parity flag(PF)
➔ auxiliary carry flag(AF)
➔ zero flag(Z)
➔ sign flag(S)
➔ overflow flag (O)
3 Control flags: These flags can be set or reset using control instructions like CLC, STC, CLD,
STD, CLI, STI, etc. The Control flags are used to control certain operations.
➔ trap flag(TF)
➔ interrupt flag(IF)
➔ direction flag(DF)

SRKREC, ECE Department 74


Microprocessors and Microcontrollers Lab Manual

Architecture of 8051 MicroConroller


The 8051 Microcontroller is one of the basic types of the microcontroller. This
microcontroller was based on Harvard Architecture.

The architecture of 8051 Microcontroller

Components:
1. BUS
2. Central Processor Unit (CPU)
3. Interrupts
4. Oscillator
5. Memory
6. Input/Output Port
7. Serial Port
8. Timers
BUS Bus is a collection of wires which work as a communication channel or medium for the
transfer of Data. These buses consist of 8, 16, or more wires of the microcontroller.
➔ Thus, these can carry 8 bits, and 16 bits simultaneously. There are two types of buses
that are shown below
◆ Address Bus
◆ Data Bus

Address Bus: Microcontroller 8051 has a 16-bit address bus for transferring the data.

SRKREC, ECE Department 75


Microprocessors and Microcontrollers Lab Manual

➔ It is used to address memory locations and to transfer the address from the CPU to
the Memory of the microcontroller.
➔ It has four addressing modes that are
➢ Immediate addressing modes.
➢ Bank address (or) Register addressing mode.
➢ Direct Addressing mode.
➢ Register indirect addressing mode.

Data Bus: Microcontroller 8051 has 8 bits of the data bus, which is used to carry data for
particular applications.
Central Processor Unit (CPU)
The CPU is the brain of any processing device of the microcontroller.
➔ The CPU is the primary device in communicating with peripheral devices like Memory,
Input, and Output.
➔ It monitors and controls all operations that are performed on the Microcontroller units.
➔ It reads programs written in ROM memory and executes them and does the expected
task of that application.
➔ CPU consists of ALU and CU.
➔ Arithmetic Logic Unit(ALU) performs the Arithmetical and Logical Operations.
➔ Control Unit (CU)is responsible for the timing of the communication process between
the CPU and its peripherals.
Interrupts
Interrupt is a subroutine call that interrupts the microcontroller's main
operations or work and causes it to execute any other program, which is more
important at the time of operation.
➔ The feature of Interrupt is very useful as it helps in case of emergency operations.
➔ Generally five interrupt sources are there in the 8051 Microcontroller.
Oscillator
Microcontroller requires clock pulses for its operation
➔ For this purpose, microcontroller 8051 has an on-chip oscillator that works as a clock
source for the Central Processing Unit of the microcontroller.
➔ An on-chip crystal oscillator has a crystal frequency of 12 MHz.
➔ The output pulses of the oscillator are stable.
➔ Therefore, it enables synchronized work of all parts of the 8051 Microcontroller.
Program Memory
The instructions of the CPU are stored in the Program Memory.
➔ It is usually implemented as a Read Only Memory or ROM, where the Program
written into it will be retained even when the power is down or the system is reset.
SRKREC, ECE Department 76
Microprocessors and Microcontrollers Lab Manual

➔ This program tells the microcontroller to do specific tasks.


➔ 8051 microcontroller has 4K of code memory or program memory.

Data Memory
Data Memory in a Microcontroller is responsible for storing values of variables,
temporary data, intermediate results , and other data for the proper operation of the
program.
➔ Data Memory is often called RAM (Random Access Memory), which is a type of
volatile memory.
➔ It is generally organized as registers and includes both Special Function Registers
(SFRs) and user accessible memory locations.
➔ 8051 has 128 bytes of data memory or RAM.
Input and Output Ports
➔ There are four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports.
➔ Port 0 occupies a total of 8 pins (pins 32-39) It can be used for input or output. To use
the pins of port 0 as both input and output ports.
➔ Port 0 is also designated as AD0-AD7, allowing it to be used for both address and
data.
➔ Port 1& Port 2 are used as simple I/O with no external memory connection.
➔ When external memory is connected Port 2 must be used along with Port 0 to
provide a 16-bit address for external memory.
➔ Port 3 is used as input or output.

SRKREC, ECE Department 77

You might also like