Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
23 views

Introduction To Microprocessor

Uploaded by

soumya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Introduction To Microprocessor

Uploaded by

soumya
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

Microprocessor and micro controller

• Microprocessor, is a miniature electronic device


that contains the arithmetic, logic, and control
circuitry necessary to perform the functions of a
digital computer’s central processing unit.
• It communicates with the other devices connected
with it. It is a single Integrated Circuit in which
several functions are combined.
• This kind of integrated circuit can interpret and
execute program instructions as well as handle
arithmetic operations.
• Microcontroller: A microcontroller is a small and
low-cost microcomputer, which is designed to
perform the specific tasks of embedded systems
like displaying microwave’s information, receiving
remote signals, etc.
• Microcontrollers are found in vehicles, robots,
office machines, medical devices, mobile radio
transceivers, vending machines and home
appliances etc.
• Microcontroller consists of the processor, the
memory (RAM, ROM, EPROM), Serial ports,
peripherals (timers, counters), etc
Introduction to Microprocessors
Bit: A bit is a single binary digit. (0 or 1)
Word: A word refers to the basic data size or bit
size that can be processed by the arithmetic and
logic unit of the processor. A 8-bit binary number
is called a word in a 8-bit processor.
Memory Word: The number of bits that can be
stored in a register or memory element is called a
memory word.
Register: General purpose registers temporary
store either data or memory location address.
3
Bus: A bus is a group of wires (lines) that carry similar
information. A bus is a high-speed internal connection.
Buses are used to send control signals and data between
the processor and other components.
• System Bus: The system bus is a group of wires used for
communication between the microprocessor and
peripherals.
• Address Bus: It carries the address, which is a unique
binary pattern used to identify a memory location or an
I/O port.(Address bus is unidirectional, i.e., numbers
only sent from microprocessor to memory.)
• Data Bus: The data bus is used to transfer data
between memory and processor or between I/O device
and processor.(this is bidirectional) 4
• Control Bus: The control bus carry control
signals, which consists of signals for selection
of memory or I/O device from the given
address, direction of data transfer etc
Operations of Microprocessor:
• Memory Read: Reads data (or instruction)
from memory.
• Memory Write: Writes data (or instruction)
into memory.
• I/O Read: Accepts data from input device.
• I/O Write: Sends data to output device.
5
8085 Microprocessor
• It is a programmable electronics chip( Integrated
Circuit (IC) ).
• A single IC has computing and decision making
capabilities similar to central processing unit of
a computer.
• It is used in almost all types of electronics
devices like mobile phones, printers, washing
machines, etc. and also used in advanced
applications like radars, satellites and flights.
6
Features of 8085
• Developed by intel in 1976
• Single chip with 40-pin IC, uses +5 V for power
• It has 8 bit data bus and 16 bit address bus(hence
it can access (216) 64 Kbytes of memory)
• It has 8 bit ALU that can perform 8 bit operations.
• It operates at a maximum frequency of 3 MHz.
• Six 8-bit registers arranged in pairs: BC, DE, HL
• Provides 74 instructions with five addressing
modes.
7
Registers
• 8085 has six general purpose registers to store 8 bit
data, 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.
• Accumulator: 8 bit register ,is a part of Arithmetic
Logic Unit (ALU).
• Used to store 8 bit data and to perform arithmetic
and logical operations. The result of an operation
is stored in the accumulator.
• Flag Register: The ALU includes five flip-flops. They are
called Zero (Z), Carry (CY), Sign (S), Parity (P) and
Auxiliary Carry (AC) flags. The microprocessor uses these
flags to test data conditions. The conditions (set or
reset) of the flags are tested through the software
instructions. 8
The 5 flag registers are:
• Sign Flag: It helps the programmer to know
whether the number stored in the accumulator
is positive or negative. If the sign flag is set, it
means that number stored in the accumulator
is negative, and if reset, then the number is
positive.
• Zero Flag:: It is set, when the operation
performed in the ALU results in zero(all 8 bits
are zero), otherwise it is reset.
• Auxiliary Carry Flag: In an arithmetic
operation, when a carry flag is generated by the
third bit and passed on to the fourth bit, then
Auxiliary Carry flag is set. If not flag is reset.
• Parity Flag:. If the accumulator holds
even number of 1’s, then this flag is set and
it is said to even parity. On the other hand
if the number of 1’s is odd, then it is reset
and it is said to be odd parity.
• Carry Flag: If the arithmetic operation
results in a carry(if result is more than 8
bit), then Carry Flag is set; otherwise it is
reset.
• Program Counter (PC): This 16 bit register deals
with sequencing the execution of instruction. 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.
• Stack Pointer (SP): The stack pointer is also a 16 bit
register used as a memory pointer. It points to a
memory location in read-write memory, called the
stack(The stack is a LIFO (last in, first out) data
structure implemented in the RAM area and is used to
store addresses and data when the microprocessor
branches to a subroutine.)
8085 pin diagram
8085 Pin Configuration
The signals of this 40 pin IC is grouped into 7
categories, which are given below:
• Power supply and clock signals
• Data bus
• Address bus
• Serial I/O ports
• Control signals
• status signals
• Interrupts and externally generated signals
1.Power supply and clock signals:
• VCC (40) –denotes VCC, and an external power supply of
+ 5 V is provided at this pin.
• VSS (20)– This pin shows the grounded connection of
the microprocessor.
• X1 and X2 (1,2) – These 2 pins are connected with a
crystal or LC network to maintain the internal frequency
of the clock generator.
• CLK (OUT) (37)–acts as the system clock that keeps the
record of time duration required by each operation to get
completed.
2.Address Bus (12-19, 21-28)(16 pins)
• The address bus has 16 lines.
• 8 are multiplexed with the data bus (AD0-AD7) and the
remaining 8 (A8-A15) from pin number 21 to 28
• These are used to carry the address of data and
instruction from the processor to the memory location
and is unidirectional in nature.
3.Data Bus with multiplexed address bus (12-19)–(8
pins).
• 8-bit data bus lines are multiplexed with the 8-bit
address bus(AD0-AD7).
• it carries the least significant 8-bit address and data bus.
4. Control signals
These signals are used to identify the nature of operation.
There are 3 control signal and 3 status signals.
• Three control signals are RD, WR & ALE.
• RD (32)− 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.
• WR (31)− This signal indicates that the data on the
data bus is to be written into a selected memory or IO
location.
• ALE(address latch enable) (30)− 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.
5.Status signals are IO/M, S0 & S1.
• IO/M (34)
• 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(29,33): These signals are used to identify
the type of current operation.
6. 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) (4)− Once the data is
processed in the microprocessor then this pin
represents bit by bit results at the output devices.
• SID (Serial input data line) (5) − With this pin, data
is serially fed to the processor directly through the
input devices.
7. Interrupts
• Interrupts are the signals generated by external devices to request the
microprocessor to perform a task.
• The 8085 has five interrupt signals that can be used to interrupt a
program execution.
• (i) TRAP (6)

(ii)RST 7.5 (7)


(iii) RST 6.5 (8)
(iv) RST 5.5 (9)
(v) INTR (10)
• The microprocessor acknowledges Interrupt Request by 𝐼𝑁𝑇𝐴 signal.
• INTA (11) − It is an interrupt acknowledgment signal.
Externally initiated signals: Reset and Hold
• RESET IN (36)− This signal is used to reset the microprocessor by
setting the program counter to zero.
• RESET OUT(3) − This signal is used to reset all the connected
devices when the microprocessor is reset.
• READY(35) − 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(39) − This pin generates a signal to notify the processor
that more than one request is present to access the data and address
bus.
• HLDA (HOLD Acknowledge)(38) − This signal is enabled at the
time when the processor gets HOLD signal and it releases HLDA
i.e., hold acknowledge signal. In order to show that the multiple
requests are kept on hold and will be considered once the bus gets
free after the recent operation..
8085 instruction set
Instruction sets are instruction codes to perform some task.
Each instruction is represented by 8 bit binary code and it is called
Opcode or instruction Byte
It is classified into five categories.
 Data transfer instructions: used to move or copy data between
registers and memory locations
 Arithmetic instructions: do arithmetical operations like ADD,SUB
 Logical instructions: Do logical operations like AND, OR, NOT etc
 Branching instructions: instructions for conditional and
unconditional jump, subroutine call and return, and restart.
 Control instructions: instructions for input/output ports, stack
and machine control.(control operations of microprocessor)
Data transfer instructions: used to transfer the data from a register to another
register from memory to register or register to memory
Instruction Set Explanation Example
MOV r1, r2 Move the content of the one register to
MOV A, B
another
MOV r, M
Move the content of memory to register MOV B, M
MOV M, r
Move the content of register to memory MOV M, C
MVI r, data
Move immediate data to register MVI B, 08H
LXI rp, data 16
Load data to Register pair HL LXI H, 2500H
LDA addr Load data from memory location to
LDA 2400 H
Accumulator
STA Addr Store data from accumulator to
STA 2000H
memory location
Arithmetic Instructions: perform arithmetic operations such as addition,
subtraction, increment or decrement of the content of a register or a memory.
Instruction Set Explanation Example
ADD r Add register content to
ADD B
accumulator content
ADD M Add memory content to
ADD M
accumulator content
SUB r Subtract data in register from data
SUB D
in accumulator
SUB M Subtract data in memory from data
SUB M
in accumulator

INR r
Increment register content INR H

DCR r
Decrement register content DCR L
Logical Instructions: perform logical operation such as AND, OR, compare, rotate,
etc.
Instruction Set Explanation
ANA r
AND register with accumulator

ORA r
OR-register with accumulator

CMA Complement the accumulator

CMP r
Compare register with accumulator
RLC
Rotate accumulator left

RRC
Rotate accumulator right
Branching Instructions :T his group contains the instructions for conditional
and unconditional jump, subroutine call and return, and restart.

Instruction Set Explanation


JMP addr(label)* Unconditional jump : jump to the specified address
Conditional Jumps location
JZ addr (label) Jump, if the result is zero
JNZ addr (label)
Jump if the result is not zero

JC addr (label)
Jump if there is a carry

JNC addr (label)


Jump if there is no carry
Other branching instructions are call, return, restart etc.
* Label : a label will be given to the address location to which jump operation has to be
performed
Control instructions : Machine control instructions
No operation is performed, i.e., the instruction is
NOP No operation fetched and decoded.

Halt and enter The CPU finishes executing the current instruction
HLT and stops further execution. An interrupt or reset is
wait state necessary to exit from the halt state.
The interrupt enable flip-flop is reset and all the
DI Disable interrupts interrupts are disabled.
The interrupt enable flip-flop is set and all the
EI Enable interrupts interrupts are enabled.

Input data to accumulator from I/O port


IN port address Input data

OUT port address Output data Output data from accumulator to I/O port
Addressing modes of 8085
The way of specifying data to be operated by an instruction is called
addressing mode. In 8085 microprocessor there are 5 types of
addressing modes:
• Immediate Addressing:
–Data is provided in the instruction .
–Load the immediate data to the destination provided.
–Eg: MVI A, 12 H (This loads the data 12H to the
accumulator register)
–LXI H 3050H (load the H-L register pair with the data
3050H)
• Register Addressing:
–Data is provided through the registers.
–the operation is performed within various
registers of the microprocessor.
–Example: MOV B, C
–ADD A,B
• Direct Addressing:
–the data to be operated is available inside a
memory location and that memory location is
directly specified as an operand.
–Example: MOV A, [1000]
• Indirect Addressing:
–Effective address is calculated by the processor and the
contents of the address is used to form a second
address. The second address is where the data is stored.
–Example: MOV A, [[1000]]
• Implicit addressing:
–In this addressing mode the instruction itself specifies
the data to be operated upon.(The data to be operated is
available in the instruction itself. )
–Example: CMA ; Complement the contents of
accumulator
– RRC (rotate accumulator A right by one bit)
– RLC (rotate accumulator A left by one bit)
Interrupts in 8085
 Interrupts are the signals generated by the
external devices to request the microprocessor to
perform a task. OR
 Interrupt is a mechanism by which an I/O or an
instruction can suspend the normal execution of
processor and get itself serviced.
There are 5 interrupt signals:
 TRAP,
 RST 7.5,
 RST 6.5,
 RST 5.5, and
 INTR.
CLASSIFICATION OF INTERRUPTS:
 HARDWARE AND SOFTWARE INTERRUPTS:
When microprocessors receive
interrupt signals through pins
(hardware) of microprocessor, they
are known as Hardware Interrupts.
There are 5 Hardware Interrupts in
8085 microprocessor. They are —
INTR, RST 7.5, RST 6.5, RST 5.5,
TRAP
 Software Interrupts are those which
are inserted in between the program
which means these are mnemonics
of microprocessor. There are 8
software interrupts in 8085
microprocessor. They are–RST 0,
RST 1, RST 2, RST 3, RST 4, RST 5,
RST 6, RST 7.
Maskable Interrupts we can disable the interrupt by writing
some instructions into the program. example: RST7.5,
RST6.5, RST5.5.
Non-Maskable Interrupts we cannot disable the interrupt by
writing some instructions into the program. example: TRAP.

