Microprocessor
Microprocessor
Intel 8085
Syllabus:
Main features of 8085. Block diagram. Components.
Pin-out diagram. Buses. Registers. ALU. Memory.
Stack memory. Timing and Control circuitry. Timing
states. Instruction cycle, Timing diagram of MOV
and MVI.
Evolution of Microprocessor
8085
3
Intel 8085A processor
• Introduced by Intel March 1976
• 8-bit microprocessor chip
• 40 Pin in DIP Package
• 5V power supply
• Binary compatible
• 3 MHz clock
• 6500 Transistors
• 64K Byte addressable memory
• Instruction set
• allows simple and low cost
microcomputer systems to be built
4
Block Diagram of Microcomputer system
8085A Microprocessor
Address
bus
6
8085A Pin Diagram
Clock
8085 A
8
Logic pin out: 8085A
1 2 40 20
SID 5 X1 X2 Vcc
Serial I/O Ports SOD 4
A15 26
3 37
RESET CLK
OUT OUT 10
The 8085A: Bus Structure
11
Bus system connection
12
Bus Organization
What is a Bus?
A bus is a shared set of pins, wires or signals, used
for communicating signals among devices, having
common functions as bus
What is system Bus?
A system bus is a bundle of wires grouped together
to serve a single purpose in microprocessor.
These are address bus, the data bus and control bus.
Bus: A shared group of wires used for communicating signals among devices
15
The Address and Data Bus: Interconnections between units
Important Facts
– A latch is used for processing before the function of the bits
changes.
– Address latch Enable ALE: used in order to separate the
address from the data,
– 16 address lines are capable of addressing a total of 216 =
65,536 (64k) memory locations.
– are tri-state lines
Bus: A shared group of wires used for communicating signals among devices
17
De-multiplexing Address- data bus (AD7-AD0): The ALE Signal
– 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.
18
Address Latch Enable (ALE)
∙ This signal is an output signal early in a machine cycle to advise the
external circuitry that the AD0 - AD7 lines contain the lower 8 bits of a
memory address.
∙ The falling edge of ALE is the point at which the signals on the AD lines, as
well as the S0, S1, and IO/M lines will be stable and may be taken by the
external circuitry.
19
The Latch in Detail
Enable
ALE is High the latch is transparent ALE
G
Output changes according to input data AD7 D Q A7
Output follows the input as long as G is
high
8085
A15-A8
ALE
Latch
AD7-AD0 A7- A0
D7- D0
S0 & S1 (pin 29 & 33) status signals similar to IO/M; can identify various operations
and
INTA (11)and HLDA ( 38) the interrupt and hold acknowledge signals go low when
µP acknowledges an interrupt or responds to a HOLD request.
8085A μP: functions of groups pin wise
Power Supply
VCC :- Vcc is to be connected to +5V power supply at pin 40
Vss :- Ground reference at pin 20
SERIAL INPUT DATA & SERIAL OUTPUT DATA (SID & SOD):
∙ These two pins 5 and 4 provide for a single serial input or output line to/from
μP They implement the serial transmission of data
∙ The lines are brought into the device as D7, and may be tested or set by the
Read Interrupt Mask (RIM) or Set Interrupt Mask (SIM) instructions.
∙ These two instructions also have control over the mask which controls the
RST 5.5, 6.5, and 7.5, and TRAP, interrupts.
∙ The SID and SOD lines are simple single bit I/O lines; any timing required to
provide external communication via them must be provided by the software
28
Memory
Memory and its organization has been done in detail in the last unit
29
Memory structure & its requirements
Data Lines
ROM
RAM
Input Buffer WR
Address Address CS
CS
Lines Lines
Data Lines
Date
Lines
• The process of interfacing the above two chips is the same with the μP
30
Interfacing Memory with μP
31
Generating Control Signals
32
Address decoding in µP
33
The Overall Picture
Putting all of the concepts learnt till now together, the figure explains
data flow from μP to memory
Chip Selection
A15- A10 Circuit
8085
CS
A15-A8
ALE
A9- A0 1K Byte
AD7-AD0 Latch Memory
A7- A0 Chip
WR RD IO/M D7- D0
RD WR
34
Input Output
I/O devices enable μP to interact with the world
– Device interface hardware connects actual
device to bus
– The CPU views the I/O device registers just
like memory that can be accessed over the
bus. However, I/O registers are connected to
external wires, device control logic, etc.
– Problems envisaged
• Reads may not return last value written
• Writes may have side effects
35
The 8085A μP: Internal Data Operations
36
The 8085A μP: CPU Internal Structure
37
8085A Functional Block Diagram
38
8085A Functional Block Diagram: Sections
Arithmetic and Logic section
– Instruction Decoder and Machine cycle Encoder
• accepts OPCODE from instruction register, decodes it and returns decoded
information to control logic.
• information includes what operation is to be executed, who is going to
execute it it, etc. It means it will understand the instruction in this block.
• decoded information is passed on to the timing and control unit that generates
control signals
– Address Buffer & Address/Data Buffer for transfer
– Incrementer / Decrementer Address Latch
• 8 bit contents of register or a memory location can be incremented or
decremented by 1
• 16-bit register is used to increment or decrement the content of program
counter and stack pointer register by 1
• Increment or decrement can be performed on any register or a memory
location
– Interrupt Control
– Serial I/O Control Group
– Timing And Control
39
8085A Functional Block Diagram: Sections
Register Section
• Temporary Register
– In 8085 available temporary register are W and Z registers; not available to the
programmer, but uses them internally to hold temporary data during execution
of some instructions. They are of 8 bits each
• General Purpose Register
– B,C,D,E,H & L are used as general purpose register of 8 bits each
– these registers can also be used to work in pairs to hold 16-bit data/ address,
such as B-C, D-E and H-L The H-L pair works as a memory pointer.
– A memory pointer holds the address of a particular memory location.
• Special Purpose Registers
– Accumulator 8 bits
– Status or Flag Register 5 bits
– Instruction Register 8 bits
– Program Counter 16 bits It also has
– Stack Pointer 16 bits Multiplexer for register select
Address Buffer & Address/Data Buffer
Incrementer/Decrementer Address Latch
40
8085A Functional Block Diagram: Sections
41
Control unit in simple words
• The circuitry that controls the flow of information
through the processor, and coordinates the
activities of the other units within it.
• it is the brain within the brain, as it controls what
happens inside the processor, which in turn
controls the rest of the PC.
• On a regular processor, the control unit performs
the tasks of fetching, decoding, managing
execution and then storing results.
42
Timing and control unit
43
The 8085: Simplified block diagram
44
Internal structure and basic operation of μP
Address bus
ALU Register
Section Section
Data bus
8085 has
six 8 bit general purpose programmable registers B, C, D, E, H, and L.
Accumulator and Flag register are part of ALU are also 8 bits, Program Counter
and Stack Pointer are 16 bit memory pointers which are specific purpose registers
48
Something about Register sets
• Registers are memory elements in the CPU of μP
• The number of registers are different for any particular CPU and the
more register a CPU has will result in easier programming tasks.
• Registers are normally measured by the number of bits they can hold,
for example, an 8 bit register stores 8 bit of data simultaneously.
Similarly, 32 bit register will have 32 bits of data
49
Registers: Details
Registers
– Six general purpose 8-bit registers: B, C, D, E, H, L
– They can also be combined as register pairs to perform 16-bit
operations: BC, DE, HL
– The H&L register pair may be used to store indirect addresses
– Registers are programmable (data load, move, etc).
Accumulator
– single 8-bit register that is part of the ALU
– specific purpose register
– used for arithmetic / logic operations
– the result is always stored in the accumulator
Example: accumulator use in summing a list of numbers.
– accumulator is initially set to zero, then each number in turn is added to the value in
the accumulator. The result of each addition is automatically reflected in the
Accumulator (A)
– Only when all numbers have been added is the result( held in the accumulator) written
to main memory or to another location, other registers, etc. 50
The Flags Register (5 bits)
Flag register is a group of flip flops used to give status of different
operations result.
• is connected to ALU.
• Once an operation is performed by ALU the result is transferred
on internal data bus and status of result will be stored in flip
flops.
• Indicate the result of condition tests
• are called Zero (Z), Carry (CY), Sign (S), Parity (P), and
Auxiliary Carry (AC) flags.
• Conditional operations (IF / THEN) are executed based on the
condition of these flag bits
• Have critical importance in the decision making process of the μP
• The most commonly used flags are Zero and Carry
51
The Flag register
Flags
S-sign flag
The sign flag is set (=1) if bit D7 of the accumulator is 1 after an arithmetic or
logic operation indicating the number is negative
Z-zero flag
Set (=1) if the result of the ALU operation is 0. Otherwise is reset (=0). This flag
is affected by operations on the accumulator as well as other registers. (DCR B).
AC-Auxiliary Carry
This flag is set (=1) when a carry is generated from bit D3 and passed to D4 .
This flag is used only internally for BCD operations.
P-Parity flag
After an ALU operation if the result has an even number of 1’s the p-flag is se
t(=1). Otherwise it is reset (=0). The flag is used to indicate even / odd parity.
CY-carry flag
After an ALU operation if the operation results in a carry the carry flag is set (=1),
indicating that answer in the accumulator is larger than 8 bits. Otherwise it is
reset (=0). The flag is also used to indicate borrow for subtraction
D7 D6 D5 D4 D3 D2 D1 D0
S Z X AC X P X CY
52
Flag Name Description
Z Zero flag Indicates that the result of a mathematical or logical operation was zero.
Bits not used in the Flag Register. There are only five flipflops in the
X No Flag flag register that are of active use. These are D7, D6, D4, D2 and D0
bits of FR
53
Program counter (PC)
Contains the memory address (16 bits) of the instruction
that will be executed in the next step. It is
• 16 bit register, used to store the next address of the
operation code to be fetched by the CPU.
• Not much use in programming, but as an indicator to
user only.
• Purpose of PC in a μP is to
– store address of next instruction to be executed.
– count the number of instructions.
– store base address of the stack.
– store address of tos (top of stack)
54
Stack pointer (SP)
Fetch
Execute
Decoding and Executing an Instruction
• Fetching Cycle
– The fetch cycle takes the instruction required from memory,
stores it in the instruction register, and
– increments the program counter by one so that it points to the
next instruction.
• Execute cycle
– Places the memory address of the instruction on the address bus
– Indicates the operation status on the status lines
– Sends the MEMR control signal to enable memory, fetches the
instruction byte and places it in the instruction decoder
– Executes the instruction.
57
Decoding and Executing an Instruction: Example
The Accumulator contains
data 82 H. The instruction
MOVC,A ( opcode 4F H) is
fetched from memory From Memory
location 2005 H.
The steps in decoding and 4F
Data
executing the instruction Bus
are Internal
Data Bus
1. The contents of data
Instruction
bus (4F) are placed in Register
the instruction register C 82H
82H 82H 4F B
and decoded
Temporary
2. The contents of Accumulator
Register Register B and C
accumulator (82 H) are Instruction
Decoder
transferred to the
temporary register in the
ALU Timing &
Control
3. The contents of
temporary register are 58
transferred to register C
Microprocessor clock
• the speed at which a microprocessor executes instructions is
called the clock rate, . Every computer contains an internal clock
that regulates the rate at which instructions are executed and
synchronizes all the various computer components.
• The CPU requires a fixed number of clock cycles to execute each
instruction. The faster the clock, the more instructions the CPU
can execute per second. Clock speeds are expressed in
megahertz (MHz) or gigahertz ((GHz).
• Some microprocessors are superscalar, which means that they
can execute more than one instruction per clock cycle.
• Like CPUs, expansion buses also have clock speeds. Ideally, the
CPU clock speed and the bus clock speed should be the same so
that neither component slows down the other. In practice, the bus
clock speed is often slower than the CPU clock speed, which
creates a bottleneck. This is why new local buses, such as AGP,
are being developed.
59
8085 μP: System Timing
The time required by the 8085 to fetch and execute
one machine language instruction is defined as an
Instruction Cycle.
The instructions may be of different complexities,
with the result that the more complicated
instructions take longer to execute.
The 8085’s method of instruction execution inside
the μP is more organized, however, and so the time
required to execute any instruction is more
predictable and more regular.
60
8085 μP: Cycles and States
62
8085 μP: The Processor cycle
● Each instruction is divided into one to five Machine Cycles.
● Each machine cycle is essentially the result of the need, by the
instruction being executed, to access the RAM.
● The shortest instruction would require just one machine cycle, in
which the instruction itself is obtained from RAM.
● The longest, of five machine cycles, would consist of five RAM
accesses, the first to obtain the instruction byte itself, and the
remaining four to be divided into fetching and saving other
bytes. For example, cycles numbers 2 & 3 may be needed to
fetch two more bytes of an address, while numbers 4 & 5 may
be needed to save a 2-byte address somewhere else in RAM.
● The type of machine cycle being executed is specified by the
status lines IO/M, S0, and S1, and the control lines RD, WR,
and INTA.
These six lines can define seven different machine cycle types 63
Machine Cycles :Types
1. OP CODE FETCH
2. MEMORY READ
3. MEMORY WRITE
4. I/O READ
5. I/O WRITE
6. INTERRUPT ACKNOWLEDGE
7. BUS IDLE
64
Control and Status signals
ALE, RD, WR, IO/M, S0 and S1
Machine cycle Status Control
IO/M S1 S0 Signals
Op-code Fetch 0 1 1 RD = 0
Memory Read 0 1 0 RD = 0
Memory Write 0 0 1 WR = 0
IO Read 1 1 0 RD = 0
IO Write 1 0 1 WR = 0
Interrupt 1 1 1 INTA = 0
Acknowledge
Halt Z 0 0 RD, WR = Z
Hold Z X X and INTA = 1
Reset Z X X
65
Generating Control Signals
67
Example: Instruction Fetch Operation
The instruction code 4FH ( MOVC,A) is stored in memory address 2005 H. Illustrate the
Data flow and list the sequence of events when the instruction code is fetched by the μP
69
Op-code Fetch Machine Cycle
The first step of executing any instruction is the
Op-code/Instruction fetch cycle.
– In this cycle, the μP brings in the instruction’s Op-code
from memory.
• To differentiate this machine cycle from the very similar memory
read cycle, the control & status signals are set as follows:
* IO/M=0, S0 and S1 are both 1.
– Opcode fetch machine cycle has four T-states.
• The 8085 uses the first 3 T-states to fetch the op-code.
• T4 (fourth T state) is used to decode and execute it i.e. transfer
accumulator contents to register C.
– It is also possible for an instruction to have 6 T-states in
an op-code fetch machine cycle.
70
Op-code Fetch: Timing Diagram
T1 T2 T3
CLK
Timing transfer of byte
from memory to μP for a
A15 –A8 Higher order MOVC,A instruction code
20H
address
IO/M M
RD
71
Op-code Fetch: Timing Diagram MOVC,A
Explanation
1. The Program Counter places ….
At T1 the higher order memory address20 H is placed on the
address lines A15 - A8 abd low order 05H on to the bus AD7 –
AD0 and ALE goes high. The status signal IO/M goes low
indicating it is a memory related operation. S0 and S1 are both 1
and is implied in the figure as it is an opcode fetch cycle
2. The control unit sends … The control signal RD is sent during
clock period 2 (T2). The RD signal is active during two clock
periods
3. The instruction 4F stored …When memory is enabled the
instruction bye 4F is placed on the bus AD7-AD0 and transferred
to the μP. The RD signal causes 4F to be placed on data bus
shown by arrow and when RD goes high it causes the bus to go to
the high impedance state ( tri state)
72
Execution of the instruction: MOVC,A
The μP does the following sequence
1. places the contents of the PC ( 2005H) on the address bus, 20 on
A15-A8 and 05 onto AD7-AD0
2. Causes the ALE to go high; demultiplexes the address/data bus
3. Identifies the nature of the machine cycle…opcode fetch…by using
the status signals IO/M=0, S0 and S1 are both 1.
4. During T2, control signal RD is sent to enable the memory and
increment the PC by 1 to next location 2006H. The contents of
2005H is placed on data bus (4F)
5. Reads the byte 4F and places it in instruction register (T3)
6. Decodes the instruction places the accumulator content (82H) in
temporary register and then transfers to register C (T4)
Memory Hex
Location code
(H) (H)
2005 4F
73
MOV C,A: Timing Diagram
T1 T2 T3 T4
CLK
RD
74
Memory Read Machine Cycle
75
Example: Memory Read Operation
76
The Memory Read Machine Cycle
To understand the memory read machine cycle, let’s study the
execution of the following instruction:
– MVI A, 32 H
( Move immediately into the accumulator data 32H)
In memory, this instruction looks like:
– The first byte 3EH represents the opcode for loading a byte
into the accumulator (MVI A),
– the second byte is the data to be loaded (32H).
The 8085 needs to read these two bytes from memory before it
can execute the instruction. Therefore, it will need at least two
machine cycles.
– The first machine cycle is the opcode fetch as discussed
Memory Hex
Location code – The second machine cycle is the Memory Read Cycle.
(H) (H) – Figure 4.2 page 99 Goankar.
2000 3E
2001 32 77
MVI A 32H: Timing Diagram
78
Reference