ELECT 707 Micro-Computer Applications: Number system & 8086 Organization Dr. Eng. Amr T. Abdel-Hamid Fall 2011 The Microprocessor Age Micro-Computer Applications World’s first microprocessor the Intel 4004. A 4-bit microprocessor-programmable controller o n a chip. Addressed 4096, 4-bit-wide memory locations. a bit is a binary digit with a value of one or zer o 4-bit-wide memory location often called a nibbl e The 4004 instruction set contained 45 instructions. Dr. Amr Talaat ELECT 707 Micro-Computer Applications Dr. Amr Talaat Main problems with early microprocessor were spe ed, word width, and memory size. Evolution of 4-bit microprocessor ended when Intel released the 4040, an updated 4004. operated at a higher speed; lacked improvement s in word width and memory size Texas Instruments and others also produced 4-bit microprocessors. still survives in low-end applications such as mic rowave ovens and small control systems Calculators still based on 4-bit BCD (binary-cod ed decimal) codes ELECT 707 Micro-Computer Applications Intel released 8008 in 1971. extended 8-bit version of 4004 microprocessor Addressed expanded memory of 16K bytes. A byte is generally an 8-bit-wide binary number and a K is 1024. memory size often specified in K bytes Contained additional instructions, 48 total. Provided opportunity for application in more advanc ed systems. engineers developed demanding uses for 8008 Dr. Amr Talaat ELECT 707 Micro-Computer Applications Intel introduced 8080 microprocessor in 1973. first of the modern 8-bit microprocessors Motorola Corporation introduced MC6800 micropr ocessor about six months later. 8080—and, to a lesser degree, the MC6800—ushe red in the age of the microprocessor. other companies soon introduced their own ver sions of the 8-bit microprocessor Dr. Amr Talaat ELECT 707 Only Intel and Motorola continue to create new, i mproved microprocessors. Micro-Computer Applications IBM also produces Motorola-style microprocesso rs Motorola sold its microprocessor division. now called Freescale Semiconductors, Inc. Zilog still manufactures microprocessors. microcontrollers and embedded controllers inste ad of general-purpose microprocessors Dr. Amr Talaat ELECT 707 The Modern Microprocessor Micro-Computer Applications Dr. Amr Talaat In 1978 Intel released the 8086; a year or so later, it released the 8088. Both devices are 16-bit microprocessors. executed instructions in as little as 400 ns (2.5 millions of instructions per second) major improvement over execution speed of 80 85 8086 & 8088 addressed 1M byte of memory. 16 times more memory than the 8085 1M-byte memory contains 1024K byte-sized m emory locations or 1,048,576 bytes ELECT 707 Micro-Computer Applications Increased memory size and additional instructions in 8086/8088 led to many sophisticated application s. Improvements to the instruction set included multi ply and divide instructions. missing on earlier microprocessors Number of instructions increased. from 45 on the 4004, to 246 on the 8085 over 20,000 variations on the 8086 & 8088 Dr. Amr Talaat ELECT 707 Micro-Computer Applications These microprocessors are called CISC (complex i nstruction set computers). additional instructions eased task of developing efficient and sophisticated applications 16-bit microprocessor also provided more internal register storage space. Popularity of Intel ensured in 1981 when IBM chose the 8088 in its personal computer. Dr. Amr Talaat ELECT 707 Micro-Computer Applications THE MICROPROCESSOR-BASED PERSONAL COMPUTER SYSTEM Computers have undergone many changes recently. Machines that once filled large areas reduced to small desktop computer systems because of the microprocessor. although compact, they possess computing power only dreamed of a few years ago Dr. Amr Talaat ELECT 707 The block diagram of a microprocessor-based computer system. Micro-Computer Applications Dr. Amr Talaat a bus is the set of common connections that carry the same type of information ELECT 707 The Microprocessor Micro-Computer Applications Called the CPU (central processing unit). The controlling element in a computer system. Controls memory and I/O through connections call ed buses. buses select an I/O or memory device, transfer data between I/O devices or memory and the m icroprocessor, control I/O and memory systems Memory and I/O controlled via instructions stored i n memory, executed by the microprocessor. Dr. Amr Talaat ELECT 707 Micro-Computer Applications Microprocessor performs three main tasks: data transfer between itself and the memory or I/O systems simple arithmetic and logic operations program flow via simple decisions Power of the microprocessor is capability to execut e billions of millions of instructions per secon d from a program or software (group of instru ctions) stored in the memory system. stored programs make the microprocessor and c omputer system very powerful devices Dr. Amr Talaat ELECT 707 Micro-Computer Applications Another powerful feature is the ability to make simple decisions based upon numerical facts. a microprocessor can decide if a number is zero, positive, and so forth These decisions allow the microprocessor to modif y the program flow, so programs appear to think through these simple decisions. Dr. Amr Talaat ELECT 707 Buses Micro-Computer Applications A common group of wires that interconnect compon ents in a computer system. Transfer address, data, & control information betwe en microprocessor, memory and I/O. Three buses exist for this transfer of information: a ddress, data, and control. Figure 1–12 shows how these buses interconnect v arious system components. Dr. Amr Talaat ELECT 707 Figure 1–12 The block diagram of a computer system showing the address, data, an d control bus structure. Micro-Computer Applications Dr. Amr Talaat ELECT 707 Micro-Computer Applications The address bus requests a memory location from the memory or an I/O location from the I/O device s. if I/O is addressed, the address bus contains a 1 6-bit I/O address from 0000H through FFFFH. if memory is addressed, the bus contains a mem ory address, varying in width by type of microprocessor. 64-bit extensions to Pentium provide 40 address pi ns, allowing up to 1T byte of memory to be access ed. Dr. Amr Talaat ELECT 707 Micro-Computer Applications Dr. Amr Talaat The data bus transfers information between the mi croprocessor and its memory and I/O address spac e. Data transfers vary in size, from 8 bits wide to 64 bits wide in various Intel microprocessors. 8088 has an 8-bit data bus that transfers 8 bits of data at a time 8086, 80286, 80386SL, 80386SX, and 80386EX transfer 16 bits of data 80386DX, 80486SX, and 80486DX, 32 bits Pentium through Core2 microprocessors transfer 64 bits of data ELECT 707 Organization of 8088 Address bus (20 bits) Micro-Computer Applications AH AL BH BL CH CL Execution Unit DH SP (EU) General purpose register DL Segment register BP SI DI CS Data bus (16 bits) DS SS ALU Data bus (16 bits) Dr. Amr Talaat ALU Flag register ES IP Instruction Queue Bus control External bus EU control Bus Interface Unit (BIU) ELECT 707 Micro-Computer Applications General Purpose Registers 15 Data Group 8 7 AX AH AL Accumulator BX BH BL Base CX CH CL Counter DX DH DL Data SP Dr. Amr Talaat Pointer and Index Group 0 BP Stack Pointer Base Pointer SI Source Index DI Destination Index ELECT 707 Micro-Computer Applications Arithmetic Logic Unit (ALU) A B n bits F n bits 0 0 0 A+B 0 0 1 A -B 0 1 0 A -1 Carry Y= 0 ? Y F A>B? 1 0 0 1 0 Y and B A or B not A 0 1 1 A 1 Dr. Amr Talaat Signal F control which function will be conducted by ALU. Signal F is generated according to the current instruction. Basic arithmetic operations: addition, subtraction, Basic logic operations: and, or, xor, shifting, Microprocessors ELECT 707 3-21 Micro-Computer Applications Flag Register Flag register contains information reflecting the current status of a microprocessor. It also contains information which controls the operation of the microprocessor. 15 Control Flags Dr. Amr Talaat IF: DF: TF: OF DF IF TF SFZF AF PF 0 CF Status Flags CF: Interrupt enable flag PF: Direction flag AF: Trap flag ZF: SF: OF: Carry flag Parity flag Auxiliary carry flag Zero flag Sign flag Overflow flag ELECT 707 Instruction Machine Codes Instruction machine codes are binary numbers Micro-Computer Applications For Example: 1000100011000011 MOV MOV AL, BL Register mode Machine code structure Opcode Mode Operand1 Operand2 Some instructions do not have operands, or have only one operand Opcode tells what operation is to be performed. EU control logic generates ALU control signals accord Dr. Amr Talaat ing to Opcode) Mode indicates the type of a instruction: Register type, or Memory type Operands tell what data should be used in the operation. Operands can be addresses telling where to get data (or where to store results) ELECT 707 Micro-Computer Applications EU Operation 1. Fetch an instruction from instruction queue 2. According to the instruction, EU control logic generates control signals. (This process is also referred to as instruction decoding) 3. Depending on the control signal, EU performs one of the following operations: Dr. Amr Talaat An arithmetic operation A logic operation Storing a datum into a register Moving a datum from a register Changing flag register ELECT 707 Registers Micro-Computer Applications A register is a storage element inside a m icroprocessor. Almost all operations would involve using registers. Some registers are general purpose regis ters, while others have special purposes. Dr. Amr Talaat General purpose registers can hold various da ta sizes and used for almost any purpose as d ictated by the program. However, each general purpose register does have its own special purposes. ELECT 707 Registers Micro-Computer Applications Dr. Amr Talaat ELECT 707 Registers Micro-Computer Applications Dr. Amr Talaat Since the x86 instr uction set is design ed to be compatible with previous micro processors, the sam e register can be ac cessed using differe nt names. Different names are given for 64-bit, 32 -bit, 16-bit and 8-b it version of the sam e register. ELECT 707 General Purpose Registers Micro-Computer Applications RAX, EAX, AX (AH & AL) A general purpose register Also an accumulator – stores intermediate res ults after arithmetic and logic operations Can also hold the offset address of a location in memory (80386 and above) RBX, EBX, BX (BH & BL) Dr. Amr Talaat A general purpose register Also a base index register – holds the offset a ddress of a location in memory Can also address memory data (80386 and a bove) ELECT 707 General Purpose Registers Micro-Computer Applications RCX, ECX, CX (CH & CL) A general purpose register Also a count register – holds the count for var ious instructions Can also hold the offset address of a location in memory (80386 and above) RDX, EDX, DX (DH & DL) Dr. Amr Talaat A general purpose register Also a data register – stores data related to a ccumulator’s calculation (multiply and divide) Can also address memory data (80386 and a bove) ELECT 707 General Purpose Registers Micro-Computer Applications RBP, EBP, BP A general purpose register Also a base pointer register – points to a me mory location for memory data transfer RDI, EDI, DI A general purpose register Also a destination index register – holds the memory address for the destination data of a string instruction Dr. Amr Talaat ELECT 707 General Purpose Registers Micro-Computer Applications RSI, ESI, SI A general purpose register Also a source index register - holds the memo ry address for the source data of a string instr uction R8 through R15 Dr. Amr Talaat General purpose registers Found only in 64-bit microprocessors Data are addressed in 64-, 32-, 16-, or 8-bit sizes ELECT 707 Special Purpose Registers Micro-Computer Applications RIP, EIP, IP Instruction pointer – points to the next instru ction in the memory to be executed RSP, ESP, SP Stack pointer – points to an area in memory c alled the stack RFLAGS, EFLAGS, FLAGS Dr. Amr Talaat Indicates the condition of the microprocessor and control its operation ELECT 707 Flags Micro-Computer Applications Dr. Amr Talaat ELECT 707 Flags Micro-Computer Applications The C, P, A, Z, S and O flags are changed by mo st arithmetic and logic operations. Flags never change for any data transfer or prog ram control operations. Some flags are also used to control features fou nd in the microprocessor. Dr. Amr Talaat ELECT 707 Flags Micro-Computer Applications Descriptions for some of the flag bits: C (carry): holds the carry after addition or bo rrow after subtraction. P (parity): the count of 1s in a number expres sed as even or odd. 0 for odd, 1 for even. A (auxiliary carry): holds the half-carry after addition or the borrow after subtraction betw een bit positions 3 and 4 of the result. Dr. Amr Talaat ELECT 707 Flags Micro-Computer Applications Z (zero): shows that the result of an arithmet ic or logic operation is zero. 0 result is not zero, 1 result is zero. S (sign): holds the arithmetic sign of the resu lt after an arithmetic or logic instruction exec utes. 0 for positive, 1 for negative. T (trap): enables trapping through an on-chip debugging feature. Dr. Amr Talaat 0 disable trapping, 1 enable trapping. If enabled, allows the microprocessor to interrupt th e flow of the program on conditions indicated by the debug registers and control registers. Microsoft Visual Studio debugging tool uses this feat ure. ELECT 707 Flags Micro-Computer Applications I (interrupt): control the operation of the INTR (interrupt request) input pin. 0 disables INTR pin, 1 enables INTR pin. D (direction): selects increment or decre ment mode for SI/DI registers. 0 increment, 1 decrement. Dr. Amr Talaat O (overflow): indicates that the result of an addition/subtraction of signed number s exceeded the capacity of the machine. ELECT 707