Logical instructions in the 8085 microprocessor are a set of instructions that perform logical operations on data in registers and memory. Logical operations are operations that manipulate the bits of data without affecting their numerical value. These operations include AND, OR, XOR, and NOT.

Common Logical Instructions
The logical instructions in the 8085 microprocessor include:
ANA – Logical AND
Performs a bitwise AND between the accumulator and a specified register or memory location, storing the result in the accumulator.
- The Zero (Z), Sign (S), Parity (P), and Carry (CY) flags are affected (CY is always reset).
- Commonly used for masking specific bits in the accumulator.
ORA – Logical OR
Performs a bitwise OR between the accumulator and a specified register or memory location, storing the result in the accumulator.
- Z, S, P, and CY flags are affected (CY is always reset).
- Useful for setting specific bits in the accumulator without affecting others.
XRA – Logical XOR
Performs a bitwise Exclusive OR between the accumulator and a specified register or memory location, storing the result in the accumulator.
- Z, S, P, and CY flags are affected (CY is always reset).
- Used to toggle specific bits or clear the accumulator when XORed with itself.
CPL – Logical Complement
Flips all bits of the accumulator, inverting its value.
- No flags are affected.
- Useful for bitwise inversion operations.
CMA – Complement Accumulator
Performs a bitwise complement of the accumulator, flipping all bits.
- No flags are affected.
- Often used in two’s complement or logical negation operations.
Usage of Logical instructions in 8085 microprocessor
Here are some specific reasons why logical instructions are used in the 8085 microprocessor:
- Data comparison: Logical instructions can be used to compare two pieces of data bit-by-bit. For example, the XOR instruction can be used to compare the contents of two registers or memory locations and set a flag if they are not equal.
- Data masking: Logical instructions can be used to selectively mask or extract specific bits of data. For example, the AND instruction can be used to mask off all but a specific set of bits, while the OR instruction can be used to set specific bits to 1.
- Data encryption: Logical instructions can be used to perform bitwise encryption of data. By performing a logical XOR between the data and a secret key, the data can be encrypted in a reversible way that can only be decrypted with the same key.
- Decision-making: Logical instructions can be used to make decisions in programs. For example, the AND instruction can be used to test if multiple conditions are true, while the OR instruction can be used to test if at least one condition is true.
Table of Instructions with Opcodes
Following is the table showing the list of logical instructions:
In the table,
R stands for register, M stands for memory and Mc stands for memory contents.
| OPCODE and OPERAND | DESTINATION and EXAMPLE |
|---|---|
| ANA R | A = A AND R → ANA B |
| ANA M | A = A AND Mc → ANA 2050 |
| ANI 8-bit data | A = A AND 8-bit data → ANI 50 |
| ORA R | A = A OR R → ORA B |
| ORA M | A = A OR Mc → ORA 2050 |
| ORI 8-bit data | A = A OR 8-bit data → ORI 50 |
| XRA R | A = A XOR R → XRA B |
| XRA M | A = A XOR Mc → XRA 2050 |
| XRI 8-bit data | A = A XOR 8-bit data → XRI 50 |
| CMA | A = 1’s complement of A → CMA |
| CMP R | Compare R with A and set flags → CMP B |
| CMP M | Compare Mc with A and set flags → CMP 2050 |
| CPI 8-bit data | Compare 8-bit data with A and set flags → CPI 50 |
| RRC | Rotate accumulator right (no carry) → RRC |
| RLC | Rotate accumulator left (no carry) → RLC |
| RAR | Rotate accumulator right with carry → RAR |
| RAL | Rotate accumulator left with carry → RAL |
| CMC | Complement the carry flag → CMC |
| STC | Set the carry flag → STC |