Microprocessor Architecture
Programming and its Application
with 8085
Presented
by
SANJOY BANERJEE
Syllabaus
• Course Code : PC-EI403
• Course Name : Microprocessor and Microcontroller
• Semester : Fourth
• Credit: 4
• Total Lectures: 60
• Objectives:
– 1. To introduce the architecture and organization of typical
microprocessors and microcontroller
– 2. To develop assembly language programming skill of microprocessor
and microcontroller along with applications.
– 3. To familiarize the technique for interfacing memory and peripheral
devices to microprocessor, including several specific standard I/O devices.
– 4. To understand the hardware/software trade-offs involved in the design
of microprocessor based systems.
• Course Outcomes:
– 1. To construct and analyze assemble language program in 8085 and
8086 microprocessor to solve various complex engineering problem.
– 2. To evaluate processing time of program and devise technique to
reduce execution time to improve microprocessor performance.
– 3. To design interfacing circuits to the microprocessor to
communicate with external devices, which can be associated with
public safety, health, security and other societal and environmental
concerns.
– 4. To design memory devices using memory chips and utilize the
knowledge in memory based devices used in academics and
industry.
– 5. To study 8051 microcontroller for using it in real life applications.
– 6. To learn architecture and programming of programmable
peripheral devices such as 8255, 8254 to use them in larger
industrial and societal application.
• Learning Resources
• Text Books:
– 1. Ramesh S. Gaonkar, Microprocessor Architecture, Programming and
Applications with the 8085A /8080A, WILEY EASTERN LIMITED.
– 2. Mohamed Ali Mazidi, Janice Gillispie Mazidi, Rolin McKinlay, “The 8051
Microcontroller and Embedded Systems: Using Assembly and C”, Second
Edition, Pearson education, 2011.
– 3. A.H. Mukhopadhyay, Microprocessor, Microcomputer and Their
Applications, 3rd Edition Alpha Science International, Ltd.
• References:
– 1. Soumitra Kumar Mandal, Microprocessor & Microcontroller
Architecture, Programming & Interfacing using 8085, 8086, 8051,
McGraw Hill Edu, 2013.
– 2. M. Rafiquzzman: Microprocessors: Theory & Applications (Intel &
Motorola), PHI. 2. Berry .B. Bray INTEL 8086/88, 80186, 286, 386, 486,
Pentium Pro & Pentium IV.
– 3. Berry .B. Bray INTEL 8086/88, 80186, 286, 386, 486, Pentium Pro &
Pentium IV.
What is a Microprocessor?
• The word comes from the combination micro and processor.
• Processor means a device that processes data. In this
context processor means a device that processes numbers,
specifically binary numbers, 0’s and 1’s.
• In the late 1960’s, processors were built using discrete
elements. These devices performed the required operation,
but were too large and too slow.
• In the early 1970’s a new technology was developed in
which all of the components that made up the processor
were now placed on a single piece of silicon. So, the size
became several thousand times smaller and the speed
became several hundred times faster.
• The “Micro”Processor was born.
Definition of the Microprocessor
• 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
those instructions, and provides result as
output.
Multipurpose
• Consumer Electronics
• House Hold applications
• Home automation and security system
• Automotive industry
• Telecommunication
• Computer peripherals
• Computer networking system
• Healthcare
• Measurement and Instrumentation
• Banking and Retail
Programmable
• A typical programmable machine can be represented
with four components: microprocessor, memory,
input and output as shown in figure. These four
components work together or interact with each
other to perform a task, thus they comprise a system.
• The physical components of this system called
hardware.
• A set of instructions written for the microprocessor to
perform a task is called a program (stored in
memory), and a group of program is called software.
History
Block diagram of a computer system
• As we know a typical programmable machine can
be represented with four components:
microprocessor, memory, input and output
devices.
• Memory: Memory is a semiconductor devices,
which is used to store data or instructions. So, a
memory is like a page of a notebook, in which
some fixed number of binary data can be written.
These pages are made of semiconductor materials,
and each page is capable to store 8 bit data so,
considered as a 8bit register. So several of these
registers are arranged in a sequences called
memory.
• These registers are always are grouped together in
powers of two. As an example a group of 1024
(210 ) 8 bit registers on a semiconductor chip is
known as 1 KB memory.
• Memory stores information such as instructions and data in
binary format (0 and 1). It provides this information to the
microprocessor whenever it is needed.
• According to the operation or function memory can be classified
into the following groups:
• Registers: The registers are used inside the microprocessor to
store 8 bit data temporally.
• ROM: Read Only Memory (ROM)used to store information that
does not change. Generally ROM is used to store instruction
which is to be executed by the processor repeatedly. Once the
data is stored in ROM, that can’t be erased.
• RAM: Random Access Memory (RAM) (also known as
Read/Write Memory) used to store information supplied by the
user, such as data. Generally RAM is used to store temporally
data, because once the power is off all data is erased from the
RAM.
• Input / Output: Users can enter instructions and
data into memory through devices such as
keyboard or simple switches. These devices are
known as input devices.
• Microprocessors reads the instruction from the
memory and process the data according to those
instructions. The result can be displayed by a
device such as seven-segment LEDs or printed by a
printer. These devices are called output devices.
Inside a microprocessor
• Internally, the microprocessor is made up of some main units.
• An array of registers used to store data temporarily during
execution of a program and also used by the user.
• The Arithmetic/Logic Unit (ALU) to perform arithmetic and
logical operations.
• Instruction decoder and the control unit.
• CPU reads the instruction from the memory and perform the
task specified. It communicates with input/output devices
either to accept or to send data. These devices are also
known as peripherals. The CPU is primary and central player
in communicating with devices such as memory, input and
output. However the timing of the communication process is
controlled by the group of circuits called the control unit.
Organization of a Microprocessor-Based System.
System Bus
System Bus
• Address Bus: The address bus is a group of l6 lines
(8085 microprocessor) identified as A0 to A15. Address
bus is unidirectional: bits flow in one directional, from
CPU to peripherals or memory. The MPU uses the
address bus to identify a peripheral of memory
location. Each peripheral or memory location is
identified by an specific binary numbers is called
address, an address bus is used to carry the address
information from MPU to peripheral or memory
locations. The 8085 microprocessor has 16 bit address
bus so, by using these 16 address line MPU is capable
to address 64K memory locations.
• Data Bus: The data bus is a group of 8 lines used
for data flow. These lines are bidirectional: data
flow in both direction i.e from MPU to peripheral
or memory and vice-versa. The eight data lines
enable the MPU to manipulate 8 bit data from 00h
to FFh.
• Control Bus: The control bus is comprised of single
lines that carry synchronization signals. Control
bus are not group of lines like address or data bus,
but individual lines that provide a pulse to indicate
a MPU operation.
8085 Programming Model
The ALU
• ALU performs Arithmetic operations like Addition,
Subtraction, Increment, decrement and logical
operations like logical OR, logical AND, logical XOR,
complement, compare and shift operations.
• The ALU includes the accumulator which help ALU
to perform arithmetic or logical operation
• The ALU also includes a temporary register used
for holding data temporarily during the execution
of the operation. This temporary register is not
accessible by the programmer.
Registers
• General Purpose Registers
• B, C, D, E, H& L(8 bit registers)
• Can be used as single 8 bit register
• Can be used as 16 bit register pairs BC, DE, HL
• BC, DC and HL can be used as a data pointer (holds memory
address)
• Special Purpose Register
• Accumulator(8 bit register)
• Store 8 bit data
• Store the result of an operation
• Store 8 bit data during I/O transfer
• Flag Register
• 8 bit register: shows the status of the microprocessor
before/after an operation.
• S (sign flag), Z (zero flag), AC (auxillary carry flag), P
(parity flag) & CY (carry flag)
• Sign Flag:
• Used for indicating the sign of the data in the accumulator
after some arithmetic or logical operation.
• The sign flag is set if negative (1 –negative)
• The sign flag is reset if positive (0 –positive)
• Zero Flag:
• Zero flag will be set to 1 if the result obtained after an arithmetic or logical
operation is 0.
• Carry Flag:
• Carry flag will be set to 1 if there is a carry or borrow from arithmetic
operation, i.e. a carry generated from the D7 bit of the accumulator.
• Auxillary Carry Flag:
• Auxillary Carry flag will be set to 1 if there is a carry out from D3 to D4 bit of
the accumulator after some arithmetic operation.
• Parity Flag:
• Parity flag will be set to 1 if the number of 1’s in accumulator is even. I.e. set if
parity is even, cleared if parity is odd
•PC (PROGRAM COUNTER)
• The Program Counter (PC)This is a register that is used to control the
sequencing of the execution of instructions.
• This register always holds the address of the next instruction.
• Since it holds an address, it must be 16 bits wide.
• SP (STACK POINTER)
• The stack pointer is also a 16-bit register that is used to point into
memory.
• The memory this register points to is a special area called the
stack.
• The stack is an area of memory used to hold data that will be
retrieved soon.
• The stack is usually accessed in a Last In First Out (LIFO) fashion.
• Non Programmable Registers
• Instruction Register & Instruction Decoder:
• Instruction is stored in IR after fetched by processor
• Instruction Decoder decodes instruction in IR (Instruction
Register)
Architecture of 8085 Microprocessor
Simplified Block Diagram
Memory Read or Write operation
How Microprocessor Fetch an
Instruction (MOV C,A)?
Pin Description
The 8085 Microprocessor
• The 8085A is an 8 bit general purpose microprocessor
capable of addressing of 64KB of memory.
• The device has 40 pins.
• It requires a +5v single power supply.
• It can operate with 3 MHz single phase clock.
• 8085A-2 can operates at maximum frequency of 5 MHz.
• All the signals can be classified into six groups (i)address
bus (ii) data bus (iii) control and status signals (Iv) power
supply and frequency signals (v) externally initiated
signals and (vi) serial I/O ports.
• Address Bus: The 8085 has 16 address lines, these lines are
separated by two segments A15-A8 and AD7-AD0. The eight
signal lines A15-A8 are unidirectional and used for most
significant bits, called the higher order address of 16 bit
address. The signal AD7-AD0 lines are used for dual purpose
as stated bellow.
• Multiplexed address/data bus: The address lines AD7-AD0
are biderectional: they serve a dual purpose. They are used
as the lower order address bus and the data bus. In
executing an instruction, during the earlier part of the cycle,
these lines are used as the lower order address bus. During
the later part of the cycle, these lines are used as the data
bus (This is known as the multiplexing the bus). However
the lower order address bus can be separated from these
signals by using a latch.
• Control and Status Signals:
• Three control signals are , & ALE.
• − This signal indicates that the selected IO or
memory device is to be read and is ready for
accepting data available on the data bus.
• − This signal indicates that the data on the data
bus is to be written into a selected memory or IO
location.
• ALE − It is a positive going pulse generated when a
new operation is started by the microprocessor.
When the pulse goes high, it indicates address.
When the pulse goes down it indicates data.
• Three status signals are IO/M, S0 & S1.
• IO/: This signal is used to differentiate between IO
and Memory operations, i.e. when it is high
indicates IO operation and when it is low then it
indicates memory operation.
• S1 & S0: These signals are used to identify the
type of current operation.
• Power Supply and Frequency Signals:
• Power Supply: There are 2 power supply signals − VCC & VSS.
VCC indicates +5v power supply and VSS indicates ground signal.
• Clock signals: There are 3 clock signals, i.e. X1, X2, CLK OUT.
• X1, X2 − A crystal (RC, LC N/W) is connected at these two pins
and is used to set frequency of the internal clock generator. This
frequency is internally divided by 2.
• CLK OUT − This signal is used as the system clock for devices
connected with the microprocessor.
• Serial I/O signals:There are 2 serial signals, i.e. SID and SOD
and these signals are used for serial communication.
• SOD (Serial output data line) − The output SOD is set/reset as
specified by the SIM instruction.
• SID (Serial input data line) − The data on this line is loaded into
accumulator whenever a RIM instruction is executed.
• Interrupts & externally initiated signals: Interrupts
are the signals generated by external devices to request the
microprocessor to perform a task. There are 5 interrupt signals,
i.e. TRAP, RST 7.5, RST 6.5, RST 5.5, and INTR. We will discuss
interrupts in detail in interrupts section.
• INTA − It is an interrupt acknowledgment signal.
• RESET IN − This signal is used to reset the microprocessor by
setting the program counter to zero.
• RESET OUT − This signal is used to reset all the connected
devices when the microprocessor is reset.
• READY − This signal indicates that the device is ready to send or
receive data. If READY is low, then the CPU has to wait for READY
to go high.
• HOLD − This signal indicates that another master is requesting the
use of the address and data buses.
• HLDA (HOLD Acknowledge) − It indicates that the CPU has
received the HOLD request and it will relinquish the bus in the next
clock cycle. HLDA is set to low after the HOLD signal is removed.
The Address and Data Busses
• The address bus has 8 signal lines A8 –A15which are
unidirectional.
• The other 8 address bits are multiplexed(time
shared) with the 8 data bits. So, the bits AD0 –
AD7are bi-directional and serve as A0 –A7and D0 –
D7at the same time. During the execution of the
instruction, these lines carry the address bits during the
early part, then during the late parts of the execution,
they carry the 8 data bits.
• In order to separate the address from the data, we can
use a latch to save the value before the function of the
bits changes.
Demultiplexing AD7-AD0
• AD7–AD0 lines are serving as a dual purpose and that they
need to be demultiplexed to get all the information.
• The high order bits of the address remain on the bus for
three clock periods. However, the low order bits remain for
only one clock period and they would be lost if they are not
saved externally. Also, notice that the low order bits of the
address disappear when they are needed most.
• To make sure we have the entire address for the full three
clock cycles, we will use an external latch to save the value of
AD7–AD0 when it is carrying the address bits. We use the
ALE signal to enable this latch.
Demultiplexing AD7-AD0
•Given that ALE operates as a pulse during T1, we will be able to latch the
address. Then when ALE goes low, the address is saved and the AD7–AD0 lines
can be used for their purpose as the bi-directional data lines.
•The high order address is placed on the address bus and hold for 3 clk periods,
•The low order address is lost after the first clk period, this address needs to be
hold however we need to use latch
•The address AD7 –AD0 is connected as inputs to the latch 74LS373.
•The ALE signal is connected to the enable (G) pin of the latch and the OC –
Output control –of the latch is grounded
Demultiplexing AD7-AD0
Demultiplexing AD7-AD0
Generating Control Signals
IO / M’ RD’ WR’ MEMR’ MEMW’ IOR’ IOW’
0 0 1 0 1 1 1
0 1 0 1 0 1 1
1 0 1 1 1 0 1
1 1 0 1 1 1 0
Timing Diagram
Memory Read Machine Cycle
Memory Write Machine Cycle
Op-code Fetch Machine Cycle
Draw the timing diagram of MVI A,32H
Machine Stack Address Program Data Bus Inetrnal Control
Cycle Pointer Bus Counter W Z Signal
(SP) (PC) Op-code Operand
M1 ------ 2000H 2001H 3EH ---- ----- RD’
OPCODE
FETCH
M2 ------- 2001H 2002H -------- 32H ----- RD’
MEMORY
READ
Draw the timing diagram of MVI A,32H
Memonics Address Machine code
Machine Stack Address Program Data Bus Interrnal Control
Cycle Pointer Bus Counter W Z Signal
(SP) (PC) Op-code Operand
Memonics Address Machine code
Machine Stack Address Program Data Bus Interrnal Control
Cycle Pointer Bus Counter W Z Signal
(SP) (PC) Op-code Operand