Open In App
Related Articles

Logical instructions in 8085 microprocessor

Improve Article
Improve
Save Article
Save
Like Article
Like

Introduction :

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.

The logical instructions in the 8085 microprocessor include:

  1. ANA – Logical AND: This instruction performs a logical AND operation between the accumulator and a specified register or memory location, and stores the result in the accumulator. For example, the instruction “ANA B” performs a logical AND operation between the contents of the accumulator and the contents of the B register.
  2. ORA – Logical OR: This instruction performs a logical OR operation between the accumulator and a specified register or memory location, and stores the result in the accumulator. For example, the instruction “ORA C” performs a logical OR operation between the contents of the accumulator and the contents of the C register.
  3. XRA – Logical XOR: This instruction performs a logical XOR operation between the accumulator and a specified register or memory location, and stores the result in the accumulator. For example, the instruction “XRA M” performs a logical XOR operation between the contents of the accumulator and the contents of the memory location pointed to by the HL register.
  4. CPL – Logical Complement: This instruction performs a logical complement operation on the contents of the accumulator. This operation flips all the bits of the accumulator, effectively reversing its value.
  5. CMA – Complement Accumulator: This instruction performs a bitwise complement operation on the contents of the accumulator. This operation flips all the bits of the accumulator, effectively reversing its value.

Logical instructions are the instructions that perform basic logical operations such as AND, OR, etc. In the 8085 microprocessor, the destination operand is always the accumulator. Here logical operation works on a bitwise level. 
 

Why use 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.

Following is the table showing the list of logical instructions: 

OPCODEOPERANDDESTINATIONEXAMPLE
ANARA = A AND RANA B
ANAMA = A AND McANA 2050
ANI8-bit dataA = A AND 8-bit dataANI 50
ORARA = A OR RORA B
ORAMA = A OR McORA 2050
ORI8-bit dataA = A OR 8-bit dataORI 50
XRARA = A XOR RXRA B
XRAMA = A XOR McXRA 2050
XRI8-bit dataA = A XOR 8-bit dataXRI 50
CMAnoneA = 1’s complement of ACMA
CMPRCompares R with A and triggers the flag registerCMP B
CMPMCompares Mc with A and triggers the flag registerCMP 2050
CPI8-bit dataCompares 8-bit data with A and triggers the flag registerCPI 50
RRCnoneRotate accumulator right without carryRRC
RLCnoneRotate accumulator left without carryRLC
RARnoneRotate accumulator right with carryRAR
RALnoneRotate accumulator left with carryRAR
CMCnoneCompliments the carry flagCMC
STCnoneSets the carry flagSTC

In the table, 
R stands for register 
M stands for memory 
Mc stands for memory contents 

Applications :

Data processing: The logical instructions in the 8085 microprocessor are used to manipulate and process data stored in memory or registers. These instructions are used to perform various logical operations, such as AND, OR, XOR, and complement, which are used to filter, mask, and manipulate data in various ways.

Control systems: The logical instructions are used in control systems to perform logical operations on sensor data and other inputs. These operations are used to generate control signals that regulate the behavior of the system.

Signal processing: The logical instructions in the 8085 microprocessor are used in digital signal processing applications, such as audio and image processing. These instructions are used to perform various logical operations on the digital signal data, such as masking, filtering, and thresholding.

Communication systems: The logical instructions are used in communication systems to perform logical operations on data, such as error detection and correction, and encryption/decryption.

Gaming: The logical instructions are used in gaming applications to perform logical operations on game data, such as collision detection, pathfinding.

Advantages:

  1. Efficient logical operations: The logical instructions in the 8085 microprocessor can perform logical operations quickly and efficiently, making it suitable for applications that require fast logical operations.
  2. Reduced memory access: The use of registers and the accumulator in the 8085 microprocessor can help reduce the number of memory accesses required during logical operations, which can improve the overall performance of the system.
  3. Simplifies programming: The logical instructions in the 8085 microprocessor simplify programming by providing a set of dedicated instructions for performing logical operations.
  4. Supports a wide range of operations: The logical instructions in the 8085 microprocessor support a wide range of operations, including AND, OR, XOR, and complement operations.

Disadvantages:

  1. Limited precision: The 8085 microprocessor uses 8-bit registers and logical operations, which limits the precision of calculations that can be performed. This can be a disadvantage for applications that require high precision logical operations.
  2. Limited range of operations: Although the 8085 microprocessor supports a wide range of logical operations, it does not support advanced operations such as trigonometric functions or complex numbers.
  3. Limited memory access: Although the use of registers can reduce the number of memory accesses required, the limited number of registers in the 8085 microprocessor can restrict the amount of data that can be manipulated at any given time.
  4. Complex addressing modes: The addressing modes used in the logical instructions can be complex, which can make programming more difficult.

Read related post: Arithmetic instructions in 8085 microprocessor
 

Last Updated : 06 May, 2023
Like Article
Save Article
Similar Reads