Unit 1

66
8085 PROCESSOR UNIT I Mr. S. VINOD ASSISTANT PROFESSOR EEE DEPARTMENT

Transcript of Unit 1

Page 1: Unit 1

8085 PROCESSOR

UNIT IMr. S. VINOD

ASSISTANT PROFESSOR

EEE DEPARTMENT

Page 2: Unit 1

8085 PROCESSOR--Functional block diagram --Signals --Memory interfacing --I/O ports and data transfer concepts --Timing Diagram --Interrupt structure.

Page 3: Unit 1

Pin detail of 8085

Page 4: Unit 1
Page 5: Unit 1

The 8085 Microprocessor Architecture

• 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. It can run at a maximum frequency of 3 MHz.– 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.

Page 6: Unit 1

The Address and Data Busses• The address bus has 8 signal lines A8 – A15 which are

unidirectional.• The other 8 address bits are multiplexed (time shared)

with the 8 data bits.– So, the bits AD0 – AD7 are bi-directional and serve as

A0 – A7 and D0 – D7 at the same time.• During the execution of the instruction, these lines

carry the address bits during the early part, then during the late parts of the execution, they carry the 8 data bits.

– In order to separate the address from the data, we can use a latch to save the value before the function of the bits changes.

Page 7: Unit 1

The Control and Status Signals• There are 4 main control and status signals. These are:

• ALE: Address Latch Enable. This signal is a pulse that become 1 when the AD0 – AD7 lines have an address on them. It becomes 0 after that. This signal can be used to enable a latch to save the address bits from the AD lines.

• RD: Read. Active low.• WR: Write. Active low.• IO/M: This signal specifies whether the operation is a

memory operation (IO/M=0) or an I/O operation (IO/M=1).• S1 and S0 : Status signals to specify the kind of operation

being performed .Usually un-used in small systems.

Page 8: Unit 1

Frequency Control Signals• There are 3 important pins in the frequency control group.

– X0 and X1 are the inputs from the crystal or clock generating circuit.

• The frequency is internally divided by 2.– So, to run the microprocessor at 3 MHz, a clock running

at 6 MHz should be connected to the X0 and X1 pins.

– CLK (OUT): An output clock pin to drive the clock of the rest of the system.

• We will discuss the rest of the control signals as we get to them.

Page 9: Unit 1

The ALU

• In addition to the arithmetic & logic circuits, the ALU includes the accumulator, which is part of every arithmetic & logic operation.

• Also, the ALU includes a temporary register used for holding data temporarily during the execution of the operation. This temporary register is not accessible by the programmer.

Page 10: Unit 1

The Flags register– There is also the flags register whose bits are affected by the arithmetic & logic

operations.• S-sign flag

– The sign flag is set if bit D7 of the accumulator is set after an arithmetic or logic operation.

• Z-zero flag– Set if the result of the ALU operation is 0. Otherwise is reset. This flag

is affected by operations on the accumulator as well as other registers. (DCR B).

• AC-Auxiliary Carry– This flag is set when a carry is generated from bit D3 and passed to

D4 . This flag is used only internally for BCD operations. (Section 10.5 describes BCD addition including the DAA instruction).

• P-Parity flag– After an ALU operation if the result has an even # of 1’s the p-flag is

set. Otherwise it is cleared. So, the flag can be used to indicate even parity.

• CY-carry flag– Discussed earlier

Page 11: Unit 1

8085 Instruction Set

Page 12: Unit 1

12

8085 Instruction Set

The 8085 instructions can be classified as follows:

Data transfer operations

Arithmetic operations (ADD, SUB, INR, DCR)

Logic operations

Branching operations (JMP, CALL, RET)

• Between registers• Between memory location and a register• Direct write to a register / memory• Between I/O device and accumulator

Page 13: Unit 1
Page 14: Unit 1
Page 15: Unit 1
Page 16: Unit 1

16

Simple Data Transfer Operations

Examples:

MOV B,A 47 From ACC to REG MOV C,D 4A Between two REGs MVI D,47 16 Direct-write into REG D

47

Page 17: Unit 1

17

Simple Data Transfer Operations

Example:

OUT 05 D305

Contents of ACC sent to output port number 05.

Page 18: Unit 1

18

Simple Memory Access Operations

Page 19: Unit 1

19

Simple Memory Access Operations

Page 20: Unit 1

20

Arithmetic Operations

Page 21: Unit 1

21

Arithmetic Operations

Page 22: Unit 1

22

Arithmetic Operations

