2. LOGICAL OPERATIONS
A Microprocessor is a programmable logic chip.it
can perform all logic functions of the hard wired
logic through its instruction set.The 8085 instruction
set includes such logic function such as
AND,OR,EX-OR,COMPLEMENT.
2
3. LOGICAL OPERATIONS
The opcode of the logical functions are as follows.
AND – AND (Logical AND with a content of Register)
ANI – AND IMMEDIATE (Logical AND 8-bit data)
ORA – OR (Logical OR with a content of Register)
ORI – OR IMMEDIATE(Logical OR 8-bit data)
XRA – X-OR(Logical X-OR with a content of Register)
XRI – X-OR IMMEDIATE(Logical X-OR 8-bit data)
3
4. AND Logic Instructions
ANA(LOGICAL AND)
This is a one byte instruction
The contents of a register or any memory location are logically
ANDed with the contents stored in the accumulator register. The
resulting answer is saved in the accumulator.
Example : ANA B , ANA 2000H
4
The Opcode The Operands Description
ANA
R Logical AND the register with accumulator
M
Logical AND the contents pointed by the memory
address pointed by the HL pair (M) with the contents
of the accumulator
5. ANI (AND IMMEDIATE)
This is a two byte instruction
The ANI instruction works exactly like the ANA instruction but
performs logical AND of 8-bit immediate value with the contents of
the accumulator register..
Example : ANI 04H 5
The Opcode The Operands Description
ANI 8-bit immediate data Logically AND immediate data with accumulator
6. OR Logic Instructions
ORA(LOGICAL OR)
This is a one byte instruction
The contents of a register or any memory location are logically
ORed with the contents stored in the accumulator register. The
resulting answer is saved in the accumulator.
Example : ORA B ,ORA 7580H
6
The Opcode The Operands Description
ORA
R Logical OR the register with accumulator
M
Logical OR the contents of the memory location
pointed by the HL pair (M) with the contents of the
accumulator
7. OR Logic Instructions
ORI(LOGICAL OR WITH DATA)
This is a two byte instruction
The ORI instruction works exactly like the ORA instruction but
performs logical OR of 8-bit immediate value with the contents of
the accumulator register.
Example : ORI 44H 7
The Opcode The Operands Description
ORI 8-bit immediate data Logically OR immediate data with accumulator
8. XRA (LOGICALLY OR WITH REGISTER OR MEMORY LOCATION)
This is a one byte instruction
The contents of a register or any memory location are logically
XORed with the contents stored in the accumulator register. The
resulting answer is saved in the accumulator. If the operand
happens to be a memory location, then its address is mentioned by
the contents of the H-L pair.
Example : XRA B ,XRA 7580H
8
The Opcode The Operands Description
XRA
R Logical XOR the register with accumulator
M
Logical XOR the contents of the memory address
pointed by the HL pair (M) with the contents of the
accumulator
9. XRI(LOGICALLY OR WITH DATA)
This is a two byte instruction
The XRI instruction works exactly like the XRA instruction but
performs logical XOR of 8-bit immediate value with the contents of
the accumulator register
Example : XRI 44H
9
The Opcode The Operands Description
XRI 8-bit immediate data Logically XOR immediate data with accumulator
10. Rotate Instructions
RLC(ROTATE ACCUMULATOR LEFT)
This is a ONE byte instruction
The RLC instruction causes each binary bit in the accumulator register to be rotated by one
position to its left. The MSB value is shifted to the LSB as well as the Carry Flag in the
PSW. The other PSW bits, such as S, Z, P, or AC, are not affected by this
operation.Example : RLC
10
The Opcode The Operands Description
RLC None Rotate Accumulator Left
11. Rotate Instructions
RRC(ROTATE ACCUMULATOR RIGHT)
This is a ONE byte instruction
The RRC instruction causes each binary bit in the accumulator register to be rotated by one
position to its right. The LSB value is shifted to the MSB as well as the Carry Flag in the
PSW. The other PSW bits, such as S, Z, P, or AC, are not affected by this
operation.Example : RRC
11
The Opcode The Operands Description
RRC None Rotate Accumulator Right
12. Rotate Instructions
RAL(ROTATE ACCUMULATOR LEFT WITH CARRY)
This is a ONE byte instruction
The RAL instruction causes each binary bit in the accumulator register to be rotated by one
position to its left through the carry flag as well. The MSB value is shifted to the Carry
Flag, and the Carry Flag in the PSW is shifted to the LSB.Example : RAL
12
The Opcode The Operands Description
RAL None Rotate Accumulator Left including the Carry
13. Rotate Instructions
RAL(ROTATE ACCUMULATOR LEFT)
This is a ONE byte instruction
The RAL instruction causes each binary bit in the accumulator register to be rotated by one
position to its left through the carry flag as well. The MSB value is shifted to the Carry
Flag, and the Carry Flag in the PSW is shifted to the LSB.Example : RAL
13
The Opcode The Operands Description
RAL None Rotate Accumulator Left including the Carry
14. Complement Instructions
CMA(COMPLEMENT ACCUMULATOR)
This is a ONE byte instruction
The CMA instruction complements the Content of the accumulator. No flags are affected.
Example : CMA
14
The Opcode The Operands Description
CMA None Complement Accumulator
15. Complement Instructions
CMC(COMPLEMENT CARRY FLAG)
This is a ONE byte instruction
The CMC instruction complements the Carry Flag bit. The other PSW bits, such as S, Z, P,
or AC, are not affected by this operation.
Example : CMC
15
The Opcode The Operands Description
CMC None Complement Carry Flag
16. Set Instruction
STC(SET CARRY FLAG)
This is a ONE byte instruction
The STC instruction sets the Carry Flag bit to 1. The other PSW bits, such as S, Z, P, or
AC, are not affected by this operation
Example : STC
16
The Opcode The Operands Description
STC None Set Carry Flag