• Vectored interrupts: those which have fixed vector


address (starting address of sub-routine) Eg:RST7.5,
RST6.5, RST5.5, TRAP.
• Non-vectored interrupts: those in which vector address
is not predefined. The interrupting device gives the
address of sub-routine for these interrupts. Eg: INTR
• TRAP
• It is a non-maskable interrupt, having the highest
priority among all interrupts. This interrupt transfers
the control to the location 0024H.
• RST7.5
• It is a maskable interrupt, having the second highest
priority among all interrupts. When this interrupt is
executed, the processor saves the content of the PC
register(point to the memory address from which
the next byte is to be fetched.) into the stack and
branches to 003CH address.
• RST 6.5
• It is a maskable interrupt, having the third highest
priority among all interrupts. When this interrupt is
executed, the processor saves the content of the PC
register into the stack and branches to 0034H address.
• RST 5.5
• It is a maskable interrupt. When this interrupt
is executed, the processor saves the content
of the PC register into the stack and branches
to 002CH address.
• INTR
• It is a maskable interrupt, having the lowest
priority among all interrupts. It can be
disabled by resetting the microprocessor
8085 programs
1. Addition of two 8-bit numbers
Algorithm

1.load the first data into Accumulator.


2. Move the 2nd data to a register (B register).
3. Add the two register contents.
4. Check for carry.
5. Store the value of sum and carry in memory
location.

6.End
• MVI A, 8bitdata1 moves first data to accumulator
• MVI B, 8bitdata2 moves second data to register B
• ADD B add (A) and (B)
• MOV H,A copies the result present in
accumulator to register H
• MVI A,00 moves immediate data (00) to A

• ADC A adds contents of A(00) and carry.

• MOV L,A copies content of A to register L


• SHLD 3050 stores the contents of L register(carry)
in 3050 memory location and contents
of H register (sum) in 3051
memory location
• HLT stop
2. Addition of two 16 bit numbers

Algorithm
• Load both the lower and the higher bits of first
number to a register pair(say H-L)
• Load the 2nd number to another register pair (say
D-E)
• Add both the register pairs and store the result in a
memory location
• LXI H, 16bit data1 loads 16 bit data1 in
H-L register pair
• LXI D, 16bitdata2 loads 16 bit data2 in
DE register pair
• DAD D (Double Add)adds the value
of H with D and L with E
and stores the result in H
and L
• SHLD 2050 stores the result at memory
location 2050
• HLT stop
Subtraction of two 8-bit numbers
Algorithm
1.load the first data into Accumulator.
2. Load the 2nd data to a register (B register).
3.Subtract the two register contents.
5. Check for carry(borrow).
6. If borrow is present take 2's complement of
Accumulator. ( complement A and add 1)(this happens if
the first number is smaller than the second number)
7. Store the value of borrow in memory location.
8. Store the difference value present in Accumulator to a
memory location.
9. Stop
(if the 1st number is smaller than the 2nd , then the
result will be negative, hence take the 2’s compliment of
the result.)
MVI A, data1 Moves 1st number to A

MVI B, data2 Moves 2nd number to register B

MVI C, 00H Moves 00 to C

SUB B [A]-[B]

JNC (LABEL) If there is no borrow/carry, jump to location (LABEL) (


when subtracting smaller from larger)

CMA Compliment Accumulator(result) (when subtracting


larger from smaller then there will be borrow)
INR A Increment accumulator data (2’s compliment=1’s
compliemnt +1)
INR C Increment Content of C

(LABEL) STA 2500 Store the result in A to memory location 2500

MOV [2502] ,C Copy the carry/borrow from C to memory location 2500


HLT stop
Subtraction of two 16 bit numbers
ALGORITHM:
• 1. Store the first number in H-L reg pair
• 2. Store the second number D-E reg pair
• 3. Subtract the second number from the first
number with borrow.
• 4: Store the result in locations memory
locations
• 5: Stop
LXI H, 16bit data1 loads 16 bit data1 in H-L register
pair

LXI D, 16bitdata2 loads 16 bit data2 in DE register pair

MOV A, L Copies lower 8 bits of first data to A

SUB E [L]-[E]

MOV L,A Copies the result to L

MOV A, H Copies upper 8 bits of 1st data to A

SBB D [H]-[D] with borrow

MOV A, H Store the result in H

SHLD 3050 Store the result in H_L pair to


memory location 3050

HLT stop

You might also like