You are on page 1of 97

Introduction to Microprocessor

Micro-Operations A computer executes a program Fetch/execute cycle Each cycle has a number of steps Called micro-operations Each step does very little Atomic operation of CPU

Types of Micro-operation Transfer data between registers Transfer data from register to external Transfer data from external to register Perform arithmetic or logical ops

Structure - Top Level

Peripherals

Computer
Central Processing Unit Main Memory

Computer

Systems Interconnection

Input Output Communication lines

Structure - The CPU

CPU
Computer
I/O System Bus Memory CPU

Registers

Arithmetic and Login Unit

Internal CPU Interconnection

Control Unit

Basic Elements of Processor ALU Registers Internal data pahs External data paths Control Unit

Organization of A Microprocessor-based System (Computer)

CPU Central Processing Unit Memory


ROM Read Only Memory RAM Random Access Memory

I/O
Keyboard Display Device

Clock Square Wave Oscillator (Timing) System Bus

Microprocessor (CPU)
Programmable integrated device (silicon chip) that has computing & decision making capabilities Communicates & operates in binary numbers 0 & 1, called bits Has a fixed set of instructions in the form of binary patterns machine language Difficult for humans to remember machine language each instruction is represented using abbreviated names (mnemonics)

Memory
Symbolic representation
8 bit FFFF FFFE Instruction 1 Instruction 2 Instruction 2 64KByte

Word length 1 word instruction 2 word instruction

0001 0000

address

Word: no. of bits micro-P recognizes and processes at a time ( 4 - 64bit ). Instruction: combination of bit patterns with specific meaning known to micro-P. Program: Set of all instructions.

I/O
Microprocessors connection to the outside world
Input: Keyboard, mouse Output: Monitor, printer

System Bus wires connecting memory & I/O to microprocessor


Address Bus
Unidirectional Identifying peripheral or memory location

Data Bus
Bidirectional Transferring data

Control Bus
Synchronization signals Timing signals Control signal

Actions performed by microprocessor:


CPU Memory CPU I/O Data Processing
Arithmetic operations Logical operations

Control
Jump Interrupts

Basic Concepts of Microprocessors

Differences between:
Microcomputer a computer with a microprocessor as its CPU. Includes memory, I/O etc. Microprocessor silicon chip which includes ALU, register circuits & control circuits Microcontroller silicon chip which includes microprocessor, memory & I/O in a single package.

Differences between:
High level language Assembly language Machine language
swap; muli $2, $5,4 add $2, $4,$2 lw $15, 0($2) lw $16, 4($2) 00011100011100 01111000011100 11110000111001 01101011001001

swap (int v[], int k) {int temp; temp = v[k]; v[k] = v[k+1]; v[k+1] = temp; }

C compiler
High Level Languange (in C) Assembly Languange

Assembler
Machine Language

Fetch - 4 Registers Memory Address Register (MAR)


Connected to address bus Specifies address for read or write op

Memory Buffer Register (MBR)


Connected to data bus Holds data to write or last data read

Program Counter (PC)


Holds address of next instruction to be fetched

Instruction Register (IR)


Holds last instruction fetched

Functions of Control Unit Sequencing


Causing the CPU to step through a series of micro-operations

Execution
Causing the performance of each micro-op

This is done using Control Signals

Control Signals Clock


One micro-instruction (or set of parallel microinstructions) per clock cycle

Instruction register
Op-code for current instruction Determines which micro-instructions are performed

Flags
State of CPU Results of previous operations

From control bus


Interrupts Acknowledgements

Model of Control Unit

Fetch Sequence Address of next instruction is in PC Address (MAR) is placed on address bus Control unit issues READ command Result (data from memory) appears on data bus Data from data bus copied into MBR PC incremented by 1 (in parallel with data fetch from memory) Data (instruction) moved from MBR to IR MBR is now free for further data fetches

Intel 8085 Microprocessor

Microprocessor consists of:


Control unit: control microprocessor operations. ALU: performs data processing function. Registers: provide storage internal to CPU. Interrupts Internal data bus

