Sei sulla pagina 1di 23

Microprocessor and Interfaces

MicroprocessorandInterfaces
Logicoperations

Logical instructions
Logicalinstructions
These
Theseinstructionsperformlogicaloperationson
instructions perform logical operations on
datastoredinregisters,memoryandstatusflags
Thelogicaloperationsare
The logical operations are

AND
OR
XOR
Rotate
Compare
Complement

AND, OR, XOR


AND,OR,XOR
Any
Any8
8bit
bitdata,orthecontentsofregister,or
data or the contents of register or
memorylocationcanlogicallyhavethese
operations with the contents of accumulator
operationswiththecontentsofaccumulator
ANDoperation
ORoperation
OR operation
XORoperation

Theresultisstoredinaccumulator
Th
lt i t d i
l t

Rotate
Each
Eachbitintheaccumulatorcanbeshifted
bit in the accumulator can be shifted
eitherleftorrighttothenextposition

Compare
Any
Any8
8bit
bitdata,orthecontentsofregister,or
data or the contents of register or
memorylocationcanbecomparedfor
Equality
GreaterThan
LessThan
Less Than

withthecontentsofaccumulator.
Theresultisreflectedinstatusflags.

Complement
The
Thecontentsofaccumulatorcanbe
contents of accumulator can be
complemented
Each0isreplacedby1andeach1isreplaced
Each 0 is replaced by 1 and each 1 is replaced
by0

Compareregisterormemorywith
accumulator
l
Opcode

Operand
R

CMP

Contentsoftheoperand(registerormemory)are
comparedwiththecontentsofaccumulator
Bothcontentsarepreserved
B h
d
Example: CMP B or CMP M
Example:CMPBorCMPM

Compareregisterormemorywith
accumulator
l
The
Theresultofthecomparisonisshownbysettingthe
result of the comparison is shown by setting the
flagsofthePSWasfollows
if(A)<(reg/mem):carryflagisset
if(A)=(reg/mem):zeroflagisset
if(A)>(reg/mem):carryandzeroflagsarereset

Compare immediate with accumulator


Compareimmediatewithaccumulator
Opcode

Operand

CPI

8bitdata

Thesecondbyte(8bitdata)iscomparedwiththe
y (
)
p
contentsoftheaccumulator
Thevaluesbeingcomparedremainunchanged
Example:CPI89H

Compare immediate with accumulator


Compareimmediatewithaccumulator
The
Theresultofthecomparisonisshownby
result of the comparison is shown by
settingtheflagsofthePSWasfollows:
if(A)<data:carryflagisset
if (A) < data: carry flag is set
if(A)=data:zeroflagisset
if(A)>data:carryandzeroflagsarereset
if (A) > data: carry and zero flags are reset

LogicalANDregisterormemorywith
accumulator
l
Opcode

Operand
R

ANA

ThecontentsoftheaccumulatorarelogicallyANDed
withthecontentsoftheoperand(registerormemory),
andtheresultisplacedintheaccumulator
d h
l i l di h
l
Iftheoperandisamemorylocation,itsaddressis
specified by the contents of HL registers
specifiedbythecontentsofHLregisters
S,Z,Paremodifiedtoreflecttheresultofthe
operation.CYisreset.ACisset
p
Example:ANABorANAM

LogicalANDimmediatewith
accumulator
l
Opcode

Operand

ANI

8bitdata

ThecontentsoftheaccumulatorarelogicallyANDed
g
y
withthe8bitdata(operand)andtheresultisplacedin
theaccumulator
S,Z,Paremodifiedtoreflecttheresultofthe
operation.CYisreset.ACisset
Example:ANI86H

ExclusiveORregisterormemorywith
accumulator
l
Opcode

Operand
R

XRA

ThecontentsoftheaccumulatorareExclusiveORed
withthecontentsoftheoperand(registerormemory),
andtheresultisplacedintheaccumulator
d h
l i l di h
l
Iftheoperandisamemorylocation,itsaddressis
specified by the contents of HL registers
specifiedbythecontentsofHLregisters
S,Z,Paremodifiedtoreflecttheresultofthe
operation.CYandACarereset
p
Example:XRABorXRAM

ExclusiveORimmediatewith
accumulator
l
Opcode

Operand

XRI

8bitdata

ThecontentsoftheaccumulatorareExclusiveORed
withthe8bitdata(operand)andtheresultisplacedin
theaccumulator
S,Z,Paremodifiedtoreflecttheresultofthe
operation.CYandACarereset
Example:XRI86H

LogicalORregisterormemorywith
accumulaotr
l
Opcode

Operand
R

ORA

ThecontentsoftheaccumulatorarelogicallyORed
withthecontentsoftheoperand(registerormemory),
andtheresultisplacedintheaccumulator
d h
l i l di h
l
Iftheoperandisamemorylocation,itsaddressis
specified by the contents of HL registers
specifiedbythecontentsofHLregisters
S,Z,Paremodifiedtoreflecttheresultofthe
operation.CYandACarereset
p
Example:ORABorORAM

LogicalORimmediatewith
accumulator
l
Opcode

Operand

ORI

8bitdata

ThecontentsoftheaccumulatorarelogicallyORed
g
y
withthe8bitdata(operand)andtheresultisplacedin
theaccumulator
S,Z,Paremodifiedtoreflecttheresultofthe
operation.CYandACarereset
Example:ORI86H

Rotate accumulator left


Rotateaccumulatorleft
Opcode

Operand

RLC

none

Eachbinarybitoftheaccumulatorisrotatedleftby
y
y
onePosition
BitD7isplacedinthepositionofD0aswellasinthe
Carryflag
CYismodifiedaccordingtobitD7
S Z P AC are not affected
S,Z,P,ACarenotaffected
Example:
Example:RLC
RLC

Rotate accumulator right


Rotateaccumulatorright
Opcode

Operand

RRC

none

Eachbinarybitoftheaccumulatorisrotatedrightby
y
g
y
oneposition
BitD0isplacedinthepositionofD7aswellasinthe
Carryflag
CYismodifiedaccordingtobitD0
S Z P AC are not affected
S,Z,P,ACarenotaffected
Example:
Example:RRC
RRC

Rotate accumulator left through carry


Rotateaccumulatorleftthroughcarry
Opcode

Operand

RAL

none

Eachbinarybitoftheaccumulatorisrotatedleftby
y
y
onepositionthroughtheCarryflag
BitD7isplacedintheCarryflag,andtheCarryflagis
placedintheleastsignificantpositionD0
CYismodifiedaccordingtobitD7
S Z P AC are not affected
S,Z,P,ACarenotaffected
Example:
Example:RAL
RAL

Rotate accumulator right through carry


Rotateaccumulatorrightthroughcarry
Opcode

Operand

RAR

none

Eachbinarybitoftheaccumulatorisrotatedrightby
y
g
y
onepositionthroughtheCarryflag
BitD0isplacedintheCarryflag,andtheCarryflagis
placedinthemostsignificantpositionD7
CYismodifiedaccordingtobitD0
S Z P AC are not affected
S,Z,P,ACarenotaffected
Example:
Example:RAR
RAR

Complement accumulator
Complementaccumulator
Opcode

Operand

CMA

none

Thecontentsoftheaccumulatorarecomplemented
p
Noflagsareaffected
Example:CMA

Complement carry
Complementcarry
Opcode

Operand

CMC

none

TheCarryflagiscomplemented
y g
p
Nootherflagsareaffected
Example:CMC

Set Carry
SetCarry
Opcode

Operand

STC

none

TheCarryflagissetto1
y g
Nootherflagsareaffected
Example:STC

Potrebbero piacerti anche