Page 23: Unit 1

23

Arithmetic Operations

Page 24: Unit 1

24

Overview of Logic Operations

Page 25: Unit 1

25

Logic Operations

Page 26: Unit 1

26

Logic Operations

Page 27: Unit 1

27

Logic Operations

Page 28: Unit 1

28

Branching Operations

Note: This is an unconditional jump operation. It will always force the program counter to a fixed memory address continuous loop !

Page 29: Unit 1

29

Branching Operations

Conditional jump operations are very useful for decision making during the execution of the program.

Page 30: Unit 1

Data transfer operation

• LHLD      Load H & L Registers Directly from Memory• SHLD     Store H & L Registers Directly in Memory• LXI       Load Register Pair with Immediate data• LDAX      Load Accumulator from Address in Register

Pair• STAX     Store Accumulator in Address in Register Pair• XCHG     Exchange H & L with D & E• XTHL    Exchange Top of Stack with H & L

Page 31: Unit 1

Arithmetic Operations• ADC          Add to Accumulator Using Carry Flag• ACI           Add Immediate data to Accumulator Using Carry • SBB          Subtract from Accumulator Using Borrow (Carry) Flag• SBI           Subtract Immediate from Accumulator Using Borrow (Carry) Flag• INX           Increment Register Pair by One• DCX          Decrement Register Pair by One• DAD          Double Register Add; Add Content of Register

              Pair to H & L Register Pair

Page 32: Unit 1

Logic OperationsThe Compare instructions compare the content of an 8-bit value with

the contents of the accumulator• CMP           Compare• CPI           Compare Using Immediate DataThe rotate instructions shift the contents of the accumulator one bit

position to the left or right: • RLC           Rotate Accumulator Left• RRC           Rotate Accumulator Right• RAL           Rotate Left Through Carry• RAR           Rotate Right Through CarryComplement and carry flag instructions:• CMA           Complement Accumulator• CMC           Complement Carry Flag• STC           Set Carry Flag

Page 33: Unit 1

Branching Operationsthe conditional branching instructions are specified as follows:

Jumps         Calls        ReturnsC             CC       RC      (Carry)INC          CNC       RNC     (No Carry)JZ            CZ            RZ      (Zero)JNZ           CNZ           RNZ     (Not Zero)JP          CP            RP      (Plus)JM            CM            RM      (Minus)JPE           CPE           RPE     (Parity Even)JP0           CPO           RPO     (Parity Odd)

Two other instructions can affect a branch by replacing the contents or the program counter: PCHL          Move H & L to Program CounterRST           Special Restart Instruction Used               with Interrupts

Page 34: Unit 1

Stack I/O and Machine Control Instructions

The following instructions affect the Stack and/or Stack Pointer: PUSH  Push Two bytes of Data onto the StackPOP        Pop Two Bytes of Data off the StackXTHL      Exchange Top of Stack with H & LSPHL      Move content of H & L to Stack Pointer

The Machine Control instructions are as follows:EI            Enable Interrupt SystemDI            Disable Interrupt SystemHLT         HaltNOP         No Operation

Page 35: Unit 1

TIMING DIAGRAMTiming Diagram is a graphical representation. It represents the execution time taken by each instruction in a graphical format. The execution time is represented in T-states.

Instruction Cycle:    The time required to execute an instruction is called instruction cycle.Machine Cycle:

The time required to access the memory or input/output devices is called machine cycle.

T-State:The machine cycle and instruction cycle takes multiple clock periods. A portion of an operation carried out in one system clock period is called as T-state.

Page 36: Unit 1

MACHINE CYCLES OF 8085The 8085 microprocessor has 5 (seven) basic machine cycles. • Opcode fetch cycle (4T) • Memory read cycle (3 T) • Memory write cycle (3 T) • I/O read cycle (3 T) • I/O write cycle (3 T)

Page 37: Unit 1

Opcode fetch cycle (4T)

Page 38: Unit 1

Memory Read Machine Cycle

Page 39: Unit 1

Memory Write Machine Cycle• The memory write machine cycle is executed by the processor to write a data byte

in a memory location. • The processor takes, 3T states to execute this machine cycle.

Page 40: Unit 1

I/O Write Cycle • The I/O write machine cycle is executed by the processor to write a data byte in

the I/O port or to a peripheral, which is I/O, mapped in the system. • The processor takes, 3T states to execute this machine cycle

Page 41: Unit 1

Timing diagram for STA 526AH

• STA means Store Accumulator -The contents of the accumulator is stored in the specified address(526A).