Intel 8085 CPU Block Diagram

ALU

Intel 8085 Pin Configuration

Registers
General Purpose Registers
B, C, D, E, H & L (8 bit registers) Can be used singly Or can be used as 16 bit register pairs
+ BC, DE, HL

H & L can be used as a data pointer (holds memory address)

Special Purpose Registers


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)
D7 D6 D5 D4 D3 D2 D1 D0

AC

CY

Sign Flag
Used for indicating the sign of the data in the accumulator The sign flag is set if negative (1 negative) The sign flag is reset if positive (0 positive)

Zero Flag
Is set if result obtained after an operation is 0 Is set following an increment or decrement operation of that register
10110011 + 01001101 --------------1 00000000

Carry Flag

Is set if there is a carry or borrow from arithmetic operation

1011 0101 + 0110 1100 --------------Carry 1 0010 0001

1011 0101 - 1100 1100 --------------Borrow 1 1110 1001

Auxillary Carry Flag


Is set if there is a carry out of bit 3
1011 0101 + 0110 1100 --------------1 0010 0001

Parity Flag
Is set if parity is even Is cleared if parity is odd

16 Bit Registers
Program Counter
A pointer to the next instruction to be executed Contains the 16-bit memory address of the next instruction Updated after processor has fetched the instruction

Stack Pointer
Stack an area in memory in which temporary info is stored Stack FILO (First In Last Out) basis Holds the address of the top of the stack

Non Programmable Registers

Instruction Register & Decoder


Instruction is stored in IR after fetched by processor Decoder decodes instruction in IR

Internal Clock generator


3.125 MHz internally 6.25 MHz externally

Microprocessor 8085 pin Configuration

Intel 8085 is an 8 bit,. It is a 40 pin IC package fabricated on a single LSI. Description of various pins: 1. A8-A15 (Output): These are address bus and are used for the MSB of the memory address. or I/O address. ADo-AD7 (Input / Output): These are time multiplexed address / data bus i.e. they serve dual purpose. They are used for the LSB of the memory address. or I/O address during the first clock cycle of the machine cycle. They are used as data during the second and third clock cycle of the machine cycle. ALE (Output): It is an address latch enable signal. It goes high during the first clock cycle of the machine cycle and enables the lower 8 bits of the address to be latched either into the memory or external latch.

1.

1.

4.

IO/M (Output): It is a status signal which distinguishes whether the address is for memory or I/O. When it goes low the address in the address bus is for the memory. So,S1 (Output): These are status signals sent by the microprocessor to distinguish the various types of operation given .
1. 2. 3. 4. 0,0 0,1 1,0 1,1 Halt write Read Fetch

5.

6.

___ RD(Output): It is a signal to control READ operation. When it is low the selected memory or I/O device is read.

7.

WR (Output): It is a signal to control WRITE operation. When it is low the data on the data bus is written into the selected memory or I/O device. READY (Input) It is used by the microprocessor to check whether the peripherals is ready to transfer data or not. If READY is high the peripheral is ready. If it is low MP waits for the signal to goes high. HOLD (Input): It indicates that another device is requesting the use of the address and data bus. Having received a HOLD request the MP relinquishes the use of the buses as soon as current machine cycle is completed.

8.

9.

10. HLDA (output): It is a signal for HOLD acknowledgement. It indicates that the HOLD request have been received.

11. INTR (input): It is an interrupt request signal. Among interrupts it has lowest priority. When it goes high the program counter does not increment its contents. The microprocessor suspends its normal sequence of operations. After completing the instruction at hand it goes to the call instruction. The INTR line is sampled in the last state of the last machine cycle of the instruction. The microprocessor acknowledges the interrupt signal and issues INTA signal. 12. RST5.5.6.5.7.5 and TRAP (inputs): These are interrupts. When an interrupt is recognized the next instruction is executed from a fixed location in the memory as given below:
1. 2. 3. 4. TRAP RST5.5 RST6.5 RST7.5 0024 002C 0034 003C

RST 7.5,6.5.5.5 are the restart interrupts. They cause an internal restart to be automatically inserted. Each of them has a programmable mask. The TRAP has the highest priority among interrupts. It is a nonmaskable interrupts. It is unaffected by any mask or interrupt. The priority of the interrupts is in the order of TRAP(Highest) , RST7.5. RST6.5, RST5.5, INTR.

13. RESET IN (Input): It resets the program counter to zero. It also resets the interrupt enable and HLDA flip-flops. It does not effect any other flag or register except the instruction register, The CPU is held in reset condition as long as RESET is applied. 14. RESET OUT (Output): It indicates that the CPU is being reset. 15. X1, X2: (Input): These are terminals to be connected to an external crystal oscillator which drives an internal circuitry of the microprocessor to produce a suitable clock for the operation of microprocessor. 16. CLK : It is a clock output for user, which can be used for other digital ICs Its frequency is same at which processor operates. 17. SID (Input) It is data line for serial input. 18. SOD (Output): it is a data line for serial output. 19. VCC: +5 Volts Supply 20. VSS: Ground Reference

The 8085 Machine Cycle and Bus Timings

An instruction is a command given to a computer to perform a specified operation on the given data. To perform a particular task a programmer writes a sequence of instructions, called a program. Program and data are stored in the memory. The processor fetches one instruction from the memory at a time and execute it. It executes all the instructions of the program one by one and produce the final result. Instruction Cycle The necessary steps which a processor carries out to fetch an instruction and data from the memory and to execute that instruction constitute and instruction cycle. An instruction cycle consist of two steps Fetch cycle and Execute cycle. In the fetch cycle the processor fetches the instruction from the memory. The necessary steps which are carried out to get data and perform the specific operation given in the instruction constitute a execute cycle. IC = FC + EC

Op-code & Operand Each instruction contains two parts Operation Code (Opcode) and Operand. The first part of the instruction which specifies a task to be performed by the processor is called Opcode. The second part of the instruction is the data to be operated upon is called Operand.

Instruction and Data Flow

Instruction Register

MDR

Memory Data Bus

Instruction Decoder
----------------------------------

Control

Program Counter

MAR

Memory Address Bus

Addressing Modes of MP 8085 Each instruction performs an operation on the specified data called operand. An operand must be specified for an instruction to be executed. The operand may be in the general purpose register, accumulator or in a memory location. The way in which the operand is specified for an instruction is called addressing mode. Various addressing modes used in MP 8085 are:
1. 2. 3. 4. 5. Direct Addressing Register Addressing Register Indirect Addressing Immediate Addressing. Implicit Addressing

Direct addressing: In this mode of addressing the address of the operand (data) is given in the instruction itself. For example:
1. 2. STA 2400H: Store the content of the accumulator to memory location 2400H. IN 02: Read data from port C , 02 is the address of the port C of an I/O port from where data is to be read.

Register Addressing: In register addressing mode the operands are in the general purpose registers. For example:
1. 2. MOV A,B: This instruction moves the contents of register B to register A or Accumulator. ADD B: Add the contents of register B to accumulator.

 Register indirect addressing: In this mode of addressing the address of the operand (data) is specified by a register pair. For example:
1. LXI H, 2500H: Load HL pair with 2500H. MOV A,M : Move the contents of memory location whose address is given in HL pair to the accumulator. HLT: Stop the program. In this program MOV A,M is the example of Register Indirect addressing. 2. LXI H, 2500H: Load HL pair with 2500H. ADD M : Add the contents of memory location whose address is given in HL pair to the accumulator. HLT: Stop the program. In this program ADD ,M is the example of Register Indirect addressing.

 Immediate Addressing: In immediate addressing mode the operands are specified within the instruction itself. For example:
1. MVI A,05 : Move 05 in the Accumulator. 2. ADI 06 : Add 06 to the contents of the accumulator.

 Implicit Addressing: There are certain instructions which operate on the content or the Accumulator directly, these instructions do not require the address of the operands. For example
1. CMA : Compliment the contents of the Accumulator. 2. RAR : Rotate the contents of the accumulator right by one bit. 3. RAL : Rotate the contents of the accumulator left by one bit.

1.

2. 3. 4.

The steps which MP8085 takes to fetches machine codes from the memory can be understood with the help of the command MOV C,A (4F) stored at memory location 2005H : The program places the 16 bit address on the address bus. At time T1 the high order address 20H is placed on the address line A15-A8, the low order memory address 05H is placed on the data bus AD7-AD0 and the address latch signal goes high. Similarly the status signal IO/M goes low, indicating that this is memory related operation. The control unit sends the control signal RD to enable the memory chip. This signal is sent out during the clock period T2, thus enabling the memory chip. The RD signal is active during two clock periods. The byte from the memory location is placed on the data bus. When the memory is enabled the instruction byte (4F) is placed on the bus AD7-AD0 and transferred to the microprocessor. The byte is placed in the instruction decoder of the microprocessor, and the task is carried out. The machine code 4F is decoded by the instruction decoder and the contents of the accumulator are copied into the register C. This task is performed during the period T4

The 8085 Machine Cycle and Bus Timings (cont..)

Example :- In MP8085 we have two machine codes 3EH ( MVI A, data) and 32H are stored at memory location 2000H and 2001H respectively. Illustrate the bus timing . Calculate the required time to execute the Opcode Fetch and Memory Read cycles and the entire instruction cycle if the clock frequency is 2 MHzs. Ans :- This instruction consists of two bytes; the first op-code and the second is the data byte. The MP reads these bytes from the memory and thus requires at least two machine cycles. The first machine cycle is the Opcode fetch and the second machine cycle is the memory read .

First machine cycle M1: At T1 microprocessor places the memory address 2000H from the PC on the address bus. 20H on the A15-A8, and 00H on the bus AD7-AD0. The ALE signal goes high during T1. which is used to latch the low order address 00H to AD7-AD0. The status signals are S1 = 1, S0=1 At T2 the MP asserts the RD control signal, which enables the memory, and memory places the byte 3EH from location 2000H on the data bus. During T3 the MP places the opcode in the instruction register and disables the RD signal . The fetch cycle is completed in state T3 During T4 the instruction is decoded

Second machine cycle M2: At T1 microprocessor places the memory address 2001H from the PC on the address bus. 20H on the A15-A8, and 01H on the bus AD7-AD0. The ALE signal goes high during T1. which is used to latch the low order address 00H to AD7-AD0. The status signals are S1 = 1, S0=0 At T2 the MP activates the data bus as the input bus, memory places the data byte 32H on the data bus. During T3 the MP reads and store the byte in accumulator.

The execution time Clock frequency f = 2 Mz T- state = Clock Period = 1/f = 0.5 s Execution time for fetch cycle = 4 X .5 = 2 s Execution time for Memory Read = 3 X .5 = 1.5 s Execution time for the instruction = 3.5 s

The 8085 Machine Cycle and Bus Timings (cont..)

Example :- In MP8085 explain the machine cycle for the instruction STA 2065 (32H,65,20). The machine codes are stored at the memory locations 2010H, 2011H, 2012H. Ans :- This instruction consists of three bytes; the first op-code and the second and the third are the address of the memory location. This instruction stores the contents of the accumulator in the memory location 2065H. It consists of 4 machine cycles. 1. First machine cycle M1:In the first machine cycle the MP places the address 2010 on the address bus and fetches the opcode 32h. It requires 4T states.

2. Second machine cycle M2:In the second machine cycle the memory is read. The processor places the address 2011 and gets the low order byte 65H. It requires 3T states.

3. Third machine cycle M3:The third machine cycle is also the Memory Read cycle. The processor gets the high order byte 20H from the memory location 2012. It requires 3 T states

4. Forth machine cycle M4 :The last machine cycle is the memory write . The MP places the address of 2065H on the address bus, identifies the operation as Memory Write ( S1=0, S0=0 ). It places the contents of the accumulator on the data bus AD7-AD0 and asserts the WR signal. During the last T state the contents of the data bus are placed in memory location 2065H. It requires 3T states.

Instruction Set of 8085


An instruction is a command given to the computer to perform a specified operation on given data. The 8085-instructions are classified into five group: 1. Data Transfer Group 2. Arithmetic Group 3. Logical Group 4. Branch Control Group 5. I/O and Machine Control Group

Data Transfer Group

Related with moving data from one place to another. Not be mistaken as the idea that data is literally moved, instead it is copied from one location to another. This particular type of instruction set does not modify data.

Data Transfer Group (Contd.)

Instructions related with this category perform the following transfers: Load data from memory into microprocessor. Store data from the microprocessor into memory. Move data within the microprocessor. Input data to the microprocessor. Output data from the microprocessor.

MOV r, M.
Move the content of memory location, whose address is in H-L pair, is moved to register r.

MOV M, r.
The content of register r is moved to the memory location addresses by H-L pair.

MVI r, data.
Move immediate data in the register r.

MVI M, data.
The data is moved to memory location whose address is in H-L pair

LXI rp, data (16-bits)


Load the register pair with 16-bits data.

LDA addr.
The content of the memory location, whose address is specified by the 2nd and 3rd bytes of the instruction; is loaded into the accumulator.

STA addr.
The content of accumulator is stored in the memory location whose address is specified by the 2nd and 3rd bytes of the instruction.

LHLD addr.
The content of the memory location, whose address is specified by the 2nd and 3rd bytes of the instruction is loaded into register L, the content of next memory location is loaded into register H.

SHLD addr.
The content of the register L is stored in the memory location whose address is specified by the 2nd and 3rd bytes of the instruction, the content of register H is stored in the next memory location.

LDAX rp.
The content of memory location, whose address is in the register pair rp, is loaded into the accumulator.

STAX rp.
The content of the accumulator is stored in the memory location whose address is in the register pair rp.

XCHG.
The contents of H-L pair are exchanged with contents of D-E pair.

Arithmetic Group Related with performing arithmetic operations. This particular type of instruction set modify data. The operations are:Addition Subtraction Increment Decrement

ADD r.
The content of register r is added to the content of the accumulator, and the sum is placed in the accumulator.

ADD M.
The content of the memory location addressed by H-L pair is added to the content of the accumulator.

ADC r.
The content of register r and carry status are added to the content of the accumulator.

ADC M.
The content of the memory location addressed by H-L pair and carry status are added to the content of the accumulator.

ADI data.
The immediate data is added to the content of the accumulator.

ACI data.
The immediate data and the carry status are added to the content of the accumulator.

DAD rp.
The contents of register pair rp are added to the contents of H-L pair and the result is placed in H-L pair.

SUB r.
The content of register r is subtracted from the content of the accumulator, and the result is placed in the accumulator.

SUB M.
The content of the memory location addressed by H-L pair is subtracted from the content of the accumulator.

SBB r.
The content of register r and carry status are subtracted from the content of the accumulator.

SBB M.
The content of memory location addressed by H-L pair and carry status are subtracted from the content of the accumulator.

SUI data.
The immediate data is subtracted from the content of the accumulator.

SBI data.
The immediate data and carry status subtracted from the content of the accumulator.

INR r.
The content of register r is incremented by one.

INR M.
The content of memory location addressed by H-L pair is incremented by one.

DCR r.
The content of register r is decremented by one.

DCR M.
The content of memory location addressed by H-L pair is decremented by one.

INX rp.
The content of register pair rp is incremented by one.

DCX rp.
The content of register pair rp is decremented by one.

DAA.
This instruction is used in the program after ADD, ADI, ACI, ADC, etc instruction. After the execution of ADD, ADC, etc instruction the result is in hexadecimal and it is placed in the accumulator. This instruction operates on this result and gives the final result in decimal system.

Logical Group Instructions in this group perform AND,OR, Ex-Or operations; compare,rotate,or take complement of data in register or memory.

ANA r.-> (AND register with accumulator.)


It contents of register are ANDed with the content of the accumulator, and the result is placed in the accumulator.

ANA M.->

(AND memory with accumulator. ) Contents of memory location addressed by H-L pair and is ANDed with the accumulator. The result is placed in accumulator.

ANI data

(AND immediate data with accumulator )

The 2nd byte of instruction is data, and it is ANDed with the content of the accumulator. The result is placed in accumulator.

ORA r (OR)

register with accumulator. Contents of registered are ORed with content of accumulator. The result is placed in the accumulator.

ORA M.-> ORI data

(OR memory with accumulator. ) Contents of memory location addressed by H-L pair and is ORed with the accumulator. The result is placed in accumulator. (OR immediate data with accumulator ) The 2nd byte of instruction is data, and it is ORed with the content of the accumulator. The result is placed in accumulator. CS=0 and AC=0.

XRA r

(Ex-OR) register with accumulator. Contents of registered are Ex-ORed with content of accumulator. The result is placed in the accumulator. (Ex-OR memory with accumulator. ) Contents of memory location addressed by H-L pair and is Ex-ORed with the accumulator. The result is placed in accumulator.

XRA M.->

XRI data

(Ex-OR immediate data with accumulator ) The 2nd byte of instruction is data, and it is Ex-ORed with the content of the accumulator. The result is placed in accumulator.

CMA

(Compliment the accumulator) 1s compliment of accumulator is obtained and result is placed in accumulator. To obtain the 1s compliment of a binary number 1 is replaced by 0 or 0 by 1.

CMC (Compliment the carry status)


CS flag is complimented. other flags are not affected.

STC

(Set carry status)

Status flag CS is set to 1. Other flags are not affected.

CMP r.
The content of register r is subtracted from the content of the accumulator and the status flags are set according to the result of the subtraction. The content of accumulator remains unchanged.

CMP M.
The content of memory location addressed by H-L pair is subtracted from the content of the accumulator and the status flags are set according to the result of the subtraction. The content of accumulator remains unchanged.

CPI data.
The 2nd byte of the instruction is data, and it is subtracted from the content of the accumulator. The status flags are set according to the result of subtraction. But the result is discarded.

RRC.
The content of the accumulator is rotated right by one bit. The zero bit of the accumulator is moved to carry bit as well as to the seventh bit of the accumulator.

RAL.
The content of the accumulator is rotated left one bit through carry. The seventh bit of the accumulator is moved to carry and the carry bit is moved to the zero bit of the accumulator.

RRC.
The content of the accumulator is rotated right one bit through carry. The zero bit of the accumulator is moved to carry bit, and the carry bit moved to seventh bit of the accumulator.

Branch Group
The instructions of this group change the normal sequence of the program. There are two types of branch instructions: Conditional Unconditional

JZ addr (label).
The program jumps to the instruction specified by the address (label) if the result is zero. Here the result after the execution of the preceding instruction is under consideration.

JNZ addr (label).


The program jumps to the instruction specified by the address (label) if the result is non-zero.

JC addr (label).
The program jumps to the instruction specified by the address (label) if there is a carry.

JNC addr (label).


The program jumps to the instruction specified by the address (label) if there is no carry.

JP addr (label).
The program jumps to the instruction specified by the address (label) if the result is plus.

JM addr (label).
The program jumps to the instruction specified by the address (label) if the result is minus.

JPE addr (label).


The program jumps to the instruction specified by the address (label) if the result contains even number of 1s.

JPO addr (label).


The program jumps to the instruction specified by the address (label) if the result contains odd number of 1s.

CALL addr (label).


[[SP]-1] [PCH] [[SP]-2] [PCL] [SP] [SP]-2 [PC] addr (label) CALL instruction is used to call a subroutine. Before the control is transferred to the subroutine, the address of the next instruction of the main program is saved in the stack.

Conditional CALL addr (label)


