Open In App

Logical instructions in 8085 microprocessor

Last Updated : 06 May, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

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: 

OPCODE OPERAND DESTINATION 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 none A = 1’s complement of A CMA
CMP R Compares R with A and triggers the flag register CMP B
CMP M Compares Mc with A and triggers the flag register CMP 2050
CPI 8-bit data Compares 8-bit data with A and triggers the flag register CPI 50
RRC none Rotate accumulator right without carry RRC
RLC none Rotate accumulator left without carry RLC
RAR none Rotate accumulator right with carry RAR
RAL none Rotate accumulator left with carry RAR
CMC none Compliments the carry flag CMC
STC none Sets the carry flag STC

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
 


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads