Microprocessor Unit II.ppt

Embed Size (px)

Citation preview

  • 7/29/2019 Microprocessor Unit II.ppt

    1/51

    Introduction to 8086Microprocessor

  • 7/29/2019 Microprocessor Unit II.ppt

    2/51

    Introduction:

    It is a 16 bit p.

    8086 has a 20 bit address bus can access

    upto 2power20

    memory locations ( 1 MB) . It can support upto 64K I/O ports.

    It provides 14, 16-bit registers.

    It has multiplexed address and data busAD0- AD15 and A16 A19.

  • 7/29/2019 Microprocessor Unit II.ppt

    3/51

    It requires single phase clock with 33% duty

    cycle to provide internal timing.

    8086 is designed to operate in two modes,Minimum and Maximum.

    It can prefetches upto 6 instruction bytes

    from memory and queues them in order to

    speed up instruction execution.

    It requires +5V power supply.

    A 40 pin dual in line package.

  • 7/29/2019 Microprocessor Unit II.ppt

    4/51

    Architecture of 8086

    The architecture of 8086 includes

    Arithmetic Logic Unit (ALU)

    Flags

    General registers

    Instruction byte queue

    Segment registers

  • 7/29/2019 Microprocessor Unit II.ppt

    5/51

    EU & BIU

    The 8086 CPU logic has been partitioned into twofunctional units namely Bus Interface Unit (BIU) andExecution Unit (EU)

    The major reason for this separation is to increase

    the processing speed of the processor The BIU has to interact with memory and input and

    output devices in fetching the instructions and datarequired by the EU

    EU is responsible for executing the instructions ofthe programs and to carry out the requiredprocessing

  • 7/29/2019 Microprocessor Unit II.ppt

    6/51

    EU & BIU

  • 7/29/2019 Microprocessor Unit II.ppt

    7/51

    Architecture Diagram

  • 7/29/2019 Microprocessor Unit II.ppt

    8/51

    Execution Unit

    The Execution Unit (EU) has

    Control unit

    Instruction decoder

    Arithmetic and Logical Unit (ALU)

    General registers

    Flag register

    Pointers

    Index registers

  • 7/29/2019 Microprocessor Unit II.ppt

    9/51

    Execution Unit

    Control unit is responsible for the co-ordination of all other units of the processor

    ALU performs various arithmetic and logical

    operations over the data The instruction decoder translates the

    instructions fetched from the memory into aseries of actions that are carried out by theEU

  • 7/29/2019 Microprocessor Unit II.ppt

    10/51

    Execution Unit - Registers

    General registers are used for temporarystorage and manipulation of data andinstructions

    Accumulator register consists of two 8-bitregisters AL and AH, which can be combinedtogether and used as a 16-bit register AX

    Accumulator can be used for I/O operationsand string manipulation

  • 7/29/2019 Microprocessor Unit II.ppt

    11/51

    Execution Unit - Registers

    Base register consists of two 8-bit registers BL andBH, which can be combined together and used as a16-bit register BX

    BX register usually contains a data pointer used for

    based, based indexed or register indirect addressing Count register consists of two 8-bit registers CL and

    CH, which can be combined together and used as a16-bit register CX

    Count register can be used as a counter in stringmanipulation and shift/rotate instructions

  • 7/29/2019 Microprocessor Unit II.ppt

    12/51

    Execution Unit - Registers

    Data register consists of two 8-bit registersDL and DH, which can be combined togetherand used as a 16-bit register DX

    Data register can be used as a port numberin I/O operations

    In integer 32-bit multiply and divideinstruction the DX register contains high-order word of the initial or resulting number

  • 7/29/2019 Microprocessor Unit II.ppt

    13/51

    Execution Unit - Registers

  • 7/29/2019 Microprocessor Unit II.ppt

    14/51

    Execution Unit - Flags

  • 7/29/2019 Microprocessor Unit II.ppt

    15/51

    Execution Unit - Flags

    Overflow Flag (OF) - set if the result is too largepositive number, or is too small negative number tofit into destination operand

    Direction Flag (DF) - if set then string manipulation

    instructions will auto-decrement index registers. Ifcleared then the index registers will be auto-incremented

    Interrupt-enable Flag (IF) - setting this bit enablesmaskable interrupts

    Single-step Flag (TF) - if set then single-stepinterrupt will occur after the next instruction

  • 7/29/2019 Microprocessor Unit II.ppt

    16/51

    Execution Unit - Flags

    Sign Flag (SF) - set if the most significant bit of theresult is set.

    Zero Flag (ZF) - set if the result is zero.

    Auxiliary carry Flag (AF) - set if there was a carryfrom or borrow to bits 0-3 in the AL register.

    Parity Flag (PF) - set if parity (the number of "1" bits)in the low-order byte of the result is even.

    Carry Flag (CF) - set if there was a carry from or

    borrow to the most significant bit during last resultcalculation

  • 7/29/2019 Microprocessor Unit II.ppt

    17/51

    Execution Unit - Flags

  • 7/29/2019 Microprocessor Unit II.ppt

    18/51

    Execution Unit - Pointers

    Stack Pointer (SP) is a 16-bit register pointing to program stack

    Base Pointer (BP) is a 16-bit register pointing to data in stacksegment. BP register is usually used for based, based indexed orregister indirect addressing.

    Source Index (SI) is a 16-bit register. SI is used for indexed,

    based indexed and register indirect addressing, as well as asource data addresses in string manipulation instructions.

    Destination Index (DI) is a 16-bit register. DI is used for indexed,based indexed and register indirect addressing, as well as adestination data addresses in string manipulation instructions.

  • 7/29/2019 Microprocessor Unit II.ppt

    19/51

    Execution Unit - Pointers

  • 7/29/2019 Microprocessor Unit II.ppt

    20/51

    Bus Interface Unit

    The BIU has

    Instruction stream byte queue

    A set of segment registers

    Instruction pointer

  • 7/29/2019 Microprocessor Unit II.ppt

    21/51

    BIU Instruction Byte Queue

    8086 instructions vary from 1 to 6 bytes

    Therefore fetch and execution are takingplace concurrently in order to improve the

    performance of the microprocessor The BIU feeds the instruction stream to the

    execution unit through a 6 byte prefetchqueue

    This prefetch queue can be considered as aform of loosely coupled pipelining

  • 7/29/2019 Microprocessor Unit II.ppt

    22/51

    BIU Instruction Byte Queue

    Execution and decoding of certain instructions donot require the use of buses

    While such instructions are executed, the BIUfetches up to six instruction bytes for the following

    instructions (the subsequent instructions) The BIU store these prefetched bytes in a first-in-

    first out register by name instruction byte queue

    When the EU is ready for its next instruction, itsimply reads the instruction byte(s) for theinstruction from the queue in BIU

  • 7/29/2019 Microprocessor Unit II.ppt

    23/51

    Segment: Offset Notation

    The total addressable memory size is 1MB

    Most of the processor instructions use 16-bitpointers the processor can effectively

    address only 64 KB of memory To access memory outside of 64 KB the

    CPU uses special segment registers tospecify where the code, stack and data 64KB segments are positioned within 1 MB ofmemory

  • 7/29/2019 Microprocessor Unit II.ppt

    24/51

    Segment: Offset Notation

    A simple scheme would be to order the bytes in aserial fashion and number them from 0 (or 1) to theend of memory

    The scheme used in the 8086 is calledsegmentation

    Every address has two parts, a SEGMENT and anOFFSET (Segmnet:Offset )

    The segment indicates the starting of a 64 kilobyteportion of memory, in multiples of 16

    The offset indicates the position within the 64kportion

    Absolute address = (segment * 16) + offset

  • 7/29/2019 Microprocessor Unit II.ppt

    25/51

    Segment Registers

    The memory of 8086 is divided into 4

    segments namely

    Code segment (program memory)

    Data segment (data memory)

    Stack memory (stack segment)

    Extra memory (extra segment)

  • 7/29/2019 Microprocessor Unit II.ppt

    26/51

    Different Areas in Memory

    Program memory Program can be locatedanywhere in memory

    Data memory The processor can access data in

    any one out of 4 available segments Stack memory A stack is a section of the memory

    set aside to store addresses and data while asubprogram executes

    Extra segment This segment is also similar to datamemory where additional data may be stored andmaintained

  • 7/29/2019 Microprocessor Unit II.ppt

    27/51

    Segment Registers

    Code Segment (CS) register is a 16-bit registercontaining address of 64 KB segment withprocessor instructions

    The processor uses CS segment for all accesses toinstructions referenced by instruction pointer (IP)

    register Stack Segment (SS) register is a 16-bit register

    containing address of 64KB segment with programstack

    By default, the processor assumes that all datareferenced by the stack pointer (SP) and basepointer (BP) registers is located in the stacksegment

  • 7/29/2019 Microprocessor Unit II.ppt

    28/51

    Segment Registers

    Data Segment (DS) register is a 16-bit registercontaining address of 64KB segment with programdata

    By default, the processor assumes that all datareferenced by general registers (AX, BX, CX, DX)

    and index register (SI, DI) is located in the datasegment

    Extra Segment (ES) register is a 16-bit registercontaining address of 64KB segment, usually withprogram data

    By default, the processor assumes that the DIregister references the ES segment in stringmanipulation instructions

  • 7/29/2019 Microprocessor Unit II.ppt

    29/51

    Segment Registers

  • 7/29/2019 Microprocessor Unit II.ppt

    30/51

    Pin Diagram

  • 7/29/2019 Microprocessor Unit II.ppt

    31/51

    Addressing Modes

    Implied Addressing The data value/data addressis implicitly associated with the instruction

    Register Addressing The data is specified byreferring the register or the register pair in which the

    data is present Immediate Addressing The data itself is provided

    in the instruction

    Direct Addressing The instruction operandspecifies the memory address where data is located

  • 7/29/2019 Microprocessor Unit II.ppt

    32/51

    Addressing Modes

    Register indirect addressing The instructionspecifies a register containing an address, wheredata is located

    Based - 8-bit or 16-bit instruction operand is addedto the contents of a base register (BX or BP), theresulting value is a pointer to location where dataresides

    Indexed - 8-bit or 16-bit instruction operand is added

    to the contents of an index register (SI or DI), theresulting value is a pointer to location where dataresides

  • 7/29/2019 Microprocessor Unit II.ppt

    33/51

    Addressing Modes

    Based Indexed - the contents of a base register (BX

    or BP) is added to the contents of an index register

    (SI or DI), the resulting value is a pointer to location

    where data resides Based Indexed with displacement - 8-bit or 16-bit

    instruction operand is added to the contents of a

    base register (BX or BP) and index register (SI or

    DI), the resulting value is a pointer to location wheredata resides

  • 7/29/2019 Microprocessor Unit II.ppt

    34/51

    Data Transfer Instructions

  • 7/29/2019 Microprocessor Unit II.ppt

    35/51

    Data Transfer Instructions

  • 7/29/2019 Microprocessor Unit II.ppt

    36/51

    Arithmetic Instructions

  • 7/29/2019 Microprocessor Unit II.ppt

    37/51

    Arithmetic Instructions

  • 7/29/2019 Microprocessor Unit II.ppt

    38/51

    Number Representation

  • 7/29/2019 Microprocessor Unit II.ppt

    39/51

    Logical Instructions

  • 7/29/2019 Microprocessor Unit II.ppt

    40/51

    String Instructions

  • 7/29/2019 Microprocessor Unit II.ppt

    41/51

    Program Transfer Instructions

  • 7/29/2019 Microprocessor Unit II.ppt

    42/51

    Program Transfer Instructions

  • 7/29/2019 Microprocessor Unit II.ppt

    43/51

    Processor Control Instructions

  • 7/29/2019 Microprocessor Unit II.ppt

    44/51

    Assembler Directives

    Assembler directives give instruction to theassembler where as other instructions discussed inthe above section give instruction to the 8086microprocessor

    Assembler directives are specific for a particularassembler

    However all the popular assemblers like the Intel8086 macro assembler, the turbo assembler and the

    IBM macro assembler use common assemblerdirectives

  • 7/29/2019 Microprocessor Unit II.ppt

    45/51

    Important Directives

    The ASSUME directive tell the assembler the name of the logicalsegment it should use for a specified segment

    The DB directive is used to declare a byte-type variable or to setaside one or more storage locations of type byte in memory(Define Byte)

    The DD directive is used to declare a variable of type doublewordor to reserve memory locations which can be accessed as typedoubleword (Define Doubleword)

    The DQ directive is used to tell the assembler to declare avariable 4 words in length or to reverse 4 words of storage in

    memory (Define Quadword)

  • 7/29/2019 Microprocessor Unit II.ppt

    46/51

    Important Directives

    The ENDS directive is used with the name of

    a segment to indicate the end of that logical

    segment

    The EQU is used to give a name to some

    value or symbol

  • 7/29/2019 Microprocessor Unit II.ppt

    47/51

    Assembly Language Program

    Writing assembly language programs for 8086 isslightly different from that of writing assemblylanguage programs for 8085

    In addition to the instructions that are meant for

    solving the problem, some additional instructions arerequired to complete the programs

    The purpose of these additional programs is toinitialize various parts of the system, such assegment registers, flags and programmable port

    devices Some of the instructions are to handle the stack of

    the 8086 based system

  • 7/29/2019 Microprocessor Unit II.ppt

    48/51

    Assembly Language Program

    Another purpose of these additional instructions is tohandle the programmable peripheral devices suchas ports, timers and controllers

    The programmable peripheral interfaces should beassigned suitable control words to make them tofunction in the way as we expect

    The best way to approach the initialization task is tomake a checklist of all the registers, programmable

    devices and flags in the system we are working on

  • 7/29/2019 Microprocessor Unit II.ppt

    49/51

    Assembly Language Program

    An 8086 assembly language program has

    five columns namely

    Address

    Data or code

    Labels

    Mmnemonics

    Operands Comments

  • 7/29/2019 Microprocessor Unit II.ppt

    50/51

    Assembly Language Program

    The address column is used for the addressor the offset of a code byte or a data byte

    The actual code bytes or data bytes are put

    in the data or code column A label is a name which represents an

    address referred to in a jump or callinstruction

    Labels are put in the labels column

  • 7/29/2019 Microprocessor Unit II.ppt

    51/51

    Assembly Language Program

    The operands column contains the registers,

    memory locations or data acted upon by the

    instructions

    A comments column gives space to describe

    the function of the instruction for future

    reference