• The opcode of the STA instruction is said to be 32H. It is fetched from the memory 41FFH(see fig). - OF machine cycle

• Then the lower order memory address is read(6A). - Memory Read Machine Cycle

• Read the higher order memory address (52).- Memory Read Machine Cycle • The combination of both the addresses are considered and the content from

accumulator is written in 526A. - Memory Write Machine Cycle • Assume the memory address for the instruction and let the content of

accumulator is C7H. So, C7H from accumulator is now stored in 526A.

Page 42: Unit 1
Page 43: Unit 1

Timing diagram for IN C0H • Fetching the Opcode DBH from the memory 4125H. • Read the port address C0H from 4126H. • Read the content of port C0H and send it to the accumulator. • Let the content of port is 5EH.

Page 44: Unit 1

INTERRUPT STRUCTURE• Interrupt is signals send by an external device to the processor, to

request the processor to perform a particular task or work. • Mainly in the microprocessor based system the interrupts are used

for data transfer between the peripheral and the microprocessor. • The processor will check the interrupts always at the 2nd T-state

of last machine cycle. • If there is any interrupt it accept the interrupt and send the INTA

(active low) signal to the peripheral. • The vectored address of particular interrupt is stored in program

counter. • The processor executes an interrupt service routine (ISR)

addressed in program counter. • It returned to main program by RET instruction.

Page 45: Unit 1

TYPES OF INTERRUPTS:It supports two types of interrupts.• Hardware       • Software

Software interrupts:

• The software interrupts are program instructions. These instructions are inserted at desired locations in a program.

• The 8085 has eight software interrupts from RST 0 to RST 7. The vector address for these interrupts can be calculated as follows.

Interrupt number * 8 = vector address For RST 5 5 *  8 = 40 = 28H

Vector address for interrupt RST 5 is 0028H

Page 46: Unit 1

HARDWARE INTERRUPTS: • An external device initiates the hardware interrupts and placing an

appropriate signal at the interrupt pin of the processor. • If the interrupt is accepted then the processor executes an interrupt

service routine.

• The 8085 has five hardware interrupts

(1) TRAP             (2) RST 7.5             (3) RST6.5         (4) RST 5.5       (5) INTR

Page 47: Unit 1

TRAP • This interrupt is a non-maskable interrupt. It is unaffected by any

mask or interrupt enable. • TRAP is the highest priority and vectored interrupt. • TRAP interrupt is edge and level triggered. This means hat the

TRAP must go high and remain high until it is acknowledged. • In sudden power failure, it executes a ISR and send the data from

main memory to backup memory. • The signal, which overrides the TRAP, is HOLD signal. (i.e., If the

processor receives HOLD and TRAP at the same time then HOLD is recognized first and then TRAP is recognized).

• There are two ways to clear TRAP interrupt.

         1.By resetting microprocessor (External signal)         2.By giving a high TRAP ACKNOWLEDGE (Internal signal)

Page 48: Unit 1

RST 7.5

• The RST 7.5 interrupt is a maskable interrupt. • It has the second highest priority. • It is edge sensitive. ie. Input goes to high and no

need to maintain high state until it recognized. • Maskable interrupt. It is disabled by,               1.DI instruction

2.System or processor reset.3.After reorganization of interrupt.

Page 49: Unit 1

RST 6.5 and 5.5• The RST 6.5 and RST 5.5 both are level

triggered. • ie. Input goes to high and stay high until it recognized.

• Maskable interrupt. It is disabled by,                1.DI, SIM instruction              2.System or processor reset.               3.After reorganization of interrupt.• Enabled by EI instruction. • The RST 6.5 has the third priority whereas

RST 5.5 has the fourth priority.

Page 50: Unit 1

INTR• INTR is a maskable interrupt. It is disabled by,               1.DI, SIM instruction

2.System or processor reset.     3.After reorganization of interrupt.

Enabled by EI instruction.• Non- vectored interrupt. After receiving INTA (active low) signal, it has to supply the

address of ISR. • It has lowest priority.• It is a level sensitive interrupts.  ie. Input goes to high and it is necessary to maintain

high state until it recognized. • The following sequence of events occurs when INTR signal goes high. • 1. The 8085 checks the status of INTR signal during execution of each instruction.• 2. If INTR signal is high, then 8085 complete its current instruction and sends active

low interrupt acknowledge signal, if the interrupt is enabled• 3. In response to the acknowledge signal, external logic places an instruction

