35
Microprocessors and Interfacing

Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Embed Size (px)

Citation preview

Page 1: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Microprocessors and Interfacing

Page 2: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Processor

• It is a device that perform an operation on data based on some pre-defined instructions for example Addition

• In starting the CPU were made on different boards and connected together, as technology improved, it became possible to bring whole CPU on a single chip named as microprocessor.

Page 3: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

MicroprocessorA Microprocessor is a multipurpose, programmable electronic device that reads binary instruction from memory; accepts binary data as Input and provides output after processing the data.

Block Diagram of computer with Microprocessor as CPU (Microcomputer)

Block Diagram of computer

Page 4: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Brain

• It gets input from eyes/ears and sends processed information to output devices such as face/Muscles.

• Example : Sit down as instruction.

Page 5: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Microprocessor (MPU)

– Read instructions– Process binary data– Microprocessor includes

ALU, Register arrays and control unit on a single chip

Page 6: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Input/Output Devices & Bus

• Input Devices– Keyboard and Switches– Provide binary information to the MPU

• Output devices– LEDs and LCDs– Receive binary information from the MPU

• Bus – Carries bits between the microprocessor and memory and I/O Devices

Page 7: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Microprocessor-Based System with Bus Architecture

Page 8: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Microcontroller

• A device that includes microprocessor, memory and I/O signal lines on a single chip.

Page 9: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Difference between Microcontroller and Microprocessor

Page 10: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

10

Microprocessor • CPU is stand-alone, RAM,

ROM, I/O, timer are separate• designer can decide on the

amount of ROM, RAM and I/O ports.

• versatility, general-purpose• High power consumption

Microcontroller• CPU, RAM, ROM, I/O and

timer are all on a single chip• fixed amount of on-chip ROM,

RAM, I/O ports• specific-purpose (control-

oriented)• Low power consumption

Page 11: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Microprocessor Evolution andTypes

Page 12: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Advances in Semiconductor Technology

• SSI <10 Gates• MSI Between 10 to 1000 Gates• LSI >1000 Gates• VLSI >100000

Page 13: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Intel Microprocessors 4,8,16,32,64 Bit Processors

Processor Year of Introduction

Address Bus ( In Bits)

Data Bus( In Bits)

Addressable Memory

4004 1971 10 4 640 Bytes

8080 1974 16 8 64 K Bytes

8085 1976 16 8 64 K Bytes

8086 1978 20 16 1 M Bytes

80386 1985 32 32 4 G Bytes

Pentium II onwards

1997 36 64 64 G Bytes

Page 14: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

8085 Hardware Model

Page 15: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

ALU• The ALU performs the following arithmetic and logical

operations.– Addition– Subtraction– Logical AND– Logical OR– Logical EXCLUSIVE OR– Complement (logical NOT)– Increment (add 1)– Decrement (subtract 1)– Left shift– Clear

Page 16: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Instruction Register and Decoder

• The instruction register and the decoder are considered as a part of the ALU

• The instruction register is a temporary storage for the current instruction of a program

• The decoder decodes the instruction and establishes the sequence of events to follow

Page 17: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

8085 Programming Model

Page 18: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

General Registers• The 8085 has six general-purpose registers to store 8-bit

data; these are identified 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• The programmer can use these registers to store or copy

data into the registers by using data copy instructions• The HL register pair is also used to address memory

locations• In other words, HL register pair plays the role of memory

address register

Page 19: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Accumulator

• Hold data for manipulation (arithmetic, logical).• Whenever the operation combines two words, either

arithmetically or logically, the accumulator contains one word (say A) and the other word(say B) may be contained in a register or in memory location. After the operation the result is placed in the Accumulator replacing the word A.

• Major working register. • Microprocessor can directly work on Acc.

Page 20: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Program counter

• The function of the PC is to point to the memory address from which the next byte is to be fetched.

• For 8085 it is 16 bit long.• PC automatically increments to point to the next

memory during the execution of the present instruction.

• PC value can be changed by some instructions.

Page 21: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Stack pointer

• 16 bit register acts as memory pointer.• Can save the value of the program counter for

later use.• points to a memory location in R/W memory

which is called stack. follows LIFO algorithm.• After every stack operation SP points to next

available location of the stack. Usually decrements.

Page 22: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Flags

• The ALU includes five flip-flops, which are set or reset after an operation according to data conditions of the result in the accumulator and other registers

• They are called Zero (Z), Carry (CY), Sign (S), Parity (P), and Auxiliary Carry (AC) flags

Page 23: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Flag register

S Z AC P CY 1. S : after the execution of an arithmetic operation, if bit 7 of the result is 1, then sign flag is set.

2. Z : bit is set if ALU operation results a zero in the Acc or registers.

3. AC: bit is set, when a carry is generated by bit 3 and passed on bit 4.

4. P: parity bit is set when the result has even number of 1s.For odd no of 1’s , the flag is reset

5. CY = carry is set when result generates a carry. Also a borrow flag.

Page 24: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

The 8085 Instruction Set

Page 25: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Data Transfer (Copy) Operations

Types Examples

1. Between Registers 1. MOV B,D – Copy the contents of the register D into Register B

2. Specific data byte to a register or a memory location

2. MVI B,32H – Load register B with the data byte 32H

3. Between a memory location and a register

3. LXI H, 2000H

MOV B,M

From a memory location 2000H to register B

4. Between an I/O device and the accumulator

4. IN 05H – The contents of the input port designated in the operand are read and loaded into the accumulator

Page 26: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Arithmetic Operations

• ADD B – [A] <----- [A]+[B]• ADD M - [A] <----- [A]+[[HL]]• SUB C – [A] <----- [A]-[C]• SUI 76H – [A] <---- [A]-76H

Page 27: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Logical Operations

• ANA B – [A] <----- [A] AND [B]• ANI 85H – [A] <----- [A] AND 85H• ORA M – [A] <----- [A] OR [[HL]]• XRA B – [A] <------ [A] XOR [B]

• Rotate• Compare• Complement

Page 28: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Branching Operations

• JMP 2050H – [PC] <----- 2050H• JZ 3100H – [PC] <----- 3100H if Z=1,

otherwise [PC] <----- [PC]+1• JNC 4250H – [PC] <----- 4250H if

C=0, otherwise [PC] <----- [PC]+1

• Call, Return

Page 29: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Machine Control Operations

• Halt• Interrupt

Page 30: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Instruction Word Size

• In terms of bytes:

• One Byte Instructions• Two Byte Instructions• Three Byte Instruction

Page 31: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

One Byte Instructions

Page 32: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Two Byte Instructions

Page 33: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Three Byte Instruction

• JMP 2085H• LDA 2050H

Page 34: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Writing Assembly Language Program

• Define the problem clearly and make the problem statement.

• Analyze the problem thoroughly. In this step we divide the problem into smaller steps to examine the process of writing programs.

• Draw the flow chart. The steps listed in the problem analysis and the sequences are represented in a block diagram.

• Translate the blocks shown in the flowchart into 8085 operations and then subsequently into mnemonics.

Page 35: Microprocessors and Interfacing. Processor It is a device that perform an operation on data based on some pre-defined instructions for example Addition

Conversion and Execution

• Convert the mnemonics into Hex code; we need to look up the code in 8085 instruction set.

• Store the program in Read/Write memory of a single-board microcomputer. This may require the knowledge about memory addresses and the output port addresses.

• Finally execute the program.