Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
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
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
Operand
CPI
8bitdata
Thesecondbyte(8bitdata)iscomparedwiththe
y (
)
p
contentsoftheaccumulator
Thevaluesbeingcomparedremainunchanged
Example:CPI89H
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
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
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
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
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