35003187 Introduction to the MICROPROCESSORS 8088 8086

67
Introduction to Microprocessor 8088/8086

description

sawdasda

Transcript of 35003187 Introduction to the MICROPROCESSORS 8088 8086

  • Introduction to Microprocessor 8088/8086

    Embedded System Course

  • Embedded System CourseWhat is a Computer?Central Processing Unit (CPU) Executes the programs Primary Memory Stores programs and data Input/Output Devices Allow CPU to communicate with external hardware System Bus Connects everything together Address, Data, Control signals

    Embedded System Course

  • Embedded System CourseWhat is a Computer?

    Embedded System Course

  • Embedded System CourseVon Neumann Model Roots of the modern PC go back to the 1940sJohn Von Neumann proposed this design:CPUInput OutputWorking MemoryPermanent Memory

    Embedded System Course

  • Embedded System CourseVon Neumann Model

    Embedded System Course

  • Embedded System CourseThe MicroprocessorThe silicon chip that contains the CPU where most calculations take placeMicroprocessors are distinguished by 3 characteristicsInstruction set: the set of instructions that the microprocessor can executeBandwidth: the number of bits processed in each instructionClock speed: (MHz) It determines how many instructions/second the processor can execute

    Embedded System Course

  • Embedded System CourseRole of The MicroprocessorFetch the Instruction from the memoryFetch the operands of the InstructionDecode the InstructionExecute the InstructionOutput the results

    CPU continuously does the (Fetch-Decode-Execute) Cycle

    Embedded System Course

  • Embedded System CourseMicroprocessor Architecture Basic ComponentsCPU Registersspecial memory locations constructed from flip-flops and implemented on-chip e.g., accumulator, count register, flag registerArithmetic and Logic Unit (ALU)ALU is where most of the action take place inside the CPU

    Embedded System Course

  • Embedded System CourseMicroprocessor Architecture Basic ComponentsBus Interface Unit (BIU)responsible for controlling the address and data busses when accessing main memory and data in the cacheControl Unit and Instruction SetCPU has a fixed set of instructions to work on, e.g., MOV, CMP, JMP

    Embedded System Course

  • Embedded System CourseMicroprocessor Architecture Instruction processingProcessing of an instruction by microprocessor consists of three basic steps fetch instruction from the memorydecode the instructionexecute (usually involves accessing the memory for getting operands and storing results)Operation of an early processor like the Intel 8085

    Embedded System Course

  • Embedded System CourseMicroprocessor Architecture Instruction processingModern microprocessors can process several instructions simultaneously at various stages of executionthis ability is called pipeliningOperation of a pipelined microprocessor like the Intel 80486

    Embedded System Course

  • Embedded System CourseMicroprocessor Architecture Instruction processing

    Embedded System Course

  • Embedded System CourseSystem ArchitectureAddress Bus provides a memory address to system memory andI/O address to system I/O devices

    Data Bus transfers data between the microprocessor and the memory and I/O attached to the system

    Control Bus provides control signals that cause memory or I/O devices to perform a read or write operation

    Embedded System Course

  • Embedded System CourseThe 8086 family of Microprocessors

    Embedded System Course

  • Embedded System CourseProcessor Data and Address Bus SizesExamplesProcessor

    8088

    8086

    80286

    80386dx

    80486

    80586/Pentium (Pro)Data Bus

    8

    16

    16

    32

    32

    64Address Bus

    20

    20

    24

    32

    32

    32Max Addressable Memory

    1,048,576 (1Mb)

    1,048,576 (1Mb)

    16,777,21(16Mb)

    4,294,976,296 (4Gb)

    4,294,976,296 (4Gb)

    4,294,976,296 (4Gb)

    Embedded System Course

  • Embedded System CourseMemory

    Microprocessor addresses a maximum of 2n different memory locations, where n is a number of bits on the address bus

    Logical Memory80x86 supports byte addressable memorybyte (8 bits) is a basic memory unite.g., when you specify address 24 in memory, you get the entire eight bitswhen the microprocessors address a 16-bit word of memory, two consecutive bytes are accessed

    Embedded System Course

  • Embedded System CourseMemory (cont.)Physical MemoryThe physical memories of 80x86 family differ in widthe.g., 8088 memory is 8 bits wide, 8086, 80286 memory is 16 bits wide, and 80386dx, 80486 memory is 32 bits widefor programming there is no difference in memory width, because the logical memory is always 8-bit widememory is organized in memory banksa memory bank is an 8-bit wide section of the memorye.g., the 16-bit microprocessors contain two memory banks to form 16-bit wide section of memory that is addressed as bytes or words

    Embedded System Course

  • Embedded System CourseThe Memory SubsystemWhat is a memory location?The 80x86 family support Byte Addressable Memory (a byte is the basic memory unit)With an address bus of size n, the processor can address a maximum of 2n memory locationsex:ample: with 20, 24, and 32 address lines, the 80x86 can address 1Mbyte, 16Mbytes, and 4GbytesWhat is the effect of the C statements:Memory[125] = 0; A = Memory[125]; ?

    Embedded System Course

  • Embedded System Course

    Embedded System Course

  • Embedded System CourseThe Memory Subsystem What happens when when want to access a word?The 80x86 family solution of a word: L.O byte in the specified address and the H.O byte in the consecutive address.A word consumes 2 consecutive memory locationsA double consumes 4 consecutive memory locations

    Embedded System Course

  • Embedded System CourseThe Memory Subsystem But we can have a possibility of overlap!Solutions:8088 and 80188 have 8 bits data bus: 2 memory operations to access a word, 4 to access a double8086, 80186, 80286, and 80386sx have 16 bits data bus: Faster Memory AccessUse of 2 banks (Even and Odd banks)

    Embedded System Course

  • Embedded System Course

    Embedded System Course

  • Embedded System Course16 bit Processor Memory AccessAccessing a word at an Even numbered addresses: 1 memory operationAccessing a word at Odd numbered addresses: 2 memory operationsOnly even addressed appear on the address bus

    Embedded System Course

  • Embedded System Course

    Embedded System Course

  • Embedded System Course16 bit Processor Memory AccessWhat happened when the CPU tries to access a word at the odd address 125?Byte 125 is read and placed in H.O, address Buss has 124 Byte 126 is read and places in L.O, address Bus has 126Internal Swap of the 2 bytes

    Embedded System Course

  • Embedded System Course32 bit Processors32 bit processors (80386, 80486, and Pentium) use four banks of memory connected to the 32 bit data busCan access a double word in a one memory operation

    Embedded System Course

  • Embedded System CoursePhysical Memory System Example (16 bit microprocessor)FFFFFF

    FFFFFD

    FFFFFB

    000005

    000003

    0000018 bitsHigh Bank(odd bank)D15 - D8FFFFFE

    FFFFFC

    FFFFFA

    000004

    000002

    0000008 bitsLow Bank(even bank)D7- D0

    Embedded System Course

  • Embedded System CourseAccessing Data in Memory Example (16 bit microprocessor)Accessing word from an even address - L.O. byte from the address specified and the H.O. byte from the next consecutive addressWhat if you access a word on an odd address?

    Embedded System Course

  • Embedded System CourseAccessing Data in Memory Example (16 bit microprocessor)Example: access memory on address 125, i.e., we want to access data on address 125 (L.O.) and 126 (H.O.)this requires two memory operationsread byte on address 125read byte on address 126swap the positions of these bytes internally since both entered the CPU on the wrong half of the data bus80x86 CPUs recognize this and perform transfer automatically

    Embedded System Course

  • Embedded System CourseAccessing Data in Memory Example (16 bit microprocessor)Your programs can access words at any address and the CPU will properly access and swap the data in memory Think about the speed of your program when accessing words at odd addresses

    Embedded System Course

  • Embedded System CourseMemory Data Types Numbers bit (e.g., 1) ; nibble = 4 bits DB: byte = octet = 8 bits DW: Word = 2 bytes = 16 bits (80x86 terminology) DD: DoubleWord = 4 bytes = 32 bits (80x86 terminology) Intel uses little endian format (i.e., LSB at lower address) Signed Integers (2's complement)

    Embedded System Course

  • Embedded System CourseMemory Data Types Text Letters and characters (7-bit ASCII standard), e.g., 'A'=65=0x41 Extended ASCII (8-bit) allows for extra 128 graphics/symbols) Collection of characters = Strings Collection of Strings = Documents

    Embedded System Course

  • Embedded System CourseMemory Data Types (cont.)

    Programs Commands (MOV, JMP, AND, OR, NOT) Collections of commands = subroutines Collection of subroutines = programs Floating point numbers (covered later) Images (GIF, TIF, JPG, BMP) Video (MPEG, QuickTime, AVI) Audio (voice, music)

    Embedded System Course

  • Embedded System CourseExample of Memory with Stored Data Address Data (8-bits) Interpretation 0xFFFFF ... 0x750000x55 byte ... 0x70009'$ String 0x70008'1' 0x700079 0x700062 0x70004E 0x70003C 0x70002E ... 0x605110x12 Word 0x605100x34 0x6050F0x12 Word 0x6050E0x34 0x6050D0x12 Word 0x6050C0x34 ... 0x555040xFE JE-2Program 0x55003opcode 0x550020x02 ADD AL,2 0x55001opcode ... 0x000003x1 integer array of 16-bit words

    Embedded System Course

  • Registers

    Embedded System Course

  • Embedded System CourseWhat is a register?A storage element inside the microprocessorAlmost all the operations would involve using registersThe 8086 has 14 16 bit registers4 general purpose registers AX, BX, CX, and DX4 addressing registers SI, DI, SP, and BP4 segmentation registers CS, DS, SS and ESInstruction pointer IPFlags register

    Embedded System Course

  • Embedded System CourseThe 8086 family of Microprocessors

    Embedded System Course

  • Embedded System CourseProgramming ModelRegistersNote:32 bit registers are not available on 8086, 8088, 80286

    Embedded System Course

  • Embedded System CourseProgramming ModelRegisters (examples)

    General-Purpose RegistersAX (accumulator) often holds the temporary result after an arithmetic and logic operationBX (base) often holds the base (offset) address of data located in the memory

    Embedded System Course

  • Embedded System CourseThe General Purpose RegistersAX: a 16 bit register, called the Accumulator registerIt consists or 2 8 bits registers: AL and AH

    AH: The high order 8 bitsAL: The low order 8 bits

    Embedded System Course

  • Embedded System CourseThe General Purpose Registers (Cont)CX: (CH,CL) The Counter registerBX: (BH,BL) The Base registerDX: (DH,DL) The Data register

    If AX = 0F63H what would be the values of AL and AH?

    Embedded System Course

  • Embedded System Course:SIDISIDI

    16 bx 8

    Embedded System Course

  • Embedded System CourseProgramming ModelRegisters

    Pointer and Index RegistersSP (stack pointer) used to address data in a LIFO (last-in, first-out) stack memoryBP (base pointer) often used to address an array of data in the stack memory

    Embedded System Course

  • Embedded System Course:SPBPSP:BP:SP push sp2popsp2BP mov ax,ss:[bp] :mov ax,ss:[bp] ss()ds

    Embedded System Course

  • Embedded System CourseFLAG162

    AFCFOFSF()PFZF

    Embedded System Course

  • Embedded System CourseProgramming ModelFlag RegisterFlags indicate the condition of the microprocessor as well as its operationThe flag bits change after many arithmetic and logic instructions executeExample flags,C(carry) indicates carry after addition or a borrow after subtractionO(overflow) is a condition that can occur when signed numbers are added or subtractedZ(zero) indicates that the result of an arithmetic or logic operation is zero

    Embedded System Course

  • Embedded System CourseThe Flags RegisterA special register that provides information about the last executed instructionThe arithmetic flags: 5 bits that indicate the results of arithmetic and related operationsO-flag, S-flag, Z-flag, A-flag, and the C-flagWhich flag(s) is affected by those instructions?MOV AL, 3HMOV BL, 2HINC BLSUB AL,BL

    Embedded System Course

  • Embedded System Coursecont.DF IFTF

    Embedded System Course

  • Embedded System CourseProgramming ModelSegment RegistersSegment registers generate memory addresses along with other registers in the microprocessorCS(code) defines the starting address of the section of memory-holding code(programs and procedures used by programs)DS(data) a section of memory that contains most data used by a program

    Embedded System Course

  • Embedded System CourseProgramming ModelSegment RegistersES(extra) an additional data segmentSS(stack) defines the area of memory used for the stackFS and GS available on 80386 and 80486 allow two additional memory segments for access by programs

    Embedded System Course

  • Embedded System Course:CSDSESSSFSGS CSIP CS DS mov ax,[bx] ES mov ax,es:[di] SS SP FS GS

    Embedded System Course

  • Memory Addressing

    Embedded System Course

  • Embedded System CourseReal Mode Memory Addressing80286 - 80486 microprocessors operate in either the real or protected mode8086, 8088, and 80186 only operate in the real modeReal mode operation allows the microprocessor to only address the first 1M byte of memory space (even if it is an 80486 microprocessor)

    Embedded System Course

  • Embedded System CourseReal Mode Memory AddressingAll 80x86 processors operates in the real mode by defaultAll real mode memory addresses consist of a segment address plus an offset addressthe segment address (in one of the segment registers) defines the beginning address of any 64K byte memory segmentthe offset address selects a location within the 64K byte memory segment

    Embedded System Course

  • Embedded System CourseSegmented MemoryA mechanism that allows the extend the addressability of a ProcessorIn case of 8086, it allowed the processor to extend the maximal addressable memory from 64K to 1megabyte!!It uses 2 components to specify memory locations: a segment value and an offset value within that segment.

    Embedded System Course

  • Embedded System CourseWhy such a scheme?

    Respecting the self imposed 6 bytes for instructions in the 8086 Processor

    Ability To attach blocks of variables (segments) with a particular piece of code (Routines)

    Embedded System Course

  • Embedded System CourseMore on segmentationIn the 8086 processor each 20bit address is expressed as:16 bit segment 16 bit offsetExample: 2000H:0BAFHConverting a segmented address to the actual address:Add a 0 to the right hand side of the segmentAdd to this the offsetExample: 020A:1BCD =>> 020A0H +1BCDH = 036DH

    Embedded System Course

  • Embedded System CourseSegment Registers 4 16 bit segment registerCS: Memory segment containing program instructionsDS: Memory segment containing data itemsSS: Memory segment containing working memoryES: Memory segment used during the access of sequences of characters by special instructions

    Embedded System Course

  • Embedded System CourseOffsets of Segment Registers

    Object Segment OffsetInstruction CS IPProgram data item DS Explicit, BX,SI, or DIWorking storage item SS SP or BPMember of character sequence ES DI

    Embedded System Course

  • Embedded System CourseReal Mode Memory Addressing (cont.)Generation of 20-bit linear address from a segment:offset address in the real mode, each segment register (16 bits) is internally appended with a 0h on its rightmost end (i.e., the segment is shifted left by 4 bits) The segment and the offset are then added to form 20-bit memory address.

    Embedded System Course

  • Embedded System CourseReal Mode Memory Addressing Examples(1) Linear address for Segment:Offset = 2222:3333 = 25553 Segment:offset address for Linear address=25553: Many Answers - One possibility: 2222:3333 Many Answers - One possibility: 2000:5553

    Embedded System Course

  • Embedded System CourseReal Mode Memory Addressing Examples(2) Linear address for Segment:Offset = 1200:F445 = 21445 Segment:offset address for Linear address=21445: Many Answers - One possibility: 1200:F445 Many Answers - One possibility 2000:1445

    Embedded System Course

  • Embedded System CourseProtected Mode Memory Addressing

    In 80286 and later processors the addressing capabilities of a microprocessor are extended by changing the function the CPU uses to convert a logical address to the linear address space

    Embedded System Course

  • Embedded System CourseProtected Mode Memory Addressing

    the protected mode processors use a look up table to compute the physical addressthe segment value is used as an index into an array (segment descriptor table) the contents of the selected array element provides the starting address for the segmentthe CPU adds this value to the offset to obtain the physical address

    Embedded System Course

  • Embedded System CourseUse of Segments

    Embedded System Course

  • Embedded System CoursePeripheralsMemory-mapped devices (special memory locations in the normal address space of the CPU)BIOS: 0xF0000-0xFFFFF (bootstrap, I/O calls) Video: 0xA0000-0xBFFFF and vBIOS: 0xC0000-0xC7FFF I/O mapped devices (sound card, com ports, parallel port) I/O addresses different than Memory addressesAddress Range: 0x0000 - 0xFFFF (16-bit)

    Embedded System Course

  • Embedded System CoursePeripheralsInterrupts Notifies the CPU when an event has occurred Timer [update clock] , serial I/O [input data], Parallel I/O [ready] Network adapter [packet arrived]

    Embedded System Course

    *****