SYLLABUS Microprocessor and Assembly Language Course Code: 343 CS CHAPTER 1 Introduction to Microprocessors CHAPTER 1 Introduction to MICROPROCESSORS Microprocessor is a multipurpose, programmable device that accepts digital data as input, processes it according to instructions stored in its memory, and provides results as output. Microprocessors operate on binary number system. It can be a general purpose processor of a computer Or Part of embedded systems doing specific purposes 4004 First general purpose commercial microprocessor APPLICATIONS OF MICROPROCESSORS • General purpose • General purpose PCs • Desktops • LAPTOPS • SUPERCOMPUTERS • Embedded Applications • Consumer Electronics • Automobiles • Process Control • Instrumentation etc. CHARACTERISTICS OF MICROPROCESSORS • Smaller size • Lower cost • Higher reliability • Higher flexibility and versatility • Functionally more powerful • Low power consumption A GENERAL MICROPROCESSOR SYSTEM. It’s a Von Neumann Architecture based on Stored Program Concept It is a general purpose, programmable, clock-driven register based electronic device which reads binary instructions from the memory, accepts binary data as input and processes data according to those instructions and provides the data as outputs. Microprocessor is the central processing unit of the system Microprocessor system can also be illustrated as: Microprocessor system with Bus Architecture Thus components of a Microprocessor system are: •Microprocessors •I/O devices •Memory •System bus Microprocessor has: •ALU •Control Unit •Register Array The Arithmetic and Logic Unit •Performs all computations on input data •Arithmetic operations performed by it are addition, subtraction etc. •Logical operations performed by it AND,OR, NOT etc. The Register Array of Microprocessor •Consists of Register Arrays identified by English Alphabets Intel 8085 has six eight bit registers namely B,C,D,E,H,L •They are accessible to the user through instructions •They store data temporarily. The Control Unit of Microprocessor •Provides timing and control signals for all operations. Memory •Stores binary instruction and data. •ALU reads instructions and data from memory •ALU stores data in the memory for future use. •ROM stores data that cannot be altered. •R/W memory stores user programs that are modifiable. I/O Devices or peripheral devices •Microprocessors communicate with the outer world through the I/O devices. •Input devices: Keyboard, Analog to digital Convertors •Output devices: LED Display, Monitor, Printer, Digital to Analog convertor. System Bus •It is a communication path between the ALU and memory, I/O devices. •They are group of wires that carry bits •Microprocessor communicates only with the I/O or memory at a time. Classification of Microprocessors Micro-processors are classified according to their word-length. The group of bits processed by the microprocessor in an unit time is called the word length of a micro-processor. •8 bit microprocessor-8 bit word length •32 bit micro processor- 32 bit word length and so on. Microprocessor Architect should concentrate on three areas: Hardware Design (Hardware model) Software Design (Programming model) System Integration ARCHITECTURE AND ORGANIZATION OF INTEL 8085 Intel 8085 •Is introduced in 1977 •It is an 8-bit processor •Has 6200 transistors approx. •It has 40 pins A model is a conceptual representation of a real object. 8085 Hardware Model •Hardware model has two segments: ALU segment and the Register segment •ALU segment includes ALU, 8-bit Accumulator, Instruction decoder and flags •ALU performs arithmetic and logic operations. •Results are stored in the accumulator. •Flags are set or reset to show the status of the results. •Register segment has 8-bit registers and 16 bit memory pointer registers to store data and address information temporarily. •There are three buses: •16-bit unidirectional address bus to address 64K memory or to address a peripheral device. •8-bit bidirectional data bus to transfer data between microprocessor and memory and peripheral devices.(largest no. sent is 11111111) •Control bus for sending control signals. •A control signal is a pulse to indicate a microprocessor operation. Control signals for Memory Read Operation •MPU sends 16-bit address on the address bus. •A pulse called Memory Read is sent as a control signal. •The pulse activates the control signals and places the 8-bit data on the data bus. 8085 Programming Model •Programming model has some segments of ALU and Registers. •The model is important in writing assembly language programming. •The model includes six 8- bit registers, accumulator, flag register, 16-bit stack pointer and program counter. •Registers •six 8-bit registers. •They are identified as B,C,D,E, H and L. •They can be combined as register pairs, BC,DE and HL for 16-bit operations. •Accumulator •8-bit register to store 8-bit data •It is identified as A •It is used to perform arithmetic and logic operations. •The results of various operations are stored in Accumulator. Example: ADD B If (A) = 25H and (B)=37H then the instruction ADD B, adds 25H and 37H and stores the result 5CH in the accumulator. •Flags •There are five flags which are set or reset according to the results in accumulator or other registers. They are: •Z-Zero: The Zero flag is set to 1 when the result is Zero. Otherwise it is reset. Example: SUB B If (A) = 05H and (B)=05H then the instruction SUB B, subtracts 05H from 05H and since the result in the accumulator is 00 H the zero flag is set. •CY-Carry: If an arithmetic operation results in a carry, Carry flag is set, otherwise reset. Example: ADD B If (A) = FEH and (B)=01H then the instruction ADD B, adds FEH and 01H and stores the result FFH in the accumulator. Since result does not exceed FFH , the carry flag is reset else if the result is more then FFH , the carry flag is set. • S-Sign: The Sign flag is set if the last bit position of the data is 1, otherwise reset. Example: If D7 bit is 0, then the number is taken as a positive number and if D7 bit is 1, the number is taken as negative number. • P-Parity: If the result has an even number of 1s then parity flag is set. Otherwise it is reset. Example: If the number of 1’s in the Accumulator is 3, which is odd, the parity flag is reset. If the number of 1’s is 4, which is even, the parity flag is set • AC-Auxillary Carry: In an arithmetic operation when a carry is generated by a digit D3 and passed to D4, AC is set,, otherwise it is reset. Program Counter (PC) • This 16-bit register deals with sequencing the execution of instructions. This register is a memory pointer. • Memory locations have 16-bit addresses, and that is why this is a 16-bit register. • 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 instruction is to be fetched. • When a byte (machine code) is being fetched, the program counter is incremented by one to point to the next memory location. Stack Pointer(SP) • The stack pointer is also a 16-bit register used as a memory pointer. • It points to a memory location in R/W memory, called the stack. • The beginning of the stack is defined by loading 16-bit address in the stack pointer. Pin diagram of 8085 Serial I/O Timing and Control signals Interrupts Address Data bus pins Address bus pins Intel 8085 pins are categorized as •Address bus pins. size-16 bits •Data bus pins. Size-8 bits •Control Signal pins. •Power Supply and Frequency Signals. •Interrupt pins. •Serial I/O pins. 1. Address Bus • 8085 has 16 signal lines as address bus. • These lines are divided into two segments: • AD0 to AD7 is used for lower order address and these lines are also used for 8 bit data. • A8 to A15 are unidirectional and used for higher order address of a 16 bit address. Example: For the address 2050H, 20H 0010 0000 Higher order address 50H 0101 0000 Lower order address 2. Data bus •The signal lines AD7 – AD0 are bidirectional. •They are used as lower order address bus as well as data bus. 3. Control and status signals a. Address Latch Enable(ALE) •This is a positive going pulse generated every time the microprocessor begins an operation. •It indicates the bits on AD7-AD0 are address bits. It is a control signal. b. RD – Read •A logic 0 on this pin indicates that the processor is performing either a memory read or an I/O read operation. •In other words, a read cycle is in progress. c. WR – Write •A logic 0 on this pin indicates that the processor is performing either a memory write or an I/O write operation. •In other words, a write cycle is in progress. d.IO/M •This is a status signal used to differentiate between I/O and memory operations. •This signal is combined with RD and WR signals to generate I/O and memory Machine IO/M RD WR Cycle 0 0 1 Memory Read 0 1 0 Memory Write 1 0 1 I/O Read 1 1 0 I/O Write e.S1, S0 •These are status signals sent by microprocessor and can be use to know the type of current operations the microprocessor is performing. •Combining IO/M with S1 and S0, more specific information about the machine cycle status can be obtained. S1 S0 Status 0 0 Halt 0 1 Write 1 0 Read 1 1 Opcode fetch 4. Power Supply and Clock Frequency a. Power supply • Vcc : +5V power supply • Vss : Ground Reference b. Frequency signals • X1, X2 : A crystal is connected at these two pins. The frequency is internally divided by two; therefore to operate a system at 3MHz the crystal should have frequency of 6MHz. • CLK(OUT) : Clock output. This signal can be used as the system clock for other devices. 5. Externally Initiated Signals including Interrupts a. RESET IN: • When the signal on this pin goes low, the program counter is set to zero and the MPU is Reset. b. RESET OUT • This signal indicates that the MPU is being Reset. The signal can be used to Reset other devices. c. INTR (Input) Interrupt Request: This is used as a general purpose interrupt; d. INTA (Output) Interrupt Acknowledge: This is used to Acknowledge the interrupt. Interrupt Description e. RST 7.5 (Inputs) RST 6.5 RST 5.5 : Restart Interrupts: These are vectored interrupts that transfer the program control to specific memory locations. They have higher priorities than INTR interrupt. Among these three priority order is 7.5, 6.5 and 5.5 f. TRAP (Input) This is non-maskable interrupt and has highest priority. g. HOLD (Input) : This signal indicates the peripherals such as DMA (Direct Memory Access) controller are requesting the use of the address and data buses. h. HLDA (Output) : Hold Acknowledge: This signal acknowledges the HOLD request. i. READY (Input) : This signal is used to delay the microprocessor Read or Write cycles until a slow-responding peripheral is ready to send or accept data. When this signal goes low, the microprocessor waits for an integral number of clock cycles until it goes high. 6. Serial I/O Ports: • The 8085 has two signals to implement the serial transmission: SID (Serial Input Data) and SOD (Serial Output Data). • In serial transmission, data bits are sent over a single line, one bit at a time, such as a transmission over telephone Lines. Microprocessor communication and bus timing: To fetch the byte (4FH) , the microprocessor needs to identify the memory location 2005H and enable the data flow from the memory. This is called fetch cycle. •Step 1: The microprocessor places the 16 bit memory address (2005H) from the PC to the address bus. Step 2: The control unit sends control signal RD to enable the memory chip. •Step 3: The byte (4FH) from the selected memory location (2005H) is placed on the data bus. •Step 4: The fetched byte is placed in the instruction decoder of the microprocessor.