4 logical operations

23
Microprocessor and Interfaces Microprocessor and Interfaces Logic operations

Upload: tejaswi-nisanth

Post on 27-Sep-2015

233 views

Category:

Documents


0 download

DESCRIPTION

xcv

TRANSCRIPT

  • Microprocessor and InterfacesMicroprocessorandInterfaces

    Logicoperations

  • Logical instructionsLogicalinstructions

    These instructions perform logical operations onTheseinstructionsperformlogicaloperationsondatastoredinregisters,memoryandstatusflags

    The logical operations areThelogicaloperationsare AND OROR XOR RotateRotate Compare ComplementComplement

  • AND, OR, XORAND,OR,XOR

    Any 8bit data or the contents of register orAny8 bitdata,orthecontentsofregister,ormemorylocationcanlogicallyhavetheseoperations with the contents of accumulatoroperationswiththecontentsofaccumulator ANDoperationOR operation ORoperation

    XORoperationTh lt i t d i l t Theresultisstoredinaccumulator

  • RotateRotate

    Each bit in the accumulator can be shiftedEachbitintheaccumulatorcanbeshiftedeitherleftorrighttothenextposition

  • CompareCompare

    Any 8bit data or the contents of register orAny8 bitdata,orthecontentsofregister,ormemorylocationcanbecomparedfor Equality Equality GreaterThanLess Than LessThan

    withthecontentsofaccumulator. Theresultisreflectedinstatusflags.

  • ComplementComplement

    The contents of accumulator can beThecontentsofaccumulatorcanbecomplemented

    Each 0 is replaced by 1 and each 1 is replaced Each0isreplacedby1andeach1isreplacedby0

  • Compareregisterormemorywithlaccumulator

    Opcode Operand

    CMPR

    M

    Contentsoftheoperand(registerormemory)arecomparedwiththecontentsofaccumulatorB h dBothcontentsarepreserved

    Example: CMP B or CMP MExample:CMPBorCMPM

  • Compareregisterormemorywithlaccumulator

    The result of the comparison is shown by setting theTheresultofthecomparisonisshownbysettingtheflagsofthePSWasfollows if(A)(reg/mem):carryandzeroflagsarereset

  • Compare immediate with accumulatorCompareimmediatewithaccumulator

    Opcode Operand

    CPI 8bitdata

    Thesecondbyte(8bitdata)iscomparedwiththey ( ) pcontentsoftheaccumulatorThevaluesbeingcomparedremainunchanged

    Example:CPI89H

  • Compare immediate with accumulatorCompareimmediatewithaccumulator

    The result of the comparison is shown byTheresultofthecomparisonisshownbysettingtheflagsofthePSWasfollows: if (A) < data: carry flag is set if(A) data: carry and zero flags are reset if(A)>data:carryandzeroflagsarereset

  • LogicalANDregisterormemorywithlaccumulator

    Opcode Operand

    ANAR

    M

    ThecontentsoftheaccumulatorarelogicallyANDedwiththecontentsoftheoperand(registerormemory),d h l i l d i h landtheresultisplacedintheaccumulator

    Iftheoperandisamemorylocation,itsaddressisspecified by the contents of HL registersspecifiedbythecontentsofHLregistersS,Z,Paremodifiedtoreflecttheresultoftheoperation.CYisreset.ACissetp

    Example:ANABorANAM

  • LogicalANDimmediatewithlaccumulator

    Opcode Operand

    ANI 8bitdata

    ThecontentsoftheaccumulatorarelogicallyANDedg ywiththe8bitdata(operand)andtheresultisplacedintheaccumulatorS,Z,Paremodifiedtoreflecttheresultoftheoperation.CYisreset.ACisset

    Example:ANI86H

  • ExclusiveORregisterormemorywithlaccumulator

    Opcode Operand

    XRAR

    M

    ThecontentsoftheaccumulatorareExclusiveORedwiththecontentsoftheoperand(registerormemory),d h l i l d i h landtheresultisplacedintheaccumulator

    Iftheoperandisamemorylocation,itsaddressisspecified by the contents of HL registersspecifiedbythecontentsofHLregistersS,Z,Paremodifiedtoreflecttheresultoftheoperation.CYandACareresetp

    Example:XRABorXRAM

  • ExclusiveORimmediatewithlaccumulator

    Opcode Operand

    XRI 8bitdata

    ThecontentsoftheaccumulatorareExclusiveORedwiththe8bitdata(operand)andtheresultisplacedintheaccumulatorS,Z,Paremodifiedtoreflecttheresultoftheoperation.CYandACarereset

    Example:XRI86H

  • LogicalORregisterormemorywithlaccumulaotr

    Opcode Operand

    ORAR

    M

    ThecontentsoftheaccumulatorarelogicallyORedwiththecontentsoftheoperand(registerormemory),d h l i l d i h landtheresultisplacedintheaccumulator

    Iftheoperandisamemorylocation,itsaddressisspecified by the contents of HL registersspecifiedbythecontentsofHLregistersS,Z,Paremodifiedtoreflecttheresultoftheoperation.CYandACareresetp

    Example:ORABorORAM

  • LogicalORimmediatewithlaccumulator

    Opcode Operand

    ORI 8bitdata

    ThecontentsoftheaccumulatorarelogicallyORedg ywiththe8bitdata(operand)andtheresultisplacedintheaccumulatorS,Z,Paremodifiedtoreflecttheresultoftheoperation.CYandACarereset

    Example:ORI86H

  • Rotate accumulator leftRotateaccumulatorleftOpcode Operand

    RLC none

    Eachbinarybitoftheaccumulatorisrotatedleftbyy yonePositionBitD7isplacedinthepositionofD0aswellasintheCarryflagCYismodifiedaccordingtobitD7S Z P AC are not affectedS,Z,P,ACarenotaffected

    Example: RLCExample:RLC

  • Rotate accumulator rightRotateaccumulatorrightOpcode Operand

    RRC none

    Eachbinarybitoftheaccumulatorisrotatedrightbyy g yonepositionBitD0isplacedinthepositionofD7aswellasintheCarryflagCYismodifiedaccordingtobitD0S Z P AC are not affectedS,Z,P,ACarenotaffected

    Example: RRCExample:RRC

  • Rotate accumulator left through carryRotateaccumulatorleftthroughcarry

    Opcode Operand

    RAL none

    Eachbinarybitoftheaccumulatorisrotatedleftbyy yonepositionthroughtheCarryflagBitD7isplacedintheCarryflag,andtheCarryflagisplacedintheleastsignificantpositionD0CYismodifiedaccordingtobitD7S Z P AC are not affectedS,Z,P,ACarenotaffected

    Example: RALExample:RAL

  • Rotate accumulator right through carryRotateaccumulatorrightthroughcarry

    Opcode Operand

    RAR none

    Eachbinarybitoftheaccumulatorisrotatedrightbyy g yonepositionthroughtheCarryflagBitD0isplacedintheCarryflag,andtheCarryflagisplacedinthemostsignificantpositionD7CYismodifiedaccordingtobitD0S Z P AC are not affectedS,Z,P,ACarenotaffected

    Example: RARExample:RAR

  • Complement accumulatorComplementaccumulatorOpcode Operand

    CMA none

    ThecontentsoftheaccumulatorarecomplementedpNoflagsareaffected

    Example:CMA

  • Complement carryComplementcarryOpcode Operand

    CMC none

    TheCarryflagiscomplementedy g pNootherflagsareaffected

    Example:CMC

  • Set CarrySetCarryOpcode Operand

    STC none

    TheCarryflagissetto1y gNootherflagsareaffected

    Example:STC