Electrical Engineering Department Engineering College Prince Sattam bin Abdul Aziz University Text Book: - Triebel and Singh, "The 8088 and 8086 Microprocessors", Prentice Hall, Last Edition. Course Grading: Midterm # 1 Midterm # 2 Reports & Projects Lab Performance Final Exam : : : : : (20%) (20%) (10%) (10%) (40%) Course Plan Microprocessor architecture Instruction sets Assembly language programming and debugging Input and Output Interfacing Interrupt controller interfacing Project. Micro-controllers Introduction Microprocessors touch nearly every aspect of our lives. Just a few of the products which use microprocessors are: Cameras Calculators Automobiles Electronic Toys Electronic Credit Card Machines Microwave Ovens What is a microprocessor? Microprocessors are small electronic devices which manipulate and control digital data with great speed and accuracy. Typically, they are about 3 to 4 inches long and about 1 inch wide. Figure . Microprocessor Computer Basics 1. INPUT: Provides information from the outside world, acting as the eyes and ears of the computer system. 2. CONTROL: Directs the overall functioning of the computer. All information must pass through the control during its processing. 3. MEMORY: Supplies temporary storage for information to be processed and permanent storage for program instructions. 4. A.L.U.: The Arithmetic Logic Unit is the actual calculating mechanism, where operations are performed on the information that is input. 5. OUTPUT: Delivers the processed information to the outside world. Figure . Fundamental Microcomputer Basic Microprocessor Operations Objectives: How memory locations are addressed How data is stored 5 basic internal registers Introduction Computer buses: Address bus (carries location details), Control bus (carries timing and enable/disable signals), Data bus (carries instructions and information to be processed). CPU receives the signals and operates upon them How the microprocessor uses these signals to perform its required tasks? Operational Process Memory contains many locations for data or instructions. Each location has a unique address. We access a location by : sending the location's address to the memory section and enabling READ (get from) or WRITE (send to). The microprocessor then gets the data stored at that address or it moves data into that location. Operational Process Memory capacity: measured by the number of bytes it can hold. Recall that: control section a word to memory, it must provide the memory with the address where the word is to go. Ex. Emailing Address In a computer, this address is sent by transmitting an additional one or two words to the memory section. Internal Registers Where to find the data? What to do with the results? Internal Registers: Status (Flag) Register General Purpose Registers Address Registers Program Counter Stack Pointer Status (Flag) Registers Used to store a binary word representing the status of ALU Each bit (or flag) of the status register represents a specific condition. Bit #7 and #6 (U): Unused Bit #5 (C): Carry Flag - Set when there is a carry of the MSB Bit #4 (O): Overflow Flag - Set if the result is out of range Bit #3 (Z): Zero Flag - Set if the result = 0 Bit #2 (N): Negative Flag - Set if the result is negative Bit #1 (I): Interrupt Flag - Set if Interrupt is enabled Bit #0 (P): Parity Flag - Set if the result has even parity (if there are an even number of 1's in the result) General Purpose (GP) Registers Required for processors to operate as fast as they do. Accumulator is a general purpose register which the ALU often uses as the default location for an operand. General Purpose (GP) Registers GP registers store one data word Each 8-bit Mic. have 8-bit GP registers Typically, each Pair register is named with a letter, for instance, "register A", "B", or "C". Individual one-word registers named "register AL" (low word of register pair A) or "register AH" (high word of register pair A). Address Registers Twice the length of the microprocessor's word size. Connected to the address bus and access the location of data in memory. Address is stored in an address register Used by the control unit whenever data is moved to or from the address. Program Counter (PG) Contains the address of the next instruction to be executed. PG begins at the memory address (e.g., 00010001) and then increments to the next address (i.e., 00010010) when the instruction in the first location has been executed. The process repeats until the program re-directs the program counter or terminates. Stack Pointer Automatically adjusts to the next available (empty) location in the stack, which is a block of memory that stores data. One format of storage is FILO (First In, Last Out) The stack pointer indicates which data is to be accessed for correct execution of the program. Computer Instructions An instruction consists of a mnemonic (which the human operator understands) and its binary code (which the computer actually uses). Examples of mnemonics: MOV (for "move"), ADD (for "add"), SUB (for "subtract"), CMP (for "compare"), and JMP (for "jump"). Architectures of 8080A and 8086 Microprocessors Objectives: Describe the major components of the 8080A microprocessor. Describe the major components of the 8086 microprocessor. Discuss the differences between the 8080A and the 8086 microprocessors 8080A MICROPROCESSORS The 8080A is an 8-bit microprocessor. Means that: its data bus and ALU are 8-bits. Address Registers 16 bits. Data Bus Ports Address bus Ports 8080A MICROPROCESSORS Accumulator : 8 bits, Program counter : 16 bits, Flag register : 5 bits. 8080A Mic. (Internal Registers) Flag Register: The 8080A's flag register is 8 bits wide and gives the status of 5 different conditions. 1- Carry Flag (CY) - Set by carry out of bit 7 (MSB) 2- Zero Flag (Z) - Set if result equals zero 3- Sign (S) - Set for positive numbers 4- Parity (P) - Set if even parity (even number of ones) 5- Auxiliary Carry (AC) - Set if carry out of bit 3 (used in BCD arithmetic) 8080A MICROPROCESSORS General Purpose (GP) Registers: Six 8-bit GP registers. These registers can be paired to form three 16-bit registers. The register pairs are B&C, D&E, and H&L. Address Register: Contains the address of the memory location or I/O device to be enabled. This register is 16 bits wide. This means that the 8080A can access up to 64 KB (2^16) of memory. 8080A MICROPROCESSORS Program Counter: contains the address of the next instruction to be executed. same width (16 bits) as the address register Stack Pointer: The stack can be located any place in memory. Therefore, the stack pointer must be able to locate any place in memory. Because the memory is 64 KB, the stack pointer is 16 bits wide. 8080A MICROPROCESSORS 8080A INTERNAL BUS SYSTEM: Data Bus: 8 bits wide. transmits information (data or instructions) to and receives information from any specified device. Address Bus : 16-bit select one memory location or I/O device. Control Bus : synchronizes and enables the devices and operations Figure . Block Diagram of the 8086 8086 Microprocessor The lowest 16 bits of this port act as both the data bus port and the address bus port. The highest 4 bits are dedicated to the address bus. The I/O port has sequential pin numbers. Figure. The 8086 I/O Port 8086 Microprocessor Figure . Block Diagram of the 8086 8086 Microprocessor ALU: Unlike the 8080A, the ALU in the 8086 can work directly with any register or memory location. Means that: nearly all arithmetic and logic instructions (except division) can be performed without first loading the accumulator with one of the operands, as is required in the 8080A. 8080A INTERNAL BUS SYSTEM: The 8086 uses one bus for both the data and address buses. 8086 Microprocessor:Flag Registers: 16 flag registers available in the 8086. Nine flags are used: six status flags and three control flags. Status Flags 1- Carry Flag (CF): Set when there is a carry out of the high order bit (8 or 16 bit) of the result. 2- Parity Flag (PF): Set if result contains an even number of 1's. 3- Auxiliary Carry Flag (AF): Set when there is a carry out of the low nibble. 4- Zero Flag (ZF): Set if the result equals zero. 5- Sign Flag (SF): Set if the result is a negative number. 6- Overflow Flag (OF): Set if the size of the result exceeds the size of the ALU. 8086 Microprocessor:Flag Registers: Control Flags: Trap Flag (TF) Interrupt Flag (IF) Direction Flag (DF) 8086 Microprocessor: General Purpose (GP) Registers: The 8086 contains four 16-bit GP registers named AX (accumulator), BX, CX, and DX. Each of these registers can be split into its High (H) and Low (L) byte to form eight 8-bit registers named AL, AH, BL, BH, and so on. Figure. General Purpose Registers in the 8086 8086 Microprocessor: General Purpose (GP) Registers: The 8086 also contains pointer, segment, and index registers. The Instruction Pointer : Points to the next instruction to be executed. This register is similar to the 8080A's program counter. 8086 has a 20-bit address bus Segment Registers is required. Figure . Pointer and Segment Registers in the 8086 8086 Microprocessor: General Purpose (GP) Registers: Code Segment register : in combination with the instruction pointer allows the entire memory to be addressed. Index registers : used for various types of addressing. Because the 8086 has a 20-bit address bus, it can access up to 1 MB (220) of memory. SUMMARY The major parts of a typical microprocessor are: Control ALU Internal registers I/O Ports The 8080A is an 8-bit microprocessor an 8-bit flag Register, an 8-bit ALU, a16-bit address bus, an 8-bit data bus. The 8086 is a 16-bit microprocessor a 16-bit flag register a 16-bit ALU. Its 20-bit address bus shares 16 bits with the data bus. SUMMARY Internal registers of the 8080A include: ALU, accumulator, flag register, GP registers, address register, program counter, and stack pointer. Internal registers of the 8086 include: ALU, flag register, GP registers, instruction pointer, code segment register, and index registers. The flag register of the 8080A uses 5 of its 8 bits: Carry flag, zero flag, sign flag, parity flag, and auxiliary carry flag. SUMMARY The flag register of the 8086 uses 9 of its 16 bits: 6 are status flags (parity flag, auxiliary carry flag, zero flag, sign flag, and overflow flag) 3 control flags (trap flag, interrupt flag, and direction flag). Both the 8080A and the 8086 microprocessors have 3 buses: data bus, address bus, and control bus. The 8080A ALU always works with the accumulator.