OPCODE on the data bus. In the case of multibyte instruction, additional interrupt acknowledge machine cycles are generated by the 8085 to transfer the additional bytes into the microprocessor.

• 4. On receiving the instruction, the 8085 save the address of next instruction on stack and execute received instruction.

Page 51: Unit 1

NAME: ADDRESS:

RST 0 00HRST 1 08HRST 2 10HRST 3 18HRST 4 20HTRAP 24HRST 5 28HREST 5.5 2CHRST 6 30HRST 6.5 34HRST 7 38HRST 7.5 3CH

Page 52: Unit 1

SIM and RIM for interrupts• The 8085 provide additional masking facility for RST 7.5, RST 6.5 and RST

5.5 using SIM instruction. • The status of these interrupts can be read by executing RIM instruction. • The masking or unmasking of RST 7.5, RST 6.5 and RST 5.5 interrupts can

be performed by moving an 8-bit data to accumulator and then executing SIM instruction.

• The format of the 8-bit data is shown below

Page 53: Unit 1

• The status of pending interrupts can be read from accumulator after executing RIM instruction.

• When RIM instruction is executed an 8-bit data is loaded in accumulator, which can be interpreted as shown in fig.

Page 54: Unit 1

MEMORY INTERFACING WITH 8085

• The memory is made up of semiconductor material used to store the programs and data. Three types of memory are– Process memory – Primary or main memory – Secondary memory

• A typical semiconductor memory IC will have n address pins, m data pins (or output pins).

• Having two power supply pins- one for connecting required supply voltage Vcc and the other for connecting ground.

• The control signals needed for static RAM are chip select (chip enable), read control (output enable) and write control (write enable).

• The control signals needed for read operation in EPROM are chip select (chip enable) and read control (output enable).

Page 55: Unit 1

RAM, EPROM

Page 56: Unit 1
Page 57: Unit 1

Interfacing EPROM 27512• The memory capacity is 64 Kbytes. i.e • 2^n = 64 x 1000 bytes where n = address lines. • So, n = 16. • In this system the entire 16 address lines of the processor are

connected to address input pins of memory IC in order to address the internal locations of memory.

• The chip select (CS) pin of EPROM is permanently tied to logic low (i.e., tied to ground).

• Since the processor is connected to EPROM, the active low RD pin is connected to active low output enable pin of EPROM.

• The range of address for EPROM is 0000H to FFFFH.

Page 58: Unit 1
Page 59: Unit 1

Interface the EPROM and RAM• 64kb memory space is equally divided between EPROM and RAM.• Implement 32kb memory capacity of EPROM using single IC 27256. • 32kb RAM capacity is implemented using single IC 62256. • The 32kb memory requires 15 address lines and so the address lines

A0 - A14 of the processor are connected to 15 address pins of both EPROM and RAM.

• The unused address line A15 is used as to chip select. If A15  is 1, it select RAM and If  A15  is 0, it select EPROM.

• RD and WR pins of processor are connected to low WE and OE pins of memory respectively.

• The address range of EPROM will be 0000H to 7FFFH and that of RAM will be 8000H to FFFFH.

Page 60: Unit 1
Page 61: Unit 1

DECODER• It is used to increase memory chip to processor. IC's used for decoder is,• 2-4 decoder (74LS139) • 3-8 decoder (74LS138)

Page 62: Unit 1

32kb memory space is implemented using four numbers of 8kb memory

• The total memory capacity is 32Kb. So, let two number of 8kb n memory be EPROM and the remaining two numbers be RAM.

• Each 8kb memory requires 13 address lines and so the address lines A0- A12 of the processor are connected to 13 address pins of all the memory.

• The address lines and A13 - A14 can be decoded using a 2-to-4 decoder to generate four chip select signals.

• These four chip select signals can be used to select one of the four memory IC at any one time.

• The address line A15 is used as enable for decoder.

Page 63: Unit 1

Interfacing 16Kb EPROM and 16Kb RAM with 8085

Page 64: Unit 1

Address Allotted to each memory IC

Page 65: Unit 1

64kb memory space by eight numbers of 8kb memory

• The total memory capacity is 64Kb. So, let 3 numbers of 8Kb EPROM and 5 numbers of 8Kb RAM.

• Each 8kb memory requires 13 address lines. So the address line A0 - A12 of the processor are connected to 13address pins of all the memory ICs.

• The address lines A13, A14 and A15 are decoded using a 3-to-8 coder to generate eight chip select signals. These eight chip select signals can be used to select one of the eight memories at any one time.

Page 66: Unit 1