Open In App

Logical instructions in 8086 microprocessor

Improve
Improve
Like Article
Like
Save
Share
Report

Introduction :

Logical instructions in the 8086 microprocessor are instructions that perform logical operations on data stored in registers or memory locations. These instructions can manipulate bits within a byte, set or clear individual bits, or perform Boolean operations such as AND, OR, XOR, and NOT.

Some of the commonly used logical instructions in the 8086 microprocessor include:

  1. AND – Performs a bitwise logical AND operation between two operands and stores the result in the destination operand.
  2. OR – Performs a bitwise logical OR operation between two operands and stores the result in the destination operand.
  3. XOR – Performs a bitwise logical XOR (exclusive OR) operation between two operands and stores the result in the destination operand.
  4. NOT – Performs a bitwise logical NOT (negation) operation on the operand and stores the result in the destination operand.
  5. TEST – Performs a bitwise logical AND operation between two operands, but does not store the result. Instead, it sets the condition code flags based on the result of the operation.

Logical instructions are used in many applications, including bit manipulation, data encryption, and data compression. They are an important part of the instruction set of the 8086 microprocessor and are used extensively in assembly language programming.

Logical instructions are the instructions which perform basic logical operations such as AND, OR, etc. In 8086 microprocessor, the destination operand need not be the accumulator. Following is the table showing the list of logical instructions:

OPCODE OPERAND DESTINATION EXAMPLE
AND D, S D = D AND S AND AX, 0010
OR D, S D = D OR S OR AX, BX
NOT D D = NOT of D NOT AL
XOR D, S D = D XOR S XOR AL, BL
TEST D, S performs bit-wise AND operation and affects the flag register TEST [0250], 06
SHR D, C shifts each bit in D to the right C times and 0 is stored at MSB position SHR AL, 04
SHL D, C shifts each bit in D to the left C times and 0 is stored at LSB position SHL AX, BL
ROR D, C rotates all bits in D to the right C times ROR BL, CL
ROL R, C rotates all bits in D to the left C times ROL BX, 06
RCR D, C rotates all bits in D to the right along with carry flag C times RCR BL, CL
RCL R, C rotates all bits in D to the left along with carry flag C times RCL BX, 06

Here D stands for destination, S stands for source and C stands for count. They can either be register, data or memory address.

Why use Logical instructions in 8086 microprocessor ?

Here are some reasons why logical instructions are used in the 8086 microprocessor:

  1. Bit manipulation: Logical instructions allow the programmer to manipulate individual bits within a byte, which is useful in many applications, including device control, signal processing, and graphics programming.
  2. Data encryption: Logical instructions are used in data encryption algorithms to scramble data by performing bitwise operations on the data.
  3. Data compression: Logical instructions are used in data compression algorithms to reduce the size of the data by removing redundant or irrelevant bits.
  4. Boolean operations: Logical instructions are used to perform Boolean operations such as AND, OR, XOR, and NOT, which are used in many applications, including control systems, signal processing, and mathematical operations.
  5. Condition code flags: Logical instructions can set the condition code flags in the flags register, which can be used to control program flow or make decisions based on the result of the logical operation.

Advantages of Logical instructions in 8086 microprocessor :

  1. Efficient data manipulation: Logical instructions allow for efficient manipulation of data in memory or registers, providing a powerful and flexible tool for programmers.
  2. Bitwise operations: Logical instructions allow for bitwise operations on individual bits within a byte, providing a powerful tool for device control, signal processing, and graphics programming.
  3. Boolean operations: Logical instructions can perform Boolean operations such as AND, OR, XOR, and NOT, providing a powerful tool for control systems, signal processing, and mathematical operations.
  4. Condition code flags: Logical instructions can set the condition code flags in the flags register, providing a way to control program flow or make decisions based on the result of the logical operation.
  5. Data encryption and compression: Logical instructions can be used in data encryption and compression algorithms, providing a way to scramble data by performing bitwise operations on the data or reducing the size of the data by removing redundant or irrelevant bits.
  6. Faster execution: Logical instructions execute faster than other instructions that perform similar operations, providing a way to optimize performance in time-critical applications.

Dis-advantages of Logical instructions in 8086 microprocessor :

  1. Limited precision: Logical instructions can only operate on 8-bit or 16-bit data, which can limit their precision in applications that require higher precision.
  2. Limited functionality: Logical instructions can only perform simple bitwise and Boolean operations, which may not be sufficient for more complex applications.
  3. Register limitations: Logical instructions require the use of registers, which can be a limited resource in the 8086 microprocessor, especially in applications that require many different operations to be performed simultaneously.
  4. Complex programming: Logical instructions can be difficult to program, especially for novice programmers who may not be familiar with the syntax and semantics of assembly language programming.
  5. Debugging challenges: Logical instructions can introduce subtle errors into programs, especially if they are used incorrectly or in combination with other instructions.

Last Updated : 24 Apr, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads