Registers

16
Microprocessor and Interfaces Microprocessor and Interfaces Internal Registers

description

jh

Transcript of Registers

  • Microprocessor and InterfacesMicroprocessorandInterfaces

    InternalRegisters

  • Internal Registers of 8086InternalRegistersof8086

    The8086hasfourgroupsoftheuseraccessibleg pinternalregisters InstructionpointerData registers (4) Dataregisters(4)

    Pointerregister(4) Index registerg Segmentregisters(4)

    The 8086has atotal offourteen 16bitregistersi l di 16 bit i t ll d th t tincluding a16bitregistercalledthe statusregister,with9ofbitsimplementedforstatusandcontrolflagsg

  • Segment registersSegmentregisters

    Mostofthe registers containdata/instructionost o t e eg ste s co ta data/ st uct ooffsetswithin64KBmemorysegment

    Therearefourdifferent64 KBsegmentsforginstructions(code),stack,dataandextradata

    Tospecifywherein1MBof processormemorythese4segmentsarelocatedtheprocessorusesfoursegmentregistersIt i ibl t h d f lt t d b Itispossibletochangedefaultsegmentsusedbygeneralandindexregistersbyprefixinginstructions with a CS SS DS or ES prefixinstructionswithaCS,SS,DSorESprefix

  • Code segment (CS)Codesegment(CS)

    16bit register containing address of 64 KB16 bit registercontainingaddressof64KBsegmentwithprocessorinstructions

    The processor uses CS segment for allTheprocessorusesCSsegmentforallaccessestoinstructionsreferencedbyinstructionpointer(IP)register

    CSregistercannotbechangeddirectly The CS register is automatically updatedTheCSregisterisautomaticallyupdatedduringfarjump,farcall andfarreturninstructions

  • Stack segment (SS)Stacksegment(SS)

    16bit register containing address of 64KB16 bitregistercontainingaddressof64KBsegmentwithprogramstack

    By default the processor assumes that all data Bydefault,theprocessorassumesthatalldatareferencedbythestack pointer(SP)andbasepointer (BP) registers is located in the stackpointer(BP)registersislocatedinthestacksegmentSS i b h d di l i POP SSregister canbechangeddirectlyusingPOPinstruction

  • Data segment (DS)Datasegment(DS)

    16bit register containing address of 64KB16 bitregister containingaddressof64KBsegmentwithprogramdata

    By default the processor assumes that all Bydefault,theprocessorassumesthatalldata referencedbygeneralregisters(AX,BX,CX DX) and index register (SI DI) is located inCX,DX)andindexregister(SI,DI)islocatedinthedatasegmentDS i b h d di l i POP DSregistercanbechangeddirectlyusingPOPandLDSinstructions

  • Extra segment (ES)Extrasegment(ES)

    16bit register containing address of 64KB16 bitregistercontainingaddressof64KBsegment,usuallywithprogramdata

    By default the processor assumes that the DI Bydefault,theprocessorassumesthattheDIregisterreferencestheESsegmentinstringmanipulation instructionsmanipulationinstructions

    ESregistercanbechangeddirectlyusingPOPd LES i iandLESinstructions

  • General RegistersGeneralRegisters

    All general registers of the 8086Allgeneralregistersofthe8086microprocessorcanbeusedforarithmeticandlogic operationslogic operations

  • Accumulator registerAccumulatorregister

    Accumulator register consists of two 8bitAccumulatorregisterconsistsoftwo8 bitregistersALandAH,whichcanbecombinedtogether and used as a 16bit register AXtogetherandusedasa16 bitregisterAX

    AL inthiscasecontainstheloworderbyteofthe word and AH contains the high order bytetheword,andAH containsthehighorderbyte

    AccumulatorcanbeusedforI/Ooperationsd i i l iandstringmanipulation

  • Base registerBaseregister

    Base register consists of two 8bit registers BLBaseregisterconsistsoftwo8 bitregistersBLandBH,whichcanbecombinedtogetherandusedas a16bitregisterBX

    BLin thiscasecontainstheloworderbyteof theword,andBHcontainsthe highorderbyte

    BXregisterusuallycontainsadatapointerusedforbased,basedindexedorregisterindirectaddressing

  • Count registerCountregister

    Count register consists of two 8bit registersCountregisterconsistsoftwo8 bitregistersCL andCH,whichcanbecombinedtogetherandusedas a16bitregisterCX

    Whencombined,CLregistercontainstheloworderbyteoftheword,andCH containsthehighorderbyte

    CountregistercanbeusedinLoop,shift/rotateinstructionsandasacounterinstringmanipulation

  • Data registerDataregister

    Dataregisterconsistsoftwo8bitregistersDLg gandDH,whichcanbecombinedtogetherandusedas a16bitregisterDX

    When combined DL register contains the low Whencombined,DLregistercontainstheloworderbyteoftheword,andDH containsthehighorderbyte

    Dataregistercanbeusedasa portnumberinI/OoperationsI i 32 bi l i l d di id i i Ininteger32bitmultiplyanddivideinstructiontheDXregistercontainshighorderwordoftheinitialorresultingnumberg

  • General and Index registersGeneraland Indexregisters

    StackPointer(SP)isa16bitregisterpointingStac o te (S ) s a 6 b t eg ste po t gto programstack

    BasePointer(BP)isa16bitregisterpointingg p gto datainstacksegment.BPregisterisusuallyusedforbased,basedindexedorregisterindirectdd iaddressing

    SourceIndex(SI)isa16bitregister.SIisusedforindexed based indexed and register indirectindexed,basedindexedandregisterindirectaddressing,aswellasasourcedataaddressin stringmanipulationinstructionsg p

  • General and Index registersGeneraland Indexregisters

    Destination Index (DI) is a 16bit register DI isDestinationIndex(DI)isa16 bitregister.DIisusedforindexed,basedindexedandregisterindirect addressing as well as a destinationindirectaddressing,aswellasadestinationdataaddressinstringmanipulationinstructionsinstructions

    InstructionPointer(IP)isa16bitregister

  • FlagsFlags

    OverflowFlag(OF):Setiftheresultistoolargeg ( ) gpositivenumber,oristoosmallnegativenumbertofit intodestinationoperand

    Direction Flag (DF) if set then string DirectionFlag(DF): ifset thenstringmanipulationinstructionswillautodecrementindexregisters.Ifclearedthentheindexregisterswill beautoincremented

    Interruptenable Flag(IF) setting this bit enablesmaskable interruptsmaskable interrupts

    SinglestepFlag(TF)ifsetthensinglestepinterruptwilloccurafterthenext instructionp

  • FlagsFlags

    SignFlag(SF)setifthemostsignificantbitoftheg g ( ) gresultisset

    ZeroFlag(ZF)setifthe resultiszero( ) AuxiliarycarryFlag(AF) setif there was

    a carry fromorborrowtobits03intheALregisterregister

    ParityFlag(PF)setifparity(thenumberof"1"bits)intheloworderbyteoftheresultis even

    CarryFlag(CF)setiftherewasacarryfromorborrowtothemostsignificantbitduringlastresult calculationresultcalculation