360 likes | 575 Views
Microprocessors and Interfacing. Processor. It is a device that perform an operation on data based on some pre-defined instructions for example Addition
E N D
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.
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
Brain • It gets input from eyes/ears and sends processed information to output devices such as face/Muscles. • Example : Sit down as instruction.
Microprocessor (MPU) • Read instructions • Process binary data • Microprocessor includes ALU, Register arrays and control unit on a single chip
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
Microcontroller • A device that includes microprocessor, memory and I/O signal lines on a single chip.
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 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
Advances in Semiconductor Technology • SSI <10 Gates • MSI Between 10 to 1000 Gates • LSI >1000 Gates • VLSI >100000
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
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
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
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.
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.
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.
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
Flag register • S : after the execution of an arithmetic operation, if bit 7 of the result is 1, then sign flag is set. • Z : bit is set if ALU operation results a zero in the Acc or registers. • AC: bit is set, when a carry is generated by bit 3 and passed on bit 4. • P: parity bit is set when the result has even number of 1s.For odd no of 1’s , the flag is reset • CY = carry is set when result generates a carry. Also a borrow flag. S Z AC P CY
Arithmetic Operations • ADD B – [A] <----- [A]+[B] • ADD M - [A] <----- [A]+[[HL]] • SUB C – [A] <----- [A]-[C] • SUI 76H – [A] <---- [A]-76H
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
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
Machine Control Operations • Halt • Interrupt
Instruction Word Size • In terms of bytes: • One Byte Instructions • Two Byte Instructions • Three Byte Instruction
Three Byte Instruction • JMP 2085H • LDA 2050H
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.
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.