Microprocessor8085pptcomplete 170518063501
Microprocessor8085pptcomplete 170518063501
Introduction to Microprocessor
1
Introduction
Computer: A computer is a programmable machine that receives input, stores and
manipulates data/information, and provides output in a useful format.
Basic computer system consist of a CPU, memory and I/O unit.
Address bus
I/O I/O
ROM RAM interface devices
CPU
2
Basic Concepts of Microprocessors
Microcomputer:- It is a programmable machine. The two principal
characteristics of a computer are:
Responds to a specific set of instructions in a well-defined manner.
It can execute a prerecorded list of instructions (a program)
Its main components are
CPU
Input & Output devices
Memory
Microcomputer
Microprocessor Microcontroller 4
Definition of the Microprocessor
5
Microprocessor Based System with bus
Architecture
ALU:- Arithmetic and logical operations like add, subtraction, AND & OR.
Control Unit: Provides necessary timing & control signal. It controls the flow of data
between microprocessor and peripherals.
Read Only Memory (ROM): used to store programs that do not need
alterations.
Random Access Memory (RAM) (R/WM): used to store programs that
can read and altered like programs and data.
7
How does a Microprocessor works
8
Machine Language
for eg:
0011 1100 – is an instruction that increments the number in accumulator by 1
1000 0000– is an instruction that add the number in register B to the accumulator
content , and keep the result in A.
9
8085 Assembly Language
Even program is written in Hexa decimal .. It is difficult to understand.
For E.g.: binary code 0011 1100 (3C H in hexadecimal) is represented by INR
A
INR A –INR stands for Increment, A is accumulator… this symbol suggest the
operation of incrementing the accumulator by 1
***So MP has 246 such bit pattern amounting to 74 different instruction for
performing various operations
10
Chapter 2
Microprocessor Architecture & Pin
diagram
11
Features of Microprocessor- 8085
8085 is developed by INTEL
It generates 8 bit I/O addresses, hence it can access 2^8 = 256 I/O ports.
It provides DMA.
12
Internal Architecture (functional block diagram)of 8085
13
8085 Architecture…….cont…
8085 architecture consists of following blocks:
1. Register Array
14
8085 Architecture …… cont….
1. Registers Array : 14 register out of which 12 are 8 bit capacity and 2 of 16 bit. Classify into 4 types
(a) General purpose register: (user accessible)
B,C,D,E,H,L are 8 bit register.(can be used singly)
Can also be used for 16-bit register pairs- BC, DE & HL.
Used to store the intermediate data and result
H & L can be used as a data pointer(holds memory address)
15
8085 Architecture …… cont….
(Flag Register)
16
Flag Register…… cont….
Flag Significance
C or CY (Carry) CY is set when an arithmetic operation generates a carry
out, otherwise it is 0 (reset)
17
8085 Architecture …… cont….
18
8085 Architecture …… cont….
(d) Pointer Register or special purpose [SP, PC]
(d.1) Stack Pointer(SP)
16 bit address which holds the address of the data present at the top of the stack memory
It is a reserved area of the memory in the RAM to store and retrieve the temporary
information.
Also hold the content of PC when subroutines are used.
When there is a subroutine call or on an interrupt. ie. pushing the return address on a
jump, and retrieving it after the operation is complete to come back to its original location.
19
8085 Architecture …… cont….
(a) ALU
Performs arithmetic and logical operations
Stores result of arithmetic and logical operations in accumulator
(b) Accumulator
General purpose register
Stores one of the operand before any arithmetic and logical
operations and result of operation is again stored back in
Accumulator
Store 8 bit data during I/O transfer
21
8085 Architecture …… cont….
(2) ALU & Logical Group…………………..cont…………………
22
8085 Architecture …… cont….
23
8085 Architecture …… cont….
24
8085 Pin Diagram
bits.
31
Power supply and Clock Signal
Vcc (Pin 40) : single +5 volt power supply
Vss (Pin 20) : Ground
There are 3 important pins in this group.
Execute cycle
The actual actions which occur during the execute cycle of an
instruction.
Depend on both the instruction itself and the addressing mode
specified to be used to access the data that may be required.
38
Fetching an instruction
Step 1: Instruction pointer (program counter) hold the
address of the next instruction to be fetch.
Fetching an instruction….Cont….
Step 2
Fetching an instruction….Cont….
Step 3
Fetching an instruction….Cont….
Step 4
Fetching an instruction….Cont….
Step 5
Fetching an instruction….Cont….
Step 6
Data flow from memory to MPU
Steps and data flow, when the
instruction code 01001111 (4FH
– MOV C, A) stored in the
location 2005H, is being fetch.
Step 1: MPU places the 16 bit memory address from PC on the address bus
Step 2: Control unit send the signal RD to enable memory chip
Step 3: The byte from the memory location is placed on the data bus.
Step 4: The byte is placed on the instruction decoder of the MPU and task is carried
out according to the instruction.
Timing: Transfer of byte from memory to MPU
How a data byte is transfer from
memory to the MPU.
It shows the five different group
of signals with clock
called as bus.
periods. However, the low order bits (05H) remain for only one clock
period and they would be lost if they are not saved externally. 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. ALE signal is
connected to the enable (G) pin of the latch.
De-multiplexing AD7-AD0
Given that ALE operates
as a pulse during T1, ALE is
high the latch is
transparent; output
changes according to input.
So during T1 output of
latch is 05H.
Step 1: Places the content of data bus (4FH) in the IR and decode the instruction.
Step 2: Transfer the content of the accumulator(82H) to the temporary register in the
ALU.
Step 3: Transfer the content of temporary register to C register.
Chapter 3
Instruction Set and addressing
modes
52
8085 Instruction
Since the 8085 is an 8-bit device it can have up to 28 (256)
instructions.
However, the 8085 only uses 246 combinations that represent a total of 74
instructions.
Most of the instructions have more than one format.
Operand - The second part is the data to be operated on. Data can be
given in various form.
It can specify in various ways: may include 8 bit/16 bit data, an internal register,
memory location or 8 bit /16 bit address.
Opcode Operand
Instruction word Size
An instruction is assembled in binary form(0,1) known as machine code or opcode.
Due to different ways of specifying data or operand the machine code are not same for
all the instruction
The size of an instruction signifies how much memory space is required to load an
instruction in the memory.8085 instructions are of following sizes:
One-byte or one word Instructions: opcode and operand in 8 bits only
i.e. one byte. Operand(s) are internal register and are coded into the instruction.
e.g. MOV, ADD, ANA, SUB, ORA etc.
MOV A,B Move the content of B in A
01 111 000 = 78H 01 for MOV operation, 111 binary code for
register A and last 000 binary code for register
B
Register Code
B 000 Register Code
pair
C 001
D 010 BC 00
E 011 DE 01
H 100 HL 10
L 101 A, F, SP 11
M 110
A 111
Addressing Modes
The various formats for specifying operands/data are called the ADDRESSING MODES. 8085
instructions can be classified in following addressing modes
Rotate- Each bit in the accumulator can be shifted either left or right to the next
position.
Compare- Any 8-bit number, or the contents of a register, or a memory location can be
compared for equality, greater than, or less than, with the contents of the accumulator.
67
Write the Assemble Program..cont..
Start
Add Numbers
Block 2: ADD B Add two bytes and save sum in A
69
Storing in Memory and converting from
Hex code to binary Code
To store the program in R/W memory, assume the
memory ranges from 2000 H to 20FFH. Now to enter
the Program
1. Reset the system by pushing the RESET key.
2. Enter the first memory address using the HEX keys, where the program
should be written.(2000H)
3. Enter each machine code by pushing Hex keys. For Ex, to enter the first
machine code, push 3E and store keys. Store key, store the program in
memory location 2000H and upgrade the memory address t0 2001.
4. Repeat step 3 until the last machine code 76H.
Check the keys and convert
5. Reset the system. Hex code into binary code
Flowchart
8085 Manual Monitor Binary To Memory
Hex Code Program
Mnemonics lookup Code for Storage
70
Program Stored in memory as
Mnemonics Hex Code Memory Content Memory Address
Eight Machine code, require eight memory location. MPU can only understand
binary code; everything else(Mnemonics, Hex code, comments) for the convenience
of human being.
71
Executing the Program
To execute the program, we need to tell the MPU
where the program begins by entering the memory
address 2000H.
Push the execute Key, so MPU loads 2000H in PC.
PC is transferred from the monitor program to our program.
MPU begin to read the one machine cycle at a time, when it
fetches the complete instruction, it execute that instruction.
For Eg. When it fetches the machine code stored in 2000 and
2001H and execute the instruction MVI A, 32H , thus load 32H in
register A.
Continue to execute the instruction until it fetches the HLT
instruction.
72
How Does a MPU differentiate
between data and instruction code
MPU is a sequential machine. When the system is turns on, it
begins the execution of the code in memory. Now the question
is that how does the MPU differentiate between code and
data when both are binary numbers.
MPU interprets the first byte , it fetches as an opcode.
When the MPU is reset its PC is reset to 0000H. fetches the first
code from the location 0000H but in our example the memory
location is 2000H.
From the previous program it fetches the 3EH .when it decode that
code it know that it is a two byte instruction. so it assume that
second code 32H is data.
But if we forget to enter 32H and enter the next code 06H, instead
it , so MPU load 06H in the accumulator and interpret the next
code 48H as an opcode. And continue the execution in sequence.
We may get a totally unexpected result.
73
Chapter 4
Timing Diagram
74
Introduction
It represents the execution time taken by each instruction in a graphical format.
It is the graphical representation of initiation of read/write and transfer of data
operations under the control of 3-status signals IO / M , S1, and S0. All the operation
is performed with respect to CLK signal.
The combination of these 3-status signals identify read or write operation and
remain valid for the duration of the cycle.
T-State
1 Clock cycle
Ideal Practical
Single Signal - Single signal status is represented by a line. It may have status
either logic 0 or logic 1 or tri-state
Group of signals - Group of signals is also called a bus. Eg:
Address bus, data bus
In the normal process of operation, the microprocessor fetches (receives or reads) and
executes one instruction at a time in the sequence until it executes the halt (HLT)
instruction.
Thus, an instruction cycle is defined as the time required to fetch and execute an
instruction.
Instruction Cycle (IC) = Fetch cycle (FC) + Execute Cycle (EC)
Processor Cycle
Instruction cycle
read” cycle, the control & status signals are set as follows:
IO/M=0(memory operation),
s1 and s0 are both 1. (opcode fetch)
This machine cycle has four T-states.
The 8085 uses the first 3 T-states to fetch the opcode.
Step 3 : During T3, Memory is enabled then instruction byte 4FH is placed on the data
bus and transferred to MPU. When RD goes high it causes the bus to go into high
impedance state.
Step 4: During T4, the machine code or byte is decoded by the instruction decoder and
content of A is copied into register.
Data Flow
form
Memory to
MP
85
Memory Read or Operand Fetch Machine Cycle
This cycle is executed by the processor to read a data byte from
memory or to fetch operand in a multi byte instruction. For ex. 2 or 3
byte instruction because in 1 byte instruction the machine code is an
opcode; so operation is always an opcode fetch
The instructions which have more than one byte word size will use
the machine cycle after the opcode fetch machine cycle.
The memory read machine cycle is exactly the same as the
opcode fetch except:
IO/M= 0(memory operation),
s1 = 1 and s0 = 0. (memory read)
WR = 1 & RD = 0
It only has 3 T-states
89
Data Flow
form
Memory to
MP
90
Memory Write Machine Cycle
The memory write machine cycle is executed by the processor
to write a data byte in a memory location.
The memory write machine cycle is exactly the same as the
memory read except:
IO/M= 0(memory operation),
s1 = 0 and s0 = 1. (memory read
WR = 0 & RD = 1
It only has 3 T-states
93
Input/ Output Read Machine Cycle
Microprocessor executes this cycle to read content of I/O port
or to read 8 bit data present on an input ports through data bus.
The I/O read machine cycle is exactly the same as the memory
read except:
IO/M= 1(I/O operation),
s0 = 0 and s1 = 1. ( read)
WR = 1 & RD = 0
It only has 3 T-states
This instruction reads the data from an input device and places
the data byte in the accumulator.
It accept the data from input device by using I/O read
signal(IOR).
Timing Diagram of I/O read Machine Cycle
Data Flow
form input
device to MP
96
Input/output write Machine Cycle
Microprocessor executes this cycle to write a data into an I/O
port or to write 8 bit data present on an output ports.
The I/O write machine cycle is exactly the same as the memory
write except:
IO/M= 1(I/O operation),
s1 = 1 and s0 = 0. ( write)
WR = 0 & RD = 1
It only has 3 T-states
This instruction places the content of the accumulator on the
data bus.
It transmit the data to output device by using I/O write
signal(IOW).
Timing Diagram of I/O write Machine Cycle
Data Flow
form MPU to
output device
99
Interrupt Acknowledge Cycle
Interrupt is hardware call of subroutine.
MPU executes this cycle to acknowledge INTR request
MPU determines the starting address of the interrupt service
routine by using interrupt information.
RSTn and CALL address is used as interrupt information.
Length of this cycle is 6T or 3T states.
So two interrupt acknowledge cycle
(A) Interrupt acknowledge of RSTn
(B) Interrupt acknowledge of CALL address
Interrupt Acknowledge of RSTn
The RSTn instruction is one byte.
It is similar to opcode fetch cycle with
INTA signal is activated instead of RD signal.
IO/M= 1(I/O operation),
s0 = 1 and s1 = 1.
It only has 6 T-states
Timing Diagram of Restart instruction
Interrupt Acknowledge for CALL
The CALL instruction is Three byte. So MPU executes 3
interrupt acknowledge cycle.
The length of the first cycle is 6 T states while second and third
cycle is 3T states.
PC is not incremented. IR is selected as destination register
during 1st interrupt acknowledge cycle and in 2nd and 3rd cycle Z
and W are selected as destination register
It is similar to opcode fetch cycle with
IO/M= 1(I/O operation),
s0 = 1 and s1 = 1.
Timing Diagram of CALL instruction
Bus Idle Cycle
The MPU executes this cycle for internal operation. Few
situations where the machine cycle are neither read nor write.