Introduction_The8085 (1)
Introduction_The8085 (1)
Programmable:
The microprocessor can perform different sets of
operations on the data it receives depending on the
sequence of instructions supplied in the given program.
By changing the program, the microprocessor
manipulates the data in different ways.
Clock Driven:
The microprocessor performs operations at specific instant of
time in a specific sequence.
Register Based:
Register is a device that hold the data.
Instructions:
Each microprocessor is designed to execute a specific group of
operations. This group of operations is called an instruction
set. This instruction set defines what microprocessor can and
cannot do.
Storage Device (Memory):
Memory is the location where information is kept while not in use.
Memory is a collection of storage devices.
Usually, each storage device holds one bit. Also, in most kinds of
memory, these storage devices are grouped into groups of 8. These
8 storage locations can only be accessed together. So, one can only
read or write in terms of bytes to and form memory.
Memory is usually measured by the number of bytes it can hold.
It is measured in Kilos, Megas and lately Gigas. A Kilo in computer
language is 210 =1024. So, a KB (KiloByte) is 1024 bytes. Mega is
1024 Kilos and Giga is 1024 Mega.
Storage Device (Memory):
When a program is entered into a computer, it is stored in
memory. Then as the microprocessor starts to execute the
instructions, it brings the instructions from memory one at a
time.
These are devices that bring data into the system from the
outside world.
Some of newer ones will have complex operations such as square root.
Output:
The results must be presented on an output device.
This can be the monitor, a paper from the printer, a simple LED
or many other forms.
Internally, the microprocessor is made up of 3 main
units.
The Arithmetic/Logic Unit (ALU)
The Control Unit.
An array of registers for holding data while it is being
manipulated.
I/O
Input / Output
Register
ALU
Array
ROM RAM
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.
Usually, There is a memory “sub-system” in a μP-based system
which includes:
The registers inside the microprocessor
Read Only Memory (ROM)
used to store data (programs) that does not change.
Random Access Memory (RAM) (also known as Read/Write Memory).
used to store information supplied by the user. Such as programs and data.
To execute a program:
the user enters its instructions in binary format into the
memory.
The microprocessor then reads these instructions and
whatever data is needed from memory, executes the
instructions and places the results either in memory or
produces it on an output device.
Input and output devices are the system’s means of
communicating with the outside world. These devices are
collectively known as peripherals.
Input devices transfer binary information from the outside world to the
microprocessor.
Examples of input devices are: keyboard, mouse, bar code reader, scanner and the
like.
Reg.
ALU
Array Memory Input Output
Data Bus
Control
Unit
Control Bus
The user has given the following instruction:
ADD R1, R2, R3
Which translates to:
add Register 1 to Register 2 and place the result in Register 3.
The control unit receives the bit pattern for this instruction
(0100
010001
0110
1011
11) from memory.
It decodes the bit pattern and determines that this is an Add operation
(0100
0100).
It also determines that the inputs to the addition come from Register R1
(01
01) and Register R2 (10
10).
It finally determines that the results go into register R3 (11
11).
EN EN EN EN
R1 R2 R3 R4
S0 S0
4 X 1 MUX 4 X 1 MUX
S1 S1
Adder
A CCUMULATOR S Z AC
F LAGS P CY
B C
D E
H L
S TACK P OINTER
P ROGRAM C OUNTER
A DDRESS 16 8 D ATA
General Purpose Registers:
B, C, D, E, H & L
The Accumulator
Special Register in a ALU and used as one of the operand in Arithmetic &
Logical operations.
The flag
It is a flip-flop. The status of which reflects the result.
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.
The 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
retreived soon.
The stack is usually accessed in a Last In First Out (LIFO)
fashion.
External devices can initiate (start) one of the 4
following operations:
Reset
All operations are stopped and the program counter is reset to 0000.
Interrupt
The microprocessor’s operations are interrupted and the
microprocessor executes what is called a “service routine”.
This routine “handles” the interrupt, (perform the necessary
operations). Then the microprocessor returns to its previous
operations and continues.
Ready
The 8085 has a pin called RDY. This pin is used by external devices to
stop the 8085 until they catch up.
As long as the RDY pin is low, the 8085 will be in a wait state.
Hold
The 8085 has a pin called HOLD. This pin is used by external devices to
gain control of the busses.
When the HOLD signal is activated by an external device, the 8085
stops executing instructions and stops using the busses.
This would allow external devices to control the information on the
busses. Example DMA.
The 8085 is an 8-bit general purpose microprocessor
that can address 64K Byte of memory.
It has 40 pins and uses +5V for power.
The pins on the chip can be grouped into 6 groups:
Address Bus.
Data Bus.
Control and Status Signals.
Power supply and frequency.
Externally Initiated Signals.
Serial I/O ports.
Vcc GND
X1
X2
H IGH -O RDER
A DDRESS B US
SOD
SID
8
TRAP 0 M ULTIPLEXED
RST7.5
RST6.5
RST5.5
8 A DD /D ATA B US
INTR
READY
5
HOLD ALE
RESETIN’ S0
S1
INTA’ IO/M’
HLDA RD’
WR’
CLK (OUT): An output clock pin to drive the clock of the rest of
the system.
SID SOD
COUT RDY RD WR ALE S0 S1 IO/M HLD HLDA RSTI RSTO A15-A8 AD7-AD0
In addition to the arithmetic & logic circuits, the ALU
includes the accumulator, which is part of every
arithmetic & logic operation.
MOV A , B
Operation: MOV
Operand: A , B
Binary Code:
0011 1000 78 Single byte.
Operation: Load an 8-bit number into the accumulator.
MVI A , 32
Operation: MVI A
Operand: The number 32
Binary Code:
0011 1110 3E 1st byte.
0011 0010 32 2nd byte.
Operation: Load Accumulator with the content of
memory location 4000.
LDA 4000
Opcode: LDA
Operand: 4000
Binary code:
0011 1010 3A 1st byte.
0000 0000 00 2nd byte
0100 0000 40 3rd byte
Operation: Load Accumulator with the content of
memory location pointed by HL register pair.
MOV A , M
Opcode: MOV
Operand: A , M
Binary code:
0111 1110 7E Single byte.
To understand how the microprocessor operates and
uses different signals, we should study the process of
communication between the microprocessor and
memory during a memory read or write operation.
Lets look at timing and the data flow of an instruction
fetch operation.
Lets assume that we are trying to fetch the instruction at memory
location 1000. That means that the program counter is now set to
that value.
The following is the sequence of operations:
The program counter places the address value on the address bus and
the controller issues a RD signal.
The memory’s address decoder gets the value and determines which
memory location is being accessed.
The value in the memory location is placed on the data bus.
The value on the data bus is read into the instruction decoder inside
the microprocessor.
After decoding the instruction, the control unit issues the proper
control signals to perform the operation.
Data Bus
Internal Bus
B C
Instr. D E
ALU H L Memory
Dec. SP
PC
RD
– At T1, high order 8 address bits are placed on the address lines A8 – A15
and low order address bits are placed on AD7–AD0. The ALE signal goes
high to indicate that AD7–AD0 are carrying an address. At exactly the
same time, the IO/M signal goes low to indicate a memory operation.
– At the beginning of the T2 cycle, the low order 8 address bits are
removed from AD7–AD0 and the controller sends the Read (RD) signal to
the memory. The signal remains low (active) for two clock periods to
allow for slow devices. During T2 , memory places the data(instruction)
from the memory location on the lines AD7– AD0.
– During T3 the RD signal is Disabled (goes high). This turns off the output
Tri-state buffers in the memory. That makes the AD7– AD0 lines go to
high impedence mode.
From the above description, it becomes obvious that the AD7– AD0
lines are serving 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.
8085
A15-A8
ALE
AD7-AD0 Latch
A7-A0
D7 – D0
AD6 D6 Q6 A6
EN
AD0 D0 Q0 A0
EN
LE OE
ALE
The 8085 generates a single RD signal. However, the signal needs
to be used with both memory and I/O. So, it must be combined
with the IO/M signal to generate different control signals for the
memory and I/O.
Keeping in mind the operation of the IO/M signal we can use the following
ckt to generate the right set of signals:
CLK
ALE
RD
IO/M,
S1,S0
WR
From the above discussion, we can define terms that will
become handy later on:
T-State: One subdivision of an operation. A T-state lasts for one clock
period.
An instruction’s execution length is usually measured in a number of T-states.
Machine Cycle: The time required to complete one operation of accessing
memory, I/O, or acknowledging an external request.
This cycle may consist of 3 to 6 T-states.
Instruction Cycle: The time required to complete the execution of an
instruction.
In the 8085, an instruction cycle may consist of 1 to 6 machine cycles.
The 8085 executes several types of instructions with
each requiring a different number of operations of
different types. However, the operations can be grouped
into a small set.
The three main types are:
Memory Read and Write.
I/O Read and Write.
Request Acknowledge.
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 op-code fetch discussed earlier.
The second machine cycle is the Memory Read Cycle.
STA 5065
5065H
H 2010h 32h
2011h 65h
2012h 50h
Opcode fetch to fetch the opcode (32H) from location 2010H, decode
it and determine that 2 more bytes are needed (4 T-states).
Memory read to read the low order byte of the address (65H) (3 T-
states).
Memory read to read the high order byte of the address (50H) (3 T-
states).
A memory write to write the contents of the accumulator into the
memory location. (3 T-States).
Opcode Fetch Machine Cycle Memory Read Memory Read Memory Write
In a memory write operation:
The 8085 places the address (2065H) on the address bus
Identifies the operation as a memory write (IO/M=0, s1=0,
s0=1).
Places the contents of the accumulator on the data bus and
asserts the signal WR.
During the last T-state, the contents of the data bus are saved
into the memory location.