Logical instructions

Last Updated : 21 Oct, 2025

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.

register_m
Logical Operations

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:

  1. 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.
  2. 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.
  3. 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.
  4. 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 OPERANDDESTINATION and EXAMPLE
ANA RA = A AND R → ANA B
ANA MA = A AND Mc → ANA 2050
ANI 8-bit dataA = A AND 8-bit data → ANI 50
ORA RA = A OR R → ORA B
ORA MA = A OR Mc → ORA 2050
ORI 8-bit dataA = A OR 8-bit data → ORI 50
XRA RA = A XOR R → XRA B
XRA MA = A XOR Mc → XRA 2050
XRI 8-bit dataA = A XOR 8-bit data → XRI 50
CMAA = 1’s complement of A → CMA
CMP RCompare R with A and set flags → CMP B
CMP MCompare Mc with A and set flags → CMP 2050
CPI 8-bit dataCompare 8-bit data with A and set flags → CPI 50
RRCRotate accumulator right (no carry) → RRC
RLCRotate accumulator left (no carry) → RLC
RARRotate accumulator right with carry → RAR
RALRotate accumulator left with carry → RAL
CMCComplement the carry flag → CMC
STCSet the carry flag → STC
Comment

Explore