Addressing: immediate/ reg. indirect. Machine cycles:2/5. If the condition is true and program calls the specified subroutine, the execution of a conditional call instruction takes 5 machine cycle; 18 states. If condition is not true, only 2 machine cycles; 9 states are required for the execution of the instruction. CC addr(label) call subroutine if carry status CS=1. CNC addr(label) call subroutine if carry status CS=0 CZ addr(label) call subroutine if result=0; i.e zero status Z=1 CNZ addr(label) call subroutine if result is not zero. Z=0 CP addr(label) call subroutine if result is plus; the sign signal status S=0. CM addr(label) call subroutine if result is minus; the sign signal status S=1. CPE addr(label) call subroutine if even parity; the parity status P=1. CPO addr(label) call subroutine if odd parity; the parity status P=0.

i. ii. iii. iv. v. vi. vii. viii.

RET (Return from subroutine)


[PCL] <- [[SP]], [PCH] <- [[SP]+1], [SP] <- [SP] + 2. RET instruction is used at the end of a subroutine. Before the execution of a subroutine the address of the next instruction of the main program is saved in the stack. The execution of RET instruction brings back the saved address from the stack to the program counter. The content of the stack pointer is incremented by 2 to indicate the new stack top. Then the program jumps to the instruction of the main program next to CALL instruction which is called subroutine.

Conditional Return
[PCL] <- [[SP]],[PCH]<-[[SP]+1], [SP]<-[SP] + 2. States: 6/12. Flags: none. Addressing: reg. indirect.Machine cycles:1/3.If the condition is true and the program returns from the subroutine, the execution return takes 3 m/c cycles, 12 states. If condition is not true only one m/c cycle, 6 states are required. i. RC return from subroutine if carry status CS=1. ii. RNC return from subroutine if carry status CS=0. iii. RZ return from subroutine if result is 0; the zero status Z=1. iv. RNZ return from subroutine if result is not 0; the zero status Z=0. v. RP return from subroutine if result is plus; the sign status S=1. vi. RM return from subroutine if result is minus; the sign status S=1. vii. RPE return from subroutine if even parity; the parity status P=1. viii. RPO return from subroutine if odd parity; the parity status P=0.

RST n (Restart)
[[SP]-1]<- [PCH],[[SP]-2]<-[PCL] [SP]<-[SP]-2, [PC]<-8 times n. States: 12 Flags: none, Addressing: reg indirect. Machine cycles : 3 Restart is a one word call instruction starting at restart location. The address of the restart location is 8 times n. The restart instruction and location are as follows: Instruction Opcode Restart location RST0 C7 0000 RST1 CF 0008 RST2 D7 0010 RST3 DF 0018 RST4 E7 0020

RST5 RST6 RST7

EF F7 FF

0028 0030 0038

PCHL (Jump to address specified by HL pair)

[PC]<-[H-L],[PCH]<-[H],[PCL]<-[L] states 6. Addressing :register. The contents of HL pair are transferred to program counter. The contents of register H are moved to high order 8 bits of register L are transferred to low order 8 bits of register PC.

Stack, I/O and Machine Control Group

IN port-address. (Input to accumulator from I/O port) [A]<-[Port] The data available on the port is moved to the accumulator. After instruction IN, the address of the port is specified. The 2nd byte of instruction contains the address of the port. The address of a port is an 8-bit address.

OUT port-address. (O/P from accumulator to I/O port.)

[Port] <-[A]. The contents of the accumulator is moved to the port specified by its address. After the OUT instruction, the port address is specified. The 2nd byte of instruction contains the address of the port.

PUSH rp. (Push the content of register pair to stack) [[SP-1]<-[rh]], [[SP-2]<-[rl]], [[SP]<-[SP]-2. Contents of register pair are moved into the stack.

PUSH PSW (Push processor status word)

[[SP]-1]<-[A], [[SP]-2]<-PSW (Program status word) [SP]<-[SP]-2. The content of the accumulator is pushed into the stack. The contents of status flag are also pushed into the stack. The content of the register SP is decremented by 2 to indicate new stacktop.

Interrupts in Microprocessor 8085

The primary function of the MP are:


To accept the data from input devices such as keyboard and A/D converters. Read instructions from memory. Process data according to the instructions. Send results to the output devices such as LEDs printers and monitors.

These I/O devices are called either peripherals or I/Os. Designing logic circuits (hardware) and writing instructions (software) to enable MP to communicate with these peripherals is called interfacing and the logic circuits are called I/O ports or interfacing devices. The microprocessor communicates with the peripherals in either or two formats.
Asynchronous means at irregular intervals. It has a low speed data transmission Synchronous means at the same time the transmitter and receiver are synchronized with the same clock. It used for high speed data transmission

Interrupts in Microprocessor 8085 (cont)

The interrupt is a process of data transfer whereby an external device or a peripheral can inform the processor that it is ready for communication and it requests attention. The process is initiated by an external device and is asynchronous i.e. can be initiated at any time without reference to the system clock. The response to the interrupt is controlled by the microprocessor.

The interrupt request can be classified into two categories maskable and non maskable . Intel 8085 has five interrupts in the priority order :
1. 2. 3. 4. 5. TRAP RST 7.5 RST 6.5 RST 5.5 INTR

Interrupts in Microprocessor 8085 (cont)

In MP 8085 the interrupt process is controlled by the Interrupt Enable flip-flop, which is internal to the processor and can be set or reset using software instructions. The working of these interrupts can be described as
1. The interrupt process is enabled by writing an instruction EI in the main program. The instruction EI sets the Interrupt Enable flip flop. The instruction DI resets the flip flop and disables the interrupt process except non maskable interrupt TRAP . When the MP is executing a program, it checks the INTR line during the execution of each instruction.

2.

3.

4.

5.

If the INTR is high and the interrupt is enabled, the MP completes the current instruction, disables the interrupt Enables flip flop and sends a signal called INTA interrupt acknowledge. The processor cannot accept any interrupt requests until the interrupt flip flop is enabled again. The signal INTA is used to insert a restart (RST) instruction (or a call instruction) through external hardware. The RST instruction is a 1 byte instruction that transfers the program control to a particular location and restarts the execution at the memory location after executing step 5. When the MP receives an RST instruction (or CALL instruction)

Interrupts in Microprocessor 8085 (cont)

Hardware and Software interrupts: Interrupts caused by I/O devices are called hardware interrupts e.g. TRAP, INTR The normal operation of the MP can also be stopped by special instruction, such instructions are called software interrupts e.g. RST n when RST n instruction is inserted in a program , the program is executed up to that point where RST n has been inserted. Interrupt call locations: When an interrupt occurs the program is transferred to a specific memory location. Then the monitor transfers the program from the specific memory location to a memory location in the memory in RAM , from where the user can write the program for interrupt sub routine . For TRAP , RST 7.5, 6.5,and 5.5 the program is automatically transferred to specific memory locations without any external hardware. The necessary hardware is already provided within 8085. An interrupt for which hardware automatically transfers the program to a specific memory location is known as vectored interrupts. The specific memory location for these interrupts are as follows.

Interrupt
TRAP

Call Location
0024H

RST 7.5

003CH

RST 6.5

0034H

RST 5.5

002C

Interrupts in Microprocessor 8085 (cont)

INTR Call location:


There are 8 number of call locations for INTR interrupt as shown in the table below:
RST n
RST 0 RST 1 RST 2 RST 3

Call Location
0000 0008 0010 0018

RST n
RST 4 RST 5 RST 6 RST 7

Call Location
0020 0028 0030 0038

For INTR external hardware is used to transfer program to specific CALL location. The hardware circuit generates RST codes for the purpose. The INTR line is sampled by the MP in the last state of the last machine cycle of each instruction. When INTR is high the MP saves the contents of the program counter on the stack and then sends an interrupt acknowledge signal INTA to the external hardware. In response to INTA the external hardware generates a RST n code. When MP receives this code, it transfers program to the corresponding CALL-location. Up to 8 number of I/O devices can be connected to INTR through an external hardware. Priority can be assigned to I/O devices connected to INTR through external hardware or interrupt controller. The external hardware recognizes which I/O device has interrupted and it generates proper RST code that causes microprocessor to take up ISS for that particular I/O device.

You might also like